Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:13:23

0001 
0002 /*--------------------------------------------------------------------*/
0003 /*--- Linux-specific kernel interface.                 vki-linux.h ---*/
0004 /*--------------------------------------------------------------------*/
0005 
0006 /*
0007    This file is part of Valgrind, a dynamic binary instrumentation
0008    framework.
0009 
0010    Copyright (C) 2000-2017 Julian Seward 
0011       jseward@acm.org
0012 
0013    This program is free software; you can redistribute it and/or
0014    modify it under the terms of the GNU General Public License as
0015    published by the Free Software Foundation; either version 2 of the
0016    License, or (at your option) any later version.
0017 
0018    This program is distributed in the hope that it will be useful, but
0019    WITHOUT ANY WARRANTY; without even the implied warranty of
0020    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0021    General Public License for more details.
0022 
0023    You should have received a copy of the GNU General Public License
0024    along with this program; if not, see <http://www.gnu.org/licenses/>.
0025 
0026    The GNU General Public License is contained in the file COPYING.
0027 */
0028 
0029 /* This file defines types and constants for the kernel interface, and to
0030    make that clear everything is prefixed VKI_/vki_.
0031 
0032    All code is copied verbatim from kernel source files, except that:
0033    - VKI_/vki_ prefixes are added
0034    - some extra explanatory comments are included;  they are all within
0035      "[[ ]]"
0036    - for some types, we only care about the size;  for a few of them (big
0037      ones that are painful to fully drag in here), a VKI_SIZEOF_* constant
0038      is used.
0039    
0040    The files the code is taken from is indicated.
0041 
0042    Note especially that the types are not the glibc versions, many of which
0043    are different to those in here. 
0044 
0045    Also note that this file contains all the generic header info, ie. that
0046    from linux/include/linux/ *.h.  The arch-specific header info, eg. that
0047    from linux/include/asm-i386/ *.h, is in vki-$PLATFORM.h and
0048    vki_posixtypes-$PLATFORM.h.  (Two files are required to avoid
0049    circular dependencies between the generic VKI header and the
0050    arch-specific VKI header.  It's possible in the future, as more stuff
0051    gets pulled in, that we might have to split files up some more to avoid
0052    further circular dependencies.)
0053    
0054    Finally, note that it is assumed that __KERNEL__ is set for all these
0055    definitions, which affects some of them.
0056 */
0057 
0058 /* The structure is (aiui, jrs 20060504):
0059 
0060      #include plat-specific posix types (vki-posixtypes-ARCH-linux.h)
0061 
0062      Lots more types, structs, consts, in this file
0063 
0064      #include other plat-specific stuff (vki-ARCH-linux.h)
0065 
0066      Even more types, structs, consts, in this file
0067 
0068    The system call numbers are dealt with by
0069    pub_{core,tool}_vkiscnums.h, not via pub_{core,tool}_vki.h, which
0070    is what this file is part of.
0071 */
0072 
0073 #ifndef __VKI_LINUX_H
0074 #define __VKI_LINUX_H
0075 
0076 //----------------------------------------------------------------------
0077 // Arch-specific POSIX types
0078 //----------------------------------------------------------------------
0079 
0080 #if defined(VGA_x86)
0081 #  include "vki-posixtypes-x86-linux.h"
0082 #elif defined(VGA_amd64)
0083 #  include "vki-posixtypes-amd64-linux.h"
0084 #elif defined(VGA_ppc32)
0085 #  include "vki-posixtypes-ppc32-linux.h"
0086 #elif defined(VGA_ppc64be) || defined(VGA_ppc64le)
0087 #  include "vki-posixtypes-ppc64-linux.h"
0088 #elif defined(VGA_arm)
0089 #  include "vki-posixtypes-arm-linux.h"
0090 #elif defined(VGA_arm64)
0091 #  include "vki-posixtypes-arm64-linux.h"
0092 #elif defined(VGA_s390x)
0093 #  include "vki-posixtypes-s390x-linux.h"
0094 #elif defined(VGA_mips32)
0095 #  include "vki-posixtypes-mips32-linux.h"
0096 #elif defined(VGA_mips64)
0097 #  include "vki-posixtypes-mips64-linux.h"
0098 #elif defined(VGA_nanomips)
0099 #  include "vki-posixtypes-nanomips-linux.h"
0100 #else
0101 #  error Unknown platform
0102 #endif
0103 
0104 //----------------------------------------------------------------------
0105 // VKI_STATIC_ASSERT(). Inspired by BUILD_BUG_ON() from
0106 // linux-2.6.34/include/linux/kernel.h
0107 //----------------------------------------------------------------------
0108 
0109 /*
0110  * Evaluates to zero if 'expr' is true and forces a compilation error if
0111  * 'expr' is false. Can be used in a context where no comma expressions
0112  * are allowed.
0113  */
0114 #ifdef __cplusplus
0115 template <bool b> struct vki_static_assert { int m_bitfield:(2*b-1); };
0116 #define VKI_STATIC_ASSERT(expr)                         \
0117     (sizeof(vki_static_assert<(expr)>) - sizeof(int))
0118 #else
0119 #define VKI_STATIC_ASSERT(expr) (sizeof(struct { int:-!(expr); }))
0120 #endif
0121 
0122 //----------------------------------------------------------------------
0123 // Based on _IOC_TYPECHECK() from linux-2.6.34/asm-generic/ioctl.h
0124 //----------------------------------------------------------------------
0125 
0126 /* provoke compile error for invalid uses of size argument */
0127 #define _VKI_IOC_TYPECHECK(t)                                           \
0128     (VKI_STATIC_ASSERT((sizeof(t) == sizeof(t[1])                       \
0129                         && sizeof(t) < (1 << _VKI_IOC_SIZEBITS)))       \
0130      + sizeof(t))
0131 
0132 //----------------------------------------------------------------------
0133 // From linux-2.6.8.1/include/linux/compiler.h
0134 //----------------------------------------------------------------------
0135 
0136 # define __user
0137 
0138 //----------------------------------------------------------------------
0139 // From linux/include/linux/compiler-gcc.h
0140 //----------------------------------------------------------------------
0141 
0142 #ifdef __GNUC__
0143 #define __vki_packed            __attribute__((packed))
0144 #endif
0145 
0146 //----------------------------------------------------------------------
0147 // From linux-2.6.8.1/include/linux/posix_types.h
0148 //----------------------------------------------------------------------
0149 
0150 #undef __VKI_NFDBITS
0151 #define __VKI_NFDBITS   (8 * sizeof(unsigned long))
0152 
0153 #undef __VKI_FD_SETSIZE
0154 #define __VKI_FD_SETSIZE    1024
0155 
0156 #undef __VKI_FDSET_LONGS
0157 #define __VKI_FDSET_LONGS   (__VKI_FD_SETSIZE/__VKI_NFDBITS)
0158 
0159 #undef __VKI_FDELT
0160 #define __VKI_FDELT(d)  ((d) / __VKI_NFDBITS)
0161 
0162 #undef __VKI_FDMASK
0163 #define __VKI_FDMASK(d) (1UL << ((d) % __VKI_NFDBITS))
0164 
0165 typedef struct {
0166     unsigned long fds_bits [__VKI_FDSET_LONGS];
0167 } __vki_kernel_fd_set;
0168 
0169 typedef int __vki_kernel_key_t;
0170 typedef int __vki_kernel_mqd_t;
0171 
0172 //----------------------------------------------------------------------
0173 // From linux-2.6.8.1/include/linux/types.h
0174 //----------------------------------------------------------------------
0175 
0176 typedef __vki_kernel_fd_set vki_fd_set;
0177 typedef __vki_kernel_mode_t vki_mode_t;
0178 typedef __vki_kernel_off_t  vki_off_t;
0179 typedef __vki_kernel_pid_t  vki_pid_t;
0180 typedef __vki_kernel_key_t  vki_key_t;
0181 typedef __vki_kernel_suseconds_t    vki_suseconds_t;
0182 typedef __vki_kernel_timer_t    vki_timer_t;
0183 typedef __vki_kernel_clockid_t  vki_clockid_t;
0184 typedef __vki_kernel_mqd_t  vki_mqd_t;
0185 
0186 // [[Nb: it's a bit unclear due to a #ifdef, but I think this is right. --njn]]
0187 typedef __vki_kernel_uid32_t    vki_uid_t;
0188 typedef __vki_kernel_gid32_t    vki_gid_t;
0189 
0190 typedef __vki_kernel_old_uid_t  vki_old_uid_t;
0191 typedef __vki_kernel_old_gid_t  vki_old_gid_t;
0192 
0193 typedef __vki_kernel_loff_t vki_loff_t;
0194 
0195 typedef __vki_kernel_size_t vki_size_t;
0196 typedef __vki_kernel_time_t vki_time_t;
0197 typedef __vki_kernel_clock_t    vki_clock_t;
0198 typedef __vki_kernel_caddr_t    vki_caddr_t;
0199 
0200 typedef unsigned long           vki_u_long;
0201 
0202 typedef unsigned int            vki_uint;
0203 
0204 //----------------------------------------------------------------------
0205 // Now the rest of the arch-specific stuff
0206 //----------------------------------------------------------------------
0207 
0208 #if defined(VGA_x86)
0209 #  include "vki-x86-linux.h"
0210 #elif defined(VGA_amd64)
0211 #  include "vki-amd64-linux.h"
0212 #elif defined(VGA_ppc32)
0213 #  include "vki-ppc32-linux.h"
0214 #elif defined(VGA_ppc64be) || defined(VGA_ppc64le)
0215 #  include "vki-ppc64-linux.h"
0216 #elif defined(VGA_arm)
0217 #  include "vki-arm-linux.h"
0218 #elif defined(VGA_arm64)
0219 #  include "vki-arm64-linux.h"
0220 #elif defined(VGA_s390x)
0221 #  include "vki-s390x-linux.h"
0222 #elif defined(VGA_mips32)
0223 #  include "vki-mips32-linux.h"
0224 #elif defined(VGA_mips64)
0225 #  include "vki-mips64-linux.h"
0226 #elif defined(VGA_nanomips)
0227 #  include "vki-nanomips-linux.h"
0228 #else
0229 #  error Unknown platform
0230 #endif
0231 
0232 //----------------------------------------------------------------------
0233 // From linux-2.6.20.1/include/linux/types.h
0234 //----------------------------------------------------------------------
0235 
0236 typedef     __vki_s32   vki_int32_t;
0237 typedef     __vki_s16   vki_int16_t;
0238 typedef     __vki_s64   vki_int64_t;
0239 
0240 typedef     __vki_u8    vki_uint8_t;
0241 typedef     __vki_u16   vki_uint16_t;
0242 typedef     __vki_u32   vki_uint32_t;
0243 typedef     __vki_u64   vki_uint64_t;
0244 
0245 typedef     __vki_u16   __vki_le16;
0246 
0247 #define __vki_aligned_u64 __vki_u64 __attribute__((aligned(8)))
0248 
0249 //----------------------------------------------------------------------
0250 // From linux-2.6.8.1/include/linux/limits.h
0251 //----------------------------------------------------------------------
0252 
0253 #define VKI_PATH_MAX       4096 /* # chars in a path name including nul */
0254 
0255 //----------------------------------------------------------------------
0256 // From linux-2.6.8.1/include/linux/kernel.h
0257 //----------------------------------------------------------------------
0258 
0259 struct vki_sysinfo {
0260     long uptime;            /* Seconds since boot */
0261     unsigned long loads[3];     /* 1, 5, and 15 minute load averages */
0262     unsigned long totalram;     /* Total usable main memory size */
0263     unsigned long freeram;      /* Available memory size */
0264     unsigned long sharedram;    /* Amount of shared memory */
0265     unsigned long bufferram;    /* Memory used by buffers */
0266     unsigned long totalswap;    /* Total swap space size */
0267     unsigned long freeswap;     /* swap space still available */
0268     unsigned short procs;       /* Number of current processes */
0269     unsigned short pad;     /* explicit padding for m68k */
0270     unsigned long totalhigh;    /* Total high memory size */
0271     unsigned long freehigh;     /* Available high memory size */
0272     unsigned int mem_unit;      /* Memory unit size in bytes */
0273     char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
0274 };
0275 
0276 //----------------------------------------------------------------------
0277 // From linux-2.6.8.1/include/linux/time.h
0278 //----------------------------------------------------------------------
0279 
0280 #define VKI_CLOCK_REALTIME            0
0281 #define VKI_CLOCK_MONOTONIC           1
0282 #define VKI_CLOCK_PROCESS_CPUTIME_ID  2
0283 #define VKI_CLOCK_THREAD_CPUTIME_ID   3
0284 
0285 struct vki_timespec {
0286     vki_time_t  tv_sec;     /* seconds */
0287     long        tv_nsec;    /* nanoseconds */
0288 };
0289 
0290 /* Special values for vki_timespec.tv_nsec when used with utimensat.  */
0291 #define VKI_UTIME_NOW  ((1l << 30) - 1l)
0292 #define VKI_UTIME_OMIT ((1l << 30) - 2l)
0293 
0294 struct vki_timeval {
0295     vki_time_t  tv_sec;     /* seconds */
0296     vki_suseconds_t tv_usec;    /* microseconds */
0297 };
0298 
0299 struct vki_timezone {
0300     int tz_minuteswest; /* minutes west of Greenwich */
0301     int tz_dsttime; /* type of dst correction */
0302 };
0303 
0304 struct  vki_itimerspec {
0305         struct  vki_timespec it_interval;    /* timer period */
0306         struct  vki_timespec it_value;       /* timer expiration */
0307 };
0308 
0309 struct  vki_itimerval {
0310     struct  vki_timeval it_interval;    /* timer interval */
0311     struct  vki_timeval it_value;   /* current value */
0312 };
0313 
0314 //----------------------------------------------------------------------
0315 // From linux-2.6.8.1/include/linux/timex.h
0316 //----------------------------------------------------------------------
0317 
0318 struct vki_timex {
0319     unsigned int modes; /* mode selector */
0320     long offset;        /* time offset (usec) */
0321     long freq;      /* frequency offset (scaled ppm) */
0322     long maxerror;      /* maximum error (usec) */
0323     long esterror;      /* estimated error (usec) */
0324     int status;     /* clock command/status */
0325     long constant;      /* pll time constant */
0326     long precision;     /* clock precision (usec) (read only) */
0327     long tolerance;     /* clock frequency tolerance (ppm)
0328                  * (read only)
0329                  */
0330     struct vki_timeval time;    /* (read only) */
0331     long tick;      /* (modified) usecs between clock ticks */
0332 
0333     long ppsfreq;           /* pps frequency (scaled ppm) (ro) */
0334     long jitter;            /* pps jitter (us) (ro) */
0335     int shift;              /* interval duration (s) (shift) (ro) */
0336     long stabil;            /* pps stability (scaled ppm) (ro) */
0337     long jitcnt;            /* jitter limit exceeded (ro) */
0338     long calcnt;            /* calibration intervals (ro) */
0339     long errcnt;            /* calibration errors (ro) */
0340     long stbcnt;            /* stability limit exceeded (ro) */
0341 
0342     int  :32; int  :32; int  :32; int  :32;
0343     int  :32; int  :32; int  :32; int  :32;
0344     int  :32; int  :32; int  :32; int  :32;
0345 };
0346 
0347 #define VKI_ADJ_OFFSET          0x0001  /* time offset */
0348 #define VKI_ADJ_FREQUENCY       0x0002  /* frequency offset */
0349 #define VKI_ADJ_MAXERROR        0x0004  /* maximum time error */
0350 #define VKI_ADJ_ESTERROR        0x0008  /* estimated time error */
0351 #define VKI_ADJ_STATUS          0x0010  /* clock status */
0352 #define VKI_ADJ_TIMECONST       0x0020  /* pll time constant */
0353 #define VKI_ADJ_TAI         0x0080  /* set TAI offset */
0354 #define VKI_ADJ_TICK            0x4000  /* tick value */
0355 #define VKI_ADJ_ADJTIME         0x8000  /* switch between adjtime/adjtimex modes */
0356 //#define VKI_ADJ_OFFSET_SINGLESHOT 0x8001  /* old-fashioned adjtime */
0357 #define VKI_ADJ_OFFSET_READONLY     0x2000  /* read-only adjtime */
0358 
0359 //----------------------------------------------------------------------
0360 // From linux-2.6.8.1/include/linux/times.h
0361 //----------------------------------------------------------------------
0362 
0363 struct vki_tms {
0364     vki_clock_t tms_utime;
0365     vki_clock_t tms_stime;
0366     vki_clock_t tms_cutime;
0367     vki_clock_t tms_cstime;
0368 };
0369 
0370 //----------------------------------------------------------------------
0371 // From linux-2.6.8.1/include/linux/utime.h
0372 //----------------------------------------------------------------------
0373 
0374 struct vki_utimbuf {
0375     vki_time_t actime;
0376     vki_time_t modtime;
0377 };
0378 
0379 //----------------------------------------------------------------------
0380 // From linux-2.6.8.1/include/linux/sched.h
0381 //----------------------------------------------------------------------
0382 
0383 #define VKI_CSIGNAL         0x000000ff  /* signal mask to be sent at exit */
0384 #define VKI_CLONE_VM            0x00000100  /* set if VM shared between processes */
0385 #define VKI_CLONE_FS            0x00000200  /* set if fs info shared between processes */
0386 #define VKI_CLONE_FILES         0x00000400  /* set if open files shared between processes */
0387 #define VKI_CLONE_SIGHAND       0x00000800  /* set if signal handlers and blocked signals shared */
0388 #define VKI_CLONE_PIDFD         0x00001000  /* set if a pidfd should be placed in parent */
0389 #define VKI_CLONE_PTRACE        0x00002000  /* set if we want to let tracing continue on the child too */
0390 #define VKI_CLONE_VFORK         0x00004000  /* set if the parent wants the child to wake it up on mm_release */
0391 #define VKI_CLONE_PARENT        0x00008000  /* set if we want to have the same parent as the cloner */
0392 #define VKI_CLONE_THREAD        0x00010000  /* Same thread group? */
0393 #define VKI_CLONE_NEWNS         0x00020000  /* New mount namespace group */
0394 #define VKI_CLONE_SYSVSEM       0x00040000  /* share system V SEM_UNDO semantics */
0395 #define VKI_CLONE_SETTLS        0x00080000  /* create a new TLS for the child */
0396 #define VKI_CLONE_PARENT_SETTID     0x00100000  /* set the TID in the parent */
0397 #define VKI_CLONE_CHILD_CLEARTID    0x00200000  /* clear the TID in the child */
0398 #define VKI_CLONE_DETACHED      0x00400000  /* Unused, ignored */
0399 #define VKI_CLONE_UNTRACED      0x00800000  /* set if the tracing process can't force CLONE_PTRACE on this clone */
0400 #define VKI_CLONE_CHILD_SETTID      0x01000000  /* set the TID in the child */
0401 #define VKI_CLONE_NEWCGROUP     0x02000000  /* New cgroup namespace */
0402 #define VKI_CLONE_NEWUTS        0x04000000  /* New utsname namespace */
0403 #define VKI_CLONE_NEWIPC        0x08000000  /* New ipc namespace */
0404 #define VKI_CLONE_NEWUSER       0x10000000  /* New user namespace */
0405 #define VKI_CLONE_NEWPID        0x20000000  /* New pid namespace */
0406 #define VKI_CLONE_NEWNET        0x40000000  /* New network namespace */
0407 #define VKI_CLONE_IO            0x80000000  /* Clone io context */
0408 
0409 struct vki_sched_param {
0410     int sched_priority;
0411 };
0412 
0413 struct vki_sched_attr {
0414     vki_uint32_t size;
0415     vki_uint32_t sched_policy;
0416     vki_uint64_t sched_flags;
0417 
0418     /* SCHED_NORMAL, SCHED_BATCH */
0419     vki_int32_t sched_nice;
0420 
0421     /* SCHED_FIFO, SCHED_RR */
0422     vki_uint32_t sched_priority;
0423 
0424     /* SCHED_DEADLINE */
0425     vki_uint64_t sched_runtime;
0426     vki_uint64_t sched_deadline;
0427     vki_uint64_t sched_period;
0428 };
0429 
0430 #define VKI_TASK_COMM_LEN 16
0431 
0432 //----------------------------------------------------------------------
0433 // From linux-2.6.8.1/include/asm-generic/siginfo.h
0434 //----------------------------------------------------------------------
0435 
0436 // Some archs, such as MIPS, have non-standard vki_siginfo.
0437 #ifndef HAVE_ARCH_SIGINFO_T
0438 typedef union vki_sigval {
0439     int sival_int;
0440     void __user *sival_ptr;
0441 } vki_sigval_t;
0442 
0443 #ifndef __VKI_ARCH_SI_PREAMBLE_SIZE
0444 #define __VKI_ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int))
0445 #endif
0446 
0447 #define VKI_SI_MAX_SIZE 128
0448 
0449 #ifndef VKI_SI_PAD_SIZE
0450 #define VKI_SI_PAD_SIZE ((VKI_SI_MAX_SIZE - __VKI_ARCH_SI_PREAMBLE_SIZE) / sizeof(int))
0451 #endif
0452 
0453 #ifndef __VKI_ARCH_SI_UID_T
0454 #define __VKI_ARCH_SI_UID_T vki_uid_t
0455 #endif
0456 
0457 #ifndef __VKI_ARCH_SI_BAND_T
0458 #define __VKI_ARCH_SI_BAND_T long
0459 #endif
0460 
0461 #ifndef __VKI_ARCH_SI_CLOCK_T
0462 #define __VKI_ARCH_SI_CLOCK_T vki_clock_t
0463 #endif
0464 
0465 #ifndef __VKI_ARCH_SI_ATTRIBUTES
0466 #define __VKI_ARCH_SI_ATTRIBUTES
0467 #endif
0468 
0469 // [[Nb: this type changed between 2.4 and 2.6, but not in a way that
0470 // affects Valgrind.]]
0471 typedef struct vki_siginfo {
0472     int si_signo;
0473     int si_errno;
0474     int si_code;
0475 
0476     union {
0477         int _pad[VKI_SI_PAD_SIZE];
0478 
0479         /* kill() */
0480         struct {
0481             vki_pid_t _pid;     /* sender's pid */
0482             __VKI_ARCH_SI_UID_T _uid;   /* sender's uid */
0483         } _kill;
0484 
0485         /* POSIX.1b timers */
0486         struct {
0487             vki_timer_t _tid;       /* timer id */
0488             int _overrun;       /* overrun count */
0489             char _pad[sizeof( __VKI_ARCH_SI_UID_T) - sizeof(int)];
0490             vki_sigval_t _sigval;   /* same as below */
0491             int _sys_private;       /* not to be passed to user */
0492         } _timer;
0493 
0494         /* POSIX.1b signals */
0495         struct {
0496             vki_pid_t _pid;     /* sender's pid */
0497             __VKI_ARCH_SI_UID_T _uid;   /* sender's uid */
0498             vki_sigval_t _sigval;
0499         } _rt;
0500 
0501         /* SIGCHLD */
0502         struct {
0503             vki_pid_t _pid;     /* which child */
0504             __VKI_ARCH_SI_UID_T _uid;   /* sender's uid */
0505             int _status;        /* exit code */
0506             __VKI_ARCH_SI_CLOCK_T _utime;
0507             __VKI_ARCH_SI_CLOCK_T _stime;
0508         } _sigchld;
0509 
0510         /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
0511         struct {
0512             void __user *_addr; /* faulting insn/memory ref. */
0513 #ifdef __ARCH_SI_TRAPNO
0514             int _trapno;    /* TRAP # which caused the signal */
0515 #endif
0516         } _sigfault;
0517 
0518         /* SIGPOLL */
0519         struct {
0520             __VKI_ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */
0521             int _fd;
0522         } _sigpoll;
0523     } _sifields;
0524 } __VKI_ARCH_SI_ATTRIBUTES vki_siginfo_t;
0525 #endif
0526 
0527 #define __VKI_SI_FAULT  0
0528 
0529 /*
0530  * si_code values
0531  * Digital reserves positive values for kernel-generated signals.
0532  */
0533 #define VKI_SI_USER 0       /* sent by kill, sigsend, raise */
0534 #define VKI_SI_TKILL    -6      /* sent by tkill system call */
0535 
0536 /*
0537  * SIGILL si_codes
0538  */
0539 #define VKI_ILL_ILLOPC  (__VKI_SI_FAULT|1)  /* illegal opcode */
0540 #define VKI_ILL_ILLOPN  (__VKI_SI_FAULT|2)  /* illegal operand */
0541 #define VKI_ILL_ILLADR  (__VKI_SI_FAULT|3)  /* illegal addressing mode */
0542 #define VKI_ILL_ILLTRP  (__VKI_SI_FAULT|4)  /* illegal trap */
0543 #define VKI_ILL_PRVOPC  (__VKI_SI_FAULT|5)  /* privileged opcode */
0544 #define VKI_ILL_PRVREG  (__VKI_SI_FAULT|6)  /* privileged register */
0545 #define VKI_ILL_COPROC  (__VKI_SI_FAULT|7)  /* coprocessor error */
0546 #define VKI_ILL_BADSTK  (__VKI_SI_FAULT|8)  /* internal stack error */
0547 
0548 /*
0549  * SIGFPE si_codes
0550  */
0551 #define VKI_FPE_INTDIV  (__VKI_SI_FAULT|1)  /* integer divide by zero */
0552 #define VKI_FPE_INTOVF  (__VKI_SI_FAULT|2)  /* integer overflow */
0553 #define VKI_FPE_FLTDIV  (__VKI_SI_FAULT|3)  /* floating point divide by zero */
0554 #define VKI_FPE_FLTOVF  (__VKI_SI_FAULT|4)  /* floating point overflow */
0555 #define VKI_FPE_FLTUND  (__VKI_SI_FAULT|5)  /* floating point underflow */
0556 #define VKI_FPE_FLTRES  (__VKI_SI_FAULT|6)  /* floating point inexact result */
0557 #define VKI_FPE_FLTINV  (__VKI_SI_FAULT|7)  /* floating point invalid operation */
0558 #define VKI_FPE_FLTSUB  (__VKI_SI_FAULT|8)  /* subscript out of range */
0559 
0560 /*
0561  * SIGSEGV si_codes
0562  */
0563 #define VKI_SEGV_MAPERR (__VKI_SI_FAULT|1)  /* address not mapped to object */
0564 #define VKI_SEGV_ACCERR (__VKI_SI_FAULT|2)  /* invalid permissions for mapped object */
0565 
0566 /*
0567  * SIGBUS si_codes
0568  */
0569 #define VKI_BUS_ADRALN  (__VKI_SI_FAULT|1)  /* invalid address alignment */
0570 #define VKI_BUS_ADRERR  (__VKI_SI_FAULT|2)  /* non-existent physical address */
0571 #define VKI_BUS_OBJERR  (__VKI_SI_FAULT|3)  /* object specific hardware error */
0572 
0573 /*
0574  * SIGTRAP si_codes
0575  */
0576 #define VKI_TRAP_BRKPT      (__VKI_SI_FAULT|1)  /* process breakpoint */
0577 #define VKI_TRAP_TRACE      (__VKI_SI_FAULT|2)  /* process trace trap */
0578 
0579 /*
0580  * SIGCHLD si_codes
0581  */
0582 #define VKI_CLD_EXITED    (__VKI_SI_FAULT|1)  /* child has exited */
0583 #define VKI_CLD_KILLED    (__VKI_SI_FAULT|2)  /* child was killed */
0584 #define VKI_CLD_DUMPED    (__VKI_SI_FAULT|3)  /* child terminated abnormally */
0585 #define VKI_CLD_TRAPPED   (__VKI_SI_FAULT|4)  /* traced child has trapped */
0586 #define VKI_CLD_STOPPED   (__VKI_SI_FAULT|5)  /* child has stopped */
0587 #define VKI_CLD_CONTINUED (__VKI_SI_FAULT|6)  /* stopped child has continued */
0588 
0589 /*
0590  * This works because the alignment is ok on all current architectures
0591  * but we leave open this being overridden in the future
0592  */
0593 #ifndef VKI___ARCH_SIGEV_PREAMBLE_SIZE
0594 #define VKI___ARCH_SIGEV_PREAMBLE_SIZE  (sizeof(int) * 2 + sizeof(vki_sigval_t))
0595 #endif
0596 
0597 #define VKI_SIGEV_MAX_SIZE  64
0598 #define VKI_SIGEV_PAD_SIZE  ((VKI_SIGEV_MAX_SIZE - VKI___ARCH_SIGEV_PREAMBLE_SIZE) \
0599         / sizeof(int))
0600 
0601 /* This is the flag the kernel handles, userspace/glibc handles SEGEV_THEAD. */
0602 #define VKI_SIGEV_THREAD_ID 4
0603 
0604 typedef struct vki_sigevent {
0605     vki_sigval_t sigev_value;
0606     int sigev_signo;
0607     int sigev_notify;
0608     union {
0609         int _pad[VKI_SIGEV_PAD_SIZE];
0610          int _tid;
0611 
0612         struct {
0613             void (*_function)(vki_sigval_t);
0614             void *_attribute;   /* really pthread_attr_t */
0615         } _sigev_thread;
0616     } _sigev_un;
0617 } vki_sigevent_t;
0618 
0619 #define vki_sigev_notify_thread_id  _sigev_un._tid
0620 
0621 //----------------------------------------------------------------------
0622 // From elsewhere...
0623 //----------------------------------------------------------------------
0624 
0625 // [[The kernel actually uses the numbers 0,1,2 directly here, believe it or
0626 // not.  So we introduce our own constants, based on the glibc ones.]]
0627 #define VKI_SEEK_SET              0
0628 #define VKI_SEEK_CUR              1
0629 #define VKI_SEEK_END              2
0630 
0631 //----------------------------------------------------------------------
0632 // From linux-2.6.8.1/include/linux/net.h
0633 //----------------------------------------------------------------------
0634 
0635 #define VKI_SYS_SOCKET      1   /* sys_socket(2)        */
0636 #define VKI_SYS_BIND        2   /* sys_bind(2)          */
0637 #define VKI_SYS_CONNECT     3   /* sys_connect(2)       */
0638 #define VKI_SYS_LISTEN      4   /* sys_listen(2)        */
0639 #define VKI_SYS_ACCEPT      5   /* sys_accept(2)        */
0640 #define VKI_SYS_GETSOCKNAME 6   /* sys_getsockname(2)       */
0641 #define VKI_SYS_GETPEERNAME 7   /* sys_getpeername(2)       */
0642 #define VKI_SYS_SOCKETPAIR  8   /* sys_socketpair(2)        */
0643 #define VKI_SYS_SEND        9   /* sys_send(2)          */
0644 #define VKI_SYS_RECV        10  /* sys_recv(2)          */
0645 #define VKI_SYS_SENDTO      11  /* sys_sendto(2)        */
0646 #define VKI_SYS_RECVFROM    12  /* sys_recvfrom(2)      */
0647 #define VKI_SYS_SHUTDOWN    13  /* sys_shutdown(2)      */
0648 #define VKI_SYS_SETSOCKOPT  14  /* sys_setsockopt(2)        */
0649 #define VKI_SYS_GETSOCKOPT  15  /* sys_getsockopt(2)        */
0650 #define VKI_SYS_SENDMSG     16  /* sys_sendmsg(2)       */
0651 #define VKI_SYS_RECVMSG     17  /* sys_recvmsg(2)       */
0652 #define VKI_SYS_ACCEPT4     18  /* sys_accept4(2)       */
0653 #define VKI_SYS_RECVMMSG    19  /* sys_recvmmsg(2)              */
0654 #define VKI_SYS_SENDMMSG    20  /* sys_sendmmsg(2)              */
0655 
0656 #ifndef ARCH_HAS_SOCKET_TYPES
0657 enum vki_sock_type {
0658     VKI_SOCK_STREAM = 1,
0659     // [[others omitted]]
0660 };
0661 #endif /* ARCH_HAS_SOCKET_TYPES */
0662 
0663 //----------------------------------------------------------------------
0664 // From linux-2.6.8.1/include/linux/uio.h
0665 //----------------------------------------------------------------------
0666 
0667 struct vki_iovec
0668 {
0669     void __user *iov_base;  /* BSD uses caddr_t (1003.1g requires void *) */
0670     __vki_kernel_size_t iov_len; /* Must be size_t (1003.1g) */
0671 };
0672 
0673 //----------------------------------------------------------------------
0674 // From linux-2.6.8.1/include/linux/socket.h
0675 //----------------------------------------------------------------------
0676 
0677 // [[Resolved arbitrarily;  doesn't really matter whether it's '__inline__'
0678 //   or 'inline']]
0679 #define __KINLINE static __inline__
0680 
0681 typedef unsigned short  vki_sa_family_t;
0682 
0683 struct vki_sockaddr {
0684     vki_sa_family_t sa_family;  /* address family, AF_xxx   */
0685     char        sa_data[14];    /* 14 bytes of protocol address */
0686 };
0687 
0688 struct vki_msghdr {
0689     void    *   msg_name;   /* Socket name          */
0690     int     msg_namelen;    /* Length of name       */
0691     struct vki_iovec *  msg_iov;    /* Data blocks          */
0692     __vki_kernel_size_t msg_iovlen; /* Number of blocks     */
0693     void    *   msg_control;    /* Per protocol magic (eg BSD file descriptor passing) */
0694     __vki_kernel_size_t msg_controllen; /* Length of cmsg list */
0695     unsigned    msg_flags;
0696 };
0697 
0698 struct vki_mmsghdr {
0699     struct vki_msghdr   msg_hdr;
0700     unsigned        msg_len;
0701 };
0702 
0703 struct vki_cmsghdr {
0704     __vki_kernel_size_t cmsg_len;   /* data byte count, including hdr */
0705         int     cmsg_level; /* originating protocol */
0706         int     cmsg_type;  /* protocol-specific type */
0707 };
0708 
0709 #define __VKI_CMSG_NXTHDR(ctl, len, cmsg) __vki_cmsg_nxthdr((ctl),(len),(cmsg))
0710 #define VKI_CMSG_NXTHDR(mhdr, cmsg) vki_cmsg_nxthdr((mhdr), (cmsg))
0711 
0712 #define VKI_CMSG_ALIGN(len) ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) )
0713 
0714 #define VKI_CMSG_DATA(cmsg) ((void *)((char *)(cmsg) + VKI_CMSG_ALIGN(sizeof(struct vki_cmsghdr))))
0715 
0716 #define __VKI_CMSG_FIRSTHDR(ctl,len) ((len) >= sizeof(struct vki_cmsghdr) ? \
0717                   (struct vki_cmsghdr *)(ctl) : \
0718                   (struct vki_cmsghdr *)NULL)
0719 #define VKI_CMSG_FIRSTHDR(msg)  __VKI_CMSG_FIRSTHDR((msg)->msg_control, (msg)->msg_controllen)
0720 
0721 // [[Urgh, this is revolting...]
0722 __KINLINE struct vki_cmsghdr * __vki_cmsg_nxthdr(void *__ctl, __vki_kernel_size_t __size,
0723                            struct vki_cmsghdr *__cmsg)
0724 {
0725     struct vki_cmsghdr * __ptr;
0726 
0727     __ptr = ASSUME_ALIGNED(struct vki_cmsghdr *,
0728             ((unsigned char *) __cmsg) +  VKI_CMSG_ALIGN(__cmsg->cmsg_len));
0729     if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size)
0730         return (struct vki_cmsghdr *)0;
0731 
0732     return __ptr;
0733 }
0734 
0735 __KINLINE struct vki_cmsghdr * vki_cmsg_nxthdr (struct vki_msghdr *__msg, struct vki_cmsghdr *__cmsg)
0736 {
0737     return __vki_cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg);
0738 }
0739 
0740 #define VKI_SCM_RIGHTS  0x01        /* rw: access rights (array of int) */
0741 
0742 #define VKI_AF_UNSPEC   0
0743 #define VKI_AF_UNIX 1   /* Unix domain sockets      */
0744 #define VKI_AF_INET 2   /* Internet IP Protocol     */
0745 #define VKI_AF_INET6    10  /* IP version 6         */
0746 #define VKI_AF_NETLINK  16
0747 #define VKI_AF_BLUETOOTH 31 /* Bluetooth sockets        */
0748 
0749 #define VKI_MSG_NOSIGNAL    0x4000  /* Do not generate SIGPIPE */
0750 
0751 #define VKI_SOL_SCTP    132
0752 
0753 //----------------------------------------------------------------------
0754 // From linux-2.6.8.1/include/linux/in.h
0755 //----------------------------------------------------------------------
0756 
0757 struct vki_in_addr {
0758     __vki_u32   s_addr;
0759 };
0760 
0761 /* Structure describing an Internet (IP) socket address. */
0762 #define __VKI_SOCK_SIZE__   16  /* sizeof(struct sockaddr)  */
0763 struct vki_sockaddr_in {
0764   vki_sa_family_t   sin_family; /* Address family       */
0765   unsigned short int    sin_port;   /* Port number          */
0766   struct vki_in_addr    sin_addr;   /* Internet address     */
0767 
0768   /* Pad to size of `struct sockaddr'. */
0769   unsigned char     __pad[__VKI_SOCK_SIZE__ - sizeof(short int) -
0770             sizeof(unsigned short int) - sizeof(struct vki_in_addr)];
0771 };
0772 
0773 #define VKI_IPPROTO_TCP 6       /* Transmission Control Protocol        */
0774 
0775 //----------------------------------------------------------------------
0776 // From linux-2.6.8.1/include/linux/in6.h
0777 //----------------------------------------------------------------------
0778 
0779 struct vki_in6_addr
0780 {
0781     union 
0782     {
0783         __vki_u8    u6_addr8[16];
0784         __vki_u16   u6_addr16[8];
0785         __vki_u32   u6_addr32[4];
0786     } vki_in6_u;
0787 #define vki_s6_addr     vki_in6_u.u6_addr8
0788 #define vki_s6_addr16       vki_in6_u.u6_addr16
0789 #define vki_s6_addr32       vki_in6_u.u6_addr32
0790 };
0791 
0792 struct vki_sockaddr_in6 {
0793     unsigned short int  sin6_family;    /* AF_INET6 */
0794     __vki_u16       sin6_port;      /* Transport layer port # */
0795     __vki_u32       sin6_flowinfo;  /* IPv6 flow information */
0796     struct vki_in6_addr sin6_addr;      /* IPv6 address */
0797     __vki_u32       sin6_scope_id;  /* scope id (new in RFC2553) */
0798 };
0799 
0800 //----------------------------------------------------------------------
0801 // From linux-2.6.8.1/include/linux/tcp.h
0802 //----------------------------------------------------------------------
0803 
0804 #define VKI_TCP_NODELAY    1       /* Turn off Nagle's algorithm. */
0805 
0806 
0807 //----------------------------------------------------------------------
0808 // From linux-2.6.8.1/include/linux/un.h
0809 //----------------------------------------------------------------------
0810 
0811 #define VKI_UNIX_PATH_MAX   108
0812 
0813 struct vki_sockaddr_un {
0814     vki_sa_family_t sun_family; /* AF_UNIX */
0815     char sun_path[VKI_UNIX_PATH_MAX];   /* pathname */
0816 };
0817 
0818 //----------------------------------------------------------------------
0819 // From linux-3.15.8/include/uapi/linux/netlink.h
0820 //----------------------------------------------------------------------
0821 
0822 struct vki_sockaddr_nl {
0823         vki_sa_family_t    nl_family;      /* AF_NETLINK   */
0824         unsigned short     nl_pad;         /* zero         */
0825         __vki_u32          nl_pid;         /* port ID      */
0826         __vki_u32          nl_groups;      /* multicast groups mask */
0827 };
0828 
0829 //----------------------------------------------------------------------
0830 // From linux-2.6.8.1/include/linux/if.h
0831 //----------------------------------------------------------------------
0832 
0833 #define VKI_IFNAMSIZ    16
0834 
0835 struct vki_ifmap 
0836 {
0837     unsigned long mem_start;
0838     unsigned long mem_end;
0839     unsigned short base_addr; 
0840     unsigned char irq;
0841     unsigned char dma;
0842     unsigned char port;
0843     /* 3 bytes spare */
0844 };
0845 
0846 struct vki_if_settings
0847 {
0848     unsigned int type;  /* Type of physical device or protocol */
0849     unsigned int size;  /* Size of the data allocated by the caller */
0850     union {
0851                 // [[Nb: converted these all to void* to avoid pulling in
0852                 //   unnecessary headers]]]
0853         /* {atm/eth/dsl}_settings anyone ? */
0854         void /*raw_hdlc_proto       */__user *raw_hdlc;
0855         void /*cisco_proto      */__user *cisco;
0856         void /*fr_proto         */__user *fr;
0857         void /*fr_proto_pvc     */__user *fr_pvc;
0858         void /*fr_proto_pvc_info    */__user *fr_pvc_info;
0859 
0860         /* interface settings */
0861         void /*sync_serial_settings */__user *sync;
0862         void /*te1_settings     */__user *te1;
0863     } ifs_ifsu;
0864 };
0865 
0866 struct vki_ifreq 
0867 {
0868 #define VKI_IFHWADDRLEN 6
0869     union
0870     {
0871         char    ifrn_name[VKI_IFNAMSIZ];        /* if name, e.g. "en0" */
0872     } ifr_ifrn;
0873     
0874     union {
0875         struct  vki_sockaddr ifru_addr;
0876         struct  vki_sockaddr ifru_dstaddr;
0877         struct  vki_sockaddr ifru_broadaddr;
0878         struct  vki_sockaddr ifru_netmask;
0879         struct  vki_sockaddr ifru_hwaddr;
0880         short   ifru_flags;
0881         int ifru_ivalue;
0882         int ifru_mtu;
0883         struct  vki_ifmap ifru_map;
0884         char    ifru_slave[VKI_IFNAMSIZ];   /* Just fits the size */
0885         char    ifru_newname[VKI_IFNAMSIZ];
0886         void __user *   ifru_data;
0887         struct  vki_if_settings ifru_settings;
0888     } ifr_ifru;
0889 };
0890 
0891 #define vki_ifr_name    ifr_ifrn.ifrn_name  /* interface name   */
0892 #define vki_ifr_hwaddr  ifr_ifru.ifru_hwaddr    /* MAC address      */
0893 #define vki_ifr_addr    ifr_ifru.ifru_addr  /* address      */
0894 #define vki_ifr_dstaddr ifr_ifru.ifru_dstaddr   /* other end of p-p lnk */
0895 #define vki_ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address  */
0896 #define vki_ifr_netmask ifr_ifru.ifru_netmask   /* interface net mask   */
0897 #define vki_ifr_flags   ifr_ifru.ifru_flags /* flags        */
0898 #define vki_ifr_metric  ifr_ifru.ifru_ivalue    /* metric       */
0899 #define vki_ifr_mtu ifr_ifru.ifru_mtu   /* mtu          */
0900 #define vki_ifr_map ifr_ifru.ifru_map   /* device map       */
0901 #define vki_ifr_slave   ifr_ifru.ifru_slave /* slave device     */
0902 #define vki_ifr_data    ifr_ifru.ifru_data  /* for use by interface */
0903 #define vki_ifr_ifindex ifr_ifru.ifru_ivalue    /* interface index  */
0904 #define vki_ifr_bandwidth ifr_ifru.ifru_ivalue  /* link bandwidth   */
0905 #define vki_ifr_qlen    ifr_ifru.ifru_ivalue    /* Queue length     */
0906 #define vki_ifr_newname ifr_ifru.ifru_newname   /* New name     */
0907 #define vki_ifr_settings ifr_ifru.ifru_settings /* Device/proto settings*/
0908 
0909 struct vki_ifconf 
0910 {
0911     int ifc_len;            /* size of buffer   */
0912     union 
0913     {
0914         char __user *ifcu_buf;
0915         struct vki_ifreq __user *ifcu_req;
0916     } ifc_ifcu;
0917 };
0918 #define vki_ifc_buf ifc_ifcu.ifcu_buf   /* buffer address   */
0919 
0920 //----------------------------------------------------------------------
0921 // From linux-2.6.8.1/include/linux/if_arp.h
0922 //----------------------------------------------------------------------
0923 
0924 struct vki_arpreq {
0925   struct vki_sockaddr   arp_pa;     /* protocol address     */
0926   struct vki_sockaddr   arp_ha;     /* hardware address     */
0927   int           arp_flags;  /* flags            */
0928   struct vki_sockaddr   arp_netmask;    /* netmask (only for proxy arps) */
0929   char          arp_dev[16];
0930 };
0931 
0932 //----------------------------------------------------------------------
0933 // From linux-2.6.8.1/include/linux/route.h
0934 //----------------------------------------------------------------------
0935 
0936 struct vki_rtentry 
0937 {
0938     unsigned long   rt_pad1;
0939     struct vki_sockaddr rt_dst;     /* target address       */
0940     struct vki_sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY)   */
0941     struct vki_sockaddr rt_genmask; /* target network mask (IP) */
0942     unsigned short  rt_flags;
0943     short       rt_pad2;
0944     unsigned long   rt_pad3;
0945     void        *rt_pad4;
0946     short       rt_metric;  /* +1 for binary compatibility! */
0947     char __user *rt_dev;    /* forcing the device at add    */
0948     unsigned long   rt_mtu;     /* per route MTU/Window     */
0949 // [[Not important for Valgrind]]
0950 //#ifndef __KERNEL__
0951 //#define rt_mss    rt_mtu      /* Compatibility :-(            */
0952 //#endif
0953     unsigned long   rt_window;  /* Window clamping      */
0954     unsigned short  rt_irtt;    /* Initial RTT          */
0955 };
0956 
0957 //----------------------------------------------------------------------
0958 // From linux-2.6.13-rc5/include/net/sctp/user.h
0959 //----------------------------------------------------------------------
0960 
0961 typedef __vki_s32 vki_sctp_assoc_t;
0962 
0963 enum vki_sctp_optname {
0964     VKI_SCTP_RTOINFO,
0965 #define VKI_SCTP_RTOINFO VKI_SCTP_RTOINFO
0966     VKI_SCTP_ASSOCINFO,
0967 #define VKI_SCTP_ASSOCINFO VKI_SCTP_ASSOCINFO
0968     VKI_SCTP_INITMSG,
0969 #define VKI_SCTP_INITMSG VKI_SCTP_INITMSG
0970     VKI_SCTP_NODELAY,   /* Get/set nodelay option. */
0971 #define VKI_SCTP_NODELAY    VKI_SCTP_NODELAY
0972     VKI_SCTP_AUTOCLOSE,
0973 #define VKI_SCTP_AUTOCLOSE VKI_SCTP_AUTOCLOSE
0974     VKI_SCTP_SET_PEER_PRIMARY_ADDR, 
0975 #define VKI_SCTP_SET_PEER_PRIMARY_ADDR VKI_SCTP_SET_PEER_PRIMARY_ADDR
0976     VKI_SCTP_PRIMARY_ADDR,
0977 #define VKI_SCTP_PRIMARY_ADDR VKI_SCTP_PRIMARY_ADDR
0978     VKI_SCTP_ADAPTION_LAYER,      
0979 #define VKI_SCTP_ADAPTION_LAYER VKI_SCTP_ADAPTION_LAYER
0980     VKI_SCTP_DISABLE_FRAGMENTS,
0981 #define VKI_SCTP_DISABLE_FRAGMENTS VKI_SCTP_DISABLE_FRAGMENTS
0982     VKI_SCTP_PEER_ADDR_PARAMS,
0983 #define VKI_SCTP_PEER_ADDR_PARAMS VKI_SCTP_PEER_ADDR_PARAMS
0984     VKI_SCTP_DEFAULT_SEND_PARAM,
0985 #define VKI_SCTP_DEFAULT_SEND_PARAM VKI_SCTP_DEFAULT_SEND_PARAM
0986     VKI_SCTP_EVENTS,
0987 #define VKI_SCTP_EVENTS VKI_SCTP_EVENTS
0988     VKI_SCTP_I_WANT_MAPPED_V4_ADDR,  /* Turn on/off mapped v4 addresses  */
0989 #define VKI_SCTP_I_WANT_MAPPED_V4_ADDR VKI_SCTP_I_WANT_MAPPED_V4_ADDR
0990     VKI_SCTP_MAXSEG,    /* Get/set maximum fragment. */
0991 #define VKI_SCTP_MAXSEG     VKI_SCTP_MAXSEG
0992     VKI_SCTP_STATUS,
0993 #define VKI_SCTP_STATUS VKI_SCTP_STATUS
0994     VKI_SCTP_GET_PEER_ADDR_INFO,
0995 #define VKI_SCTP_GET_PEER_ADDR_INFO VKI_SCTP_GET_PEER_ADDR_INFO
0996 
0997     /* Internal Socket Options. Some of the sctp library functions are 
0998      * implemented using these socket options.
0999      */
1000     VKI_SCTP_SOCKOPT_BINDX_ADD = 100,/* BINDX requests for adding addresses. */
1001 #define VKI_SCTP_SOCKOPT_BINDX_ADD  VKI_SCTP_SOCKOPT_BINDX_ADD
1002     VKI_SCTP_SOCKOPT_BINDX_REM, /* BINDX requests for removing addresses. */
1003 #define VKI_SCTP_SOCKOPT_BINDX_REM  VKI_SCTP_SOCKOPT_BINDX_REM
1004     VKI_SCTP_SOCKOPT_PEELOFF,   /* peel off association. */
1005 #define VKI_SCTP_SOCKOPT_PEELOFF    VKI_SCTP_SOCKOPT_PEELOFF
1006     VKI_SCTP_GET_PEER_ADDRS_NUM,    /* Get number of peer addresss. */
1007 #define VKI_SCTP_GET_PEER_ADDRS_NUM VKI_SCTP_GET_PEER_ADDRS_NUM
1008     VKI_SCTP_GET_PEER_ADDRS,    /* Get all peer addresss. */
1009 #define VKI_SCTP_GET_PEER_ADDRS VKI_SCTP_GET_PEER_ADDRS
1010     VKI_SCTP_GET_LOCAL_ADDRS_NUM,   /* Get number of local addresss. */
1011 #define VKI_SCTP_GET_LOCAL_ADDRS_NUM    VKI_SCTP_GET_LOCAL_ADDRS_NUM
1012     VKI_SCTP_GET_LOCAL_ADDRS,   /* Get all local addresss. */
1013 #define VKI_SCTP_GET_LOCAL_ADDRS    VKI_SCTP_GET_LOCAL_ADDRS
1014     VKI_SCTP_SOCKOPT_CONNECTX, /* CONNECTX requests. */
1015 #define VKI_SCTP_SOCKOPT_CONNECTX   VKI_SCTP_SOCKOPT_CONNECTX
1016 };
1017 
1018 struct vki_sctp_getaddrs {
1019     vki_sctp_assoc_t        assoc_id;
1020     int         addr_num;
1021     struct vki_sockaddr *addrs;
1022 };
1023 
1024 //----------------------------------------------------------------------
1025 // From linux-2.6.8.1/include/linux/resource.h
1026 //----------------------------------------------------------------------
1027 
1028 #define VKI_RUSAGE_SELF     0
1029 #define VKI_RUSAGE_CHILDREN (-1)
1030 #define VKI_RUSAGE_BOTH     (-2)        /* sys_wait4() uses this */
1031 #define VKI_RUSAGE_THREAD   1           /* only the calling thread */
1032 
1033 struct  vki_rusage {
1034     struct vki_timeval ru_utime;    /* user time used */
1035     struct vki_timeval ru_stime;    /* system time used */
1036     long    ru_maxrss;      /* maximum resident set size */
1037     long    ru_ixrss;       /* integral shared memory size */
1038     long    ru_idrss;       /* integral unshared data size */
1039     long    ru_isrss;       /* integral unshared stack size */
1040     long    ru_minflt;      /* page reclaims */
1041     long    ru_majflt;      /* page faults */
1042     long    ru_nswap;       /* swaps */
1043     long    ru_inblock;     /* block input operations */
1044     long    ru_oublock;     /* block output operations */
1045     long    ru_msgsnd;      /* messages sent */
1046     long    ru_msgrcv;      /* messages received */
1047     long    ru_nsignals;        /* signals received */
1048     long    ru_nvcsw;       /* voluntary context switches */
1049     long    ru_nivcsw;      /* involuntary " */
1050 };
1051 
1052 struct vki_rlimit {
1053     unsigned long   rlim_cur;
1054     unsigned long   rlim_max;
1055 };
1056 
1057 struct vki_rlimit64 {
1058     __vki_u64 rlim_cur;
1059     __vki_u64 rlim_max;
1060 };
1061 
1062 //----------------------------------------------------------------------
1063 // From linux-2.6.8.1/include/linux/elfcore.h
1064 //----------------------------------------------------------------------
1065 
1066 struct vki_elf_siginfo
1067 {
1068     int si_signo;           /* signal number */
1069     int si_code;            /* extra code */
1070     int si_errno;           /* errno */
1071 };
1072 
1073 // [[Removed some commented out lines here]]
1074 struct vki_elf_prstatus
1075 {
1076     struct vki_elf_siginfo pr_info; /* Info associated with signal */
1077     short   pr_cursig;      /* Current signal */
1078     unsigned long pr_sigpend;   /* Set of pending signals */
1079     unsigned long pr_sighold;   /* Set of held signals */
1080     vki_pid_t   pr_pid;
1081     vki_pid_t   pr_ppid;
1082     vki_pid_t   pr_pgrp;
1083     vki_pid_t   pr_sid;
1084     struct vki_timeval pr_utime;    /* User time */
1085     struct vki_timeval pr_stime;    /* System time */
1086     struct vki_timeval pr_cutime;   /* Cumulative user time */
1087     struct vki_timeval pr_cstime;   /* Cumulative system time */
1088     vki_elf_gregset_t pr_reg;   /* GP registers */
1089     int pr_fpvalid;     /* True if math co-processor being used.  */
1090 };
1091 
1092 #define VKI_ELF_PRARGSZ (80)    /* Number of chars for args */
1093 
1094 struct vki_elf_prpsinfo
1095 {
1096     char    pr_state;   /* numeric process state */
1097     char    pr_sname;   /* char for pr_state */
1098     char    pr_zomb;    /* zombie */
1099     char    pr_nice;    /* nice val */
1100     unsigned long pr_flag;  /* flags */
1101     __vki_kernel_uid_t  pr_uid;
1102     __vki_kernel_gid_t  pr_gid;
1103     vki_pid_t   pr_pid, pr_ppid, pr_pgrp, pr_sid;
1104     /* Lots missing */
1105     char    pr_fname[16];   /* filename of executable */
1106     char    pr_psargs[VKI_ELF_PRARGSZ]; /* initial part of arg list */
1107 };
1108 
1109 //----------------------------------------------------------------------
1110 // From linux-2.6.12.1/include/linux/eventpoll.h
1111 //----------------------------------------------------------------------
1112 
1113 /* Valid opcodes to issue to sys_epoll_ctl() */
1114 #define VKI_EPOLL_CTL_ADD 1
1115 #define VKI_EPOLL_CTL_DEL 2
1116 #define VKI_EPOLL_CTL_MOD 3
1117 
1118 #ifdef __x86_64__
1119 #define VKI_EPOLL_PACKED __attribute__((packed))
1120 #else
1121 #define VKI_EPOLL_PACKED
1122 #endif
1123 
1124 struct vki_epoll_event {
1125     __vki_u32 events;
1126     __vki_u64 data;
1127 } VKI_EPOLL_PACKED;
1128 
1129 
1130 //----------------------------------------------------------------------
1131 // From linux-2.6.8.1/include/linux/mqueue.h
1132 //----------------------------------------------------------------------
1133 
1134 struct vki_mq_attr {
1135     long    mq_flags;   /* message queue flags          */
1136     long    mq_maxmsg;  /* maximum number of messages       */
1137     long    mq_msgsize; /* maximum message size         */
1138     long    mq_curmsgs; /* number of messages currently queued  */
1139     long    __reserved[4];  /* ignored for input, zeroed for output */
1140 };
1141 
1142 //----------------------------------------------------------------------
1143 // From linux-2.6.8.1/include/linux/utsname.h
1144 //----------------------------------------------------------------------
1145 
1146 struct vki_new_utsname {
1147     char sysname[65];
1148     char nodename[65];
1149     char release[65];
1150     char version[65];
1151     char machine[65];
1152     char domainname[65];
1153 };
1154 
1155 //----------------------------------------------------------------------
1156 // From linux-2.6.8.1/include/linux/mii.h
1157 //----------------------------------------------------------------------
1158 
1159 /* This structure is used in all SIOCxMIIxxx ioctl calls */
1160 struct vki_mii_ioctl_data {
1161     vki_u16     phy_id;
1162     vki_u16     reg_num;
1163     vki_u16     val_in;
1164     vki_u16     val_out;
1165 };
1166 
1167 //----------------------------------------------------------------------
1168 // From linux-2.6.8.1/include/linux/capability.h
1169 //----------------------------------------------------------------------
1170 
1171 // [[capget()/capset() man page says this, ominously:
1172 //
1173 //   The kernel API is likely to change and use of these functions  (in
1174 //   particular the format of the cap_user_*_t types) is subject to
1175 //   change with each kernel revision.
1176 //
1177 // However, the format hasn't changed since at least Linux 2.4.6.]]
1178 
1179 typedef struct __vki_user_cap_header_struct {
1180     __vki_u32 version;
1181     int pid;
1182 } __user *vki_cap_user_header_t;
1183  
1184 typedef struct __vki_user_cap_data_struct {
1185         __vki_u32 effective;
1186         __vki_u32 permitted;
1187         __vki_u32 inheritable;
1188 } __user *vki_cap_user_data_t;
1189   
1190 
1191 //----------------------------------------------------------------------
1192 // From linux-2.6.8.1/include/linux/module.h
1193 //----------------------------------------------------------------------
1194 
1195 // [[We do a VKI_SIZEOF_* here because this type is so big, and its size
1196 //   depends on the word size, so see vki_arch.h]]
1197 
1198 //----------------------------------------------------------------------
1199 // From linux-2.6.8.1/include/linux/ipc.h
1200 //----------------------------------------------------------------------
1201 
1202 /* Obsolete, used only for backwards compatibility and libc5 compiles */
1203 struct vki_ipc_perm
1204 {
1205     __vki_kernel_key_t  key;
1206     __vki_kernel_uid_t  uid;
1207     __vki_kernel_gid_t  gid;
1208     __vki_kernel_uid_t  cuid;
1209     __vki_kernel_gid_t  cgid;
1210     __vki_kernel_mode_t mode; 
1211     unsigned short  seq;
1212 };
1213 
1214 #define VKI_IPC_CREAT  00001000   /* create if key is nonexistent */
1215 #define VKI_IPC_EXCL   00002000   /* fail if key exists */
1216 #define VKI_IPC_NOWAIT 00004000   /* return error on wait */
1217 
1218 //#define VKI_IPC_RMID 0     /* remove resource */
1219 #define VKI_IPC_SET  1     /* set ipc_perm options */
1220 #define VKI_IPC_STAT 2     /* get ipc_perm options */
1221 #define VKI_IPC_INFO 3     /* see ipcs */
1222 
1223 #define VKI_IPC_64  0x0100  /* New version (support 32-bit UIDs, bigger
1224                    message sizes, etc. */
1225 // From /usr/include/bits/shm.h
1226 # define VKI_SHM_HUGETLB   04000
1227 
1228 
1229 //----------------------------------------------------------------------
1230 // From linux-2.6.8.1/include/linux/sem.h
1231 //----------------------------------------------------------------------
1232 
1233 #define VKI_GETALL  13       /* get all semval's */
1234 #define VKI_SETVAL  16       /* set semval */
1235 #define VKI_SETALL  17       /* set all semval's */
1236 
1237 #define VKI_SEM_STAT 18
1238 #define VKI_SEM_INFO 19
1239 
1240 /* Obsolete, used only for backwards compatibility and libc5 compiles */
1241 struct vki_semid_ds {
1242     struct vki_ipc_perm sem_perm;       /* permissions .. see ipc.h */
1243     __vki_kernel_time_t sem_otime;      /* last semop time */
1244     __vki_kernel_time_t sem_ctime;      /* last change time */
1245         // [[Use void* to avoid excess header copying]]
1246     void/*struct sem    */*sem_base;        /* ptr to first semaphore in array */
1247     void/*struct sem_queue */*sem_pending;      /* pending operations to be processed */
1248     void/*struct sem_queue */**sem_pending_last;    /* last pending operation */
1249     void/*struct sem_undo   */*undo;            /* undo requests on this array */
1250     unsigned short  sem_nsems;      /* no. of semaphores in array */
1251 };
1252 
1253 struct vki_sembuf {
1254     unsigned short  sem_num;    /* semaphore index in array */
1255     short       sem_op;     /* semaphore operation */
1256     short       sem_flg;    /* operation flags */
1257 };
1258 
1259 union vki_semun {
1260     int val;            /* value for SETVAL */
1261     struct vki_semid_ds __user *buf;    /* buffer for IPC_STAT & IPC_SET */
1262     struct vki_semid64_ds __user *buf64;    /* buffer for IPC_STAT & IPC_SET */
1263     unsigned short __user *array;   /* array for GETALL & SETALL */
1264     struct vki_seminfo __user *__buf;   /* buffer for IPC_INFO */
1265     void __user *__pad;
1266 };
1267 
1268 struct  vki_seminfo {
1269     int semmap;
1270     int semmni;
1271     int semmns;
1272     int semmnu;
1273     int semmsl;
1274     int semopm;
1275     int semume;
1276     int semusz;
1277     int semvmx;
1278     int semaem;
1279 };
1280 
1281 //----------------------------------------------------------------------
1282 // From linux-2.6.8.1/include/asm-generic/errno-base.h
1283 //----------------------------------------------------------------------
1284 
1285 #define VKI_EPERM        1  /* Operation not permitted */
1286 #define VKI_ENOENT       2  /* No such file or directory */
1287 #define VKI_ESRCH        3  /* No such process */
1288 #define VKI_EINTR        4  /* Interrupted system call */
1289 #define VKI_EIO          5  /* I/O error */
1290 #define VKI_ENXIO        6  /* No such device or address */
1291 #define VKI_E2BIG        7  /* Argument list too long */
1292 #define VKI_ENOEXEC      8  /* Exec format error */
1293 #define VKI_EBADF        9  /* Bad file number */
1294 #define VKI_ECHILD      10  /* No child processes */
1295 #define VKI_EAGAIN      11  /* Try again */
1296 #define VKI_ENOMEM      12  /* Out of memory */
1297 #define VKI_EACCES      13  /* Permission denied */
1298 #define VKI_EFAULT      14  /* Bad address */
1299 #define VKI_ENOTBLK     15  /* Block device required */
1300 #define VKI_EBUSY       16  /* Device or resource busy */
1301 #define VKI_EEXIST      17  /* File exists */
1302 #define VKI_EXDEV       18  /* Cross-device link */
1303 #define VKI_ENODEV      19  /* No such device */
1304 #define VKI_ENOTDIR     20  /* Not a directory */
1305 #define VKI_EISDIR      21  /* Is a directory */
1306 #define VKI_EINVAL      22  /* Invalid argument */
1307 #define VKI_ENFILE      23  /* File table overflow */
1308 #define VKI_EMFILE      24  /* Too many open files */
1309 #define VKI_ENOTTY      25  /* Not a typewriter */
1310 #define VKI_ETXTBSY     26  /* Text file busy */
1311 #define VKI_EFBIG       27  /* File too large */
1312 #define VKI_ENOSPC      28  /* No space left on device */
1313 #define VKI_ESPIPE      29  /* Illegal seek */
1314 #define VKI_EROFS       30  /* Read-only file system */
1315 #define VKI_EMLINK      31  /* Too many links */
1316 #define VKI_EPIPE       32  /* Broken pipe */
1317 #define VKI_EDOM        33  /* Math argument out of domain of func */
1318 #define VKI_ERANGE      34  /* Math result not representable */
1319 
1320 //----------------------------------------------------------------------
1321 // From linux-2.6.8.1/include/asm-generic/errno.h
1322 //----------------------------------------------------------------------
1323 
1324 #define VKI_EWOULDBLOCK     VKI_EAGAIN
1325 
1326 #define VKI_ELOOP 40
1327 
1328 //----------------------------------------------------------------------
1329 // From linux-2.6.8.1/include/linux/wait.h
1330 //----------------------------------------------------------------------
1331 
1332 #define VKI_WNOHANG 0x00000001
1333 
1334 #define __VKI_WALL  0x40000000  /* Wait on all children, regardless of type */
1335 #define __VKI_WCLONE    0x80000000  /* Wait only on non-SIGCHLD children */
1336 
1337 //----------------------------------------------------------------------
1338 // From linux-2.6.8.1/include/linux/mman.h
1339 //----------------------------------------------------------------------
1340 
1341 #define VKI_MREMAP_MAYMOVE  1
1342 #define VKI_MREMAP_FIXED    2
1343 
1344 //----------------------------------------------------------------------
1345 // From linux-2.6.31-rc4/include/linux/futex.h
1346 //----------------------------------------------------------------------
1347 
1348 #define VKI_FUTEX_WAIT (0)
1349 #define VKI_FUTEX_WAKE (1)
1350 #define VKI_FUTEX_FD (2)
1351 #define VKI_FUTEX_REQUEUE (3)
1352 #define VKI_FUTEX_CMP_REQUEUE (4)
1353 #define VKI_FUTEX_WAKE_OP (5)
1354 #define VKI_FUTEX_LOCK_PI (6)
1355 #define VKI_FUTEX_UNLOCK_PI (7)
1356 #define VKI_FUTEX_TRYLOCK_PI (8)
1357 #define VKI_FUTEX_WAIT_BITSET (9)
1358 #define VKI_FUTEX_WAKE_BITSET (10)
1359 #define VKI_FUTEX_WAIT_REQUEUE_PI (11)
1360 #define VKI_FUTEX_CMP_REQUEUE_PI (12)
1361 #define VKI_FUTEX_PRIVATE_FLAG (128)
1362 #define VKI_FUTEX_CLOCK_REALTIME (256)
1363 
1364 struct vki_robust_list {
1365     struct vki_robust_list __user *next;
1366 };
1367 
1368 struct vki_robust_list_head {
1369     /*
1370      * The head of the list. Points back to itself if empty:
1371      */
1372     struct vki_robust_list list;
1373 
1374     /*
1375      * This relative offset is set by user-space, it gives the kernel
1376      * the relative position of the futex field to examine. This way
1377      * we keep userspace flexible, to freely shape its data-structure,
1378      * without hardcoding any particular offset into the kernel:
1379      */
1380     long futex_offset;
1381 
1382     /*
1383      * The death of the thread may race with userspace setting
1384      * up a lock's links. So to handle this race, userspace first
1385      * sets this field to the address of the to-be-taken lock,
1386      * then does the lock acquire, and then adds itself to the
1387      * list, and then clears this field. Hence the kernel will
1388      * always have full knowledge of all locks that the thread
1389      * _might_ have taken. We check the owner TID in any case,
1390      * so only truly owned locks will be handled.
1391      */
1392     struct vki_robust_list __user *list_op_pending;
1393 };
1394 
1395 //----------------------------------------------------------------------
1396 // From linux-2.6.8.1/include/linux/errno.h
1397 //----------------------------------------------------------------------
1398 
1399 #define VKI_ERESTARTSYS 512
1400 
1401 //----------------------------------------------------------------------
1402 // From linux-2.6.8.1/include/linux/stat.h
1403 //----------------------------------------------------------------------
1404 
1405 #define VKI_S_IFMT  00170000
1406 #define VKI_S_IFSOCK 0140000
1407 #define VKI_S_IFLNK  0120000
1408 #define VKI_S_IFREG  0100000
1409 #define VKI_S_IFBLK  0060000
1410 #define VKI_S_IFDIR  0040000
1411 #define VKI_S_IFCHR  0020000
1412 #define VKI_S_IFIFO  0010000
1413 #define VKI_S_ISUID  0004000
1414 #define VKI_S_ISGID  0002000
1415 #define VKI_S_ISVTX  0001000
1416 
1417 #define VKI_S_ISLNK(m)  (((m) & VKI_S_IFMT) == VKI_S_IFLNK)
1418 #define VKI_S_ISREG(m)  (((m) & VKI_S_IFMT) == VKI_S_IFREG)
1419 #define VKI_S_ISDIR(m)  (((m) & VKI_S_IFMT) == VKI_S_IFDIR)
1420 #define VKI_S_ISCHR(m)  (((m) & VKI_S_IFMT) == VKI_S_IFCHR)
1421 #define VKI_S_ISBLK(m)  (((m) & VKI_S_IFMT) == VKI_S_IFBLK)
1422 #define VKI_S_ISFIFO(m) (((m) & VKI_S_IFMT) == VKI_S_IFIFO)
1423 #define VKI_S_ISSOCK(m) (((m) & VKI_S_IFMT) == VKI_S_IFSOCK)
1424 
1425 #define VKI_S_IRWXU 00700
1426 #define VKI_S_IRUSR 00400
1427 #define VKI_S_IWUSR 00200
1428 #define VKI_S_IXUSR 00100
1429 
1430 #define VKI_S_IRWXG 00070
1431 #define VKI_S_IRGRP 00040
1432 #define VKI_S_IWGRP 00020
1433 #define VKI_S_IXGRP 00010
1434 
1435 #define VKI_S_IRWXO 00007
1436 #define VKI_S_IROTH 00004
1437 #define VKI_S_IWOTH 00002
1438 #define VKI_S_IXOTH 00001
1439 
1440 #define VKI_STATX_ALL 0x00000FFFU
1441 
1442 struct vki_statx_timestamp {
1443         __vki_s64   tv_sec;
1444         __vki_u32   tv_nsec;
1445         __vki_s32   __reserved;
1446 };
1447 
1448 struct vki_statx {
1449         /* 0x00 */
1450         __vki_u32   stx_mask;       /* What results were written [uncond] */
1451         __vki_u32   stx_blksize;    /* Preferred general I/O size [uncond] */
1452         __vki_u64   stx_attributes; /* Flags conveying information about the file [uncond] */
1453         /* 0x10 */
1454         __vki_u32   stx_nlink;      /* Number of hard links */
1455         __vki_u32   stx_uid;        /* User ID of owner */
1456         __vki_u32   stx_gid;        /* Group ID of owner */
1457         __vki_u16   stx_mode;       /* File mode */
1458         __vki_u16   __spare0[1];
1459         /* 0x20 */
1460         __vki_u64   stx_ino;        /* Inode number */
1461         __vki_u64   stx_size;       /* File size */
1462         __vki_u64   stx_blocks;     /* Number of 512-byte blocks allocated */
1463         __vki_u64   stx_attributes_mask; /* Mask to show what's supported in stx_attributes */
1464         /* 0x40 */
1465         struct vki_statx_timestamp  stx_atime;      /* Last access time */
1466         struct vki_statx_timestamp  stx_btime;      /* File creation time */
1467         struct vki_statx_timestamp  stx_ctime;      /* Last attribute change time */
1468         struct vki_statx_timestamp  stx_mtime;      /* Last data modification time */
1469         /* 0x80 */
1470         __vki_u32   stx_rdev_major; /* Device ID of special file [if bdev/cdev] */
1471         __vki_u32   stx_rdev_minor;
1472         __vki_u32   stx_dev_major;  /* ID of device containing file [uncond] */
1473         __vki_u32   stx_dev_minor;
1474         /* 0x90 */
1475         __vki_u64   __spare2[14];   /* Spare space for future expansion */
1476         /* 0x100 */
1477 };
1478 
1479 
1480 //----------------------------------------------------------------------
1481 // From linux-2.6.8.1/include/linux/dirent.h
1482 //----------------------------------------------------------------------
1483 
1484 /* This is the old compat structure to use with the old dirent syscall. */
1485 struct vki_dirent {
1486     long        d_ino;
1487     __vki_kernel_off_t  d_off;
1488     unsigned short  d_reclen;
1489     char        d_name[256]; /* We must not include limits.h! */
1490 };
1491 
1492 /* This is the new structure to use with the dirent64 syscall. */
1493 struct vki_dirent64 {
1494     __vki_u64 d_ino;
1495     __vki_s64 d_off;
1496     unsigned short d_reclen;
1497     unsigned char d_type;
1498     char d_name[256]; /* Note we hard code a max file length here. */
1499 };
1500 
1501 //----------------------------------------------------------------------
1502 // From linux-2.6.8.1/include/linux/fcntl.h
1503 //----------------------------------------------------------------------
1504 
1505 #define VKI_F_SETLEASE      (VKI_F_LINUX_SPECIFIC_BASE + 0)
1506 #define VKI_F_GETLEASE      (VKI_F_LINUX_SPECIFIC_BASE + 1)
1507 
1508 #define VKI_F_CANCELLK      (VKI_F_LINUX_SPECIFIC_BASE + 5)
1509 
1510 #define VKI_F_DUPFD_CLOEXEC (VKI_F_LINUX_SPECIFIC_BASE + 6)
1511 
1512 #define VKI_F_NOTIFY        (VKI_F_LINUX_SPECIFIC_BASE + 2)
1513 
1514 #define VKI_F_SETPIPE_SZ    (VKI_F_LINUX_SPECIFIC_BASE + 7)
1515 #define VKI_F_GETPIPE_SZ    (VKI_F_LINUX_SPECIFIC_BASE + 8)
1516 
1517 #define VKI_F_ADD_SEALS     (VKI_F_LINUX_SPECIFIC_BASE + 9)
1518 #define VKI_F_GET_SEALS     (VKI_F_LINUX_SPECIFIC_BASE + 10)
1519 
1520 struct vki_flock {
1521     short           l_type;
1522     short           l_whence;
1523     __vki_kernel_off_t  l_start;
1524     __vki_kernel_off_t  l_len;
1525     __vki_kernel_pid_t  l_pid;
1526 };
1527 
1528 struct vki_flock64 {
1529     short           l_type;
1530     short           l_whence;
1531     __vki_kernel_loff_t l_start;
1532     __vki_kernel_loff_t l_len;
1533     __vki_kernel_pid_t  l_pid;
1534 };
1535 
1536 #define VKI_AT_EMPTY_PATH       0x1000  /* Allow empty relative pathname */
1537 #define VKI_AT_SYMLINK_NOFOLLOW 0x100   /* Do not follow symbolic links.  */
1538 
1539 //----------------------------------------------------------------------
1540 // From linux-2.6.8.1/include/linux/sysctl.h
1541 //----------------------------------------------------------------------
1542 
1543 struct __vki_sysctl_args {
1544     int __user *name;
1545     int nlen;
1546     void __user *oldval;
1547     vki_size_t __user *oldlenp;
1548     void __user *newval;
1549     vki_size_t newlen;
1550     unsigned long __unused0[4];
1551 };
1552 
1553 //----------------------------------------------------------------------
1554 // From linux-2.6.8.1/include/linux/aio_abi.h
1555 //----------------------------------------------------------------------
1556 
1557 typedef unsigned long   vki_aio_context_t;
1558 
1559 enum {
1560     VKI_IOCB_CMD_PREAD = 0,
1561     VKI_IOCB_CMD_PWRITE = 1,
1562     VKI_IOCB_CMD_FSYNC = 2,
1563     VKI_IOCB_CMD_FDSYNC = 3,
1564     VKI_IOCB_CMD_PREADV = 7,
1565     VKI_IOCB_CMD_PWRITEV = 8,
1566 };
1567 
1568 /* read() from /dev/aio returns these structures. */
1569 struct vki_io_event {
1570     __vki_u64   data;       /* the data field from the iocb */
1571     __vki_u64   obj;        /* what iocb this event came from */
1572         // [[Nb: These fields renamed from 'res' and 'res2' because 'res' is
1573         //   a macro in vg_syscalls.c!]]
1574     __vki_s64   result;     /* result code for this event */
1575     __vki_s64   result2;    /* secondary result */
1576 };
1577 
1578 #if defined(VKI_LITTLE_ENDIAN)
1579 #  define VKI_PADDED(x,y)   x, y
1580 #elif defined(VKI_BIG_ENDIAN)
1581 #  define VKI_PADDED(x,y)   y, x
1582 #else
1583 #error edit for your odd byteorder.
1584 #endif
1585 
1586 struct vki_iocb {
1587     /* these are internal to the kernel/libc. */
1588     __vki_u64   aio_data;   /* data to be returned in event's data */
1589     __vki_u32   VKI_PADDED(aio_key, aio_reserved1);
1590                 /* the kernel sets aio_key to the req # */
1591 
1592     /* common fields */
1593     __vki_u16   aio_lio_opcode; /* see IOCB_CMD_ above */
1594     __vki_s16   aio_reqprio;
1595     __vki_u32   aio_fildes;
1596 
1597     __vki_u64   aio_buf;
1598     __vki_u64   aio_nbytes;
1599     __vki_s64   aio_offset;
1600 
1601     /* extra parameters */
1602     __vki_u64   aio_reserved2;  /* TODO: use this for a (struct sigevent *) */
1603     __vki_u64   aio_reserved3;
1604 }; /* 64 bytes */
1605 
1606 //----------------------------------------------------------------------
1607 // From linux-2.6.8.1/include/linux/aio.h
1608 //----------------------------------------------------------------------
1609 
1610 struct vki_aio_ring {
1611     unsigned    id; /* kernel internal index number */
1612     unsigned    nr; /* number of io_events */
1613     unsigned    head;
1614     unsigned    tail;
1615 
1616     unsigned    magic;
1617     unsigned    compat_features;
1618     unsigned    incompat_features;
1619     unsigned    header_length;  /* size of aio_ring */
1620 
1621     struct vki_io_event     io_events[0];
1622 }; /* 128 bytes + ring size */
1623 
1624 //----------------------------------------------------------------------
1625 // From linux-2.6.8.1/include/linux/msg.h
1626 //----------------------------------------------------------------------
1627 
1628 #define VKI_MSG_STAT 11
1629 #define VKI_MSG_INFO 12
1630 
1631 struct vki_msqid_ds {
1632     struct vki_ipc_perm msg_perm;
1633     struct vki_msg *msg_first;      /* first message on queue,unused  */
1634     struct vki_msg *msg_last;       /* last message in queue,unused */
1635     __vki_kernel_time_t msg_stime;  /* last msgsnd time */
1636     __vki_kernel_time_t msg_rtime;  /* last msgrcv time */
1637     __vki_kernel_time_t msg_ctime;  /* last change time */
1638     unsigned long  msg_lcbytes; /* Reuse junk fields for 32 bit */
1639     unsigned long  msg_lqbytes; /* ditto */
1640     unsigned short msg_cbytes;  /* current number of bytes on queue */
1641     unsigned short msg_qnum;    /* number of messages in queue */
1642     unsigned short msg_qbytes;  /* max number of bytes on queue */
1643     __vki_kernel_ipc_pid_t msg_lspid;   /* pid of last msgsnd */
1644     __vki_kernel_ipc_pid_t msg_lrpid;   /* last receive pid */
1645 };
1646 
1647 struct vki_msgbuf {
1648     long mtype;         /* type of message */
1649     char mtext[1];      /* message text */
1650 };
1651 
1652 struct vki_msginfo {
1653     int msgpool;
1654     int msgmap; 
1655     int msgmax; 
1656     int msgmnb; 
1657     int msgmni; 
1658     int msgssz; 
1659     int msgtql; 
1660     unsigned short  msgseg; 
1661 };
1662 
1663 //----------------------------------------------------------------------
1664 // From linux-2.6.8.1/include/linux/shm.h
1665 //----------------------------------------------------------------------
1666 
1667 struct vki_shmid_ds {
1668     struct vki_ipc_perm     shm_perm;   /* operation perms */
1669     int         shm_segsz;  /* size of segment (bytes) */
1670     __vki_kernel_time_t     shm_atime;  /* last attach time */
1671     __vki_kernel_time_t     shm_dtime;  /* last detach time */
1672     __vki_kernel_time_t     shm_ctime;  /* last change time */
1673     __vki_kernel_ipc_pid_t  shm_cpid;   /* pid of creator */
1674     __vki_kernel_ipc_pid_t  shm_lpid;   /* pid of last operator */
1675     unsigned short      shm_nattch; /* no. of current attaches */
1676     unsigned short      shm_unused; /* compatibility */
1677     void            *shm_unused2;   /* ditto - used by DIPC */
1678     void            *shm_unused3;   /* unused */
1679 };
1680 
1681 #define VKI_SHM_RDONLY  010000  /* read-only access */
1682 #define VKI_SHM_RND     020000  /* round attach address to SHMLBA boundary */
1683 
1684 #define VKI_SHM_STAT    13
1685 #define VKI_SHM_INFO    14
1686 
1687 /* Obsolete, used only for backwards compatibility */
1688 struct  vki_shminfo {
1689     int shmmax;
1690     int shmmin;
1691     int shmmni;
1692     int shmseg;
1693     int shmall;
1694 };
1695 
1696 struct vki_shm_info {
1697     int used_ids;
1698     unsigned long shm_tot;  /* total allocated shm */
1699     unsigned long shm_rss;  /* total resident shm */
1700     unsigned long shm_swp;  /* total swapped shm */
1701     unsigned long swap_attempts;
1702     unsigned long swap_successes;
1703 };
1704 
1705 //----------------------------------------------------------------------
1706 // From linux-2.6.8.1/include/linux/rtc.h
1707 //----------------------------------------------------------------------
1708 
1709 struct vki_rtc_time {
1710     int tm_sec;
1711     int tm_min;
1712     int tm_hour;
1713     int tm_mday;
1714     int tm_mon;
1715     int tm_year;
1716     int tm_wday;
1717     int tm_yday;
1718     int tm_isdst;
1719 };
1720 
1721 #define VKI_RTC_AIE_ON  _VKI_IO('p', 0x01)  /* Alarm int. enable on */
1722 #define VKI_RTC_AIE_OFF _VKI_IO('p', 0x02)  /* ... off      */
1723 #define VKI_RTC_UIE_ON  _VKI_IO('p', 0x03)  /* Update int. enable on*/
1724 #define VKI_RTC_UIE_OFF _VKI_IO('p', 0x04)  /* ... off      */
1725 #define VKI_RTC_PIE_ON  _VKI_IO('p', 0x05)  /* Periodic int. enable on*/
1726 #define VKI_RTC_PIE_OFF _VKI_IO('p', 0x06)  /* ... off      */
1727 
1728 #define VKI_RTC_ALM_SET     _VKI_IOW('p', 0x07, struct vki_rtc_time) /* Set alarm time  */
1729 #define VKI_RTC_ALM_READ    _VKI_IOR('p', 0x08, struct vki_rtc_time) /* Read alarm time */
1730 #define VKI_RTC_RD_TIME     _VKI_IOR('p', 0x09, struct vki_rtc_time) /* Read RTC time   */
1731 //#define RTC_SET_TIME  _IOW('p', 0x0a, struct rtc_time) /* Set RTC time    */
1732 #define VKI_RTC_IRQP_READ   _VKI_IOR('p', 0x0b, unsigned long)   /* Read IRQ rate   */
1733 #define VKI_RTC_IRQP_SET    _VKI_IOW('p', 0x0c, unsigned long)   /* Set IRQ rate    */
1734 
1735 //----------------------------------------------------------------------
1736 // From linux-2.6.8.1/include/linux/isdn.h
1737 //----------------------------------------------------------------------
1738 
1739 // [[Nb: Resolved this for the common case where CONFIG_COBALT_MICRO_SERVER
1740 //   is not defined]]
1741 #define VKI_ISDN_MAX_CHANNELS   64
1742 
1743 #define VKI_IIOCGETCPS  _VKI_IO('I',21)
1744 
1745 #define VKI_IIOCNETGPN  _VKI_IO('I',34)
1746 
1747 #define VKI_ISDN_MSNLEN          32
1748 
1749 typedef struct {
1750   char name[10];
1751   char phone[VKI_ISDN_MSNLEN];
1752   int  outgoing;
1753 } vki_isdn_net_ioctl_phone;
1754 
1755 //----------------------------------------------------------------------
1756 // From linux-2.6.8.1/include/linux/sockios.h
1757 //----------------------------------------------------------------------
1758 
1759 #define VKI_SIOCOUTQ        VKI_TIOCOUTQ
1760 
1761 #define VKI_SIOCADDRT       0x890B  /* add routing table entry  */
1762 #define VKI_SIOCDELRT       0x890C  /* delete routing table entry   */
1763 
1764 #define VKI_SIOCGIFNAME     0x8910  /* get iface name       */
1765 #define VKI_SIOCGIFCONF     0x8912  /* get iface list       */
1766 #define VKI_SIOCGIFFLAGS    0x8913  /* get flags            */
1767 #define VKI_SIOCSIFFLAGS    0x8914  /* set flags            */
1768 #define VKI_SIOCGIFADDR     0x8915  /* get PA address       */
1769 #define VKI_SIOCSIFADDR     0x8916  /* set PA address       */
1770 #define VKI_SIOCGIFDSTADDR  0x8917  /* get remote PA address    */
1771 #define VKI_SIOCSIFDSTADDR  0x8918  /* set remote PA address    */
1772 #define VKI_SIOCGIFBRDADDR  0x8919  /* get broadcast PA address */
1773 #define VKI_SIOCSIFBRDADDR  0x891a  /* set broadcast PA address */
1774 #define VKI_SIOCGIFNETMASK  0x891b  /* get network PA mask      */
1775 #define VKI_SIOCSIFNETMASK  0x891c  /* set network PA mask      */
1776 #define VKI_SIOCGIFMETRIC   0x891d  /* get metric           */
1777 #define VKI_SIOCSIFMETRIC   0x891e  /* set metric           */
1778 #define VKI_SIOCGIFMTU      0x8921  /* get MTU size         */
1779 #define VKI_SIOCSIFMTU      0x8922  /* set MTU size         */
1780 #define VKI_SIOCSIFHWADDR   0x8924  /* set hardware address     */
1781 #define VKI_SIOCGIFHWADDR   0x8927  /* Get hardware address     */
1782 #define VKI_SIOCGIFINDEX    0x8933  /* name -> if_index mapping */
1783 
1784 #define VKI_SIOCGIFTXQLEN   0x8942  /* Get the tx queue length  */
1785 #define VKI_SIOCSIFTXQLEN   0x8943  /* Set the tx queue length  */
1786 
1787 #define VKI_SIOCETHTOOL     0x8946  /* Ethtool interface        */
1788 
1789 #define VKI_SIOCGMIIPHY     0x8947  /* Get address of MII PHY in use. */
1790 #define VKI_SIOCGMIIREG     0x8948  /* Read MII PHY register.   */
1791 #define VKI_SIOCSMIIREG     0x8949  /* Write MII PHY register.  */
1792 
1793 #define VKI_SIOCDARP        0x8953  /* delete ARP table entry   */
1794 #define VKI_SIOCGARP        0x8954  /* get ARP table entry      */
1795 #define VKI_SIOCSARP        0x8955  /* set ARP table entry      */
1796 
1797 #define VKI_SIOCDRARP       0x8960  /* delete RARP table entry  */
1798 #define VKI_SIOCGRARP       0x8961  /* get RARP table entry     */
1799 #define VKI_SIOCSRARP       0x8962  /* set RARP table entry     */
1800 
1801 #define VKI_SIOCGIFMAP      0x8970  /* Get device parameters    */
1802 #define VKI_SIOCSIFMAP      0x8971  /* Set device parameters    */
1803 
1804 #define VKI_SIOCSHWTSTAMP   0x89B0  /* Set hardware time stamping */
1805 
1806 //----------------------------------------------------------------------
1807 // From linux-2.6.8.1/include/linux/ppdev.h
1808 //----------------------------------------------------------------------
1809 
1810 #define VKI_PP_MAJOR    99
1811 
1812 #define VKI_PP_IOCTL    'p'
1813 
1814 /* Set mode for read/write (e.g. IEEE1284_MODE_EPP) */
1815 #define VKI_PPSETMODE   _VKI_IOW(VKI_PP_IOCTL, 0x80, int)
1816 
1817 /* Read status */
1818 #define VKI_PPRSTATUS   _VKI_IOR(VKI_PP_IOCTL, 0x81, unsigned char)
1819 //#define PPWSTATUS OBSOLETE__IOW(PP_IOCTL, 0x82, unsigned char)
1820 
1821 /* Read/write control */
1822 #define VKI_PPRCONTROL  _VKI_IOR(VKI_PP_IOCTL, 0x83, unsigned char)
1823 #define VKI_PPWCONTROL  _VKI_IOW(VKI_PP_IOCTL, 0x84, unsigned char)
1824 
1825 struct vki_ppdev_frob_struct {
1826     unsigned char mask;
1827     unsigned char val;
1828 };
1829 #define VKI_PPFCONTROL      _VKI_IOW(VKI_PP_IOCTL, 0x8e, struct vki_ppdev_frob_struct)
1830 
1831 /* Read/write data */
1832 #define VKI_PPRDATA     _VKI_IOR(VKI_PP_IOCTL, 0x85, unsigned char)
1833 #define VKI_PPWDATA     _VKI_IOW(VKI_PP_IOCTL, 0x86, unsigned char)
1834 
1835 /* Claim the port to start using it */
1836 #define VKI_PPCLAIM     _VKI_IO(VKI_PP_IOCTL, 0x8b)
1837 
1838 /* Release the port when you aren't using it */
1839 #define VKI_PPRELEASE   _VKI_IO(VKI_PP_IOCTL, 0x8c)
1840 
1841 /* Yield the port (release it if another driver is waiting,
1842  * then reclaim) */
1843 #define VKI_PPYIELD     _VKI_IO(VKI_PP_IOCTL, 0x8d)
1844 
1845 /* Register device exclusively (must be before PPCLAIM). */
1846 #define VKI_PPEXCL      _VKI_IO(VKI_PP_IOCTL, 0x8f)
1847 
1848 /* Data line direction: non-zero for input mode. */
1849 #define VKI_PPDATADIR   _VKI_IOW(VKI_PP_IOCTL, 0x90, int)
1850 
1851 /* Negotiate a particular IEEE 1284 mode. */
1852 #define VKI_PPNEGOT _VKI_IOW(VKI_PP_IOCTL, 0x91, int)
1853 
1854 /* Set control lines when an interrupt occurs. */
1855 #define VKI_PPWCTLONIRQ _VKI_IOW(VKI_PP_IOCTL, 0x92, unsigned char)
1856 
1857 /* Clear (and return) interrupt count. */
1858 #define VKI_PPCLRIRQ    _VKI_IOR(VKI_PP_IOCTL, 0x93, int)
1859 
1860 /* Set the IEEE 1284 phase that we're in (e.g. IEEE1284_PH_FWD_IDLE) */
1861 #define VKI_PPSETPHASE  _VKI_IOW(VKI_PP_IOCTL, 0x94, int)
1862 
1863 /* Set and get port timeout (struct timeval's) */
1864 #define VKI_PPGETTIME   _VKI_IOR(VKI_PP_IOCTL, 0x95, struct vki_timeval)
1865 #define VKI_PPSETTIME   _VKI_IOW(VKI_PP_IOCTL, 0x96, struct vki_timeval)
1866 
1867 #define VKI_PPGETMODES  _VKI_IOR(VKI_PP_IOCTL, 0x97, unsigned int)
1868 
1869 #define VKI_PPGETMODE   _VKI_IOR(VKI_PP_IOCTL, 0x98, int)
1870 #define VKI_PPGETPHASE  _VKI_IOR(VKI_PP_IOCTL, 0x99, int)
1871 
1872 #define VKI_PPGETFLAGS  _VKI_IOR(VKI_PP_IOCTL, 0x9a, int)
1873 #define VKI_PPSETFLAGS  _VKI_IOW(VKI_PP_IOCTL, 0x9b, int)
1874 
1875 //----------------------------------------------------------------------
1876 // From linux-5.2.5/include/uapi/linux/fs.h
1877 //----------------------------------------------------------------------
1878 
1879 #define VKI_BLKROSET   _VKI_IO(0x12,93) /* set device read-only (0 = read-write) */
1880 #define VKI_BLKROGET   _VKI_IO(0x12,94) /* get read-only status (0 = read_write) */
1881 #define VKI_BLKRRPART  _VKI_IO(0x12,95) /* re-read partition table */
1882 #define VKI_BLKGETSIZE _VKI_IO(0x12,96) /* return device size /512 (long *arg) */
1883 #define VKI_BLKFLSBUF  _VKI_IO(0x12,97) /* flush buffer cache */
1884 #define VKI_BLKRASET   _VKI_IO(0x12,98) /* set read ahead for block device */
1885 #define VKI_BLKRAGET   _VKI_IO(0x12,99) /* get current read ahead setting */
1886 #define VKI_BLKFRASET  _VKI_IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
1887 #define VKI_BLKFRAGET  _VKI_IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
1888 #define VKI_BLKSECTSET _VKI_IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
1889 #define VKI_BLKSECTGET _VKI_IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
1890 #define VKI_BLKSSZGET  _VKI_IO(0x12,104)/* get block device sector size */
1891 #define VKI_BLKBSZGET  _VKI_IOR(0x12,112,vki_size_t)
1892 #define VKI_BLKBSZSET  _VKI_IOW(0x12,113,vki_size_t)
1893 #define VKI_BLKGETSIZE64 _VKI_IOR(0x12,114,vki_size_t) /* return device size in bytes (u64 *arg) */
1894 #define VKI_BLKDISCARD _VKI_IO(0x12,119)
1895 #define VKI_BLKIOMIN _VKI_IO(0x12,120)
1896 #define VKI_BLKIOOPT _VKI_IO(0x12,121)
1897 #define VKI_BLKALIGNOFF _VKI_IO(0x12,122)
1898 #define VKI_BLKPBSZGET _VKI_IO(0x12,123)
1899 #define VKI_BLKDISCARDZEROES _VKI_IO(0x12,124)
1900 #define VKI_BLKZEROOUT _VKI_IO(0x12,127)
1901 
1902 #define VKI_FIBMAP  _VKI_IO(0x00,1) /* bmap access */
1903 #define VKI_FIGETBSZ    _VKI_IO(0x00,2) /* get the block size used for bmap */
1904 #define VKI_FICLONE     _VKI_IOW(0x94, 9, int)
1905 
1906 //----------------------------------------------------------------------
1907 // From linux-2.6.8.1/include/scsi/sg.h
1908 //----------------------------------------------------------------------
1909 
1910 typedef struct vki_sg_io_hdr
1911 {
1912     int interface_id;           /* [i] 'S' for SCSI generic (required) */
1913     int dxfer_direction;        /* [i] data transfer direction  */
1914     unsigned char cmd_len;      /* [i] SCSI command length ( <= 16 bytes) */
1915     unsigned char mx_sb_len;    /* [i] max length to write to sbp */
1916     unsigned short iovec_count; /* [i] 0 implies no scatter gather */
1917     unsigned int dxfer_len;     /* [i] byte count of data transfer */
1918     void __user *dxferp;    /* [i], [*io] points to data transfer memory
1919                           or scatter gather list */
1920     unsigned char __user *cmdp; /* [i], [*i] points to command to perform */
1921     void __user *sbp;       /* [i], [*o] points to sense_buffer memory */
1922     unsigned int timeout;       /* [i] MAX_UINT->no timeout (unit: millisec) */
1923     unsigned int flags;         /* [i] 0 -> default, see SG_FLAG... */
1924     int pack_id;                /* [i->o] unused internally (normally) */
1925     void __user * usr_ptr;      /* [i->o] unused internally */
1926     unsigned char status;       /* [o] scsi status */
1927     unsigned char masked_status;/* [o] shifted, masked scsi status */
1928     unsigned char msg_status;   /* [o] messaging level data (optional) */
1929     unsigned char sb_len_wr;    /* [o] byte count actually written to sbp */
1930     unsigned short host_status; /* [o] errors from host adapter */
1931     unsigned short driver_status;/* [o] errors from software driver */
1932     int resid;                  /* [o] dxfer_len - actual_transferred */
1933     unsigned int duration;      /* [o] time taken by cmd (unit: millisec) */
1934     unsigned int info;          /* [o] auxiliary information */
1935 } vki_sg_io_hdr_t;  /* 64 bytes long (on i386) */
1936 
1937 #define VKI_SG_DXFER_NONE -1        /* e.g. a SCSI Test Unit Ready command */
1938 #define VKI_SG_DXFER_TO_DEV -2      /* e.g. a SCSI WRITE command */
1939 #define VKI_SG_DXFER_FROM_DEV -3    /* e.g. a SCSI READ command */
1940 #define VKI_SG_DXFER_TO_FROM_DEV -4 /* treated like SG_DXFER_FROM_DEV with the
1941                    additional property than during indirect
1942                    IO the user buffer is copied into the
1943                    kernel buffers before the transfer */
1944 
1945 typedef struct vki_sg_scsi_id { /* used by SG_GET_SCSI_ID ioctl() */
1946     int host_no;        /* as in "scsi<n>" where 'n' is one of 0, 1, 2 etc */
1947     int channel;
1948     int scsi_id;        /* scsi id of target device */
1949     int lun;
1950     int scsi_type;      /* TYPE_... defined in scsi/scsi.h */
1951     short h_cmd_per_lun;/* host (adapter) maximum commands per lun */
1952     short d_queue_depth;/* device (or adapter) maximum queue length */
1953     int unused[2];      /* probably find a good use, set 0 for now */
1954 } vki_sg_scsi_id_t; /* 32 bytes long on i386 */
1955 
1956 #define VKI_SG_EMULATED_HOST 0x2203 /* true for emulated host adapter (ATAPI) */
1957 
1958 #define VKI_SG_SET_RESERVED_SIZE 0x2275  /* request a new reserved buffer size */
1959 #define VKI_SG_GET_RESERVED_SIZE 0x2272  /* actual size of reserved buffer */
1960 
1961 #define VKI_SG_GET_SCSI_ID 0x2276   /* Yields fd's bus, chan, dev, lun + type */
1962 
1963 #define VKI_SG_GET_SG_TABLESIZE 0x227F  /* 0 implies can't do scatter gather */
1964 
1965 #define VKI_SG_GET_VERSION_NUM 0x2282 /* Example: version 2.1.34 yields 20134 */
1966 
1967 #define VKI_SG_IO 0x2285   /* similar effect as write() followed by read() */
1968 
1969 #define VKI_SG_SET_TIMEOUT 0x2201  /* unit: jiffies (10ms on i386) */
1970 #define VKI_SG_GET_TIMEOUT 0x2202  /* yield timeout as _return_ value */
1971 
1972 //#define SG_GET_COMMAND_Q 0x2270   /* Yields 0 (queuing off) or 1 (on) */
1973 #define VKI_SG_SET_COMMAND_Q 0x2271   /* Change queuing state with 0 or 1 */
1974 
1975 //----------------------------------------------------------------------
1976 // From linux-2.6.34/include/scsi/scsi.h and scsi/scsi_ioctl.h
1977 //----------------------------------------------------------------------
1978 
1979 #define VKI_SCSI_IOCTL_DOORLOCK     0x5380 /* Lock the eject mechanism.  */
1980 #define VKI_SCSI_IOCTL_DOORUNLOCK   0x5381 /* Unlock the mechanism.  */
1981 #define VKI_SCSI_IOCTL_GET_IDLUN    0x5382
1982 #define VKI_SCSI_IOCTL_GET_BUS_NUMBER   0x5386
1983 
1984 struct vki_scsi_idlun {
1985     __vki_u32 dev_id;
1986     __vki_u32 host_unique_id;
1987 };
1988 
1989 //----------------------------------------------------------------------
1990 // From linux-2.6.8.1/include/linux/cdrom.h
1991 //----------------------------------------------------------------------
1992 
1993 #define VKI_CDROMPLAYMSF        0x5303 /* Play Audio MSF (struct cdrom_msf) */
1994 #define VKI_CDROMREADTOCHDR     0x5305 /* Read TOC header 
1995                                                (struct cdrom_tochdr) */
1996 #define VKI_CDROMREADTOCENTRY       0x5306 /* Read TOC entry 
1997                                                (struct cdrom_tocentry) */
1998 #define VKI_CDROMSTOP           0x5307 /* Stop the cdrom drive */
1999 #define VKI_CDROMSUBCHNL        0x530b /* Read subchannel data 
2000                                                (struct cdrom_subchnl) */
2001 #define VKI_CDROMREADMODE2      0x530c /* Read CDROM mode 2 data (2336 Bytes) 
2002                                                (struct cdrom_read) */
2003 #define VKI_CDROMREADMODE1      0x530d /* Read CDROM mode 1 data (2048 Bytes)
2004                                                    (struct cdrom_read) */
2005 #define VKI_CDROMREADAUDIO      0x530e /* (struct cdrom_read_audio) */
2006 #define VKI_CDROMMULTISESSION       0x5310 /* Obtain the start-of-last-session 
2007                                                address of multi session disks 
2008                                                (struct cdrom_multisession) */
2009 #define VKI_CDROM_GET_MCN       0x5311 /* Obtain the "Universal Product Code" 
2010                                                if available (struct cdrom_mcn) */
2011 #define VKI_CDROMVOLREAD        0x5313 /* Get the drive's volume setting
2012                                               (struct cdrom_volctrl) */
2013 #define VKI_CDROMREADRAW        0x5314  /* read data in raw mode (2352 Bytes)
2014                                                (struct cdrom_read) */
2015 #define VKI_CDROM_CLEAR_OPTIONS     0x5321  /* Clear behavior options */
2016 #define VKI_CDROM_DRIVE_STATUS      0x5326  /* Get tray position, etc. */
2017 #define VKI_CDROM_DISC_STATUS       0x5327  /* get CD type information */
2018 #define VKI_CDROM_GET_CAPABILITY    0x5331  /* get capabilities */
2019 
2020 #define VKI_DVD_READ_STRUCT     0x5390  /* read structure */
2021 #define VKI_CDROM_SEND_PACKET       0x5393  /* send a packet to the drive */
2022 
2023 struct vki_cdrom_msf0       
2024 {
2025     __vki_u8    minute;
2026     __vki_u8    second;
2027     __vki_u8    frame;
2028 };
2029 
2030 union vki_cdrom_addr        
2031 {
2032     struct vki_cdrom_msf0   msf;
2033     int         lba;
2034 };
2035 
2036 struct vki_cdrom_msf 
2037 {
2038     __vki_u8    cdmsf_min0; /* start minute */
2039     __vki_u8    cdmsf_sec0; /* start second */
2040     __vki_u8    cdmsf_frame0;   /* start frame */
2041     __vki_u8    cdmsf_min1; /* end minute */
2042     __vki_u8    cdmsf_sec1; /* end second */
2043     __vki_u8    cdmsf_frame1;   /* end frame */
2044 };
2045 
2046 struct vki_cdrom_tochdr     
2047 {
2048     __vki_u8    cdth_trk0;  /* start track */
2049     __vki_u8    cdth_trk1;  /* end track */
2050 };
2051 
2052 struct vki_cdrom_volctrl
2053 {
2054     __vki_u8    channel0;
2055     __vki_u8    channel1;
2056     __vki_u8    channel2;
2057     __vki_u8    channel3;
2058 };
2059 
2060 struct vki_cdrom_subchnl 
2061 {
2062     __vki_u8    cdsc_format;
2063     __vki_u8    cdsc_audiostatus;
2064     __vki_u8    cdsc_adr:   4;
2065     __vki_u8    cdsc_ctrl:  4;
2066     __vki_u8    cdsc_trk;
2067     __vki_u8    cdsc_ind;
2068     union vki_cdrom_addr cdsc_absaddr;
2069     union vki_cdrom_addr cdsc_reladdr;
2070 };
2071 
2072 struct vki_cdrom_tocentry 
2073 {
2074     __vki_u8    cdte_track;
2075     __vki_u8    cdte_adr    :4;
2076     __vki_u8    cdte_ctrl   :4;
2077     __vki_u8    cdte_format;
2078     union vki_cdrom_addr cdte_addr;
2079     __vki_u8    cdte_datamode;
2080 };
2081 
2082 struct vki_cdrom_read      
2083 {
2084     int cdread_lba;
2085     char    *cdread_bufaddr;
2086     int cdread_buflen;
2087 };
2088 
2089 struct vki_cdrom_read_audio
2090 {
2091     union vki_cdrom_addr addr; /* frame address */
2092     __vki_u8 addr_format;      /* CDROM_LBA or CDROM_MSF */
2093     int nframes;           /* number of 2352-byte-frames to read at once */
2094     __vki_u8 __user *buf;      /* frame buffer (size: nframes*2352 bytes) */
2095 };
2096 
2097 struct vki_cdrom_multisession
2098 {
2099     union vki_cdrom_addr addr; /* frame address: start-of-last-session 
2100                                (not the new "frame 16"!).  Only valid
2101                                if the "xa_flag" is true. */
2102     __vki_u8 xa_flag;        /* 1: "is XA disk" */
2103     __vki_u8 addr_format;    /* CDROM_LBA or CDROM_MSF */
2104 };
2105 
2106 struct vki_cdrom_mcn 
2107 {
2108   __vki_u8 medium_catalog_number[14]; /* 13 ASCII digits, null-terminated */
2109 };
2110 
2111 #define VKI_CDROM_PACKET_SIZE   12
2112 
2113 struct vki_cdrom_generic_command
2114 {
2115     unsigned char       cmd[VKI_CDROM_PACKET_SIZE];
2116     unsigned char       __user *buffer;
2117     unsigned int        buflen;
2118     int         stat;
2119         // [[replace with void* to reduce inclusion amounts]]
2120     void/*struct vki_request_sense  */__user *sense;
2121     unsigned char       data_direction;
2122     int         quiet;
2123     int         timeout;
2124     void            __user *reserved[1];    /* unused, actually */
2125 };
2126 
2127 #define VKI_CD_SYNC_SIZE         12 /* 12 sync bytes per raw data frame */
2128 #define VKI_CD_HEAD_SIZE          4 /* header (address) bytes per raw data frame */
2129 #define VKI_CD_FRAMESIZE_RAW   2352 /* bytes per frame, "raw" mode */
2130 #define VKI_CD_FRAMESIZE_RAW0 (VKI_CD_FRAMESIZE_RAW-VKI_CD_SYNC_SIZE-VKI_CD_HEAD_SIZE) /*2336*/
2131 #define VKI_CD_FRAMESIZE_RAW1  2048 /* bytes per frame, mode 1*/
2132 
2133 //----------------------------------------------------------------------
2134 // From linux-2.6.8.1/include/linux/soundcard.h
2135 //----------------------------------------------------------------------
2136 
2137 #ifndef _VKI_SIOWR
2138 #if defined(_VKI_IOWR) && (defined(_AIX) || (!defined(sun) && !defined(sparc) && !defined(__sparc__) && !defined(__INCioctlh) && !defined(__Lynx__)))
2139 /* Use already defined ioctl defines if they exist (except with Sun or Sparc) */
2140 #define _VKI_SIO        _VKI_IO
2141 #define _VKI_SIOR       _VKI_IOR
2142 #define _VKI_SIOW       _VKI_IOW
2143 #define _VKI_SIOWR      _VKI_IOWR
2144 #else
2145 // [[Valgrind: Install this case if/when necessary]
2146 #error Valgrind: Cannot handle sparc/sun case yet...
2147 #  endif /* _IOWR */
2148 #endif  /* !_VKI_SIOWR */
2149 
2150 #define VKI_SNDCTL_SEQ_CTRLRATE     _VKI_SIOWR('Q', 3, int) /* Set/get timer resolution (HZ) */
2151 #define VKI_SNDCTL_SEQ_GETOUTCOUNT  _VKI_SIOR ('Q', 4, int)
2152 #define VKI_SNDCTL_SEQ_GETINCOUNT   _VKI_SIOR ('Q', 5, int)
2153 #define VKI_SNDCTL_SEQ_PERCMODE     _VKI_SIOW ('Q', 6, int)
2154 #define VKI_SNDCTL_SEQ_TESTMIDI     _VKI_SIOW ('Q', 8, int)
2155 #define VKI_SNDCTL_SEQ_RESETSAMPLES _VKI_SIOW ('Q', 9, int)
2156 #define VKI_SNDCTL_SEQ_NRSYNTHS     _VKI_SIOR ('Q',10, int)
2157 #define VKI_SNDCTL_SEQ_NRMIDIS      _VKI_SIOR ('Q',11, int)
2158 #define VKI_SNDCTL_SEQ_GETTIME      _VKI_SIOR ('Q',19, int)
2159 
2160 #define VKI_SNDCTL_TMR_TIMEBASE     _VKI_SIOWR('T', 1, int)
2161 #define VKI_SNDCTL_TMR_TEMPO        _VKI_SIOWR('T', 5, int)
2162 #define VKI_SNDCTL_TMR_SOURCE       _VKI_SIOWR('T', 6, int)
2163 
2164 #define VKI_SNDCTL_MIDI_PRETIME     _VKI_SIOWR('m', 0, int)
2165 #define VKI_SNDCTL_MIDI_MPUMODE     _VKI_SIOWR('m', 1, int)
2166 
2167 #define VKI_SNDCTL_DSP_RESET        _VKI_SIO  ('P', 0)
2168 #define VKI_SNDCTL_DSP_SYNC     _VKI_SIO  ('P', 1)
2169 #define VKI_SNDCTL_DSP_SPEED        _VKI_SIOWR('P', 2, int)
2170 #define VKI_SNDCTL_DSP_STEREO       _VKI_SIOWR('P', 3, int)
2171 #define VKI_SNDCTL_DSP_GETBLKSIZE   _VKI_SIOWR('P', 4, int)
2172 #define VKI_SNDCTL_DSP_CHANNELS     _VKI_SIOWR('P', 6, int)
2173 #define VKI_SOUND_PCM_WRITE_FILTER  _VKI_SIOWR('P', 7, int)
2174 #define VKI_SNDCTL_DSP_POST     _VKI_SIO  ('P', 8)
2175 #define VKI_SNDCTL_DSP_SUBDIVIDE    _VKI_SIOWR('P', 9, int)
2176 #define VKI_SNDCTL_DSP_SETFRAGMENT  _VKI_SIOWR('P',10, int)
2177 
2178 #define VKI_SNDCTL_DSP_GETFMTS      _VKI_SIOR ('P',11, int) /* Returns a mask */
2179 #define VKI_SNDCTL_DSP_SETFMT       _VKI_SIOWR('P', 5, int) /* Selects ONE fmt */
2180 
2181 typedef struct vki_audio_buf_info {
2182             int fragments;  /* # of available fragments (partially usend ones not counted) */
2183             int fragstotal; /* Total # of fragments allocated */
2184             int fragsize;   /* Size of a fragment in bytes */
2185 
2186             int bytes;  /* Available space in bytes (includes partially used fragments) */
2187             /* Note! 'bytes' could be more than fragments*fragsize */
2188         } vki_audio_buf_info;
2189 
2190 #define VKI_SNDCTL_DSP_GETOSPACE    _VKI_SIOR ('P',12, vki_audio_buf_info)
2191 #define VKI_SNDCTL_DSP_GETISPACE    _VKI_SIOR ('P',13, vki_audio_buf_info)
2192 #define VKI_SNDCTL_DSP_NONBLOCK     _VKI_SIO  ('P',14)
2193 #define VKI_SNDCTL_DSP_GETCAPS      _VKI_SIOR ('P',15, int)
2194 
2195 #define VKI_SNDCTL_DSP_GETTRIGGER   _VKI_SIOR ('P',16, int)
2196 #define VKI_SNDCTL_DSP_SETTRIGGER   _VKI_SIOW ('P',16, int)
2197 
2198 #define VKI_SNDCTL_DSP_SETSYNCRO    _VKI_SIO  ('P', 21)
2199 #define VKI_SNDCTL_DSP_SETDUPLEX    _VKI_SIO  ('P', 22)
2200 #define VKI_SNDCTL_DSP_GETODELAY    _VKI_SIOR ('P', 23, int)
2201 
2202 #define VKI_SNDCTL_DSP_GETCHANNELMASK   _VKI_SIOWR('P', 64, int)
2203 #define VKI_SNDCTL_DSP_BIND_CHANNEL _VKI_SIOWR('P', 65, int)
2204 
2205 #define VKI_SNDCTL_DSP_SETSPDIF     _VKI_SIOW ('P', 66, int)
2206 #define VKI_SNDCTL_DSP_GETSPDIF     _VKI_SIOR ('P', 67, int)
2207 
2208 #define VKI_SOUND_PCM_READ_RATE     _VKI_SIOR ('P', 2, int)
2209 #define VKI_SOUND_PCM_READ_CHANNELS _VKI_SIOR ('P', 6, int)
2210 #define VKI_SOUND_PCM_READ_BITS     _VKI_SIOR ('P', 5, int)
2211 #define VKI_SOUND_PCM_READ_FILTER   _VKI_SIOR ('P', 7, int)
2212 
2213 
2214 //----------------------------------------------------------------------
2215 // From linux-2.6.8.1/include/linux/hdreg.h
2216 //----------------------------------------------------------------------
2217 
2218 struct vki_hd_geometry {
2219       unsigned char heads;
2220       unsigned char sectors;
2221       unsigned short cylinders;
2222       unsigned long start;
2223 };
2224 
2225 #define VKI_HDIO_GETGEO     0x0301  /* get device geometry */
2226 #define VKI_HDIO_GET_DMA    0x030b  /* get use-dma flag */
2227 #define VKI_HDIO_GET_IDENTITY   0x030d  /* get IDE identification info */
2228 
2229 // [[Nb: done like this because the original type is a huge struct that will
2230 //   always be the same size.]]
2231 #define VKI_SIZEOF_STRUCT_HD_DRIVEID   512
2232 
2233 //----------------------------------------------------------------------
2234 // From linux-2.6.8.1/include/linux/fb.h
2235 //----------------------------------------------------------------------
2236 
2237 #define VKI_FBIOGET_VSCREENINFO 0x4600
2238 #define VKI_FBIOPUT_VSCREENINFO 0x4601
2239 #define VKI_FBIOGET_FSCREENINFO 0x4602
2240 #define VKI_FBIOPAN_DISPLAY 0x4606
2241 
2242 struct vki_fb_fix_screeninfo {
2243     char id[16];            /* identification string eg "TT Builtin" */
2244     unsigned long smem_start;   /* Start of frame buffer mem */
2245                     /* (physical address) */
2246     __vki_u32 smem_len;         /* Length of frame buffer mem */
2247     __vki_u32 type;         /* see FB_TYPE_*        */
2248     __vki_u32 type_aux;     /* Interleave for interleaved Planes */
2249     __vki_u32 visual;       /* see FB_VISUAL_*      */ 
2250     __vki_u16 xpanstep;     /* zero if no hardware panning  */
2251     __vki_u16 ypanstep;     /* zero if no hardware panning  */
2252     __vki_u16 ywrapstep;        /* zero if no hardware ywrap    */
2253     __vki_u32 line_length;      /* length of a line in bytes    */
2254     unsigned long mmio_start;   /* Start of Memory Mapped I/O   */
2255                     /* (physical address) */
2256     __vki_u32 mmio_len;     /* Length of Memory Mapped I/O  */
2257     __vki_u32 accel;        /* Indicate to driver which */
2258                     /*  specific chip/card we have  */
2259     __vki_u16 reserved[3];      /* Reserved for future compatibility */
2260 };
2261 
2262 struct vki_fb_bitfield {
2263     __vki_u32 offset;       /* beginning of bitfield    */
2264     __vki_u32 length;       /* length of bitfield       */
2265     __vki_u32 msb_right;        /* != 0 : Most significant bit is */ 
2266                     /* right */ 
2267 };
2268 
2269 struct vki_fb_var_screeninfo {
2270     __vki_u32 xres;         /* visible resolution       */
2271     __vki_u32 yres;
2272     __vki_u32 xres_virtual;     /* virtual resolution       */
2273     __vki_u32 yres_virtual;
2274     __vki_u32 xoffset;      /* offset from virtual to visible */
2275     __vki_u32 yoffset;      /* resolution           */
2276 
2277     __vki_u32 bits_per_pixel;   /* guess what           */
2278     __vki_u32 grayscale;        /* != 0 Graylevels instead of colors */
2279 
2280     struct vki_fb_bitfield red; /* bitfield in fb mem if true color, */
2281     struct vki_fb_bitfield green;   /* else only length is significant */
2282     struct vki_fb_bitfield blue;
2283     struct vki_fb_bitfield transp;  /* transparency         */  
2284 
2285     __vki_u32 nonstd;       /* != 0 Non standard pixel format */
2286 
2287     __vki_u32 activate;     /* see FB_ACTIVATE_*        */
2288 
2289     __vki_u32 height;       /* height of picture in mm    */
2290     __vki_u32 width;        /* width of picture in mm     */
2291 
2292     __vki_u32 accel_flags;      /* (OBSOLETE) see fb_info.flags */
2293 
2294     /* Timing: All values in pixclocks, except pixclock (of course) */
2295     __vki_u32 pixclock;     /* pixel clock in ps (pico seconds) */
2296     __vki_u32 left_margin;      /* time from sync to picture    */
2297     __vki_u32 right_margin;     /* time from picture to sync    */
2298     __vki_u32 upper_margin;     /* time from sync to picture    */
2299     __vki_u32 lower_margin;
2300     __vki_u32 hsync_len;        /* length of horizontal sync    */
2301     __vki_u32 vsync_len;        /* length of vertical sync  */
2302     __vki_u32 sync;         /* see FB_SYNC_*        */
2303     __vki_u32 vmode;        /* see FB_VMODE_*       */
2304     __vki_u32 rotate;       /* angle we rotate counter clockwise */
2305     __vki_u32 reserved[5];      /* Reserved for future compatibility */
2306 };
2307 
2308 //----------------------------------------------------------------------
2309 // From linux-2.6.9/include/linux/kd.h
2310 //----------------------------------------------------------------------
2311 
2312 #define VKI_GIO_FONT       0x4B60  /* gets font in expanded form */
2313 #define VKI_PIO_FONT       0x4B61  /* use font in expanded form */
2314 
2315 #define VKI_GIO_FONTX      0x4B6B  /* get font using struct consolefontdesc */
2316 #define VKI_PIO_FONTX      0x4B6C  /* set font using struct consolefontdesc */
2317 struct vki_consolefontdesc {
2318     unsigned short charcount;   /* characters in font (256 or 512) */
2319     unsigned short charheight;  /* scan lines per character (1-32) */
2320     char __user *chardata;      /* font data in expanded form */
2321 };
2322 
2323 #define VKI_PIO_FONTRESET  0x4B6D  /* reset to default font */
2324 
2325 #define VKI_GIO_CMAP       0x4B70  /* gets colour palette on VGA+ */
2326 #define VKI_PIO_CMAP       0x4B71  /* sets colour palette on VGA+ */
2327 
2328 #define VKI_KIOCSOUND      0x4B2F  /* start sound generation (0 for off) */
2329 #define VKI_KDMKTONE       0x4B30  /* generate tone */
2330 
2331 #define VKI_KDGETLED       0x4B31  /* return current led state */
2332 #define VKI_KDSETLED       0x4B32  /* set led state [lights, not flags] */
2333 
2334 #define VKI_KDGKBTYPE      0x4B33  /* get keyboard type */
2335 
2336 #define VKI_KDADDIO        0x4B34  /* add i/o port as valid */
2337 #define VKI_KDDELIO        0x4B35  /* del i/o port as valid */
2338 #define VKI_KDENABIO       0x4B36  /* enable i/o to video board */
2339 #define VKI_KDDISABIO      0x4B37  /* disable i/o to video board */
2340 
2341 #define VKI_KDSETMODE      0x4B3A  /* set text/graphics mode */
2342 #define VKI_KDGETMODE      0x4B3B  /* get current mode */
2343 
2344 #define VKI_KDMAPDISP      0x4B3C  /* map display into address space */
2345 #define VKI_KDUNMAPDISP    0x4B3D  /* unmap display from address space */
2346 
2347 #define     VKI_E_TABSZ     256
2348 #define VKI_GIO_SCRNMAP    0x4B40  /* get screen mapping from kernel */
2349 #define VKI_PIO_SCRNMAP    0x4B41  /* put screen mapping table in kernel */
2350 #define VKI_GIO_UNISCRNMAP 0x4B69  /* get full Unicode screen mapping */
2351 #define VKI_PIO_UNISCRNMAP 0x4B6A  /* set full Unicode screen mapping */
2352 
2353 #define VKI_GIO_UNIMAP     0x4B66  /* get unicode-to-font mapping from kernel */
2354 struct vki_unipair {
2355     unsigned short unicode;
2356     unsigned short fontpos;
2357 };
2358 struct vki_unimapdesc {
2359     unsigned short entry_ct;
2360     struct vki_unipair __user *entries;
2361 };
2362 #define VKI_PIO_UNIMAP     0x4B67  /* put unicode-to-font mapping in kernel */
2363 #define VKI_PIO_UNIMAPCLR  0x4B68  /* clear table, possibly advise hash algorithm */
2364 struct vki_unimapinit {
2365     unsigned short advised_hashsize;  /* 0 if no opinion */
2366     unsigned short advised_hashstep;  /* 0 if no opinion */
2367     unsigned short advised_hashlevel; /* 0 if no opinion */
2368 };
2369 
2370 #define VKI_KDGKBMODE      0x4B44  /* gets current keyboard mode */
2371 #define VKI_KDSKBMODE      0x4B45  /* sets current keyboard mode */
2372 
2373 #define VKI_KDGKBMETA      0x4B62  /* gets meta key handling mode */
2374 #define VKI_KDSKBMETA      0x4B63  /* sets meta key handling mode */
2375 
2376 #define VKI_KDGKBLED       0x4B64  /* get led flags (not lights) */
2377 #define VKI_KDSKBLED       0x4B65  /* set led flags (not lights) */
2378 
2379 struct vki_kbentry {
2380     unsigned char kb_table;
2381     unsigned char kb_index;
2382     unsigned short kb_value;
2383 };
2384 #define VKI_KDGKBENT       0x4B46  /* gets one entry in translation table */
2385 #define VKI_KDSKBENT       0x4B47  /* sets one entry in translation table */
2386 
2387 struct vki_kbsentry {
2388     unsigned char kb_func;
2389     unsigned char kb_string[512];
2390 };
2391 #define VKI_KDGKBSENT      0x4B48  /* gets one function key string entry */
2392 #define VKI_KDSKBSENT      0x4B49  /* sets one function key string entry */
2393 
2394 struct vki_kbdiacr {
2395         unsigned char diacr, base, result;
2396 };
2397 struct vki_kbdiacrs {
2398         unsigned int kb_cnt;    /* number of entries in following array */
2399     struct vki_kbdiacr kbdiacr[256];    /* MAX_DIACR from keyboard.h */
2400 };
2401 #define VKI_KDGKBDIACR     0x4B4A  /* read kernel accent table */
2402 #define VKI_KDSKBDIACR     0x4B4B  /* write kernel accent table */
2403 
2404 struct vki_kbkeycode {
2405     unsigned int scancode, keycode;
2406 };
2407 #define VKI_KDGETKEYCODE   0x4B4C  /* read kernel keycode table entry */
2408 #define VKI_KDSETKEYCODE   0x4B4D  /* write kernel keycode table entry */
2409 
2410 #define VKI_KDSIGACCEPT    0x4B4E  /* accept kbd generated signals */
2411 
2412 struct vki_kbd_repeat {
2413     int delay;  /* in msec; <= 0: don't change */
2414     int period; /* in msec; <= 0: don't change */
2415             /* earlier this field was misnamed "rate" */
2416 };
2417 #define VKI_KDKBDREP       0x4B52  /* set keyboard delay/repeat rate;
2418                                     * actually used values are returned */
2419 
2420 #define VKI_KDFONTOP       0x4B72  /* font operations */
2421 
2422 struct vki_console_font_op {
2423     unsigned int op;    /* operation code KD_FONT_OP_* */
2424     unsigned int flags; /* KD_FONT_FLAG_* */
2425     unsigned int width, height; /* font size */
2426     unsigned int charcount;
2427     unsigned char __user *data; /* font data with height fixed to 32 */
2428 };
2429 
2430 #define VKI_KD_FONT_OP_SET      0   /* Set font */
2431 #define VKI_KD_FONT_OP_GET      1   /* Get font */
2432 #define VKI_KD_FONT_OP_SET_DEFAULT  2   /* Set font to default, data points to name / NULL */
2433 #define VKI_KD_FONT_OP_COPY     3   /* Copy from another console */
2434 
2435 //----------------------------------------------------------------------
2436 // From linux-2.6.9/include/linux/kb.h
2437 //----------------------------------------------------------------------
2438 
2439 typedef __vki_kernel_uid32_t vki_qid_t; /* Type in which we store ids in memory */
2440 
2441 //----------------------------------------------------------------------
2442 // From linux-2.6.20.1/include/linux/ptrace.h
2443 //----------------------------------------------------------------------
2444 
2445 #define VKI_PTRACE_TRACEME         0
2446 #define VKI_PTRACE_PEEKTEXT    1
2447 #define VKI_PTRACE_PEEKDATA    2
2448 #define VKI_PTRACE_PEEKUSR     3
2449 #define VKI_PTRACE_POKEUSR     6
2450 
2451 #define VKI_PTRACE_DETACH         17
2452 
2453 #define VKI_PTRACE_GETEVENTMSG  0x4201
2454 #define VKI_PTRACE_GETSIGINFO   0x4202
2455 #define VKI_PTRACE_SETSIGINFO   0x4203
2456 #define VKI_PTRACE_GETREGSET    0x4204
2457 #define VKI_PTRACE_SETREGSET    0x4205
2458 
2459 #define VKI_PT_PTRACED 0x00000001
2460 
2461 //----------------------------------------------------------------------
2462 // From linux-2.6.14/include/sound/asound.h
2463 //----------------------------------------------------------------------
2464 
2465 enum {
2466     VKI_SNDRV_PCM_IOCTL_HW_FREE = _VKI_IO('A', 0x12),
2467     VKI_SNDRV_PCM_IOCTL_HWSYNC = _VKI_IO('A', 0x22),
2468     VKI_SNDRV_PCM_IOCTL_PREPARE = _VKI_IO('A', 0x40),
2469     VKI_SNDRV_PCM_IOCTL_RESET = _VKI_IO('A', 0x41),
2470     VKI_SNDRV_PCM_IOCTL_START = _VKI_IO('A', 0x42),
2471     VKI_SNDRV_PCM_IOCTL_DROP = _VKI_IO('A', 0x43),
2472     VKI_SNDRV_PCM_IOCTL_DRAIN = _VKI_IO('A', 0x44),
2473     VKI_SNDRV_PCM_IOCTL_PAUSE = _VKI_IOW('A', 0x45, int),
2474     VKI_SNDRV_PCM_IOCTL_RESUME = _VKI_IO('A', 0x47),
2475     VKI_SNDRV_PCM_IOCTL_XRUN = _VKI_IO('A', 0x48),
2476     VKI_SNDRV_PCM_IOCTL_LINK = _VKI_IOW('A', 0x60, int),
2477     VKI_SNDRV_PCM_IOCTL_UNLINK = _VKI_IO('A', 0x61),
2478 };
2479 
2480 enum {
2481     VKI_SNDRV_TIMER_IOCTL_START = _VKI_IO('T', 0xa0),
2482     VKI_SNDRV_TIMER_IOCTL_STOP = _VKI_IO('T', 0xa1),
2483     VKI_SNDRV_TIMER_IOCTL_CONTINUE = _VKI_IO('T', 0xa2),
2484     VKI_SNDRV_TIMER_IOCTL_PAUSE = _VKI_IO('T', 0xa3),
2485 };
2486 
2487 struct vki_snd_ctl_card_info {
2488     int card;           /* card number */
2489     int pad;            /* reserved for future (was type) */
2490     unsigned char id[16];       /* ID of card (user selectable) */
2491     unsigned char driver[16];   /* Driver name */
2492     unsigned char name[32];     /* Short name of soundcard */
2493     unsigned char longname[80]; /* name + info text about soundcard */
2494     unsigned char reserved_[16];    /* reserved for future (was ID of mixer) */
2495     unsigned char mixername[80];    /* visual mixer identification */
2496     unsigned char components[128];  /* card components / fine identification, delimited with one space (AC97 etc..) */
2497 };
2498 
2499 typedef int vki_snd_ctl_elem_iface_t;
2500 #define VKI_SNDRV_CTL_ELEM_IFACE_CARD       ((vki_snd_ctl_elem_iface_t) 0) /* global control */
2501 #define VKI_SNDRV_CTL_ELEM_IFACE_HWDEP      ((vki_snd_ctl_elem_iface_t) 1) /* hardware dependent device */
2502 #define VKI_SNDRV_CTL_ELEM_IFACE_MIXER      ((vki_snd_ctl_elem_iface_t) 2) /* virtual mixer device */
2503 #define VKI_SNDRV_CTL_ELEM_IFACE_PCM        ((vki_snd_ctl_elem_iface_t) 3) /* PCM device */
2504 #define VKI_SNDRV_CTL_ELEM_IFACE_RAWMIDI    ((vki_snd_ctl_elem_iface_t) 4) /* RawMidi device */
2505 #define VKI_SNDRV_CTL_ELEM_IFACE_TIMER      ((vki_snd_ctl_elem_iface_t) 5) /* timer device */
2506 #define VKI_SNDRV_CTL_ELEM_IFACE_SEQUENCER  ((vki_snd_ctl_elem_iface_t) 6) /* sequencer client */
2507 #define VKI_SNDRV_CTL_ELEM_IFACE_LAST       VKI_SNDRV_CTL_ELEM_IFACE_SEQUENCER
2508 
2509 struct vki_snd_ctl_elem_id {
2510     unsigned int numid;     /* numeric identifier, zero = invalid */
2511     vki_snd_ctl_elem_iface_t iface; /* interface identifier */
2512     unsigned int device;        /* device/client number */
2513     unsigned int subdevice;     /* subdevice (substream) number */
2514     unsigned char name[44];     /* ASCII name of item */
2515     unsigned int index;     /* index of item */
2516 };
2517 
2518 struct vki_snd_ctl_elem_list {
2519     unsigned int offset;        /* W: first element ID to get */
2520     unsigned int space;     /* W: count of element IDs to get */
2521     unsigned int used;      /* R: count of element IDs set */
2522     unsigned int count;     /* R: count of all elements */
2523     struct vki_snd_ctl_elem_id __user *pids; /* R: IDs */
2524     unsigned char reserved[50];
2525 };
2526 
2527 struct vki_snd_ctl_tlv {
2528     unsigned int numid; /* control element numeric identification */
2529     unsigned int length;    /* in bytes aligned to 4 */
2530     unsigned int tlv[0];    /* first TLV */
2531 };
2532 
2533 #define VKI_SNDRV_CTL_IOCTL_PVERSION    _VKI_IOR('U', 0x00, int)
2534 #define VKI_SNDRV_CTL_IOCTL_CARD_INFO   _VKI_IOR('U', 0x01, struct vki_snd_ctl_card_info)
2535 #define VKI_SNDRV_CTL_IOCTL_ELEM_LIST   _VKI_IOWR('U', 0x10, struct vki_snd_ctl_elem_list)
2536 #define VKI_SNDRV_CTL_IOCTL_TLV_READ    _VKI_IOWR('U', 0x1a, struct vki_snd_ctl_tlv)
2537 #define VKI_SNDRV_CTL_IOCTL_TLV_WRITE   _VKI_IOWR('U', 0x1b, struct vki_snd_ctl_tlv)
2538 #define VKI_SNDRV_CTL_IOCTL_TLV_COMMAND _VKI_IOWR('U', 0x1c, struct vki_snd_ctl_tlv)
2539 
2540 //----------------------------------------------------------------------
2541 // From linux-2.6.15.4/include/linux/serial.h
2542 //----------------------------------------------------------------------
2543 
2544 struct vki_serial_icounter_struct {
2545     int cts, dsr, rng, dcd;
2546     int rx, tx;
2547     int frame, overrun, parity, brk;
2548     int buf_overrun;
2549     int reserved[9];
2550 };
2551 
2552 //----------------------------------------------------------------------
2553 // From linux-2.6.16/include/linux/vt.h
2554 //----------------------------------------------------------------------
2555 
2556 #define VKI_VT_OPENQRY  0x5600  /* find available vt */
2557 
2558 struct vki_vt_mode {
2559     char mode;      /* vt mode */
2560     char waitv;     /* if set, hang on writes if not active */
2561     short relsig;       /* signal to raise on release req */
2562     short acqsig;       /* signal to raise on acquisition */
2563     short frsig;        /* unused (set to 0) */
2564 };
2565 #define VKI_VT_GETMODE  0x5601  /* get mode of active vt */
2566 #define VKI_VT_SETMODE  0x5602  /* set mode of active vt */
2567 
2568 struct vki_vt_stat {
2569     unsigned short v_active;    /* active vt */
2570     unsigned short v_signal;    /* signal to send */
2571     unsigned short v_state;     /* vt bitmask */
2572 };
2573 #define VKI_VT_GETSTATE 0x5603  /* get global vt state info */
2574 #define VKI_VT_SENDSIG  0x5604  /* signal to send to bitmask of vts */
2575 
2576 #define VKI_VT_RELDISP  0x5605  /* release display */
2577 
2578 #define VKI_VT_ACTIVATE 0x5606  /* make vt active */
2579 #define VKI_VT_WAITACTIVE   0x5607  /* wait for vt active */
2580 #define VKI_VT_DISALLOCATE  0x5608  /* free memory associated to vt */
2581 
2582 struct vki_vt_sizes {
2583     unsigned short v_rows;      /* number of rows */
2584     unsigned short v_cols;      /* number of columns */
2585     unsigned short v_scrollsize;    /* number of lines of scrollback */
2586 };
2587 #define VKI_VT_RESIZE   0x5609  /* set kernel's idea of screensize */
2588 
2589 struct vki_vt_consize {
2590     unsigned short v_rows;  /* number of rows */
2591     unsigned short v_cols;  /* number of columns */
2592     unsigned short v_vlin;  /* number of pixel rows on screen */
2593     unsigned short v_clin;  /* number of pixel rows per character */
2594     unsigned short v_vcol;  /* number of pixel columns on screen */
2595     unsigned short v_ccol;  /* number of pixel columns per character */
2596 };
2597 #define VKI_VT_RESIZEX      0x560A  /* set kernel's idea of screensize + more */
2598 #define VKI_VT_LOCKSWITCH   0x560B  /* disallow vt switching */
2599 #define VKI_VT_UNLOCKSWITCH 0x560C  /* allow vt switching */
2600 
2601 //----------------------------------------------------------------------
2602 // From linux-2.6.19/include/linux/prctl.h
2603 //----------------------------------------------------------------------
2604 
2605 #define VKI_PR_SET_PDEATHSIG  1  /* Second arg is a signal */
2606 #define VKI_PR_GET_PDEATHSIG  2  /* Second arg is a ptr to return the signal */
2607 
2608 #define VKI_PR_GET_DUMPABLE   3
2609 #define VKI_PR_SET_DUMPABLE   4
2610 
2611 #define VKI_PR_GET_UNALIGN    5
2612 #define VKI_PR_SET_UNALIGN    6
2613 # define VKI_PR_UNALIGN_NOPRINT 1   /* silently fix up unaligned user accesses */
2614 # define VKI_PR_UNALIGN_SIGBUS  2   /* generate SIGBUS on unaligned user access */
2615 
2616 #define VKI_PR_GET_KEEPCAPS   7
2617 #define VKI_PR_SET_KEEPCAPS   8
2618 
2619 #define VKI_PR_GET_FPEMU  9
2620 #define VKI_PR_SET_FPEMU 10
2621 # define VKI_PR_FPEMU_NOPRINT   1   /* silently emulate fp operations accesses */
2622 # define VKI_PR_FPEMU_SIGFPE    2   /* don't emulate fp operations, send SIGFPE instead */
2623 
2624 #define VKI_PR_GET_FPEXC    11
2625 #define VKI_PR_SET_FPEXC    12
2626 # define VKI_PR_FP_EXC_SW_ENABLE    0x80    /* Use FPEXC for FP exception enables */
2627 # define VKI_PR_FP_EXC_DIV      0x010000    /* floating point divide by zero */
2628 # define VKI_PR_FP_EXC_OVF      0x020000    /* floating point overflow */
2629 # define VKI_PR_FP_EXC_UND      0x040000    /* floating point underflow */
2630 # define VKI_PR_FP_EXC_RES      0x080000    /* floating point inexact result */
2631 # define VKI_PR_FP_EXC_INV      0x100000    /* floating point invalid operation */
2632 # define VKI_PR_FP_EXC_DISABLED 0   /* FP exceptions disabled */
2633 # define VKI_PR_FP_EXC_NONRECOV 1   /* async non-recoverable exc. mode */
2634 # define VKI_PR_FP_EXC_ASYNC    2   /* async recoverable exception mode */
2635 # define VKI_PR_FP_EXC_PRECISE  3   /* precise exception mode */
2636 
2637 #define VKI_PR_GET_TIMING   13
2638 #define VKI_PR_SET_TIMING   14
2639 # define VKI_PR_TIMING_STATISTICAL  0       /* Normal, traditional,
2640                                                    statistical process timing */
2641 # define VKI_PR_TIMING_TIMESTAMP    1       /* Accurate timestamp based
2642                                                    process timing */
2643 
2644 #define VKI_PR_SET_NAME    15       /* Set process name */
2645 #define VKI_PR_GET_NAME    16       /* Get process name */
2646 
2647 #define VKI_PR_GET_ENDIAN   19
2648 #define VKI_PR_SET_ENDIAN   20
2649 # define VKI_PR_ENDIAN_BIG      0
2650 # define VKI_PR_ENDIAN_LITTLE   1   /* True little endian mode */
2651 # define VKI_PR_ENDIAN_PPC_LITTLE   2   /* "PowerPC" pseudo little endian */
2652 
2653 #define VKI_PR_SET_SECCOMP 22
2654 
2655 #define VKI_PR_CAPBSET_READ 23
2656 #define VKI_PR_CAPBSET_DROP 24
2657 
2658 #define VKI_PR_GET_TSC 25
2659 #define VKI_PR_SET_TSC 26
2660 
2661 #define VKI_PR_GET_SECUREBITS 27
2662 #define VKI_PR_SET_SECUREBITS 28
2663 
2664 #define VKI_PR_SET_TIMERSLACK 29
2665 #define VKI_PR_GET_TIMERSLACK 30
2666 
2667 #define VKI_PR_TASK_PERF_EVENTS_DISABLE     31
2668 #define VKI_PR_TASK_PERF_EVENTS_ENABLE      32
2669 
2670 #define VKI_PR_MCE_KILL 33
2671 #define VKI_PR_MCE_KILL_GET 34
2672 
2673 #define VKI_PR_SET_PTRACER 0x59616d61
2674 
2675 #define VKI_PR_SET_CHILD_SUBREAPER  36
2676 #define VKI_PR_GET_CHILD_SUBREAPER  37
2677 
2678 #define VKI_PR_SET_NO_NEW_PRIVS 38
2679 #define VKI_PR_GET_NO_NEW_PRIVS 39
2680 
2681 #define VKI_PR_GET_TID_ADDRESS  40
2682 
2683 #define VKI_PR_SET_THP_DISABLE  41
2684 #define VKI_PR_GET_THP_DISABLE  42
2685 
2686 #define VKI_PR_MPX_ENABLE_MANAGEMENT  43
2687 #define VKI_PR_MPX_DISABLE_MANAGEMENT 44
2688 
2689 #define VKI_PR_SET_FP_MODE      45
2690 #define VKI_PR_GET_FP_MODE      46
2691 
2692 #define VKI_PR_CAP_AMBIENT      47
2693 
2694 #define VKI_PR_SVE_SET_VL       50
2695 #define VKI_PR_SVE_GET_VL       51
2696 #define VKI_PR_GET_SPECULATION_CTRL 52
2697 #define VKI_PR_SET_SPECULATION_CTRL 53
2698 #define VKI_PR_PAC_RESET_KEYS       54
2699 #define VKI_PR_SET_TAGGED_ADDR_CTRL 55
2700 #define VKI_PR_GET_TAGGED_ADDR_CTRL 56
2701 
2702 //----------------------------------------------------------------------
2703 // From linux-2.6.19/include/linux/usbdevice_fs.h
2704 //----------------------------------------------------------------------
2705 
2706 struct vki_usbdevfs_ctrltransfer {
2707     __vki_u8 bRequestType;
2708     __vki_u8 bRequest;
2709     __vki_u16 wValue;
2710     __vki_u16 wIndex;
2711     __vki_u16 wLength;
2712     __vki_u32 timeout;  /* in milliseconds */
2713     void __user *data;
2714 };
2715 
2716 struct vki_usbdevfs_bulktransfer {
2717     unsigned int ep;
2718     unsigned int len;
2719     unsigned int timeout; /* in milliseconds */
2720     void __user *data;
2721 };
2722 
2723 #define VKI_USBDEVFS_MAXDRIVERNAME 255
2724 
2725 struct vki_usbdevfs_getdriver {
2726     unsigned int interface;
2727     char driver[VKI_USBDEVFS_MAXDRIVERNAME + 1];
2728 };
2729 
2730 struct vki_usbdevfs_connectinfo {
2731     unsigned int devnum;
2732     unsigned char slow;
2733 };
2734 
2735 struct vki_usbdevfs_iso_packet_desc {
2736     unsigned int length;
2737     unsigned int actual_length;
2738     unsigned int status;
2739 };
2740 
2741 struct vki_usbdevfs_urb {
2742     unsigned char type;
2743     unsigned char endpoint;
2744     int status;
2745     unsigned int flags;
2746     void __user *buffer;
2747     int buffer_length;
2748     int actual_length;
2749     int start_frame;
2750     int number_of_packets;
2751     int error_count;
2752     unsigned int signr;  /* signal to be sent on error, -1 if none should be sent */
2753     void *usercontext;
2754     struct vki_usbdevfs_iso_packet_desc iso_frame_desc[0];
2755 };
2756 
2757 struct vki_usbdevfs_ioctl {
2758     int ifno;       /* interface 0..N ; negative numbers reserved */
2759     int ioctl_code; /* MUST encode size + direction of data so the
2760                  * macros in <asm/ioctl.h> give correct values */
2761     void __user *data;  /* param buffer (in, or out) */
2762 };
2763 
2764 #define VKI_USBDEVFS_CONTROL           _VKI_IOWR('U', 0, struct vki_usbdevfs_ctrltransfer)
2765 #define VKI_USBDEVFS_BULK              _VKI_IOWR('U', 2, struct vki_usbdevfs_bulktransfer)
2766 #define VKI_USBDEVFS_GETDRIVER         _VKI_IOW('U', 8, struct vki_usbdevfs_getdriver)
2767 #define VKI_USBDEVFS_SUBMITURB         _VKI_IOR('U', 10, struct vki_usbdevfs_urb)
2768 #define VKI_USBDEVFS_DISCARDURB        _VKI_IO('U', 11)
2769 #define VKI_USBDEVFS_REAPURB           _VKI_IOW('U', 12, void *)
2770 #define VKI_USBDEVFS_REAPURBNDELAY     _VKI_IOW('U', 13, void *)
2771 #define VKI_USBDEVFS_CONNECTINFO       _VKI_IOW('U', 17, struct vki_usbdevfs_connectinfo)
2772 #define VKI_USBDEVFS_IOCTL             _VKI_IOWR('U', 18, struct vki_usbdevfs_ioctl)
2773 #define VKI_USBDEVFS_RESET             _VKI_IO('U', 20)
2774 
2775 #define VKI_USBDEVFS_URB_TYPE_ISO              0
2776 #define VKI_USBDEVFS_URB_TYPE_INTERRUPT        1
2777 #define VKI_USBDEVFS_URB_TYPE_CONTROL          2
2778 #define VKI_USBDEVFS_URB_TYPE_BULK             3
2779 
2780 // [[this is missing in usbdevice_fs.h]]
2781 struct vki_usbdevfs_setuppacket {
2782        __vki_u8 bRequestType;
2783        __vki_u8 bRequest;
2784        __vki_u16 wValue;
2785        __vki_u16 wIndex;
2786        __vki_u16 wLength;
2787 };
2788 
2789 //----------------------------------------------------------------------
2790 // From linux-2.6.20.1/include/linux/i2c.h
2791 //----------------------------------------------------------------------
2792 
2793 #define VKI_I2C_SMBUS_QUICK             0
2794 #define VKI_I2C_SMBUS_BYTE              1
2795 #define VKI_I2C_SMBUS_BYTE_DATA         2
2796 #define VKI_I2C_SMBUS_WORD_DATA         3
2797 #define VKI_I2C_SMBUS_PROC_CALL         4
2798 #define VKI_I2C_SMBUS_BLOCK_DATA        5
2799 #define VKI_I2C_SMBUS_I2C_BLOCK_BROKEN  6
2800 #define VKI_I2C_SMBUS_BLOCK_PROC_CALL   7           /* SMBus 2.0 */
2801 #define VKI_I2C_SMBUS_I2C_BLOCK_DATA    8
2802 
2803 /* smbus_access read or write markers */
2804 #define VKI_I2C_SMBUS_READ  1
2805 #define VKI_I2C_SMBUS_WRITE 0
2806 
2807 #define VKI_I2C_SLAVE        0x0703  /* Change slave address                 */
2808                                      /* Attn.: Slave address is 7 or 10 bits */
2809 #define VKI_I2C_SLAVE_FORCE  0x0706  /* Change slave address                 */
2810                                      /* Attn.: Slave address is 7 or 10 bits */
2811                                      /* This changes the address, even if it */
2812                                      /* is already taken!                    */
2813 #define VKI_I2C_TENBIT       0x0704  /* 0 for 7 bit addrs, != 0 for 10 bit   */
2814 #define VKI_I2C_FUNCS        0x0705  /* Get the adapter functionality */
2815 #define VKI_I2C_RDWR         0x0707  /* Combined R/W transfer (one STOP only) */
2816 #define VKI_I2C_PEC          0x0708  /* != 0 for SMBus PEC                   */
2817 #define VKI_I2C_SMBUS        0x0720  /* SMBus transfer */
2818 
2819 #define VKI_I2C_SMBUS_BLOCK_MAX  32  /* As specified in SMBus standard */
2820 union vki_i2c_smbus_data {
2821         __vki_u8 byte;
2822         __vki_u16 word;
2823         __vki_u8 block[VKI_I2C_SMBUS_BLOCK_MAX + 2];
2824                  /* block[0] is used for length */
2825                  /* and one more for PEC */
2826 };
2827 
2828 /* This is the structure as used in the I2C_SMBUS ioctl call */
2829 struct vki_i2c_smbus_ioctl_data {
2830         __vki_u8 read_write;
2831         __vki_u8 command;
2832         __vki_u32 size;
2833         union vki_i2c_smbus_data __user *data;
2834 };
2835 
2836 struct vki_i2c_msg {
2837     __vki_u16 addr;     /* slave address            */
2838     __vki_u16 flags;
2839 #define VKI_I2C_M_TEN       0x0010  /* this is a ten bit chip address */
2840 #define VKI_I2C_M_RD        0x0001  /* read data, from slave to master */
2841 #define VKI_I2C_M_NOSTART   0x4000  /* if I2C_FUNC_PROTOCOL_MANGLING */
2842 #define VKI_I2C_M_REV_DIR_ADDR  0x2000  /* if I2C_FUNC_PROTOCOL_MANGLING */
2843 #define VKI_I2C_M_IGNORE_NAK    0x1000  /* if I2C_FUNC_PROTOCOL_MANGLING */
2844 #define VKI_I2C_M_NO_RD_ACK 0x0800  /* if I2C_FUNC_PROTOCOL_MANGLING */
2845 #define VKI_I2C_M_RECV_LEN  0x0400  /* length will be first received byte */
2846     __vki_u16 len;      /* msg length               */
2847     __vki_u8 *buf;      /* pointer to msg data          */
2848 };
2849 
2850 struct vki_i2c_rdwr_ioctl_data {
2851     struct vki_i2c_msg *msgs;   /* pointers to i2c_msgs */
2852     __vki_u32 nmsgs;        /* number of i2c_msgs */
2853 };
2854 
2855 //----------------------------------------------------------------------
2856 // From linux-2.6.20.1/include/linux/keyctl.h
2857 //----------------------------------------------------------------------
2858 
2859 /* keyctl commands */
2860 #define VKI_KEYCTL_GET_KEYRING_ID   0   /* ask for a keyring's ID */
2861 #define VKI_KEYCTL_JOIN_SESSION_KEYRING 1   /* join or start named session keyring */
2862 #define VKI_KEYCTL_UPDATE       2   /* update a key */
2863 #define VKI_KEYCTL_REVOKE       3   /* revoke a key */
2864 #define VKI_KEYCTL_CHOWN        4   /* set ownership of a key */
2865 #define VKI_KEYCTL_SETPERM      5   /* set perms on a key */
2866 #define VKI_KEYCTL_DESCRIBE     6   /* describe a key */
2867 #define VKI_KEYCTL_CLEAR        7   /* clear contents of a keyring */
2868 #define VKI_KEYCTL_LINK         8   /* link a key into a keyring */
2869 #define VKI_KEYCTL_UNLINK       9   /* unlink a key from a keyring */
2870 #define VKI_KEYCTL_SEARCH       10  /* search for a key in a keyring */
2871 #define VKI_KEYCTL_READ         11  /* read a key or keyring's contents */
2872 #define VKI_KEYCTL_INSTANTIATE      12  /* instantiate a partially constructed key */
2873 #define VKI_KEYCTL_NEGATE       13  /* negate a partially constructed key */
2874 #define VKI_KEYCTL_SET_REQKEY_KEYRING   14  /* set default request-key keyring */
2875 #define VKI_KEYCTL_SET_TIMEOUT      15  /* set key timeout */
2876 #define VKI_KEYCTL_ASSUME_AUTHORITY 16  /* assume request_key() authorisation */
2877 
2878 /*--------------------------------------------------------------------*/
2879 // From linux-2.6.20.1/include/linux/key.h
2880 /*--------------------------------------------------------------------*/
2881 
2882 /* key handle serial number */
2883 typedef vki_int32_t vki_key_serial_t;
2884 
2885 /* key handle permissions mask */
2886 typedef vki_uint32_t vki_key_perm_t;
2887 
2888 //----------------------------------------------------------------------
2889 // From linux-2.6.24.7/include/linux/wireless.h
2890 // (wireless extensions version 22, 2007-03-16)
2891 //----------------------------------------------------------------------
2892 
2893 /*
2894  * [[Wireless extensions ioctls.]]
2895  */
2896 
2897 /* Wireless Identification */
2898 #define VKI_SIOCSIWCOMMIT   0x8B00  /* Commit pending changes to driver */
2899 #define VKI_SIOCGIWNAME     0x8B01  /* get name == wireless protocol */
2900 
2901 /* Basic operations */
2902 #define VKI_SIOCSIWNWID     0x8B02  /* set network id (pre-802.11) */
2903 #define VKI_SIOCGIWNWID     0x8B03  /* get network id (the cell) */
2904 #define VKI_SIOCSIWFREQ     0x8B04  /* set channel/frequency (Hz) */
2905 #define VKI_SIOCGIWFREQ     0x8B05  /* get channel/frequency (Hz) */
2906 #define VKI_SIOCSIWMODE     0x8B06  /* set operation mode */
2907 #define VKI_SIOCGIWMODE     0x8B07  /* get operation mode */
2908 #define VKI_SIOCSIWSENS     0x8B08  /* set sensitivity (dBm) */
2909 #define VKI_SIOCGIWSENS     0x8B09  /* get sensitivity (dBm) */
2910 
2911 /* Informative stuff */
2912 #define VKI_SIOCSIWRANGE    0x8B0A  /* Unused */
2913 #define VKI_SIOCGIWRANGE    0x8B0B  /* Get range of parameters */
2914 #define VKI_SIOCSIWPRIV     0x8B0C  /* Unused */
2915 #define VKI_SIOCGIWPRIV     0x8B0D  /* get private ioctl interface info */
2916 #define VKI_SIOCSIWSTATS    0x8B0E  /* Unused */
2917 #define VKI_SIOCGIWSTATS    0x8B0F  /* Get /proc/net/wireless stats */
2918 
2919 /* Spy support (statistics per MAC address - used for Mobile IP support) */
2920 #define VKI_SIOCSIWSPY      0x8B10  /* set spy addresses */
2921 #define VKI_SIOCGIWSPY      0x8B11  /* get spy info (quality of link) */
2922 #define VKI_SIOCSIWTHRSPY   0x8B12  /* set spy threshold (spy event) */
2923 #define VKI_SIOCGIWTHRSPY   0x8B13  /* get spy threshold */
2924 
2925 /* Access Point manipulation */
2926 #define VKI_SIOCSIWAP       0x8B14  /* set access point MAC addresses */
2927 #define VKI_SIOCGIWAP       0x8B15  /* get access point MAC addresses */
2928 #define VKI_SIOCGIWAPLIST   0x8B17  /* Deprecated in favor of scanning */
2929 #define VKI_SIOCSIWSCAN         0x8B18  /* trigger scanning (list cells) */
2930 #define VKI_SIOCGIWSCAN         0x8B19  /* get scanning results */
2931 
2932 /* 802.11 specific support */
2933 #define VKI_SIOCSIWESSID    0x8B1A  /* set ESSID (network name) */
2934 #define VKI_SIOCGIWESSID    0x8B1B  /* get ESSID */
2935 #define VKI_SIOCSIWNICKN    0x8B1C  /* set node name/nickname */
2936 #define VKI_SIOCGIWNICKN    0x8B1D  /* get node name/nickname */
2937 
2938 /* Other parameters useful in 802.11 and some other devices */
2939 #define VKI_SIOCSIWRATE     0x8B20  /* set default bit rate (bps) */
2940 #define VKI_SIOCGIWRATE     0x8B21  /* get default bit rate (bps) */
2941 #define VKI_SIOCSIWRTS      0x8B22  /* set RTS/CTS threshold (bytes) */
2942 #define VKI_SIOCGIWRTS      0x8B23  /* get RTS/CTS threshold (bytes) */
2943 #define VKI_SIOCSIWFRAG     0x8B24  /* set fragmentation thr (bytes) */
2944 #define VKI_SIOCGIWFRAG     0x8B25  /* get fragmentation thr (bytes) */
2945 #define VKI_SIOCSIWTXPOW    0x8B26  /* set transmit power (dBm) */
2946 #define VKI_SIOCGIWTXPOW    0x8B27  /* get transmit power (dBm) */
2947 #define VKI_SIOCSIWRETRY    0x8B28  /* set retry limits and lifetime */
2948 #define VKI_SIOCGIWRETRY    0x8B29  /* get retry limits and lifetime */
2949 
2950 /* Encoding stuff (scrambling, hardware security, WEP...) */
2951 #define VKI_SIOCSIWENCODE   0x8B2A  /* set encoding token & mode */
2952 #define VKI_SIOCGIWENCODE   0x8B2B  /* get encoding token & mode */
2953 
2954 /* Power saving stuff (power management, unicast and multicast) */
2955 #define VKI_SIOCSIWPOWER    0x8B2C  /* set Power Management settings */
2956 #define VKI_SIOCGIWPOWER    0x8B2D  /* get Power Management settings */
2957 
2958 /* WPA : Generic IEEE 802.11 information element (e.g., for WPA/RSN/WMM). */
2959 #define VKI_SIOCSIWGENIE    0x8B30      /* set generic IE */
2960 #define VKI_SIOCGIWGENIE    0x8B31      /* get generic IE */
2961 
2962 /* WPA : IEEE 802.11 MLME requests */
2963 #define VKI_SIOCSIWMLME     0x8B16  /* request MLME operation; uses
2964                      * struct iw_mlme */
2965 /* WPA : Authentication mode parameters */
2966 #define VKI_SIOCSIWAUTH     0x8B32  /* set authentication mode params */
2967 #define VKI_SIOCGIWAUTH     0x8B33  /* get authentication mode params */
2968 
2969 /* WPA : Extended version of encoding configuration */
2970 #define VKI_SIOCSIWENCODEEXT    0x8B34  /* set encoding token & mode */
2971 #define VKI_SIOCGIWENCODEEXT    0x8B35  /* get encoding token & mode */
2972 
2973 /* WPA2 : PMKSA cache management */
2974 #define VKI_SIOCSIWPMKSA    0x8B36  /* PMKSA cache operation */
2975 
2976 /*
2977  * [[Payload for the wireless extensions ioctls.]]
2978  */
2979 
2980 struct  vki_iw_param
2981 {
2982   __vki_s32 value;      /* The value of the parameter itself */
2983   __vki_u8  fixed;      /* Hardware should not use auto select */
2984   __vki_u8  disabled;   /* Disable the feature */
2985   __vki_u16 flags;      /* Various specific flags (if any) */
2986 };
2987 
2988 struct  vki_iw_point
2989 {
2990   void __user   *pointer;   /* Pointer to the data  (in user space) */
2991   __vki_u16 length;     /* number of fields or size in bytes */
2992   __vki_u16 flags;      /* Optional params */
2993 };
2994 
2995 struct  vki_iw_freq
2996 {
2997     __vki_s32   m;      /* Mantissa */
2998     __vki_s16   e;      /* Exponent */
2999     __vki_u8    i;      /* List index (when in range struct) */
3000     __vki_u8    flags;      /* Flags (fixed/auto) */
3001 };
3002 
3003 struct  vki_iw_quality
3004 {
3005     __vki_u8    qual;       /* link quality (%retries, SNR,
3006                        %missed beacons or better...) */
3007     __vki_u8    level;      /* signal level (dBm) */
3008     __vki_u8    noise;      /* noise level (dBm) */
3009     __vki_u8    updated;    /* Flags to know if updated */
3010 };
3011 
3012 union   vki_iwreq_data
3013 {
3014     /* Config - generic */
3015     char        name[VKI_IFNAMSIZ];
3016     /* Name : used to verify the presence of  wireless extensions.
3017      * Name of the protocol/provider... */
3018 
3019     struct vki_iw_point essid;  /* Extended network name */
3020     struct vki_iw_param nwid;   /* network id (or domain - the cell) */
3021     struct vki_iw_freq  freq;   /* frequency or channel :
3022                      * 0-1000 = channel
3023                      * > 1000 = frequency in Hz */
3024 
3025     struct vki_iw_param sens;   /* signal level threshold */
3026     struct vki_iw_param bitrate;/* default bit rate */
3027     struct vki_iw_param txpower;/* default transmit power */
3028     struct vki_iw_param rts;    /* RTS threshold threshold */
3029     struct vki_iw_param frag;   /* Fragmentation threshold */
3030     __vki_u32       mode;   /* Operation mode */
3031     struct vki_iw_param retry;  /* Retry limits & lifetime */
3032 
3033     struct vki_iw_point encoding; /* Encoding stuff : tokens */
3034     struct vki_iw_param power;  /* PM duration/timeout */
3035     struct vki_iw_quality   qual;   /* Quality part of statistics */
3036 
3037     struct vki_sockaddr ap_addr;    /* Access point address */
3038     struct vki_sockaddr addr;   /* Destination address (hw/mac) */
3039 
3040     struct vki_iw_param param;  /* Other small parameters */
3041     struct vki_iw_point data;   /* Other large parameters */
3042 };
3043 
3044 struct  vki_iwreq 
3045 {
3046     union
3047     {
3048         char ifrn_name[VKI_IFNAMSIZ];   /* if name, e.g. "eth0" */
3049     } ifr_ifrn;
3050 
3051     /* Data part (defined just above) */
3052     union   vki_iwreq_data  u;
3053 };
3054 
3055 /*--------------------------------------------------------------------*/
3056 // From linux-2.6.31.5/include/linux/perf_event.h
3057 /*--------------------------------------------------------------------*/
3058 
3059 struct vki_perf_event_attr {
3060 
3061     /*
3062      * Major type: hardware/software/tracepoint/etc.
3063      */
3064     __vki_u32           type;
3065 
3066     /*
3067      * Size of the attr structure, for fwd/bwd compat.
3068      */
3069     __vki_u32           size;
3070 
3071     /*
3072      * Type specific configuration information.
3073      */
3074     __vki_u64           config;
3075 
3076     union {
3077         __vki_u64       sample_period;
3078         __vki_u64       sample_freq;
3079     };
3080 
3081     __vki_u64           sample_type;
3082     __vki_u64           read_format;
3083 
3084     __vki_u64           disabled       :  1, /* off by default        */
3085                     inherit        :  1, /* children inherit it   */
3086                     pinned         :  1, /* must always be on PMU */
3087                     exclusive      :  1, /* only group on PMU     */
3088                     exclude_user   :  1, /* don't count user      */
3089                     exclude_kernel :  1, /* ditto kernel          */
3090                     exclude_hv     :  1, /* ditto hypervisor      */
3091                     exclude_idle   :  1, /* don't count when idle */
3092                     mmap           :  1, /* include mmap data     */
3093                     comm           :  1, /* include comm data     */
3094                     freq           :  1, /* use freq, not period  */
3095                     inherit_stat   :  1, /* per task counts       */
3096                     enable_on_exec :  1, /* next exec enables     */
3097                     task           :  1, /* trace fork/exit       */
3098                     watermark      :  1, /* wakeup_watermark      */
3099                     /*
3100                      * precise_ip:
3101                      *
3102                      *  0 - SAMPLE_IP can have arbitrary skid
3103                      *  1 - SAMPLE_IP must have constant skid
3104                      *  2 - SAMPLE_IP requested to have 0 skid
3105                      *  3 - SAMPLE_IP must have 0 skid
3106                      *
3107                      *  See also PERF_RECORD_MISC_EXACT_IP
3108                      */
3109                     precise_ip     :  2, /* skid constraint       */
3110                     mmap_data      :  1, /* non-exec mmap data    */
3111                     sample_id_all  :  1, /* sample_type all events */
3112 
3113                     __reserved_1   : 45;
3114 
3115     union {
3116         __vki_u32       wakeup_events;    /* wakeup every n events */
3117         __vki_u32       wakeup_watermark; /* bytes before wakeup   */
3118     };
3119 
3120     __vki_u32           bp_type;
3121     union {
3122         __vki_u64       bp_addr;
3123         __vki_u64       config1; /* extension of config */
3124     };
3125     union {
3126         __vki_u64       bp_len;
3127         __vki_u64       config2; /* extension of config1 */
3128     };
3129 };
3130 
3131 #define VKI_PERF_EVENT_IOC_ENABLE       _VKI_IO ('$', 0)
3132 #define VKI_PERF_EVENT_IOC_DISABLE      _VKI_IO ('$', 1)
3133 #define VKI_PERF_EVENT_IOC_REFRESH      _VKI_IO ('$', 2)
3134 #define VKI_PERF_EVENT_IOC_RESET        _VKI_IO ('$', 3)
3135 #define VKI_PERF_EVENT_IOC_PERIOD       _VKI_IOW('$', 4, __vki_u64)
3136 #define VKI_PERF_EVENT_IOC_SET_OUTPUT   _VKI_IO ('$', 5)
3137 #define VKI_PERF_EVENT_IOC_SET_FILTER   _VKI_IOW('$', 6, char *)
3138 #define VKI_PERF_EVENT_IOC_ID           _VKI_IOR('$', 7, __vki_u64 *)
3139 #define VKI_PERF_EVENT_IOC_SET_BPF      _VKI_IOW('$', 8, __vki_u32)
3140 
3141 /*--------------------------------------------------------------------*/
3142 // From linux-2.6.32.4/include/linux/getcpu.h
3143 /*--------------------------------------------------------------------*/
3144 
3145 struct vki_getcpu_cache {
3146     unsigned long blob[128 / sizeof(long)];
3147 };
3148 
3149 //----------------------------------------------------------------------
3150 // From linux-2.6.33.3/include/linux/input.h
3151 //----------------------------------------------------------------------
3152 
3153 /*
3154  * IOCTLs (0x00 - 0x7f)
3155  */
3156 
3157 #define VKI_EVIOCGNAME(len) _VKI_IOC(_VKI_IOC_READ, 'E', 0x06, len)     /* get device name */
3158 #define VKI_EVIOCGPHYS(len) _VKI_IOC(_VKI_IOC_READ, 'E', 0x07, len)     /* get physical location */
3159 #define VKI_EVIOCGUNIQ(len) _VKI_IOC(_VKI_IOC_READ, 'E', 0x08, len)     /* get unique identifier */
3160 
3161 #define VKI_EVIOCGKEY(len)  _VKI_IOC(_VKI_IOC_READ, 'E', 0x18, len)     /* get global keystate */
3162 #define VKI_EVIOCGLED(len)  _VKI_IOC(_VKI_IOC_READ, 'E', 0x19, len)     /* get all LEDs */
3163 #define VKI_EVIOCGSND(len)  _VKI_IOC(_VKI_IOC_READ, 'E', 0x1a, len)     /* get all sounds status */
3164 #define VKI_EVIOCGSW(len)   _VKI_IOC(_VKI_IOC_READ, 'E', 0x1b, len)     /* get all switch states */
3165 
3166 #define VKI_EVIOCGBIT(ev,len)   _VKI_IOC(_VKI_IOC_READ, 'E', 0x20 + ev, len)    /* get event bits */
3167 
3168 /*
3169  * Event types
3170  */
3171 
3172 #define VKI_EV_SYN      0x00
3173 #define VKI_EV_KEY      0x01
3174 #define VKI_EV_REL      0x02
3175 #define VKI_EV_ABS      0x03
3176 #define VKI_EV_MSC      0x04
3177 #define VKI_EV_SW       0x05
3178 #define VKI_EV_LED      0x11
3179 #define VKI_EV_SND      0x12
3180 #define VKI_EV_REP      0x14
3181 #define VKI_EV_FF       0x15
3182 #define VKI_EV_PWR      0x16
3183 #define VKI_EV_FF_STATUS    0x17
3184 #define VKI_EV_MAX      0x1f
3185 #define VKI_EV_CNT      (VKI_EV_MAX+1)
3186 
3187 //----------------------------------------------------------------------
3188 // From linux-2.6.39-rc2/include/asm_generic/ioctls.h
3189 //----------------------------------------------------------------------
3190 
3191 #ifndef VKI_FIOQSIZE
3192 #define VKI_FIOQSIZE 0x5460     /* Value differs on some platforms */
3193 #endif
3194 
3195 #ifndef VKI_TIOCSIG
3196 #define VKI_TIOCSIG _VKI_IOW('T', 0x36, int) /* Value differs on some platforms */
3197 #endif
3198 
3199 //----------------------------------------------------------------------
3200 // From kernel/common/include/linux/ashmem.h
3201 //----------------------------------------------------------------------
3202 
3203 #if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
3204     || defined(VGPV_mips32_linux_android) \
3205     || defined(VGPV_arm64_linux_android)
3206 
3207 #define VKI_ASHMEM_NAME_LEN 256
3208 
3209 #define VKI_ASHMEM_NAME_DEF "dev/ashmem"
3210 
3211 #define VKI_ASHMEM_NOT_PURGED 0
3212 #define VKI_ASHMEM_WAS_PURGED 1
3213 
3214 #define VKI_ASHMEM_IS_UNPINNED 0
3215 #define VKI_ASHMEM_IS_PINNED 1
3216 
3217 struct vki_ashmem_pin {
3218    vki_uint32_t offset;
3219    vki_uint32_t len;
3220 };
3221 
3222 #define __VKI_ASHMEMIOC 0x77
3223 
3224 #define VKI_ASHMEM_SET_NAME _VKI_IOW(__VKI_ASHMEMIOC, 1, char[VKI_ASHMEM_NAME_LEN])
3225 #define VKI_ASHMEM_GET_NAME _VKI_IOR(__VKI_ASHMEMIOC, 2, char[VKI_ASHMEM_NAME_LEN])
3226 #define VKI_ASHMEM_SET_SIZE _VKI_IOW(__VKI_ASHMEMIOC, 3, vki_size_t)
3227 #define VKI_ASHMEM_GET_SIZE _VKI_IO(__VKI_ASHMEMIOC, 4)
3228 #define VKI_ASHMEM_SET_PROT_MASK _VKI_IOW(__VKI_ASHMEMIOC, 5, unsigned long)
3229 #define VKI_ASHMEM_GET_PROT_MASK _VKI_IO(__VKI_ASHMEMIOC, 6)
3230 #define VKI_ASHMEM_PIN _VKI_IOW(__VKI_ASHMEMIOC, 7, struct vki_ashmem_pin)
3231 #define VKI_ASHMEM_UNPIN _VKI_IOW(__VKI_ASHMEMIOC, 8, struct vki_ashmem_pin)
3232 #define VKI_ASHMEM_GET_PIN_STATUS _VKI_IO(__VKI_ASHMEMIOC, 9)
3233 #define VKI_ASHMEM_PURGE_ALL_CACHES _VKI_IO(__VKI_ASHMEMIOC, 10)
3234 
3235 //----------------------------------------------------------------------
3236 // From kernel/common/include/linux/binder.h
3237 //----------------------------------------------------------------------
3238 
3239 struct vki_binder_write_read {
3240  signed long write_size;
3241  signed long write_consumed;
3242  unsigned long write_buffer;
3243  signed long read_size;
3244  signed long read_consumed;
3245  unsigned long read_buffer;
3246 };
3247 
3248 struct vki_binder_version {
3249  signed long protocol_version;
3250 };
3251 
3252 #define VKI_BINDER_WRITE_READ _VKI_IOWR('b', 1, struct vki_binder_write_read)
3253 #define VKI_BINDER_SET_IDLE_TIMEOUT _VKI_IOW('b', 3, vki_int64_t)
3254 #define VKI_BINDER_SET_MAX_THREADS _VKI_IOW('b', 5, vki_size_t)
3255 #define VKI_BINDER_SET_IDLE_PRIORITY _VKI_IOW('b', 6, int)
3256 #define VKI_BINDER_SET_CONTEXT_MGR _VKI_IOW('b', 7, int)
3257 #define VKI_BINDER_THREAD_EXIT _VKI_IOW('b', 8, int)
3258 #define VKI_BINDER_VERSION _VKI_IOWR('b', 9, struct vki_binder_version)
3259 
3260 #endif /* defined(VGPV_*_linux_android) */
3261 
3262 //----------------------------------------------------------------------
3263 // From linux-3.0.4/include/net/bluetooth/bluetooth.h
3264 //----------------------------------------------------------------------
3265 
3266 typedef struct {
3267    __vki_u8 b[6];
3268 } __vki_packed vki_bdaddr_t;
3269 
3270 //----------------------------------------------------------------------
3271 // From linux-3.0.4/include/net/bluetooth/hci.h
3272 //----------------------------------------------------------------------
3273 
3274 #define VKI_HCIDEVUP        _VKI_IOW('H', 201, int)
3275 #define VKI_HCIDEVDOWN      _VKI_IOW('H', 202, int)
3276 #define VKI_HCIDEVRESET     _VKI_IOW('H', 203, int)
3277 #define VKI_HCIDEVRESTAT    _VKI_IOW('H', 204, int)
3278 
3279 #define VKI_HCIGETDEVLIST   _VKI_IOR('H', 210, int)
3280 
3281 struct vki_hci_dev_req {
3282     __vki_u16  dev_id;
3283     __vki_u32  dev_opt;
3284 };
3285 
3286 struct vki_hci_dev_list_req {
3287     __vki_u16  dev_num;
3288     struct vki_hci_dev_req dev_req[0];  /* hci_dev_req structures */
3289 };
3290 
3291 #define VKI_HCIGETDEVINFO   _VKI_IOR('H', 211, int)
3292 #define VKI_HCIGETCONNLIST  _VKI_IOR('H', 212, int)
3293 #define VKI_HCIGETCONNINFO  _VKI_IOR('H', 213, int)
3294 #define VKI_HCIGETAUTHINFO  _VKI_IOR('H', 215, int)
3295 
3296 #define VKI_HCISETRAW       _VKI_IOW('H', 220, int)
3297 #define VKI_HCISETSCAN      _VKI_IOW('H', 221, int)
3298 #define VKI_HCISETAUTH      _VKI_IOW('H', 222, int)
3299 #define VKI_HCISETENCRYPT   _VKI_IOW('H', 223, int)
3300 #define VKI_HCISETPTYPE     _VKI_IOW('H', 224, int)
3301 #define VKI_HCISETLINKPOL   _VKI_IOW('H', 225, int)
3302 #define VKI_HCISETLINKMODE  _VKI_IOW('H', 226, int)
3303 #define VKI_HCISETACLMTU    _VKI_IOW('H', 227, int)
3304 #define VKI_HCISETSCOMTU    _VKI_IOW('H', 228, int)
3305 
3306 #define VKI_HCIBLOCKADDR    _VKI_IOW('H', 230, int)
3307 #define VKI_HCIUNBLOCKADDR  _VKI_IOW('H', 231, int)
3308 
3309 #define VKI_HCIINQUIRY      _VKI_IOR('H', 240, int)
3310 
3311 struct vki_inquiry_info {
3312    vki_bdaddr_t bdaddr;
3313    __vki_u8     pscan_rep_mode;
3314    __vki_u8     pscan_period_mode;
3315    __vki_u8     pscan_mode;
3316    __vki_u8     dev_class[3];
3317    __vki_le16   clock_offset;
3318 } __vki_packed;
3319 
3320 struct vki_hci_inquiry_req {
3321    __vki_u16 dev_id;
3322    __vki_u16 flags;
3323    __vki_u8  lap[3];
3324    __vki_u8  length;
3325    __vki_u8  num_rsp;
3326 };
3327 
3328 //----------------------------------------------------------------------
3329 // From linux-3.9.2/include/net/bluetooth/rfcomm.h
3330 //----------------------------------------------------------------------
3331 
3332 struct vki_sockaddr_rc {
3333         vki_sa_family_t     rc_family;
3334         vki_bdaddr_t        rc_bdaddr;
3335         __vki_u8            rc_channel;
3336 };
3337 
3338 //----------------------------------------------------------------------
3339 // From linux-3.4/include/linux/kvm.h
3340 //----------------------------------------------------------------------
3341 #define KVMIO 0xAE
3342 
3343 #define VKI_KVM_GET_API_VERSION       _VKI_IO(KVMIO,   0x00)
3344 #define VKI_KVM_CREATE_VM             _VKI_IO(KVMIO,   0x01) /* returns a VM fd */
3345 #define VKI_KVM_CHECK_EXTENSION       _VKI_IO(KVMIO,   0x03)
3346 #define VKI_KVM_GET_VCPU_MMAP_SIZE    _VKI_IO(KVMIO,   0x04) /* in bytes */
3347 #define VKI_KVM_S390_ENABLE_SIE       _VKI_IO(KVMIO,   0x06)
3348 #define VKI_KVM_CREATE_VCPU           _VKI_IO(KVMIO,   0x41)
3349 #define VKI_KVM_SET_NR_MMU_PAGES      _VKI_IO(KVMIO,   0x44)
3350 #define VKI_KVM_GET_NR_MMU_PAGES      _VKI_IO(KVMIO,   0x45)
3351 #define VKI_KVM_SET_TSS_ADDR          _VKI_IO(KVMIO,   0x47)
3352 #define VKI_KVM_CREATE_IRQCHIP        _VKI_IO(KVMIO,   0x60)
3353 #define VKI_KVM_CREATE_PIT            _VKI_IO(KVMIO,   0x64)
3354 #define VKI_KVM_REINJECT_CONTROL      _VKI_IO(KVMIO,   0x71)
3355 #define VKI_KVM_SET_BOOT_CPU_ID       _VKI_IO(KVMIO,   0x78)
3356 #define VKI_KVM_SET_TSC_KHZ           _VKI_IO(KVMIO,  0xa2)
3357 #define VKI_KVM_GET_TSC_KHZ           _VKI_IO(KVMIO,  0xa3)
3358 #define VKI_KVM_RUN                   _VKI_IO(KVMIO,   0x80)
3359 #define VKI_KVM_S390_INITIAL_RESET    _VKI_IO(KVMIO,   0x97)
3360 #define VKI_KVM_NMI                   _VKI_IO(KVMIO,   0x9a)
3361 #define VKI_KVM_KVMCLOCK_CTRL         _VKI_IO(KVMIO,   0xad)
3362 
3363 struct vki_kvm_s390_mem_op {
3364         /* in */
3365         __vki_u64 gaddr;            /* the guest address */
3366         __vki_u64 flags;            /* flags */
3367         __vki_u32 size;             /* amount of bytes */
3368         __vki_u32 op;               /* type of operation */
3369         __vki_u64 buf;              /* buffer in userspace */
3370         __vki_u8 ar;                /* the access register number */
3371         __vki_u8 reserved[31];      /* should be set to 0 */
3372 };
3373 
3374 #define VKI_KVM_S390_MEMOP_LOGICAL_READ     0
3375 #define VKI_KVM_S390_MEMOP_LOGICAL_WRITE    1
3376 #define VKI_KVM_S390_MEMOP_F_CHECK_ONLY     (1ULL << 0)
3377 #define VKI_KVM_S390_MEMOP_F_INJECT_EXCEPTION   (1ULL << 1)
3378 
3379 #define VKI_KVM_S390_MEM_OP           _VKI_IOW(KVMIO,  0xb1, struct vki_kvm_s390_mem_op)
3380 
3381 //----------------------------------------------------------------------
3382 // From linux-2.6/include/linux/net_stamp.h
3383 //----------------------------------------------------------------------
3384 
3385 struct vki_hwtstamp_config {
3386     int flags;
3387     int tx_type;
3388     int rx_filter;
3389 };
3390 
3391 //----------------------------------------------------------------------
3392 // From linux-2.6.12-rc2/include/linux/uinput.h
3393 //----------------------------------------------------------------------
3394 
3395 #define VKI_UINPUT_IOCTL_BASE       'U'
3396 #define VKI_UI_DEV_CREATE       _VKI_IO(VKI_UINPUT_IOCTL_BASE, 1)
3397 #define VKI_UI_DEV_DESTROY      _VKI_IO(VKI_UINPUT_IOCTL_BASE, 2)
3398 
3399 #define VKI_UI_SET_EVBIT        _VKI_IOW(VKI_UINPUT_IOCTL_BASE, 100, int)
3400 #define VKI_UI_SET_KEYBIT       _VKI_IOW(VKI_UINPUT_IOCTL_BASE, 101, int)
3401 #define VKI_UI_SET_RELBIT       _VKI_IOW(VKI_UINPUT_IOCTL_BASE, 102, int)
3402 #define VKI_UI_SET_ABSBIT       _VKI_IOW(VKI_UINPUT_IOCTL_BASE, 103, int)
3403 #define VKI_UI_SET_MSCBIT       _VKI_IOW(VKI_UINPUT_IOCTL_BASE, 104, int)
3404 #define VKI_UI_SET_LEDBIT       _VKI_IOW(VKI_UINPUT_IOCTL_BASE, 105, int)
3405 #define VKI_UI_SET_SNDBIT       _VKI_IOW(VKI_UINPUT_IOCTL_BASE, 106, int)
3406 #define VKI_UI_SET_FFBIT        _VKI_IOW(VKI_UINPUT_IOCTL_BASE, 107, int)
3407 #define VKI_UI_SET_SWBIT        _VKI_IOW(VKI_UINPUT_IOCTL_BASE, 109, int)
3408 #define VKI_UI_SET_PROPBIT      _VKI_IOW(VKI_UINPUT_IOCTL_BASE, 110, int)
3409 
3410 //----------------------------------------------------------------------
3411 // From linux-2.6/include/uapi/rdma/ib_user_mad.h
3412 //----------------------------------------------------------------------
3413 
3414 #define VKI_IB_IOCTL_MAGIC          0x1b
3415 
3416 #define VKI_IB_USER_MAD_REGISTER_AGENT    _VKI_IOWR(VKI_IB_IOCTL_MAGIC, 1, \
3417                                               struct ib_user_mad_reg_req)
3418 
3419 #define VKI_IB_USER_MAD_UNREGISTER_AGENT  _VKI_IOW(VKI_IB_IOCTL_MAGIC, 2, __u32)
3420 
3421 #define VKI_IB_USER_MAD_ENABLE_PKEY       _VKI_IO(VKI_IB_IOCTL_MAGIC, 3)
3422 
3423 //----------------------------------------------------------------------
3424 // From linux-3.8/include/uapi/linux/if_tun.h
3425 //----------------------------------------------------------------------
3426 
3427 #define VKI_TUNSETNOCSUM  _VKI_IOW('T', 200, int) 
3428 #define VKI_TUNSETDEBUG   _VKI_IOW('T', 201, int) 
3429 #define VKI_TUNSETIFF     _VKI_IOW('T', 202, int) 
3430 #define VKI_TUNSETPERSIST _VKI_IOW('T', 203, int) 
3431 #define VKI_TUNSETOWNER   _VKI_IOW('T', 204, int)
3432 #define VKI_TUNSETLINK    _VKI_IOW('T', 205, int)
3433 #define VKI_TUNSETGROUP   _VKI_IOW('T', 206, int)
3434 #define VKI_TUNGETFEATURES _VKI_IOR('T', 207, unsigned int)
3435 #define VKI_TUNSETOFFLOAD  _VKI_IOW('T', 208, unsigned int)
3436 #define VKI_TUNSETTXFILTER _VKI_IOW('T', 209, unsigned int)
3437 #define VKI_TUNGETIFF      _VKI_IOR('T', 210, unsigned int)
3438 #define VKI_TUNGETSNDBUF   _VKI_IOR('T', 211, int)
3439 #define VKI_TUNSETSNDBUF   _VKI_IOW('T', 212, int)
3440 //#define VKI_TUNATTACHFILTER _VKI_IOW('T', 213, struct sock_fprog)
3441 //#define VKI_TUNDETACHFILTER _VKI_IOW('T', 214, struct sock_fprog)
3442 #define VKI_TUNGETVNETHDRSZ _VKI_IOR('T', 215, int)
3443 #define VKI_TUNSETVNETHDRSZ _VKI_IOW('T', 216, int)
3444 #define VKI_TUNSETQUEUE  _VKI_IOW('T', 217, int)
3445 #define VKI_TUNSETIFINDEX   _VKI_IOW('T', 218, unsigned int)
3446 //#define VKI_TUNGETFILTER _VKI_IOR('T', 219, struct sock_fprog)
3447 
3448 //----------------------------------------------------------------------
3449 // From linux-3.8/include/uapi/linux/vhost.h
3450 //----------------------------------------------------------------------
3451 
3452 #define VKI_VHOST_VIRTIO 0xAF
3453 #define VKI_VHOST_SET_OWNER _VKI_IO(VKI_VHOST_VIRTIO, 0x01)
3454 #define VKI_VHOST_RESET_OWNER _VKI_IO(VKI_VHOST_VIRTIO, 0x02)
3455 
3456 //----------------------------------------------------------------------
3457 // Xen privcmd IOCTL
3458 //----------------------------------------------------------------------
3459 
3460 typedef unsigned long __vki_xen_pfn_t;
3461 
3462 struct vki_xen_privcmd_hypercall {
3463        __vki_u64 op;
3464        __vki_u64 arg[5];
3465 };
3466 
3467 struct vki_xen_privcmd_mmap_entry {
3468         __vki_u64 va;
3469         __vki_u64 mfn;
3470         __vki_u64 npages;
3471 };
3472 
3473 struct vki_xen_privcmd_mmap {
3474         int num;
3475         __vki_u16 dom; /* target domain */
3476         struct vki_xen_privcmd_mmap_entry *entry;
3477 };
3478 
3479 struct vki_xen_privcmd_mmapbatch {
3480         int num;     /* number of pages to populate */
3481         __vki_u16 dom; /* target domain */
3482         __vki_u64 addr;  /* virtual address */
3483         __vki_xen_pfn_t *arr; /* array of mfns - top nibble set on err */
3484 };
3485 
3486 struct vki_xen_privcmd_mmapbatch_v2 {
3487         unsigned int num; /* number of pages to populate */
3488         __vki_u16 dom;      /* target domain */
3489         __vki_u64 addr;       /* virtual address */
3490         const __vki_xen_pfn_t *arr; /* array of mfns */
3491         int __user *err;  /* array of error codes */
3492 };
3493 
3494 #define VKI_XEN_IOCTL_PRIVCMD_HYPERCALL    _VKI_IOC(_VKI_IOC_NONE, 'P', 0, sizeof(struct vki_xen_privcmd_hypercall))
3495 #define VKI_XEN_IOCTL_PRIVCMD_MMAP         _VKI_IOC(_VKI_IOC_NONE, 'P', 2, sizeof(struct vki_xen_privcmd_mmap))
3496 
3497 #define VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH    _VKI_IOC(_VKI_IOC_NONE, 'P', 3, sizeof(struct vki_xen_privcmd_mmapbatch))
3498 #define VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2 _VKI_IOC(_VKI_IOC_NONE, 'P', 4, sizeof(struct vki_xen_privcmd_mmapbatch_v2))
3499 
3500 //----------------------------------------------------------------------
3501 // Xen evtchn IOCTL
3502 //----------------------------------------------------------------------
3503 
3504 #define VKI_XEN_IOCTL_EVTCHN_BIND_VIRQ              \
3505     _VKI_IOC(_VKI_IOC_NONE, 'E', 0, sizeof(struct vki_xen_ioctl_evtchn_bind_virq))
3506 struct vki_xen_ioctl_evtchn_bind_virq {
3507     vki_uint32_t virq;
3508 };
3509 
3510 #define VKI_XEN_IOCTL_EVTCHN_BIND_INTERDOMAIN           \
3511     _VKI_IOC(_VKI_IOC_NONE, 'E', 1, sizeof(struct vki_xen_ioctl_evtchn_bind_interdomain))
3512 struct vki_xen_ioctl_evtchn_bind_interdomain {
3513     vki_uint32_t remote_domain;
3514     vki_uint32_t remote_port;
3515 };
3516 
3517 #define VKI_XEN_IOCTL_EVTCHN_BIND_UNBOUND_PORT          \
3518     _VKI_IOC(_VKI_IOC_NONE, 'E', 2, sizeof(struct vki_xen_ioctl_evtchn_bind_unbound_port))
3519 struct vki_xen_ioctl_evtchn_bind_unbound_port {
3520     vki_uint32_t remote_domain;
3521 };
3522 
3523 #define VKI_XEN_IOCTL_EVTCHN_UNBIND             \
3524     _VKI_IOC(_VKI_IOC_NONE, 'E', 3, sizeof(struct vki_xen_ioctl_evtchn_unbind))
3525 struct vki_xen_ioctl_evtchn_unbind {
3526     vki_uint32_t port;
3527 };
3528 
3529 #define VKI_XEN_IOCTL_EVTCHN_NOTIFY             \
3530     _VKI_IOC(_VKI_IOC_NONE, 'E', 4, sizeof(struct vki_xen_ioctl_evtchn_notify))
3531 struct vki_xen_ioctl_evtchn_notify {
3532     vki_uint32_t port;
3533 };
3534 
3535 #define VKI_XEN_IOCTL_EVTCHN_RESET              \
3536     _VKI_IOC(_VKI_IOC_NONE, 'E', 5, 0)
3537 
3538 
3539 //----------------------------------------------------------------------
3540 // From linux-3.4.0/include/linux/fs.h
3541 //----------------------------------------------------------------------
3542 
3543 struct vki_file_handle {
3544    __vki_u32 handle_bytes;
3545    int handle_type;
3546    /* file identifier */
3547    unsigned char f_handle[0];
3548 };
3549 
3550 //----------------------------------------------------------------------
3551 // From linux-3.2.0/include/linux/filter.h
3552 //----------------------------------------------------------------------
3553 
3554 struct vki_sock_filter {
3555     __vki_u16 code; /* Actual filter code */
3556     __vki_u8 jt;    /* Jump true */
3557     __vki_u8 jf;    /* Jump false */
3558     __vki_u32 k;    /* Generic multiuse field */
3559 };
3560 
3561 struct vki_sock_fprog {
3562     __vki_u16 len;  /* actually unsigned short */
3563     struct vki_sock_filter *filter;
3564 };
3565    
3566 //----------------------------------------------------------------------
3567 // From linux/include/uapi/linux/ethtool.h
3568 //----------------------------------------------------------------------
3569 
3570 struct vki_ethtool_cmd {
3571     __vki_u32   cmd;
3572     __vki_u32   supported;
3573     __vki_u32   advertising;
3574     __vki_u16   speed;
3575     __vki_u8    duplex;
3576     __vki_u8    port;
3577     __vki_u8    phy_address;
3578     __vki_u8    transceiver;
3579     __vki_u8    autoneg;
3580     __vki_u8    mdio_support;
3581     __vki_u32   maxtxpkt;
3582     __vki_u32   maxrxpkt;
3583     __vki_u16   speed_hi;
3584     __vki_u8    eth_tp_mdix;
3585     __vki_u8    eth_tp_mdix_ctrl;
3586     __vki_u32   lp_advertising;
3587     __vki_u32   reserved[2];
3588 };
3589 
3590 #define VKI_ETHTOOL_FWVERS_LEN  32
3591 #define VKI_ETHTOOL_BUSINFO_LEN 32
3592 
3593 struct vki_ethtool_drvinfo {
3594     __vki_u32   cmd;
3595     char    driver[32];
3596     char    version[32];
3597     char    fw_version[VKI_ETHTOOL_FWVERS_LEN];
3598     char    bus_info[VKI_ETHTOOL_BUSINFO_LEN];
3599     char    reserved1[32];
3600     char    reserved2[12];
3601     __vki_u32   n_priv_flags;
3602     __vki_u32   n_stats;
3603     __vki_u32   testinfo_len;
3604     __vki_u32   eedump_len;
3605     __vki_u32   regdump_len;
3606 };
3607 
3608 #define VKI_SOPASS_MAX  6
3609 
3610 struct vki_ethtool_wolinfo {
3611     __vki_u32   cmd;
3612     __vki_u32   supported;
3613     __vki_u32   wolopts;
3614     __vki_u8    sopass[VKI_SOPASS_MAX];
3615 };
3616 
3617 struct vki_ethtool_value {
3618     __vki_u32   cmd;
3619     __vki_u32   data;
3620 };
3621 
3622 struct vki_ethtool_regs {
3623     __vki_u32   cmd;
3624     __vki_u32   version;
3625     __vki_u32   len;
3626     __vki_u8    data[0];
3627 };
3628 
3629 struct vki_ethtool_ringparam {
3630     __vki_u32   cmd;
3631     __vki_u32   rx_max_pending;
3632     __vki_u32   rx_mini_max_pending;
3633     __vki_u32   rx_jumbo_max_pending;
3634     __vki_u32   tx_max_pending;
3635     __vki_u32   rx_pending;
3636     __vki_u32   rx_mini_pending;
3637     __vki_u32   rx_jumbo_pending;
3638     __vki_u32   tx_pending;
3639 };
3640 
3641 struct vki_ethtool_channels {
3642     __vki_u32   cmd;
3643     __vki_u32   max_rx;
3644     __vki_u32   max_tx;
3645     __vki_u32   max_other;
3646     __vki_u32   max_combined;
3647     __vki_u32   rx_count;
3648     __vki_u32   tx_count;
3649     __vki_u32   other_count;
3650     __vki_u32   combined_count;
3651 };
3652 
3653 struct vki_ethtool_sset_info {
3654     __vki_u32   cmd;
3655     __vki_u32   reserved;
3656     __vki_u64   sset_mask;
3657     __vki_u32   data[0];
3658 };
3659 
3660 struct vki_ethtool_test {
3661     __vki_u32   cmd;
3662     __vki_u32   flags;
3663     __vki_u32   reserved;
3664     __vki_u32   len;
3665     __vki_u64   data[0];
3666 };
3667 
3668 struct vki_ethtool_perm_addr {
3669     __vki_u32   cmd;
3670     __vki_u32   size;
3671     __vki_u8    data[0];
3672 };
3673 
3674 struct vki_ethtool_get_features_block {
3675     __vki_u32   available;
3676     __vki_u32   requested;
3677     __vki_u32   active;
3678     __vki_u32   never_changed;
3679 };
3680 
3681 struct vki_ethtool_gfeatures {
3682     __vki_u32   cmd;
3683     __vki_u32   size;
3684     struct vki_ethtool_get_features_block features[0];
3685 };
3686 
3687 struct vki_ethtool_set_features_block {
3688     __vki_u32   valid;
3689     __vki_u32   requested;
3690 };
3691 
3692 struct vki_ethtool_sfeatures {
3693     __vki_u32   cmd;
3694     __vki_u32   size;
3695     struct vki_ethtool_set_features_block features[0];
3696 };
3697 
3698 struct vki_ethtool_ts_info {
3699     __vki_u32   cmd;
3700     __vki_u32   so_timestamping;
3701     __vki_s32   phc_index;
3702     __vki_u32   tx_types;
3703     __vki_u32   tx_reserved[3];
3704     __vki_u32   rx_filters;
3705     __vki_u32   rx_reserved[3];
3706 };
3707 
3708 #define VKI_ETHTOOL_GSET    0x00000001 /* Get settings. */
3709 #define VKI_ETHTOOL_SSET    0x00000002 /* Set settings. */
3710 #define VKI_ETHTOOL_GDRVINFO    0x00000003 /* Get driver info. */
3711 #define VKI_ETHTOOL_GREGS   0x00000004 /* Get NIC registers. */
3712 #define VKI_ETHTOOL_GWOL    0x00000005 /* Get wake-on-lan options. */
3713 #define VKI_ETHTOOL_SWOL    0x00000006 /* Set wake-on-lan options. */
3714 #define VKI_ETHTOOL_GMSGLVL 0x00000007 /* Get driver message level */
3715 #define VKI_ETHTOOL_SMSGLVL 0x00000008 /* Set driver msg level. */
3716 #define VKI_ETHTOOL_NWAY_RST    0x00000009 /* Restart autonegotiation. */
3717 #define VKI_ETHTOOL_GLINK   0x0000000a
3718 #define VKI_ETHTOOL_GRINGPARAM  0x00000010 /* Get ring parameters */
3719 #define VKI_ETHTOOL_SRINGPARAM  0x00000011 /* Set ring parameters. */
3720 #define VKI_ETHTOOL_GRXCSUM 0x00000014 /* Get RX hw csum enable (ethtool_value) */
3721 #define VKI_ETHTOOL_SRXCSUM 0x00000015 /* Set RX hw csum enable (ethtool_value) */
3722 #define VKI_ETHTOOL_GTXCSUM 0x00000016 /* Get TX hw csum enable (ethtool_value) */
3723 #define VKI_ETHTOOL_STXCSUM 0x00000017 /* Set TX hw csum enable (ethtool_value) */
3724 #define VKI_ETHTOOL_GSG     0x00000018 /* Get scatter-gather enable
3725                         * (ethtool_value) */
3726 #define VKI_ETHTOOL_SSG     0x00000019 /* Set scatter-gather enable
3727                         * (ethtool_value). */
3728 #define VKI_ETHTOOL_TEST    0x0000001a /* execute NIC self-test. */
3729 #define VKI_ETHTOOL_PHYS_ID 0x0000001c /* identify the NIC */
3730 #define VKI_ETHTOOL_GTSO    0x0000001e /* Get TSO enable (ethtool_value) */
3731 #define VKI_ETHTOOL_STSO    0x0000001f /* Set TSO enable (ethtool_value) */
3732 #define VKI_ETHTOOL_GPERMADDR   0x00000020 /* Get permanent hardware address */
3733 #define VKI_ETHTOOL_GUFO    0x00000021 /* Get UFO enable (ethtool_value) */
3734 #define VKI_ETHTOOL_SUFO    0x00000022 /* Set UFO enable (ethtool_value) */
3735 #define VKI_ETHTOOL_GGSO    0x00000023 /* Get GSO enable (ethtool_value) */
3736 #define VKI_ETHTOOL_SGSO    0x00000024 /* Set GSO enable (ethtool_value) */
3737 #define VKI_ETHTOOL_GFLAGS  0x00000025 /* Get flags bitmap(ethtool_value) */
3738 #define VKI_ETHTOOL_SFLAGS  0x00000026 /* Set flags bitmap(ethtool_value) */
3739 #define VKI_ETHTOOL_GGRO    0x0000002b /* Get GRO enable (ethtool_value) */
3740 #define VKI_ETHTOOL_SGRO    0x0000002c /* Set GRO enable (ethtool_value) */
3741 #define VKI_ETHTOOL_RESET   0x00000034 /* Reset hardware */
3742 #define VKI_ETHTOOL_GSSET_INFO  0x00000037 /* Get string set info */
3743 #define VKI_ETHTOOL_GFEATURES   0x0000003a /* Get device offload settings */
3744 #define VKI_ETHTOOL_SFEATURES   0x0000003b /* Change device offload settings */
3745 #define VKI_ETHTOOL_GCHANNELS   0x0000003c /* Get no of channels */
3746 #define VKI_ETHTOOL_SCHANNELS   0x0000003d /* Set no of channels */
3747 #define VKI_ETHTOOL_GET_TS_INFO 0x00000041 /* Get time stamping and PHC info */
3748 
3749 //----------------------------------------------------------------------
3750 // From linux-3.15.8/drivers/staging/android/uapi/ion.h
3751 //----------------------------------------------------------------------
3752 
3753 typedef int vki_ion_user_handle_t;
3754 
3755 struct vki_ion_allocation_data {
3756         vki_size_t len;
3757         vki_size_t align;
3758         unsigned int heap_id_mask;
3759         unsigned int flags;
3760         vki_ion_user_handle_t handle;
3761 };
3762 
3763 struct vki_ion_fd_data {
3764         vki_ion_user_handle_t handle;
3765         int fd;
3766 };
3767 
3768 struct vki_ion_handle_data {
3769         vki_ion_user_handle_t handle;
3770 };
3771 
3772 struct vki_ion_custom_data {
3773         unsigned int cmd;
3774         unsigned long arg;
3775 };
3776 
3777 #define VKI_ION_IOC_MAGIC   'I'
3778 
3779 #define VKI_ION_IOC_ALLOC \
3780    _VKI_IOWR(VKI_ION_IOC_MAGIC, 0, struct vki_ion_allocation_data)
3781 
3782 #define VKI_ION_IOC_FREE \
3783    _VKI_IOWR(VKI_ION_IOC_MAGIC, 1, struct vki_ion_handle_data)
3784 
3785 #define VKI_ION_IOC_MAP \
3786    _VKI_IOWR(VKI_ION_IOC_MAGIC, 2, struct vki_ion_fd_data)
3787 
3788 #define VKI_ION_IOC_SHARE \
3789    _VKI_IOWR(VKI_ION_IOC_MAGIC, 4, struct vki_ion_fd_data)
3790 
3791 #define VKI_ION_IOC_IMPORT \
3792    _VKI_IOWR(VKI_ION_IOC_MAGIC, 5, struct vki_ion_fd_data)
3793 
3794 #define VKI_ION_IOC_SYNC \
3795    _VKI_IOWR(VKI_ION_IOC_MAGIC, 7, struct vki_ion_fd_data)
3796 
3797 #define VKI_ION_IOC_CUSTOM \
3798    _VKI_IOWR(VKI_ION_IOC_MAGIC, 6, struct vki_ion_custom_data)
3799 
3800 //----------------------------------------------------------------------
3801 // From linux-3.19-rc5/drivers/staging/android/uapi/sync.h
3802 //----------------------------------------------------------------------
3803 
3804 struct vki_sync_merge_data {
3805         __vki_s32 fd2;
3806         char      name[32];
3807         __vki_s32 fence;
3808 };
3809 
3810 struct vki_sync_pt_info {
3811         __vki_u32 len;
3812         char      obj_name[32];
3813         char      driver_name[32];
3814         __vki_s32 status;
3815         __vki_u64 timestamp_ns;
3816         __vki_u8  driver_data[0];
3817 };
3818 
3819 struct vki_sync_fence_info_data {
3820         __vki_u32 len;
3821         char      name[32];
3822         __vki_s32 status;
3823         __vki_u8  pt_info[0];
3824 };
3825 
3826 #define VKI_SYNC_IOC_MAGIC   '>'
3827 
3828 #define VKI_SYNC_IOC_WAIT \
3829    _VKI_IOW(VKI_SYNC_IOC_MAGIC, 0, __vki_s32)
3830 
3831 #define VKI_SYNC_IOC_MERGE \
3832    _VKI_IOWR(VKI_SYNC_IOC_MAGIC, 1, struct vki_sync_merge_data)
3833 
3834 #define VKI_SYNC_IOC_FENCE_INFO \
3835    _VKI_IOWR(VKI_SYNC_IOC_MAGIC, 2, struct vki_sync_fence_info_data)
3836 
3837 //----------------------------------------------------------------------
3838 // From drivers/staging/lustre/lustre/include/lustre/lustre_user.h
3839 //----------------------------------------------------------------------
3840 
3841 struct vki_lu_fid {
3842     __vki_u64   f_seq;
3843     __vki_u32   f_oid;
3844     __vki_u32   f_ver;
3845 };
3846 
3847 //----------------------------------------------------------------------
3848 // From drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
3849 //----------------------------------------------------------------------
3850 
3851 struct vki_getinfo_fid2path {
3852     struct vki_lu_fid   gf_fid;
3853     __vki_u64       gf_recno;
3854     __vki_u32       gf_linkno;
3855     __vki_u32       gf_pathlen;
3856     char            gf_path[0];
3857 } __attribute__((packed));
3858 
3859 //----------------------------------------------------------------------
3860 // From drivers/staging/lustre/lustre/include/linux/lustre_lib.h
3861 //----------------------------------------------------------------------
3862 
3863 #define VKI_OBD_IOC_DATA_TYPE               long
3864 
3865 //----------------------------------------------------------------------
3866 // From drivers/staging/lustre/lustre/include/lustre_lib.h
3867 //----------------------------------------------------------------------
3868 
3869 #define VKI_OBD_IOC_FID2PATH \
3870            _VKI_IOWR ('f', 150, VKI_OBD_IOC_DATA_TYPE)
3871 #define VKI_LL_IOC_PATH2FID \
3872            _VKI_IOR ('f', 173, long)
3873 
3874 //----------------------------------------------------------------------
3875 // From lustre/include/lustre/lustre_idl.h
3876 //----------------------------------------------------------------------
3877 
3878 struct vki_getparent {
3879     struct vki_lu_fid   gp_fid;
3880     __vki_u32       gp_linkno;
3881     __vki_u32       gp_name_size;
3882     char            gp_name[0];
3883 } __attribute__((packed));
3884 
3885 //----------------------------------------------------------------------
3886 // From Lustre's lustre/include/lustre/lustre_user.h
3887 //----------------------------------------------------------------------
3888 #define VKI_LL_IOC_GROUP_LOCK \
3889            _VKI_IOW('f', 158, long)
3890 #define VKI_LL_IOC_GROUP_UNLOCK \
3891            _VKI_IOW('f', 159, long)
3892 #define VKI_LL_IOC_GETPARENT \
3893            _VKI_IOWR('f', 249, struct vki_getparent)
3894 
3895 
3896 struct vki_v4l2_rect {
3897     __vki_s32   left;
3898     __vki_s32   top;
3899     __vki_u32   width;
3900     __vki_u32   height;
3901 };
3902 
3903 struct vki_v4l2_fract {
3904     __vki_u32   numerator;
3905     __vki_u32   denominator;
3906 };
3907 
3908 struct vki_v4l2_capability {
3909     __vki_u8    driver[16];
3910     __vki_u8    card[32];
3911     __vki_u8    bus_info[32];
3912     __vki_u32   version;
3913     __vki_u32   capabilities;
3914     __vki_u32   device_caps;
3915     __vki_u32   reserved[3];
3916 };
3917 
3918 struct vki_v4l2_pix_format {
3919     __vki_u32               width;
3920     __vki_u32           height;
3921     __vki_u32           pixelformat;
3922     __vki_u32           field;      /* enum vki_v4l2_field */
3923     __vki_u32               bytesperline;   /* for padding, zero if unused */
3924     __vki_u32               sizeimage;
3925     __vki_u32           colorspace; /* enum vki_v4l2_colorspace */
3926     __vki_u32           priv;       /* private data, depends on pixelformat */
3927     __vki_u32           flags;      /* format flags (VKI_V4L2_PIX_FMT_FLAG_*) */
3928     __vki_u32           ycbcr_enc;
3929     __vki_u32           quantization;
3930 };
3931 
3932 struct vki_v4l2_fmtdesc {
3933     __vki_u32           index;             /* Format number      */
3934     __vki_u32           type;              /* enum vki_v4l2_buf_type */
3935     __vki_u32               flags;
3936     __vki_u8            description[32];   /* Description string */
3937     __vki_u32           pixelformat;       /* Format fourcc      */
3938     __vki_u32           reserved[4];
3939 };
3940 
3941 struct vki_v4l2_frmsize_discrete {
3942     __vki_u32           width;      /* Frame width [pixel] */
3943     __vki_u32           height;     /* Frame height [pixel] */
3944 };
3945 
3946 struct vki_v4l2_frmsize_stepwise {
3947     __vki_u32           min_width;  /* Minimum frame width [pixel] */
3948     __vki_u32           max_width;  /* Maximum frame width [pixel] */
3949     __vki_u32           step_width; /* Frame width step size [pixel] */
3950     __vki_u32           min_height; /* Minimum frame height [pixel] */
3951     __vki_u32           max_height; /* Maximum frame height [pixel] */
3952     __vki_u32           step_height;    /* Frame height step size [pixel] */
3953 };
3954 
3955 struct vki_v4l2_frmsizeenum {
3956     __vki_u32           index;      /* Frame size number */
3957     __vki_u32           pixel_format;   /* Pixel format */
3958     __vki_u32           type;       /* Frame size type the device supports. */
3959 
3960     union {                 /* Frame size */
3961         struct vki_v4l2_frmsize_discrete    discrete;
3962         struct vki_v4l2_frmsize_stepwise    stepwise;
3963     };
3964 
3965     __vki_u32   reserved[2];            /* Reserved space for future use */
3966 };
3967 
3968 struct vki_v4l2_frmival_stepwise {
3969     struct vki_v4l2_fract   min;
3970     struct vki_v4l2_fract   max;
3971     struct vki_v4l2_fract   step;
3972 };
3973 
3974 struct vki_v4l2_frmivalenum {
3975     __vki_u32           index;
3976     __vki_u32           pixel_format;
3977     __vki_u32           width;
3978     __vki_u32           height;
3979     __vki_u32           type;
3980 
3981     union {
3982         struct vki_v4l2_fract       discrete;
3983         struct vki_v4l2_frmival_stepwise    stepwise;
3984     };
3985 
3986     __vki_u32   reserved[2];
3987 };
3988 
3989 struct vki_v4l2_timecode {
3990     __vki_u32   type;
3991     __vki_u32   flags;
3992     __vki_u8    frames;
3993     __vki_u8    seconds;
3994     __vki_u8    minutes;
3995     __vki_u8    hours;
3996     __vki_u8    userbits[4];
3997 };
3998 
3999 struct vki_v4l2_jpegcompression {
4000     int quality;
4001     int  APPn;
4002     int  APP_len;
4003     char APP_data[60];
4004     int  COM_len;
4005     char COM_data[60];
4006     __vki_u32 jpeg_markers;
4007 };
4008 
4009 struct vki_v4l2_requestbuffers {
4010     __vki_u32           count;
4011     __vki_u32           type;
4012     __vki_u32           memory;
4013     __vki_u32           reserved[2];
4014 };
4015 
4016 struct vki_v4l2_plane {
4017     __vki_u32           bytesused;
4018     __vki_u32           length;
4019     union {
4020         __vki_u32       mem_offset;
4021         unsigned long   userptr;
4022         __vki_s32       fd;
4023     } m;
4024     __vki_u32           data_offset;
4025     __vki_u32           reserved[11];
4026 };
4027 
4028 #define VKI_V4L2_MEMORY_MMAP             1
4029 #define VKI_V4L2_MEMORY_DMABUF           4
4030 #define VKI_V4L2_BUF_FLAG_TIMESTAMP_MASK        0x0000e000
4031 #define VKI_V4L2_BUF_FLAG_TIMESTAMP_COPY        0x00004000
4032 struct vki_v4l2_buffer {
4033     __vki_u32           index;
4034     __vki_u32           type;
4035     __vki_u32           bytesused;
4036     __vki_u32           flags;
4037     __vki_u32           field;
4038     struct vki_timeval      timestamp;
4039     struct vki_v4l2_timecode    timecode;
4040     __vki_u32           sequence;
4041 
4042     /* memory location */
4043     __vki_u32           memory;
4044     union {
4045         __vki_u32           offset;
4046         unsigned long   userptr;
4047         struct vki_v4l2_plane *planes;
4048         __vki_s32       fd;
4049     } m;
4050     __vki_u32           length;
4051     __vki_u32           reserved2;
4052     __vki_u32           reserved;
4053 };
4054 
4055 struct vki_v4l2_exportbuffer {
4056     __vki_u32       type; /* enum vki_v4l2_buf_type */
4057     __vki_u32       index;
4058     __vki_u32       plane;
4059     __vki_u32       flags;
4060     __vki_s32       fd;
4061     __vki_u32       reserved[11];
4062 };
4063 
4064 struct vki_v4l2_framebuffer {
4065     __vki_u32           capability;
4066     __vki_u32           flags;
4067     void                    *base;
4068     struct {
4069         __vki_u32       width;
4070         __vki_u32       height;
4071         __vki_u32       pixelformat;
4072         __vki_u32       field;      /* enum vki_v4l2_field */
4073         __vki_u32       bytesperline;   /* for padding, zero if unused */
4074         __vki_u32       sizeimage;
4075         __vki_u32       colorspace; /* enum vki_v4l2_colorspace */
4076         __vki_u32       priv;       /* reserved field, set to 0 */
4077     } fmt;
4078 };
4079 
4080 struct vki_v4l2_clip {
4081     struct vki_v4l2_rect        c;
4082     struct vki_v4l2_clip    __user *next;
4083 };
4084 
4085 struct vki_v4l2_window {
4086     struct vki_v4l2_rect        w;
4087     __vki_u32           field;   /* enum vki_v4l2_field */
4088     __vki_u32           chromakey;
4089     struct vki_v4l2_clip    __user *clips;
4090     __vki_u32           clipcount;
4091     void            __user *bitmap;
4092     __vki_u8                    global_alpha;
4093 };
4094 
4095 struct vki_v4l2_captureparm {
4096     __vki_u32          capability;    /*  Supported modes */
4097     __vki_u32          capturemode;   /*  Current mode */
4098     struct vki_v4l2_fract  timeperframe;  /*  Time per frame in seconds */
4099     __vki_u32          extendedmode;  /*  Driver-specific extensions */
4100     __vki_u32              readbuffers;   /*  # of buffers for read */
4101     __vki_u32          reserved[4];
4102 };
4103 
4104 struct vki_v4l2_outputparm {
4105     __vki_u32          capability;   /*  Supported modes */
4106     __vki_u32          outputmode;   /*  Current mode */
4107     struct vki_v4l2_fract  timeperframe; /*  Time per frame in seconds */
4108     __vki_u32          extendedmode; /*  Driver-specific extensions */
4109     __vki_u32              writebuffers; /*  # of buffers for write */
4110     __vki_u32          reserved[4];
4111 };
4112 
4113 struct vki_v4l2_cropcap {
4114     __vki_u32           type;   /* enum vki_v4l2_buf_type */
4115     struct vki_v4l2_rect        bounds;
4116     struct vki_v4l2_rect        defrect;
4117     struct vki_v4l2_fract       pixelaspect;
4118 };
4119 
4120 struct vki_v4l2_crop {
4121     __vki_u32           type;   /* enum vki_v4l2_buf_type */
4122     struct vki_v4l2_rect        c;
4123 };
4124 
4125 struct vki_v4l2_selection {
4126     __vki_u32           type;
4127     __vki_u32           target;
4128     __vki_u32                   flags;
4129     struct vki_v4l2_rect        r;
4130     __vki_u32                   reserved[9];
4131 };
4132 
4133 typedef __vki_u64 vki_v4l2_std_id;
4134 
4135 struct vki_v4l2_standard {
4136     __vki_u32            index;
4137     vki_v4l2_std_id          id;
4138     __vki_u8             name[24];
4139     struct vki_v4l2_fract    frameperiod; /* Frames, not fields */
4140     __vki_u32            framelines;
4141     __vki_u32            reserved[4];
4142 };
4143 
4144 struct vki_v4l2_bt_timings {
4145     __vki_u32   width;
4146     __vki_u32   height;
4147     __vki_u32   interlaced;
4148     __vki_u32   polarities;
4149     __vki_u64   pixelclock;
4150     __vki_u32   hfrontporch;
4151     __vki_u32   hsync;
4152     __vki_u32   hbackporch;
4153     __vki_u32   vfrontporch;
4154     __vki_u32   vsync;
4155     __vki_u32   vbackporch;
4156     __vki_u32   il_vfrontporch;
4157     __vki_u32   il_vsync;
4158     __vki_u32   il_vbackporch;
4159     __vki_u32   standards;
4160     __vki_u32   flags;
4161     __vki_u32   reserved[14];
4162 } __attribute__ ((packed));
4163 
4164 struct vki_v4l2_dv_timings {
4165     __vki_u32 type;
4166     union {
4167         struct vki_v4l2_bt_timings  bt;
4168         __vki_u32   reserved[32];
4169     };
4170 } __attribute__ ((packed));
4171 
4172 struct vki_v4l2_enum_dv_timings {
4173     __vki_u32 index;
4174     __vki_u32 pad;
4175     __vki_u32 reserved[2];
4176     struct vki_v4l2_dv_timings timings;
4177 };
4178 
4179 struct vki_v4l2_bt_timings_cap {
4180     __vki_u32   min_width;
4181     __vki_u32   max_width;
4182     __vki_u32   min_height;
4183     __vki_u32   max_height;
4184     __vki_u64   min_pixelclock;
4185     __vki_u64   max_pixelclock;
4186     __vki_u32   standards;
4187     __vki_u32   capabilities;
4188     __vki_u32   reserved[16];
4189 } __attribute__ ((packed));
4190 
4191 struct vki_v4l2_dv_timings_cap {
4192     __vki_u32 type;
4193     __vki_u32 pad;
4194     __vki_u32 reserved[2];
4195     union {
4196         struct vki_v4l2_bt_timings_cap bt;
4197         __vki_u32 raw_data[32];
4198     };
4199 };
4200 
4201 struct vki_v4l2_input {
4202     __vki_u32        index;     /*  Which input */
4203     __vki_u8         name[32];      /*  Label */
4204     __vki_u32        type;      /*  Type of input */
4205     __vki_u32        audioset;      /*  Associated audios (bitfield) */
4206     __vki_u32        tuner;             /*  enum vki_v4l2_tuner_type */
4207     vki_v4l2_std_id  std;
4208     __vki_u32        status;
4209     __vki_u32        capabilities;
4210     __vki_u32        reserved[3];
4211 };
4212 
4213 struct vki_v4l2_output {
4214     __vki_u32        index;     /*  Which output */
4215     __vki_u8         name[32];      /*  Label */
4216     __vki_u32        type;      /*  Type of output */
4217     __vki_u32        audioset;      /*  Associated audios (bitfield) */
4218     __vki_u32        modulator;         /*  Associated modulator */
4219     vki_v4l2_std_id  std;
4220     __vki_u32        capabilities;
4221     __vki_u32        reserved[3];
4222 };
4223 
4224 struct vki_v4l2_control {
4225     __vki_u32            id;
4226     __vki_s32            value;
4227 };
4228 
4229 struct vki_v4l2_ext_control {
4230     __vki_u32 id;
4231     __vki_u32 size;
4232     __vki_u32 reserved2[1];
4233     union {
4234         __vki_s32 value;
4235         __vki_s64 value64;
4236         char *string;
4237         __vki_u8 *p_u8;
4238         __vki_u16 *p_u16;
4239         __vki_u32 *p_u32;
4240         void *ptr;
4241     };
4242 } __attribute__ ((packed));
4243 
4244 struct vki_v4l2_ext_controls {
4245     __vki_u32 ctrl_class;
4246     __vki_u32 count;
4247     __vki_u32 error_idx;
4248     __vki_u32 reserved[2];
4249     struct vki_v4l2_ext_control *controls;
4250 };
4251 
4252 struct vki_v4l2_queryctrl {
4253     __vki_u32            id;
4254     __vki_u32            type;  /* enum vki_v4l2_ctrl_type */
4255     __vki_u8             name[32];  /* Whatever */
4256     __vki_s32            minimum;   /* Note signedness */
4257     __vki_s32            maximum;
4258     __vki_s32            step;
4259     __vki_s32            default_value;
4260     __vki_u32                flags;
4261     __vki_u32            reserved[2];
4262 };
4263 
4264 #define VKI_V4L2_CTRL_MAX_DIMS    (4)
4265 struct vki_v4l2_query_ext_ctrl {
4266     __vki_u32            id;
4267     __vki_u32            type;
4268     char             name[32];
4269     __vki_s64            minimum;
4270     __vki_s64            maximum;
4271     __vki_u64            step;
4272     __vki_s64            default_value;
4273     __vki_u32                flags;
4274     __vki_u32                elem_size;
4275     __vki_u32                elems;
4276     __vki_u32                nr_of_dims;
4277     __vki_u32                dims[VKI_V4L2_CTRL_MAX_DIMS];
4278     __vki_u32            reserved[32];
4279 };
4280 
4281 struct vki_v4l2_querymenu {
4282     __vki_u32       id;
4283     __vki_u32       index;
4284     union {
4285         __vki_u8    name[32];   /* Whatever */
4286         __vki_s64   value;
4287     };
4288     __vki_u32       reserved;
4289 } __attribute__ ((packed));
4290 
4291 struct vki_v4l2_tuner {
4292     __vki_u32                   index;
4293     __vki_u8            name[32];
4294     __vki_u32           type;   /* enum vki_v4l2_tuner_type */
4295     __vki_u32           capability;
4296     __vki_u32           rangelow;
4297     __vki_u32           rangehigh;
4298     __vki_u32           rxsubchans;
4299     __vki_u32           audmode;
4300     __vki_s32           signal;
4301     __vki_s32           afc;
4302     __vki_u32           reserved[4];
4303 };
4304 
4305 struct vki_v4l2_modulator {
4306     __vki_u32           index;
4307     __vki_u8            name[32];
4308     __vki_u32           capability;
4309     __vki_u32           rangelow;
4310     __vki_u32           rangehigh;
4311     __vki_u32           txsubchans;
4312     __vki_u32           reserved[4];
4313 };
4314 
4315 struct vki_v4l2_frequency {
4316     __vki_u32   tuner;
4317     __vki_u32   type;   /* enum vki_v4l2_tuner_type */
4318     __vki_u32   frequency;
4319     __vki_u32   reserved[8];
4320 };
4321 
4322 struct vki_v4l2_frequency_band {
4323     __vki_u32   tuner;
4324     __vki_u32   type;   /* enum vki_v4l2_tuner_type */
4325     __vki_u32   index;
4326     __vki_u32   capability;
4327     __vki_u32   rangelow;
4328     __vki_u32   rangehigh;
4329     __vki_u32   modulation;
4330     __vki_u32   reserved[9];
4331 };
4332 
4333 struct vki_v4l2_hw_freq_seek {
4334     __vki_u32   tuner;
4335     __vki_u32   type;   /* enum vki_v4l2_tuner_type */
4336     __vki_u32   seek_upward;
4337     __vki_u32   wrap_around;
4338     __vki_u32   spacing;
4339     __vki_u32   rangelow;
4340     __vki_u32   rangehigh;
4341     __vki_u32   reserved[5];
4342 };
4343 
4344 struct vki_v4l2_audio {
4345     __vki_u32   index;
4346     __vki_u8    name[32];
4347     __vki_u32   capability;
4348     __vki_u32   mode;
4349     __vki_u32   reserved[2];
4350 };
4351 
4352 struct vki_v4l2_audioout {
4353     __vki_u32   index;
4354     __vki_u8    name[32];
4355     __vki_u32   capability;
4356     __vki_u32   mode;
4357     __vki_u32   reserved[2];
4358 };
4359 
4360 struct vki_v4l2_enc_idx_entry {
4361     __vki_u64 offset;
4362     __vki_u64 pts;
4363     __vki_u32 length;
4364     __vki_u32 flags;
4365     __vki_u32 reserved[2];
4366 };
4367 
4368 #define VKI_V4L2_ENC_IDX_ENTRIES (64)
4369 struct vki_v4l2_enc_idx {
4370     __vki_u32 entries;
4371     __vki_u32 entries_cap;
4372     __vki_u32 reserved[4];
4373     struct vki_v4l2_enc_idx_entry entry[VKI_V4L2_ENC_IDX_ENTRIES];
4374 };
4375 
4376 struct vki_v4l2_encoder_cmd {
4377     __vki_u32 cmd;
4378     __vki_u32 flags;
4379     union {
4380         struct {
4381             __vki_u32 data[8];
4382         } raw;
4383     };
4384 };
4385 
4386 struct vki_v4l2_decoder_cmd {
4387     __vki_u32 cmd;
4388     __vki_u32 flags;
4389     union {
4390         struct {
4391             __vki_u64 pts;
4392         } stop;
4393 
4394         struct {
4395             __vki_s32 speed;
4396             __vki_u32 format;
4397         } start;
4398 
4399         struct {
4400             __vki_u32 data[16];
4401         } raw;
4402     };
4403 };
4404 
4405 struct vki_v4l2_vbi_format {
4406     __vki_u32   sampling_rate;      /* in 1 Hz */
4407     __vki_u32   offset;
4408     __vki_u32   samples_per_line;
4409     __vki_u32   sample_format;      /* VKI_V4L2_PIX_FMT_* */
4410     __vki_s32   start[2];
4411     __vki_u32   count[2];
4412     __vki_u32   flags;          /* VKI_V4L2_VBI_* */
4413     __vki_u32   reserved[2];        /* must be zero */
4414 };
4415 
4416 struct vki_v4l2_sliced_vbi_format {
4417     __vki_u16   service_set;
4418     __vki_u16   service_lines[2][24];
4419     __vki_u32   io_size;
4420     __vki_u32   reserved[2];            /* must be zero */
4421 };
4422 
4423 struct vki_v4l2_sliced_vbi_cap {
4424     __vki_u16   service_set;
4425     __vki_u16   service_lines[2][24];
4426     __vki_u32   type;       /* enum vki_v4l2_buf_type */
4427     __vki_u32   reserved[3];    /* must be 0 */
4428 };
4429 
4430 struct vki_v4l2_sliced_vbi_data {
4431     __vki_u32   id;
4432     __vki_u32   field;          /* 0: first field, 1: second field */
4433     __vki_u32   line;           /* 1-23 */
4434     __vki_u32   reserved;       /* must be 0 */
4435     __vki_u8    data[48];
4436 };
4437 
4438 struct vki_v4l2_plane_pix_format {
4439     __vki_u32       sizeimage;
4440     __vki_u32       bytesperline;
4441     __vki_u16       reserved[6];
4442 } __attribute__ ((packed));
4443 
4444 #define VKI_VIDEO_MAX_PLANES               8
4445 
4446 struct vki_v4l2_pix_format_mplane {
4447     __vki_u32               width;
4448     __vki_u32               height;
4449     __vki_u32               pixelformat;
4450     __vki_u32               field;
4451     __vki_u32               colorspace;
4452 
4453     struct vki_v4l2_plane_pix_format    plane_fmt[VKI_VIDEO_MAX_PLANES];
4454     __vki_u8                num_planes;
4455     __vki_u8                flags;
4456     __vki_u8                ycbcr_enc;
4457     __vki_u8                quantization;
4458     __vki_u8                reserved[8];
4459 } __attribute__ ((packed));
4460 
4461 struct vki_v4l2_sdr_format {
4462     __vki_u32               pixelformat;
4463     __vki_u32               buffersize;
4464     __vki_u8                reserved[24];
4465 } __attribute__ ((packed));
4466 
4467 enum vki_v4l2_buf_type {
4468     VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE        = 1,
4469     VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT         = 2,
4470     VKI_V4L2_BUF_TYPE_VIDEO_OVERLAY        = 3,
4471     VKI_V4L2_BUF_TYPE_VBI_CAPTURE          = 4,
4472     VKI_V4L2_BUF_TYPE_VBI_OUTPUT           = 5,
4473     VKI_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE   = 6,
4474     VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT    = 7,
4475     VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY = 8,
4476     VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9,
4477     VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE  = 10,
4478     VKI_V4L2_BUF_TYPE_SDR_CAPTURE          = 11,
4479 };
4480 
4481 struct vki_v4l2_format {
4482     __vki_u32    type;
4483     union {
4484         struct vki_v4l2_pix_format      pix;
4485         struct vki_v4l2_pix_format_mplane   pix_mp;
4486         struct vki_v4l2_window      win;
4487         struct vki_v4l2_vbi_format      vbi;
4488         struct vki_v4l2_sliced_vbi_format   sliced;
4489         struct vki_v4l2_sdr_format      sdr;
4490         __vki_u8    raw_data[200];
4491     } fmt;
4492 };
4493 
4494 struct vki_v4l2_streamparm {
4495     __vki_u32    type;
4496     union {
4497         struct vki_v4l2_captureparm capture;
4498         struct vki_v4l2_outputparm  output;
4499         __vki_u8    raw_data[200];  /* user-defined */
4500     } parm;
4501 };
4502 
4503 struct vki_v4l2_event_vsync {
4504     __vki_u8 field;
4505 } __attribute__ ((packed));
4506 
4507 struct vki_v4l2_event_ctrl {
4508     __vki_u32 changes;
4509     __vki_u32 type;
4510     union {
4511         __vki_s32 value;
4512         __vki_s64 value64;
4513     };
4514     __vki_u32 flags;
4515     __vki_s32 minimum;
4516     __vki_s32 maximum;
4517     __vki_s32 step;
4518     __vki_s32 default_value;
4519 };
4520 
4521 struct vki_v4l2_event_frame_sync {
4522     __vki_u32 frame_sequence;
4523 };
4524 
4525 struct vki_v4l2_event_src_change {
4526     __vki_u32 changes;
4527 };
4528 
4529 struct vki_v4l2_event_motion_det {
4530     __vki_u32 flags;
4531     __vki_u32 frame_sequence;
4532     __vki_u32 region_mask;
4533 };
4534 
4535 struct vki_v4l2_event {
4536     __vki_u32               type;
4537     union {
4538         struct vki_v4l2_event_vsync     vsync;
4539         struct vki_v4l2_event_ctrl      ctrl;
4540         struct vki_v4l2_event_frame_sync    frame_sync;
4541         struct vki_v4l2_event_src_change    src_change;
4542         struct vki_v4l2_event_motion_det    motion_det;
4543         __vki_u8                data[64];
4544     } u;
4545     __vki_u32               pending;
4546     __vki_u32               sequence;
4547     struct vki_timespec         timestamp;
4548     __vki_u32               id;
4549     __vki_u32               reserved[8];
4550 };
4551 
4552 struct vki_v4l2_event_subscription {
4553     __vki_u32               type;
4554     __vki_u32               id;
4555     __vki_u32               flags;
4556     __vki_u32               reserved[5];
4557 };
4558 
4559 struct vki_v4l2_dbg_match {
4560     __vki_u32 type; /* Match type */
4561     union {     /* Match this chip, meaning determined by type */
4562         __vki_u32 addr;
4563         char name[32];
4564     };
4565 } __attribute__ ((packed));
4566 
4567 struct vki_v4l2_dbg_register {
4568     struct vki_v4l2_dbg_match match;
4569     __vki_u32 size; /* register size in bytes */
4570     __vki_u64 reg;
4571     __vki_u64 val;
4572 } __attribute__ ((packed));
4573 
4574 struct vki_v4l2_dbg_chip_info {
4575     struct vki_v4l2_dbg_match match;
4576     char name[32];
4577     __vki_u32 flags;
4578     __vki_u32 reserved[32];
4579 } __attribute__ ((packed));
4580 
4581 struct vki_v4l2_create_buffers {
4582     __vki_u32           index;
4583     __vki_u32           count;
4584     __vki_u32           memory;
4585     struct vki_v4l2_format  format;
4586     __vki_u32           reserved[8];
4587 };
4588 
4589 struct vki_v4l2_edid {
4590     __vki_u32 pad;
4591     __vki_u32 start_block;
4592     __vki_u32 blocks;
4593     __vki_u32 reserved[5];
4594     __vki_u8  *edid;
4595 };
4596 
4597 #define VKI_V4L2_QUERYCAP       _VKI_IOR('V',  0, struct vki_v4l2_capability)
4598 #define VKI_V4L2_ENUM_FMT       _VKI_IOWR('V',  2, struct vki_v4l2_fmtdesc)
4599 #define VKI_V4L2_G_FMT          _VKI_IOWR('V',  4, struct vki_v4l2_format)
4600 #define VKI_V4L2_S_FMT          _VKI_IOWR('V',  5, struct vki_v4l2_format)
4601 #define VKI_V4L2_REQBUFS        _VKI_IOWR('V',  8, struct vki_v4l2_requestbuffers)
4602 #define VKI_V4L2_QUERYBUF       _VKI_IOWR('V',  9, struct vki_v4l2_buffer)
4603 #define VKI_V4L2_G_FBUF         _VKI_IOR('V', 10, struct vki_v4l2_framebuffer)
4604 #define VKI_V4L2_S_FBUF         _VKI_IOW('V', 11, struct vki_v4l2_framebuffer)
4605 #define VKI_V4L2_OVERLAY        _VKI_IOW('V', 14, int)
4606 #define VKI_V4L2_QBUF           _VKI_IOWR('V', 15, struct vki_v4l2_buffer)
4607 #define VKI_V4L2_EXPBUF         _VKI_IOWR('V', 16, struct vki_v4l2_exportbuffer)
4608 #define VKI_V4L2_DQBUF          _VKI_IOWR('V', 17, struct vki_v4l2_buffer)
4609 #define VKI_V4L2_STREAMON       _VKI_IOW('V', 18, int)
4610 #define VKI_V4L2_STREAMOFF      _VKI_IOW('V', 19, int)
4611 #define VKI_V4L2_G_PARM         _VKI_IOWR('V', 21, struct vki_v4l2_streamparm)
4612 #define VKI_V4L2_S_PARM         _VKI_IOWR('V', 22, struct vki_v4l2_streamparm)
4613 #define VKI_V4L2_G_STD          _VKI_IOR('V', 23, vki_v4l2_std_id)
4614 #define VKI_V4L2_S_STD          _VKI_IOW('V', 24, vki_v4l2_std_id)
4615 #define VKI_V4L2_ENUMSTD        _VKI_IOWR('V', 25, struct vki_v4l2_standard)
4616 #define VKI_V4L2_ENUMINPUT      _VKI_IOWR('V', 26, struct vki_v4l2_input)
4617 #define VKI_V4L2_G_CTRL         _VKI_IOWR('V', 27, struct vki_v4l2_control)
4618 #define VKI_V4L2_S_CTRL         _VKI_IOWR('V', 28, struct vki_v4l2_control)
4619 #define VKI_V4L2_G_TUNER        _VKI_IOWR('V', 29, struct vki_v4l2_tuner)
4620 #define VKI_V4L2_S_TUNER        _VKI_IOW('V', 30, struct vki_v4l2_tuner)
4621 #define VKI_V4L2_G_AUDIO        _VKI_IOR('V', 33, struct vki_v4l2_audio)
4622 #define VKI_V4L2_S_AUDIO        _VKI_IOW('V', 34, struct vki_v4l2_audio)
4623 #define VKI_V4L2_QUERYCTRL      _VKI_IOWR('V', 36, struct vki_v4l2_queryctrl)
4624 #define VKI_V4L2_QUERYMENU      _VKI_IOWR('V', 37, struct vki_v4l2_querymenu)
4625 #define VKI_V4L2_G_INPUT        _VKI_IOR('V', 38, int)
4626 #define VKI_V4L2_S_INPUT        _VKI_IOWR('V', 39, int)
4627 #define VKI_V4L2_G_EDID         _VKI_IOWR('V', 40, struct vki_v4l2_edid)
4628 #define VKI_V4L2_S_EDID         _VKI_IOWR('V', 41, struct vki_v4l2_edid)
4629 #define VKI_V4L2_G_OUTPUT       _VKI_IOR('V', 46, int)
4630 #define VKI_V4L2_S_OUTPUT       _VKI_IOWR('V', 47, int)
4631 #define VKI_V4L2_ENUMOUTPUT     _VKI_IOWR('V', 48, struct vki_v4l2_output)
4632 #define VKI_V4L2_G_AUDOUT       _VKI_IOR('V', 49, struct vki_v4l2_audioout)
4633 #define VKI_V4L2_S_AUDOUT       _VKI_IOW('V', 50, struct vki_v4l2_audioout)
4634 #define VKI_V4L2_G_MODULATOR        _VKI_IOWR('V', 54, struct vki_v4l2_modulator)
4635 #define VKI_V4L2_S_MODULATOR        _VKI_IOW('V', 55, struct vki_v4l2_modulator)
4636 #define VKI_V4L2_G_FREQUENCY        _VKI_IOWR('V', 56, struct vki_v4l2_frequency)
4637 #define VKI_V4L2_S_FREQUENCY        _VKI_IOW('V', 57, struct vki_v4l2_frequency)
4638 #define VKI_V4L2_CROPCAP        _VKI_IOWR('V', 58, struct vki_v4l2_cropcap)
4639 #define VKI_V4L2_G_CROP         _VKI_IOWR('V', 59, struct vki_v4l2_crop)
4640 #define VKI_V4L2_S_CROP         _VKI_IOW('V', 60, struct vki_v4l2_crop)
4641 #define VKI_V4L2_G_JPEGCOMP     _VKI_IOR('V', 61, struct vki_v4l2_jpegcompression)
4642 #define VKI_V4L2_S_JPEGCOMP     _VKI_IOW('V', 62, struct vki_v4l2_jpegcompression)
4643 #define VKI_V4L2_QUERYSTD           _VKI_IOR('V', 63, vki_v4l2_std_id)
4644 #define VKI_V4L2_TRY_FMT            _VKI_IOWR('V', 64, struct vki_v4l2_format)
4645 #define VKI_V4L2_ENUMAUDIO      _VKI_IOWR('V', 65, struct vki_v4l2_audio)
4646 #define VKI_V4L2_ENUMAUDOUT     _VKI_IOWR('V', 66, struct vki_v4l2_audioout)
4647 #define VKI_V4L2_G_PRIORITY     _VKI_IOR('V', 67, __vki_u32)
4648 #define VKI_V4L2_S_PRIORITY     _VKI_IOW('V', 68, __vki_u32)
4649 #define VKI_V4L2_G_SLICED_VBI_CAP   _VKI_IOWR('V', 69, struct vki_v4l2_sliced_vbi_cap)
4650 #define VKI_V4L2_LOG_STATUS         _VKI_IO('V', 70)
4651 #define VKI_V4L2_G_EXT_CTRLS        _VKI_IOWR('V', 71, struct vki_v4l2_ext_controls)
4652 #define VKI_V4L2_S_EXT_CTRLS        _VKI_IOWR('V', 72, struct vki_v4l2_ext_controls)
4653 #define VKI_V4L2_TRY_EXT_CTRLS      _VKI_IOWR('V', 73, struct vki_v4l2_ext_controls)
4654 #define VKI_V4L2_ENUM_FRAMESIZES    _VKI_IOWR('V', 74, struct vki_v4l2_frmsizeenum)
4655 #define VKI_V4L2_ENUM_FRAMEINTERVALS    _VKI_IOWR('V', 75, struct vki_v4l2_frmivalenum)
4656 #define VKI_V4L2_G_ENC_INDEX        _VKI_IOR('V', 76, struct vki_v4l2_enc_idx)
4657 #define VKI_V4L2_ENCODER_CMD        _VKI_IOWR('V', 77, struct vki_v4l2_encoder_cmd)
4658 #define VKI_V4L2_TRY_ENCODER_CMD    _VKI_IOWR('V', 78, struct vki_v4l2_encoder_cmd)
4659 #define VKI_V4L2_DBG_S_REGISTER     _VKI_IOW('V', 79, struct vki_v4l2_dbg_register)
4660 #define VKI_V4L2_DBG_G_REGISTER     _VKI_IOWR('V', 80, struct vki_v4l2_dbg_register)
4661 #define VKI_V4L2_S_HW_FREQ_SEEK     _VKI_IOW('V', 82, struct vki_v4l2_hw_freq_seek)
4662 #define VKI_V4L2_S_DV_TIMINGS       _VKI_IOWR('V', 87, struct vki_v4l2_dv_timings)
4663 #define VKI_V4L2_G_DV_TIMINGS       _VKI_IOWR('V', 88, struct vki_v4l2_dv_timings)
4664 #define VKI_V4L2_DQEVENT        _VKI_IOR('V', 89, struct vki_v4l2_event)
4665 #define VKI_V4L2_SUBSCRIBE_EVENT    _VKI_IOW('V', 90, struct vki_v4l2_event_subscription)
4666 #define VKI_V4L2_UNSUBSCRIBE_EVENT  _VKI_IOW('V', 91, struct vki_v4l2_event_subscription)
4667 #define VKI_V4L2_CREATE_BUFS        _VKI_IOWR('V', 92, struct vki_v4l2_create_buffers)
4668 #define VKI_V4L2_PREPARE_BUF        _VKI_IOWR('V', 93, struct vki_v4l2_buffer)
4669 #define VKI_V4L2_G_SELECTION        _VKI_IOWR('V', 94, struct vki_v4l2_selection)
4670 #define VKI_V4L2_S_SELECTION        _VKI_IOWR('V', 95, struct vki_v4l2_selection)
4671 #define VKI_V4L2_DECODER_CMD        _VKI_IOWR('V', 96, struct vki_v4l2_decoder_cmd)
4672 #define VKI_V4L2_TRY_DECODER_CMD    _VKI_IOWR('V', 97, struct vki_v4l2_decoder_cmd)
4673 #define VKI_V4L2_ENUM_DV_TIMINGS    _VKI_IOWR('V', 98, struct vki_v4l2_enum_dv_timings)
4674 #define VKI_V4L2_QUERY_DV_TIMINGS   _VKI_IOR('V', 99, struct vki_v4l2_dv_timings)
4675 #define VKI_V4L2_DV_TIMINGS_CAP     _VKI_IOWR('V', 100, struct vki_v4l2_dv_timings_cap)
4676 #define VKI_V4L2_ENUM_FREQ_BANDS    _VKI_IOWR('V', 101, struct vki_v4l2_frequency_band)
4677 #define VKI_V4L2_DBG_G_CHIP_INFO    _VKI_IOWR('V', 102, struct vki_v4l2_dbg_chip_info)
4678 #define VKI_V4L2_QUERY_EXT_CTRL     _VKI_IOWR('V', 103, struct vki_v4l2_query_ext_ctrl)
4679 
4680 struct vki_v4l2_mbus_framefmt {
4681     __vki_u32           width;
4682     __vki_u32           height;
4683     __vki_u32           code;
4684     __vki_u32           field;
4685     __vki_u32           colorspace;
4686     __vki_u16           ycbcr_enc;
4687     __vki_u16           quantization;
4688     __vki_u32           reserved[6];
4689 };
4690 
4691 struct vki_v4l2_subdev_format {
4692     __vki_u32 which;
4693     __vki_u32 pad;
4694     struct vki_v4l2_mbus_framefmt format;
4695     __vki_u32 reserved[8];
4696 };
4697 
4698 struct vki_v4l2_subdev_crop {
4699     __vki_u32 which;
4700     __vki_u32 pad;
4701     struct vki_v4l2_rect rect;
4702     __vki_u32 reserved[8];
4703 };
4704 
4705 struct vki_v4l2_subdev_mbus_code_enum {
4706     __vki_u32 pad;
4707     __vki_u32 index;
4708     __vki_u32 code;
4709     __vki_u32 which;
4710     __vki_u32 reserved[8];
4711 };
4712 
4713 struct vki_v4l2_subdev_frame_size_enum {
4714     __vki_u32 index;
4715     __vki_u32 pad;
4716     __vki_u32 code;
4717     __vki_u32 min_width;
4718     __vki_u32 max_width;
4719     __vki_u32 min_height;
4720     __vki_u32 max_height;
4721     __vki_u32 which;
4722     __vki_u32 reserved[8];
4723 };
4724 
4725 struct vki_v4l2_subdev_frame_interval {
4726     __vki_u32 pad;
4727     struct vki_v4l2_fract interval;
4728     __vki_u32 reserved[9];
4729 };
4730 
4731 struct vki_v4l2_subdev_frame_interval_enum {
4732     __vki_u32 index;
4733     __vki_u32 pad;
4734     __vki_u32 code;
4735     __vki_u32 width;
4736     __vki_u32 height;
4737     struct vki_v4l2_fract interval;
4738     __vki_u32 which;
4739     __vki_u32 reserved[8];
4740 };
4741 
4742 struct vki_v4l2_subdev_selection {
4743     __vki_u32 which;
4744     __vki_u32 pad;
4745     __vki_u32 target;
4746     __vki_u32 flags;
4747     struct vki_v4l2_rect r;
4748     __vki_u32 reserved[8];
4749 };
4750 
4751 #define VKI_V4L2_SUBDEV_G_FMT           _VKI_IOWR('V',  4, struct vki_v4l2_subdev_format)
4752 #define VKI_V4L2_SUBDEV_S_FMT           _VKI_IOWR('V',  5, struct vki_v4l2_subdev_format)
4753 #define VKI_V4L2_SUBDEV_G_FRAME_INTERVAL    _VKI_IOWR('V', 21, struct vki_v4l2_subdev_frame_interval)
4754 #define VKI_V4L2_SUBDEV_S_FRAME_INTERVAL    _VKI_IOWR('V', 22, struct vki_v4l2_subdev_frame_interval)
4755 #define VKI_V4L2_SUBDEV_ENUM_MBUS_CODE      _VKI_IOWR('V',  2, struct vki_v4l2_subdev_mbus_code_enum)
4756 #define VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE     _VKI_IOWR('V', 74, struct vki_v4l2_subdev_frame_size_enum)
4757 #define VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL _VKI_IOWR('V', 75, struct vki_v4l2_subdev_frame_interval_enum)
4758 #define VKI_V4L2_SUBDEV_G_CROP          _VKI_IOWR('V', 59, struct vki_v4l2_subdev_crop)
4759 #define VKI_V4L2_SUBDEV_S_CROP          _VKI_IOWR('V', 60, struct vki_v4l2_subdev_crop)
4760 #define VKI_V4L2_SUBDEV_G_SELECTION     _VKI_IOWR('V', 61, struct vki_v4l2_subdev_selection)
4761 #define VKI_V4L2_SUBDEV_S_SELECTION     _VKI_IOWR('V', 62, struct vki_v4l2_subdev_selection)
4762 
4763 struct vki_media_device_info {
4764     char driver[16];
4765     char model[32];
4766     char serial[40];
4767     char bus_info[32];
4768     __vki_u32 media_version;
4769     __vki_u32 hw_revision;
4770     __vki_u32 driver_version;
4771     __vki_u32 reserved[31];
4772 };
4773 
4774 struct vki_media_entity_desc {
4775     __vki_u32 id;
4776     char name[32];
4777     __vki_u32 type;
4778     __vki_u32 revision;
4779     __vki_u32 flags;
4780     __vki_u32 group_id;
4781     __vki_u16 pads;
4782     __vki_u16 links;
4783 
4784     __vki_u32 reserved[4];
4785 
4786     union {
4787         /* Node specifications */
4788         struct {
4789             __vki_u32 major;
4790             __vki_u32 minor;
4791         } v4l;
4792         struct {
4793             __vki_u32 major;
4794             __vki_u32 minor;
4795         } fb;
4796         struct {
4797             __vki_u32 card;
4798             __vki_u32 device;
4799             __vki_u32 subdevice;
4800         } alsa;
4801         int dvb;
4802 
4803         /* Sub-device specifications */
4804         /* Nothing needed yet */
4805         __vki_u8 raw[184];
4806     };
4807 };
4808 
4809 struct vki_media_pad_desc {
4810     __vki_u32 entity;       /* entity ID */
4811     __vki_u16 index;        /* pad index */
4812     __vki_u32 flags;        /* pad flags */
4813     __vki_u32 reserved[2];
4814 };
4815 
4816 struct vki_media_link_desc {
4817     struct vki_media_pad_desc source;
4818     struct vki_media_pad_desc sink;
4819     __vki_u32 flags;
4820     __vki_u32 reserved[2];
4821 };
4822 
4823 struct vki_media_links_enum {
4824     __vki_u32 entity;
4825     struct vki_media_pad_desc __user *pads;
4826     struct vki_media_link_desc __user *links;
4827     __vki_u32 reserved[4];
4828 };
4829 
4830 #define VKI_MEDIA_IOC_DEVICE_INFO       _VKI_IOWR('|', 0x00, struct vki_media_device_info)
4831 #define VKI_MEDIA_IOC_ENUM_ENTITIES     _VKI_IOWR('|', 0x01, struct vki_media_entity_desc)
4832 #define VKI_MEDIA_IOC_ENUM_LINKS        _VKI_IOWR('|', 0x02, struct vki_media_links_enum)
4833 #define VKI_MEDIA_IOC_SETUP_LINK        _VKI_IOWR('|', 0x03, struct vki_media_link_desc)
4834 
4835 /* DVB demux API */
4836 #define VKI_DMX_STOP    _VKI_IO('o', 42)
4837 
4838 /* Comparison type */
4839 enum vki_kcmp_type {
4840    VKI_KCMP_FILE,
4841    VKI_KCMP_VM,
4842    VKI_KCMP_FILES,
4843    VKI_KCMP_FS,
4844    VKI_KCMP_SIGHAND,
4845    VKI_KCMP_IO,
4846    VKI_KCMP_SYSVSEM,
4847 
4848    VKI_KCMP_TYPES
4849 };
4850 
4851 //----------------------------------------------------------------------
4852 // From linux-3.19-rc5/include/uapi/linux/seccomp.h
4853 //----------------------------------------------------------------------
4854 
4855 #define VKI_SECCOMP_MODE_FILTER 2
4856 
4857 //----------------------------------------------------------------------
4858 // From linux-3.19.3/include/uapi/linux/binfmts.h
4859 //----------------------------------------------------------------------
4860 #define VKI_BINPRM_BUF_SIZE 128
4861 
4862 //----------------------------------------------------------------------
4863 // From linux-3.19.0/include/linux/serial.h
4864 //----------------------------------------------------------------------
4865 
4866 struct vki_serial_struct {
4867     int type;
4868     int line;
4869     unsigned int    port;
4870     int irq;
4871     int flags;
4872     int xmit_fifo_size;
4873     int custom_divisor;
4874     int baud_base;
4875     unsigned short  close_delay;
4876     char    io_type;
4877     char    reserved_char[1];
4878     int hub6;
4879     unsigned short  closing_wait; /* time to wait before closing */
4880     unsigned short  closing_wait2; /* no longer used... */
4881     unsigned char   *iomem_base;
4882     unsigned short  iomem_reg_shift;
4883     unsigned int    port_high;
4884     unsigned long   iomap_base; /* cookie passed into ioremap */
4885 };
4886 
4887 //----------------------------------------------------------------------
4888 // From linux-3.19.0/fs/binfmt_elf.c
4889 //----------------------------------------------------------------------
4890 
4891 #if !defined(VKI_INIT_ARCH_ELF_STATE)
4892    /* This structure is used to preserve architecture specific data during
4893       the loading of an ELF file, throughout the checking of architecture
4894       specific ELF headers & through to the point where the ELF load is
4895       known to be proceeding. This implementation is a dummy for
4896       architectures which require no specific state. */
4897    struct vki_arch_elf_state {
4898    };
4899 
4900 #  define VKI_INIT_ARCH_ELF_STATE { }
4901 
4902 #endif
4903 
4904 //----------------------------------------------------------------------
4905 // From linux-4.0/include/uapi/linux/prctl.h
4906 //----------------------------------------------------------------------
4907 
4908 #define VKI_PR_SET_FP_MODE          45
4909 #define VKI_PR_GET_FP_MODE          46
4910 # define VKI_PR_FP_MODE_FR          (1 << 0)     /* 64b FP registers  */
4911 # define VKI_PR_FP_MODE_FRE         (1 << 1)     /* 32b compatibility */
4912 
4913 #endif // __VKI_LINUX_H
4914 
4915 //----------------------------------------------------------------------
4916 // From linux-4.10/include/uapi/linux/blkzoned.h
4917 //----------------------------------------------------------------------
4918 
4919 struct vki_blk_zone {
4920     __vki_u64   start;
4921     __vki_u64   len;
4922     __vki_u64   wp;
4923     __vki_u8    type;
4924     __vki_u8    cond;
4925     __vki_u8    non_seq;
4926     __vki_u8    reset;
4927     __vki_u8    reserved[36];
4928 };
4929 
4930 struct vki_blk_zone_report {
4931     __vki_u64       sector;
4932     __vki_u32       nr_zones;
4933     __vki_u8        reserved[4];
4934     struct vki_blk_zone zones[0];
4935 };
4936 
4937 struct vki_blk_zone_range {
4938     __vki_u64       sector;
4939     __vki_u64       nr_sectors;
4940 };
4941 
4942 #define VKI_BLKREPORTZONE   _VKI_IOWR(0x12, 130, struct vki_blk_zone_report)
4943 #define VKI_BLKRESETZONE    _VKI_IOW(0x12, 131, struct vki_blk_zone_range)
4944 
4945 //----------------------------------------------------------------------
4946 // From linux-4.18/include/uapi/linux/bpf.h
4947 //----------------------------------------------------------------------
4948 
4949 struct vki_bpf_insn {
4950     __vki_u8    code;       /* opcode */
4951     __vki_u8    dst_reg:4;  /* dest register */
4952     __vki_u8    src_reg:4;  /* source register */
4953     __vki_s16   off;        /* signed offset */
4954     __vki_s32   imm;        /* signed immediate constant */
4955 };
4956 
4957 enum vki_bpf_cmd {
4958     VKI_BPF_MAP_CREATE,
4959     VKI_BPF_MAP_LOOKUP_ELEM,
4960     VKI_BPF_MAP_UPDATE_ELEM,
4961     VKI_BPF_MAP_DELETE_ELEM,
4962     VKI_BPF_MAP_GET_NEXT_KEY,
4963     VKI_BPF_PROG_LOAD,
4964     VKI_BPF_OBJ_PIN,
4965     VKI_BPF_OBJ_GET,
4966     VKI_BPF_PROG_ATTACH,
4967     VKI_BPF_PROG_DETACH,
4968     VKI_BPF_PROG_TEST_RUN,
4969     VKI_BPF_PROG_GET_NEXT_ID,
4970     VKI_BPF_MAP_GET_NEXT_ID,
4971     VKI_BPF_PROG_GET_FD_BY_ID,
4972     VKI_BPF_MAP_GET_FD_BY_ID,
4973     VKI_BPF_OBJ_GET_INFO_BY_FD,
4974     VKI_BPF_PROG_QUERY,
4975     VKI_BPF_RAW_TRACEPOINT_OPEN,
4976     VKI_BPF_BTF_LOAD,
4977     VKI_BPF_BTF_GET_FD_BY_ID,
4978     VKI_BPF_TASK_FD_QUERY,
4979     VKI_BPF_MAP_LOOKUP_AND_DELETE_ELEM,
4980     VKI_BPF_MAP_FREEZE,
4981 };
4982 
4983 enum vki_bpf_map_type {
4984     VKI_BPF_MAP_TYPE_UNSPEC,
4985     VKI_BPF_MAP_TYPE_HASH,
4986     VKI_BPF_MAP_TYPE_ARRAY,
4987     VKI_BPF_MAP_TYPE_PROG_ARRAY,
4988     VKI_BPF_MAP_TYPE_PERF_EVENT_ARRAY,
4989     VKI_BPF_MAP_TYPE_PERCPU_HASH,
4990     VKI_BPF_MAP_TYPE_PERCPU_ARRAY,
4991     VKI_BPF_MAP_TYPE_STACK_TRACE,
4992     VKI_BPF_MAP_TYPE_CGROUP_ARRAY,
4993     VKI_BPF_MAP_TYPE_LRU_HASH,
4994     VKI_BPF_MAP_TYPE_LRU_PERCPU_HASH,
4995     VKI_BPF_MAP_TYPE_LPM_TRIE,
4996     VKI_BPF_MAP_TYPE_ARRAY_OF_MAPS,
4997     VKI_BPF_MAP_TYPE_HASH_OF_MAPS,
4998     VKI_BPF_MAP_TYPE_DEVMAP,
4999     VKI_BPF_MAP_TYPE_SOCKMAP,
5000     VKI_BPF_MAP_TYPE_CPUMAP,
5001     VKI_BPF_MAP_TYPE_XSKMAP,
5002     VKI_BPF_MAP_TYPE_SOCKHASH,
5003 };
5004 
5005 enum vki_bpf_prog_type {
5006     VKI_BPF_PROG_TYPE_UNSPEC,
5007     VKI_BPF_PROG_TYPE_SOCKET_FILTER,
5008     VKI_BPF_PROG_TYPE_KPROBE,
5009     VKI_BPF_PROG_TYPE_SCHED_CLS,
5010     VKI_BPF_PROG_TYPE_SCHED_ACT,
5011     VKI_BPF_PROG_TYPE_TRACEPOINT,
5012     VKI_BPF_PROG_TYPE_XDP,
5013     VKI_BPF_PROG_TYPE_PERF_EVENT,
5014     VKI_BPF_PROG_TYPE_CGROUP_SKB,
5015     VKI_BPF_PROG_TYPE_CGROUP_SOCK,
5016     VKI_BPF_PROG_TYPE_LWT_IN,
5017     VKI_BPF_PROG_TYPE_LWT_OUT,
5018     VKI_BPF_PROG_TYPE_LWT_XMIT,
5019     VKI_BPF_PROG_TYPE_SOCK_OPS,
5020     VKI_BPF_PROG_TYPE_SK_SKB,
5021     VKI_BPF_PROG_TYPE_CGROUP_DEVICE,
5022     VKI_BPF_PROG_TYPE_SK_MSG,
5023     VKI_BPF_PROG_TYPE_RAW_TRACEPOINT,
5024     VKI_BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
5025     VKI_BPF_PROG_TYPE_LWT_SEG6LOCAL,
5026     VKI_BPF_PROG_TYPE_LIRC_MODE2,
5027 };
5028 
5029 enum vki_bpf_attach_type {
5030     VKI_BPF_CGROUP_INET_INGRESS,
5031     VKI_BPF_CGROUP_INET_EGRESS,
5032     VKI_BPF_CGROUP_INET_SOCK_CREATE,
5033     VKI_BPF_CGROUP_SOCK_OPS,
5034     VKI_BPF_SK_SKB_STREAM_PARSER,
5035     VKI_BPF_SK_SKB_STREAM_VERDICT,
5036     VKI_BPF_CGROUP_DEVICE,
5037     VKI_BPF_SK_MSG_VERDICT,
5038     VKI_BPF_CGROUP_INET4_BIND,
5039     VKI_BPF_CGROUP_INET6_BIND,
5040     VKI_BPF_CGROUP_INET4_CONNECT,
5041     VKI_BPF_CGROUP_INET6_CONNECT,
5042     VKI_BPF_CGROUP_INET4_POST_BIND,
5043     VKI_BPF_CGROUP_INET6_POST_BIND,
5044     VKI_BPF_CGROUP_UDP4_SENDMSG,
5045     VKI_BPF_CGROUP_UDP6_SENDMSG,
5046     VKI_BPF_LIRC_MODE2,
5047     __VKI_MAX_BPF_ATTACH_TYPE
5048 };
5049 
5050 /* Specify numa node during map creation */
5051 #define VKI_BPF_F_NUMA_NODE     (1U << 2)
5052 
5053 #define VKI_BPF_OBJ_NAME_LEN 16U
5054 
5055 union vki_bpf_attr {
5056     struct { /* anonymous struct used by BPF_MAP_CREATE command */
5057         __vki_u32   map_type;   /* one of enum bpf_map_type */
5058         __vki_u32   key_size;   /* size of key in bytes */
5059         __vki_u32   value_size; /* size of value in bytes */
5060         __vki_u32   max_entries;    /* max number of entries in a map */
5061         __vki_u32   map_flags;  /* BPF_MAP_CREATE related
5062                      * flags defined above.
5063                      */
5064         __vki_u32   inner_map_fd;   /* fd pointing to the inner map */
5065         __vki_u32   numa_node;  /* numa node (effective only if
5066                      * BPF_F_NUMA_NODE is set).
5067                      */
5068         char    map_name[VKI_BPF_OBJ_NAME_LEN];
5069         __vki_u32   map_ifindex;    /* ifindex of netdev to create on */
5070         __vki_u32   btf_fd;     /* fd pointing to a BTF type data */
5071         __vki_u32   btf_key_type_id;    /* BTF type_id of the key */
5072         __vki_u32   btf_value_type_id;  /* BTF type_id of the value */
5073     };
5074 
5075     struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */
5076         __vki_u32       map_fd;
5077         __vki_aligned_u64   key;
5078         union {
5079             __vki_aligned_u64 value;
5080             __vki_aligned_u64 next_key;
5081         };
5082         __vki_u64       flags;
5083     };
5084 
5085     struct { /* anonymous struct used by BPF_PROG_LOAD command */
5086         __vki_u32       prog_type;  /* one of enum bpf_prog_type */
5087         __vki_u32       insn_cnt;
5088         __vki_aligned_u64   insns;
5089         __vki_aligned_u64   license;
5090         __vki_u32       log_level;  /* verbosity level of verifier */
5091         __vki_u32       log_size;   /* size of user buffer */
5092         __vki_aligned_u64   log_buf;    /* user supplied buffer */
5093         __vki_u32       kern_version;   /* checked when prog_type=kprobe */
5094         __vki_u32       prog_flags;
5095         char        prog_name[VKI_BPF_OBJ_NAME_LEN];
5096         __vki_u32       prog_ifindex;   /* ifindex of netdev to prep for */
5097         /* For some prog types expected attach type must be known at
5098          * load time to verify attach type specific parts of prog
5099          * (context accesses, allowed helpers, etc).
5100          */
5101         __vki_u32       expected_attach_type;
5102     };
5103 
5104     struct { /* anonymous struct used by BPF_OBJ_* commands */
5105         __vki_aligned_u64   pathname;
5106         __vki_u32       bpf_fd;
5107         __vki_u32       file_flags;
5108     };
5109 
5110     struct { /* anonymous struct used by BPF_PROG_ATTACH/DETACH commands */
5111         __vki_u32       target_fd;  /* container object to attach to */
5112         __vki_u32       attach_bpf_fd;  /* eBPF program to attach */
5113         __vki_u32       attach_type;
5114         __vki_u32       attach_flags;
5115     };
5116 
5117     struct { /* anonymous struct used by BPF_PROG_TEST_RUN command */
5118         __vki_u32       prog_fd;
5119         __vki_u32       retval;
5120         __vki_u32       data_size_in;
5121         __vki_u32       data_size_out;
5122         __vki_aligned_u64   data_in;
5123         __vki_aligned_u64   data_out;
5124         __vki_u32       repeat;
5125         __vki_u32       duration;
5126     } test;
5127 
5128     struct { /* anonymous struct used by BPF_*_GET_*_ID */
5129         union {
5130             __vki_u32       start_id;
5131             __vki_u32       prog_id;
5132             __vki_u32       map_id;
5133             __vki_u32       btf_id;
5134         };
5135         __vki_u32       next_id;
5136         __vki_u32       open_flags;
5137     };
5138 
5139     struct { /* anonymous struct used by BPF_OBJ_GET_INFO_BY_FD */
5140         __vki_u32       bpf_fd;
5141         __vki_u32       info_len;
5142         __vki_aligned_u64   info;
5143     } info;
5144 
5145     struct { /* anonymous struct used by BPF_PROG_QUERY command */
5146         __vki_u32       target_fd;  /* container object to query */
5147         __vki_u32       attach_type;
5148         __vki_u32       query_flags;
5149         __vki_u32       attach_flags;
5150         __vki_aligned_u64   prog_ids;
5151         __vki_u32       prog_cnt;
5152     } query;
5153 
5154     struct {
5155         __vki_u64 name;
5156         __vki_u32 prog_fd;
5157     } raw_tracepoint;
5158 
5159     struct { /* anonymous struct for BPF_BTF_LOAD */
5160         __vki_aligned_u64   btf;
5161         __vki_aligned_u64   btf_log_buf;
5162         __vki_u32       btf_size;
5163         __vki_u32       btf_log_size;
5164         __vki_u32       btf_log_level;
5165     };
5166 
5167     struct {
5168         __vki_u32       pid;        /* input: pid */
5169         __vki_u32       fd;     /* input: fd */
5170         __vki_u32       flags;      /* input: flags */
5171         __vki_u32       buf_len;    /* input/output: buf len */
5172         __vki_aligned_u64   buf;        /* input/output:
5173                          *   tp_name for tracepoint
5174                          *   symbol for kprobe
5175                          *   filename for uprobe
5176                          */
5177         __vki_u32       prog_id;    /* output: prod_id */
5178         __vki_u32       fd_type;    /* output: BPF_FD_TYPE_* */
5179         __vki_u64       probe_offset;   /* output: probe_offset */
5180         __vki_u64       probe_addr; /* output: probe_addr */
5181     } task_fd_query;
5182 } __attribute__((aligned(8)));
5183 
5184 #define VKI_XDP_PACKET_HEADROOM 256
5185 
5186 #define VKI_BPF_TAG_SIZE    8
5187 
5188 struct vki_bpf_prog_info {
5189     __vki_u32 type;
5190     __vki_u32 id;
5191     __vki_u8  tag[VKI_BPF_TAG_SIZE];
5192     __vki_u32 jited_prog_len;
5193     __vki_u32 xlated_prog_len;
5194     __vki_aligned_u64 jited_prog_insns;
5195     __vki_aligned_u64 xlated_prog_insns;
5196     __vki_u64 load_time;    /* ns since boottime */
5197     __vki_u32 created_by_uid;
5198     __vki_u32 nr_map_ids;
5199     __vki_aligned_u64 map_ids;
5200     char name[VKI_BPF_OBJ_NAME_LEN];
5201     __vki_u32 ifindex;
5202     __vki_u32 gpl_compatible:1;
5203     __vki_u64 netns_dev;
5204     __vki_u64 netns_ino;
5205     __vki_u32 nr_jited_ksyms;
5206     __vki_u32 nr_jited_func_lens;
5207     __vki_aligned_u64 jited_ksyms;
5208     __vki_aligned_u64 jited_func_lens;
5209 } __attribute__((aligned(8)));
5210 
5211 struct vki_bpf_map_info {
5212     __vki_u32 type;
5213     __vki_u32 id;
5214     __vki_u32 key_size;
5215     __vki_u32 value_size;
5216     __vki_u32 max_entries;
5217     __vki_u32 map_flags;
5218     char  name[VKI_BPF_OBJ_NAME_LEN];
5219     __vki_u32 ifindex;
5220     __vki_u32 :32;
5221     __vki_u64 netns_dev;
5222     __vki_u64 netns_ino;
5223     __vki_u32 btf_id;
5224     __vki_u32 btf_key_type_id;
5225     __vki_u32 btf_value_type_id;
5226 } __attribute__((aligned(8)));
5227 
5228 struct vki_bpf_btf_info {
5229     __vki_aligned_u64 btf;
5230     __vki_u32 btf_size;
5231     __vki_u32 id;
5232 } __attribute__((aligned(8)));
5233 
5234 //----------------------------------------------------------------------
5235 // From linux-5.1/include/uapi/linux/pps.h
5236 //----------------------------------------------------------------------
5237 
5238 struct vki_pps_ktime {
5239     __vki_s64 sec;
5240     __vki_s32 nsec;
5241     __vki_u32 flags;
5242 };
5243 
5244 struct vki_pps_kinfo {
5245     __vki_u32 assert_sequence;
5246     __vki_u32 clear_sequence;
5247     struct vki_pps_ktime assert_tu;
5248     struct vki_pps_ktime clear_tu;
5249     int current_mode;
5250 };
5251 
5252 struct vki_pps_kparams {
5253     int api_version;
5254     int mode;
5255     struct vki_pps_ktime assert_off_tu;
5256     struct vki_pps_ktime clear_off_tu;
5257 };
5258 
5259 struct vki_pps_fdata {
5260     struct vki_pps_kinfo info;
5261     struct vki_pps_ktime timeout;
5262 };
5263 
5264 struct vki_pps_bind_args {
5265     int tsformat;
5266     int edge;
5267     int consumer;
5268 };
5269 
5270 #define VKI_PPS_GETPARAMS   _VKI_IOR('p', 0xa1, struct vki_pps_kparams *)
5271 #define VKI_PPS_SETPARAMS   _VKI_IOW('p', 0xa2, struct vki_pps_kparams *)
5272 #define VKI_PPS_GETCAP      _VKI_IOR('p', 0xa3, int *)
5273 #define VKI_PPS_FETCH       _VKI_IOWR('p', 0xa4, struct vki_pps_fdata *)
5274 #define VKI_PPS_KC_BIND     _VKI_IOW('p', 0xa5, struct vki_pps_bind_args *)
5275 
5276 //----------------------------------------------------------------------
5277 // From linux-5.1/include/uapi/linux/ptp_clock.h
5278 //----------------------------------------------------------------------
5279 
5280 struct vki_ptp_clock_time {
5281     __vki_s64 sec;
5282     __vki_u32 nsec;
5283     __vki_u32 reserved;
5284 };
5285 
5286 struct vki_ptp_clock_caps {
5287     int max_adj;
5288     int n_alarm;
5289     int n_ext_ts;
5290     int n_per_out;
5291     int pps;
5292     int n_pins;
5293     int cross_timestamping;
5294     int rsv[13];
5295 };
5296 
5297 struct vki_ptp_extts_request {
5298     unsigned int index;
5299     unsigned int flags;
5300     unsigned int rsv[2];
5301 };
5302 
5303 struct vki_ptp_perout_request {
5304     struct vki_ptp_clock_time start;
5305     struct vki_ptp_clock_time period;
5306     unsigned int index;
5307     unsigned int flags;
5308     unsigned int rsv[4];
5309 };
5310 
5311 #define VKI_PTP_MAX_SAMPLES 25
5312 
5313 struct vki_ptp_sys_offset {
5314     unsigned int n_samples;
5315     unsigned int rsv[3];
5316     struct vki_ptp_clock_time ts[2 * VKI_PTP_MAX_SAMPLES + 1];
5317 };
5318 
5319 struct vki_ptp_sys_offset_extended {
5320     unsigned int n_samples;
5321     unsigned int rsv[3];
5322     struct vki_ptp_clock_time ts[VKI_PTP_MAX_SAMPLES][3];
5323 };
5324 
5325 struct vki_ptp_sys_offset_precise {
5326     struct vki_ptp_clock_time device;
5327     struct vki_ptp_clock_time sys_realtime;
5328     struct vki_ptp_clock_time sys_monoraw;
5329     unsigned int rsv[4];
5330 };
5331 
5332 struct vki_ptp_pin_desc {
5333     char name[64];
5334     unsigned int index;
5335     unsigned int func;
5336     unsigned int chan;
5337     unsigned int rsv[5];
5338 };
5339 
5340 #define VKI_PTP_CLOCK_GETCAPS  _VKI_IOR('=', 1, struct vki_ptp_clock_caps)
5341 #define VKI_PTP_EXTTS_REQUEST  _VKI_IOW('=', 2, struct vki_ptp_extts_request)
5342 #define VKI_PTP_PEROUT_REQUEST _VKI_IOW('=', 3, struct vki_ptp_perout_request)
5343 #define VKI_PTP_ENABLE_PPS     _VKI_IOW('=', 4, int)
5344 #define VKI_PTP_SYS_OFFSET     _VKI_IOW('=', 5, struct vki_ptp_sys_offset)
5345 #define VKI_PTP_PIN_GETFUNC    _VKI_IOWR('=', 6, struct vki_ptp_pin_desc)
5346 #define VKI_PTP_PIN_SETFUNC    _VKI_IOW('=', 7, struct vki_ptp_pin_desc)
5347 #define VKI_PTP_SYS_OFFSET_PRECISE \
5348     _VKI_IOWR('=', 8, struct vki_ptp_sys_offset_precise)
5349 #define VKI_PTP_SYS_OFFSET_EXTENDED \
5350     _VKI_IOWR('=', 9, struct vki_ptp_sys_offset_extended)
5351 
5352 /* Needed for 64bit time_t on 32bit arches.  */
5353 
5354 typedef vki_int64_t vki_time64_t;
5355 
5356 /* Note that this is the padding used by glibc, the kernel uses
5357    a 64-bit signed int, but is ignoring the upper 32 bits of the
5358    tv_nsec field.  It does always write the full struct though.
5359    So this is only needed for PRE_MEM_READ. See pre_read_timespec64. */
5360 struct vki_timespec64 {
5361    vki_time64_t tv_sec;
5362 #if defined(VKI_BIG_ENDIAN)
5363    vki_int32_t tv_pad;
5364    vki_int32_t tv_nsec;
5365 #elif defined(VKI_LITTLE_ENDIAN)
5366    vki_int32_t tv_nsec;
5367    vki_int32_t tv_pad;
5368 #else
5369 #error edit for your odd byteorder.
5370 #endif
5371 };
5372 
5373 struct vki_itimerspec64 {
5374    struct vki_timespec it_interval;
5375    struct vki_timespec it_value;
5376 };
5377 
5378 #ifndef VKI_RLIM_INFINITY
5379 #define VKI_RLIM_INFINITY (~0UL)
5380 #endif
5381 
5382 #define VKI_RLIM64_INFINITY (~0ULL)
5383 
5384 #define VKI_CLOSE_RANGE_UNSHARE (1U << 1)
5385 #define VKI_CLOSE_RANGE_CLOEXEC (1U << 2)
5386 
5387 /*--------------------------------------------------------------------*/
5388 /*--- end                                                          ---*/
5389 /*--------------------------------------------------------------------*/