Home | History | Annotate | Download | only in vki
      1 
      2 /*--------------------------------------------------------------------*/
      3 /*--- Darwin-specific kernel interface.               vki-darwin.h ---*/
      4 /*--------------------------------------------------------------------*/
      5 
      6 /*
      7    This file is part of Valgrind, a dynamic binary instrumentation
      8    framework.
      9 
     10    Copyright (C) 2007-2015 Apple Inc.
     11       Greg Parker  gparker (at) apple.com
     12 
     13    This program is free software; you can redistribute it and/or
     14    modify it under the terms of the GNU General Public License as
     15    published by the Free Software Foundation; either version 2 of the
     16    License, or (at your option) any later version.
     17 
     18    This program is distributed in the hope that it will be useful, but
     19    WITHOUT ANY WARRANTY; without even the implied warranty of
     20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     21    General Public License for more details.
     22 
     23    You should have received a copy of the GNU General Public License
     24    along with this program; if not, write to the Free Software
     25    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
     26    02111-1307, USA.
     27 
     28    The GNU General Public License is contained in the file COPYING.
     29 */
     30 
     31 /* Unlike vki-linux, this Darwin kernel interface includes system headers
     32    directly, to avoid copyright complexity. */
     33 
     34 #ifndef __VKI_DARWIN_H
     35 #define __VKI_DARWIN_H
     36 
     37 /* struct __darwin_ucontext isn't fully declared without
     38  * this definition.  It's crazy but there it is.  */
     39 #ifndef _XOPEN_SOURCE
     40 #define _XOPEN_SOURCE 0500
     41 #endif
     42 
     43 #include <stdint.h>
     44 
     45 #define vki_int8_t int8_t
     46 #define vki_uint8_t uint8_t
     47 #define vki_int16_t int16_t
     48 #define vki_uint16_t uint16_t
     49 #define vki_int32_t int32_t
     50 #define vki_uint32_t uint32_t
     51 #define vki_int64_t int64_t
     52 #define vki_uint64_t uint64_t
     53 #define vki_intptr_t intptr_t
     54 #define vki_uintptr_t uintptr_t
     55 
     56 #include <sys/types.h>
     57 
     58 #define vki_dev_t dev_t
     59 #define vki_mode_t mode_t
     60 #define vki_ino_t ino_t
     61 #define vki_ino64_t ino64_t
     62 #define vki_nlink_t nlink_t
     63 #define vki_uid_t uid_t
     64 #define vki_gid_t gid_t
     65 #define vki_time_t time_t
     66 #define vki_off_t off_t
     67 #define vki_blkcnt_t blkcnt_t
     68 #define vki_blksize_t blksize_t
     69 #define vki_size_t size_t
     70 #define vki_ssize_t ssize_t
     71 #define vki_pid_t pid_t
     72 #define vki_socklen_t socklen_t
     73 #define vki_suseconds_t suseconds_t
     74 #define vki_caddr_t caddr_t
     75 #define vki_u_long u_long
     76 #define vki_u_short u_short
     77 #define vki_clock_t clock_t
     78 #define vki_u_int32_t u_int32_t
     79 #define vki_u_int16_t u_int16_t
     80 #define vki_pthread_t pthread_t
     81 
     82 
     83 // valgrind special
     84 
     85 // magic mmap() flags
     86 #define	VKI_MAP_ANONYMOUS MAP_ANON	// linux synonym
     87 
     88 // fds for mmap(MAP_ANON), displayed by vmmap
     89 #define VM_TAG_VALGRIND VM_MAKE_TAG(239)  // SkAnonV
     90 
     91 // page sizes
     92 #define VKI_MAX_PAGE_SHIFT VKI_PAGE_SHIFT
     93 #define VKI_MAX_PAGE_SIZE VKI_PAGE_SIZE
     94 
     95 // types
     96 typedef uint32_t vki_u32;
     97 
     98 // linux-like ioctl flags
     99 #define _VKI_IOC_DIR(x)		((x) & IOC_DIRMASK)
    100 #define _VKI_IOC_SIZE(x)	IOCPARM_LEN(x)
    101 #define _VKI_IOC_NONE		IOC_VOID  /* GrP fixme correct? */
    102 #define _VKI_IOC_READ		IOC_OUT
    103 #define _VKI_IOC_WRITE		IOC_IN
    104 
    105 
    106 #include <malloc/malloc.h>
    107 
    108 #define vki_malloc_zone_t malloc_zone_t
    109 
    110 
    111 #include <sys/time.h>
    112 
    113 #define vki_timeval timeval
    114 #define vki_timeval32 timeval32
    115 #define vki_tv_sec tv_sec
    116 #define vki_tv_usec tv_usec
    117 #define vki_timespec timespec
    118 #define vki_itimerval itimerval
    119 #define vki_timezone timezone
    120 
    121 
    122 #include <sys/stat.h>
    123 
    124 #define	VKI_S_ISBLK(m)	S_ISBLK(m)
    125 #define	VKI_S_ISCHR(m)	S_ISCHR(m)
    126 #define	VKI_S_ISDIR(m)	S_ISDIR(m)
    127 #define	VKI_S_ISFIFO(m)	S_ISFIFO(m)
    128 #define	VKI_S_ISREG(m)	S_ISREG(m)
    129 #define	VKI_S_ISLNK(m)	S_ISLNK(m)
    130 #define	VKI_S_ISSOCK(m)	S_ISSOCK(m)
    131 #define	VKI_S_ISWHT(m)	S_ISWHT(m)
    132 #define VKI_S_ISXATTR(m) S_ISXATTR(m)
    133 
    134 #define	VKI_S_IRWXU	S_IRWXU
    135 #define	VKI_S_IRUSR	S_IRUSR
    136 #define	VKI_S_IWUSR	S_IWUSR
    137 #define	VKI_S_IXUSR	S_IXUSR
    138 #define	VKI_S_IRWXG	S_IRWXG
    139 #define	VKI_S_IRGRP	S_IRGRP
    140 #define	VKI_S_IWGRP	S_IWGRP
    141 #define	VKI_S_IXGRP	S_IXGRP
    142 #define	VKI_S_IRWXO	S_IRWXO
    143 #define	VKI_S_IROTH	S_IROTH
    144 #define	VKI_S_IWOTH	S_IWOTH
    145 #define	VKI_S_IXOTH	S_IXOTH
    146 #define	VKI_S_ISUID	S_ISUID
    147 #define	VKI_S_ISGID	S_ISGID
    148 #define	VKI_S_ISVTX	S_ISVTX
    149 
    150 #define vki_stat stat
    151 #define vki_stat64 stat64
    152 
    153 #define st_atime      st_atimespec.tv_sec
    154 #define st_atime_nsec st_atimespec.tv_nsec
    155 #define st_mtime      st_mtimespec.tv_sec
    156 #define st_mtime_nsec st_mtimespec.tv_nsec
    157 #define st_ctime      st_ctimespec.tv_sec
    158 #define st_ctime_nsec st_ctimespec.tv_nsec
    159 
    160 
    161 #include <sys/dirent.h>
    162 
    163 #define VKI_MAXNAMLEN MAXNAMLEN
    164 #define vki_dirent dirent
    165 
    166 
    167 #include <sys/socket.h>
    168 #define	VKI_SOCK_STREAM	SOCK_STREAM
    169 #define	VKI_SOCK_DGRAM	SOCK_DGRAM
    170 #define	VKI_SOCK_RAW	SOCK_RAW
    171 
    172 #define	VKI_AF_UNIX	AF_UNIX
    173 #define	VKI_AF_INET	AF_INET
    174 #define	VKI_AF_INET6	AF_INET6
    175 
    176 #define	VKI_SOL_SOCKET	SOL_SOCKET
    177 
    178 #define	VKI_SO_REUSEADDR SO_REUSEADDR
    179 
    180 #define VKI_SO_SNDBUF	SO_SNDBUF
    181 #define VKI_SO_RCVBUF	SO_RCVBUF
    182 #define VKI_SO_SNDLOWAT	SO_SNDLOWAT
    183 #define VKI_SO_RCVLOWAT	SO_RCVLOWAT
    184 #define VKI_SO_SNDTIMEO	SO_SNDTIMEO
    185 #define VKI_SO_RCVTIMEO	SO_RCVTIMEO
    186 #define	VKI_SO_ERROR	SO_ERROR
    187 #define	VKI_SO_TYPE	SO_TYPE
    188 #define VKI_SO_NREAD	SO_NREAD
    189 #define VKI_SO_NKE	SO_NKE
    190 #define VKI_SO_NOSIGPIPE	SO_NOSIGPIPE
    191 #define VKI_SO_NOADDRERR	SO_NOADDRERR
    192 #define VKI_SO_NWRITE	SO_NWRITE
    193 #define VKI_SO_LINGER_SEC	SO_LINGER_SEC
    194 
    195 #define vki_sa_family_t sa_family_t
    196 #define vki_sockaddr sockaddr
    197 #define vki_iovec iovec
    198 #define vki_msghdr msghdr
    199 #define vki_cmsghdr cmsghdr
    200 
    201 
    202 #define VKI_CMSG_ALIGN(a) 	ALIGN(a)
    203 #define	VKI_CMSG_DATA(cmsg)	CMSG_DATA(cmsg)
    204 #define	VKI_CMSG_FIRSTHDR(mhdr)	CMSG_FIRSTHDR(mhdr)
    205 #define	VKI_CMSG_NXTHDR(mhdr, cmsg)	CMSG_NXTHDR(mhdr, cmsg)
    206 
    207 #define	VKI_SCM_RIGHTS		SCM_RIGHTS
    208 #define	VKI_SCM_TIMESTAMP	SCM_TIMESTAMP
    209 #define	VKI_SCM_CREDS		SCM_CREDS
    210 
    211 
    212 #include <sys/un.h>
    213 
    214 #define vki_sockaddr_un sockaddr_un
    215 
    216 
    217 #include <netinet/in.h>
    218 
    219 #define vki_in_addr_t in_addr_t
    220 #define vki_in_port_t in_port_t
    221 #define vki_in_addr in_addr
    222 #define vki_sockaddr_in sockaddr_in
    223 
    224 #define	VKI_INADDR_LOOPBACK	INADDR_LOOPBACK
    225 
    226 
    227 // #include <netinet6/in6.h>
    228 
    229 #define vki_in6_addr in6_addr
    230 #define vki_sockaddr_in6 sockaddr_in6
    231 
    232 
    233 #include <net/if.h>
    234 
    235 #define	VKI_IFNAMSIZ	IFNAMSIZ
    236 
    237 #define vki_ifdevmtu ifdevmtu
    238 #define vki_ifreq ifreq
    239 #define vki_ifr_name 	ifr_name
    240 #define	vki_ifr_addr	ifr_addr
    241 #define	vki_ifr_dstaddr	ifr_dstaddr
    242 #define	vki_ifr_broadaddr	ifr_broadaddr
    243 #define	vki_ifr_flags	ifr_flags
    244 #define	vki_ifr_metric	ifr_metric
    245 #define	vki_ifr_mtu	ifr_mtu
    246 #define vki_ifr_phys	ifr_phys
    247 #define vki_ifr_media	ifr_media
    248 #define	vki_ifr_data	ifr_data
    249 #define vki_ifr_devmtu	ifr_devmtu
    250 #define vki_ifr_intval	ifr_intval
    251 
    252 #define vki_ifconf ifconf
    253 #define vki_ifc_buf 	ifc_buf
    254 #define vki_ifc_req 	ifc_req
    255 
    256 
    257 #include <sys/fcntl.h>
    258 
    259 #define	VKI_SEEK_SET	SEEK_SET
    260 #define	VKI_SEEK_CUR	SEEK_CUR
    261 #define	VKI_SEEK_END	SEEK_END
    262 
    263 #define	VKI_O_RDONLY	O_RDONLY
    264 #define	VKI_O_WRONLY	O_WRONLY
    265 #define	VKI_O_RDWR	O_RDWR
    266 #define	VKI_O_ACCMODE	O_ACCMODE
    267 #define	VKI_O_NONBLOCK	O_NONBLOCK
    268 #define	VKI_O_APPEND	O_APPEND
    269 #define	VKI_O_SYNC	O_SYN
    270 #define	VKI_O_SHLOCK	O_SHLOCK
    271 #define	VKI_O_EXLOCK	O_EXLOCK
    272 #define	VKI_O_ASYNC	O_ASYNC
    273 #define VKI_O_NOFOLLOW  O_NOFOLLOW
    274 #define	VKI_O_CREAT	O_CREAT
    275 #define	VKI_O_TRUNC	O_TRUNC
    276 #define	VKI_O_EXCL	O_EXCL
    277 #define	VKI_O_EVTONLY	O_EVTONLY
    278 
    279 #define	VKI_F_DUPFD	F_DUPFD
    280 #define	VKI_F_GETFD	F_GETFD
    281 #define	VKI_F_SETFD	F_SETFD
    282 #define	VKI_F_GETFL	F_GETFL
    283 #define	VKI_F_SETFL	F_SETFL
    284 #define	VKI_F_GETOWN	F_GETOWN
    285 #define VKI_F_SETOWN	F_SETOWN
    286 #define	VKI_F_GETLK	F_GETLK
    287 #define	VKI_F_SETLK	F_SETLK
    288 #define	VKI_F_SETLKW	F_SETLKW
    289 #if DARWIN_VERS >= DARWIN_10_10
    290 #define	VKI_F_SETLKWTIMEOUT F_SETLKWTIMEOUT
    291 #endif
    292 
    293 #define VKI_F_CHKCLEAN	F_CHKCLEAN
    294 #define VKI_F_PREALLOCATE	F_PREALLOCATE
    295 #define VKI_F_SETSIZE	F_SETSIZE
    296 #define VKI_F_RDADVISE	F_RDADVISE
    297 #define VKI_F_RDAHEAD	F_RDAHEAD
    298 #define VKI_F_READBOOTSTRAP	F_READBOOTSTRAP
    299 #define VKI_F_WRITEBOOTSTRAP	F_WRITEBOOTSTRAP
    300 #define VKI_F_NOCACHE	F_NOCACHE
    301 #define VKI_F_LOG2PHYS	F_LOG2PHYS
    302 #define VKI_F_GETPATH	F_GETPATH
    303 #define VKI_F_ADDSIGS	F_ADDSIGS
    304 #if DARWIN_VERS >= DARWIN_10_9
    305 # define VKI_F_ADDFILESIGS  F_ADDFILESIGS
    306 #endif
    307 #if DARWIN_VERS >= DARWIN_10_11
    308 # define VKI_F_ADDFILESIGS_FOR_DYLD_SIM  F_ADDFILESIGS_FOR_DYLD_SIM
    309 # define VKI_F_BARRIERFSYNC              F_BARRIERFSYNC
    310 # define VKI_F_ADDFILESIGS_RETURN        F_ADDFILESIGS_RETURN
    311 #endif
    312 #define VKI_F_FULLFSYNC	F_FULLFSYNC
    313 #define VKI_F_PATHPKG_CHECK	F_PATHPKG_CHECK
    314 #define VKI_F_FREEZE_FS	F_FREEZE_FS
    315 #define VKI_F_THAW_FS	F_THAW_FS
    316 #define	VKI_F_GLOBAL_NOCACHE	F_GLOBAL_NOCACHE
    317 
    318 #define VKI_FD_CLOEXEC	FD_CLOEXEC
    319 
    320 #define vki_radvisory radvisory
    321 #define vki_fstore fstore
    322 #define vki_fbootstraptransfer fbootstraptransfer
    323 #define vki_log2phys log2phys
    324 #define vki_fsignatures_t fsignatures_t
    325 
    326 // These constants aren't in a standard header, they are from the kernel code:
    327 // xnu-1228.3.13/bsd/sys/codesign.h
    328 // Mac OS X 10.5.6 - Darwin 9.6
    329 #define VKI_CS_OPS_STATUS           0       /* return status */
    330 #define VKI_CS_OPS_MARKINVALID      1       /* invalidate process */
    331 #define VKI_CS_OPS_MARKHARD         2       /* set HARD flag */
    332 #define VKI_CS_OPS_MARKKILL         3       /* set KILL flag (sticky) */
    333 #define VKI_CS_OPS_PIDPATH          4       /* get executable's pathname */
    334 #define VKI_CS_OPS_CDHASH           5       /* get code directory hash */
    335 
    336 #include <sys/mman.h>
    337 
    338 #define	VKI_PROT_NONE	PROT_NONE
    339 #define	VKI_PROT_READ	PROT_READ
    340 #define	VKI_PROT_WRITE	PROT_WRITE
    341 #define	VKI_PROT_EXEC	PROT_EXEC
    342 
    343 #define	VKI_MAP_SHARED	MAP_SHARED
    344 #define	VKI_MAP_PRIVATE	MAP_PRIVATE
    345 #define	VKI_MAP_FIXED	MAP_FIXED
    346 #define	VKI_MAP_RENAME	MAP_RENAME
    347 #define	VKI_MAP_NORESERVE	MAP_NORESERVE
    348 #define	VKI_MAP_RESERVED0080	MAP_RESERVED0080
    349 #define	VKI_MAP_NOEXTEND	MAP_NOEXTEND
    350 #define	VKI_MAP_HASSEMAPHORE	MAP_HASSEMAPHORE
    351 #define	VKI_MAP_FILE	MAP_FILE
    352 #define	VKI_MAP_ANON	MAP_ANON
    353 #define VKI_MAP_FAILED	MAP_FAILED
    354 
    355 
    356 #include <mach/vm_param.h>
    357 
    358 #define VKI_PAGE_SHIFT PAGE_SHIFT
    359 #define VKI_PAGE_SIZE PAGE_SIZE
    360 #define VKI_PAGE_MASK PAGE_MASK
    361 
    362 
    363 #include <sys/vmparam.h>
    364 
    365 #define VKI_USRSTACK USRSTACK
    366 #define VKI_USRSTACK64 USRSTACK64
    367 
    368 
    369 #include <mach/mach_time.h>
    370 
    371 #define vki_mach_timebase_info mach_timebase_info
    372 
    373 
    374 #include <sys/syslimits.h>
    375 
    376 #define VKI_PATH_MAX PATH_MAX
    377 
    378 
    379 #include <sys/param.h>
    380 
    381 #define VKI_MAXPATHLEN MAXPATHLEN
    382 
    383 
    384 #include <sys/signal.h>
    385 
    386 /* While we fully intend to make 'vki_sigset_t' match the native
    387    Darwin 'sigset_t', we can't just clone the Darwin sigset_t type,
    388    because it isn't an array, and the VG_(sigfillset) etc functions
    389    assume it is.  So instead define another isomorphic type, and check
    390    in VG_(vki_do_initial_consistency_checks) that it really is
    391    correct. */
    392 /* #define vki_sigset_t sigset_t */
    393 #define _VKI_NSIG_BPW   32
    394 #define _VKI_NSIG       32
    395 #define _VKI_NSIG_WORDS (_VKI_NSIG / _VKI_NSIG_BPW)
    396 typedef struct {
    397    UInt sig[_VKI_NSIG_WORDS];
    398 } vki_sigset_t;
    399 /* and now let VG_(vki_do_initial_consistency_checks) make sure it
    400    matches 'sigset_t'. */
    401 
    402 
    403 #define VKI_SS_ONSTACK	SS_ONSTACK
    404 #define	VKI_SS_DISABLE	SS_DISABLE
    405 #define	VKI_MINSIGSTKSZ	MINSIGSTKSZ
    406 #define	VKI_SIGSTKSZ	SIGSTKSZ
    407 
    408 #define vki_stack_t        stack_t
    409 #define vki_siginfo_t      siginfo_t
    410 
    411 /* There are two versions of this.  'struct __sigaction' is used for
    412    passing sigactions to the kernel interface, and has the added
    413    complexity of requiring an extra pointer to a new demultiplexing
    414    function to be run in user space.  'struct sigaction' is used for
    415    receiving old sigactions from the kernel, and lacks this
    416    demux-function pointer.  So the type of the second and third
    417    parameters in Darwin's sys_sigaction appear to be different,
    418    respectively 'struct __sigaction*' and 'struct sigaction*'.
    419 */
    420 //#define vki_sigaction      __sigaction
    421 //#define vki_user_sigaction sigaction
    422 //#define vki_sigaltstack    sigaltstack
    423 //#define vki_sigval         sigval
    424 //#define vki_sigaction_u    sigaction_u
    425 //#define vki_sigaction     sigaction
    426 
    427 //typedef  struct __sigaction  vki_sigaction_toK_t;
    428 //typedef  struct sigaction    vki_sigaction_fromK_t;
    429 
    430 typedef
    431    struct {
    432       void* ksa_handler;
    433       void (*sa_tramp)(void*,UWord,UWord,void*,void*);
    434       vki_sigset_t sa_mask;
    435       int sa_flags;
    436    }
    437    vki_sigaction_toK_t;
    438 
    439 typedef
    440    struct {
    441       void* ksa_handler;
    442       vki_sigset_t sa_mask;
    443       int sa_flags;
    444    }
    445    vki_sigaction_fromK_t;
    446 
    447 
    448 
    449 /* and /usr/include/sys/signal.c in turn defines 'sa_handler' to
    450    be '__sigaction_u.__sa_handler' */
    451 //#define	ksa_handler      sa_handler
    452 
    453 //#define	vki_sa_sigaction sa_sigaction
    454 
    455 #define VKI_SA_ONSTACK	SA_ONSTACK
    456 #define VKI_SA_RESTART	SA_RESTART
    457 #define	VKI_SA_DISABLE	SA_DISABLE
    458 #define	VKI_SA_RESETHAND	SA_RESETHAND
    459 #define VKI_SA_NOCLDSTOP	SA_NOCLDSTOP
    460 #define	VKI_SA_NODEFER	SA_NODEFER
    461 #define	VKI_SA_NOCLDWAIT	SA_NOCLDWAIT
    462 #define	VKI_SA_SIGINFO	SA_SIGINFO
    463 #define	VKI_SA_USERTRAMP	SA_USERTRAMP
    464 #define	VKI_SA_64REGSET	SA_64REGSET
    465 #define VKI_SA_RESTORER  0 /* Darwin doesn't have this */
    466 
    467 #define	VKI_SIG_BLOCK	SIG_BLOCK
    468 #define	VKI_SIG_UNBLOCK	SIG_UNBLOCK
    469 #define	VKI_SIG_SETMASK	SIG_SETMASK
    470 
    471 #define	VKI_SIGHUP	SIGHUP
    472 #define	VKI_SIGINT	SIGINT
    473 #define	VKI_SIGQUIT	SIGQUIT
    474 #define	VKI_SIGILL	SIGILL
    475 #define	VKI_SIGTRAP	SIGTRAP
    476 #define	VKI_SIGABRT	SIGABRT
    477 #define	VKI_SIGPOLL	SIGPOLL
    478 #define	VKI_SIGFPE	SIGFPE
    479 #define	VKI_SIGKILL	SIGKILL
    480 #define	VKI_SIGBUS	SIGBUS
    481 #define	VKI_SIGSEGV	SIGSEGV
    482 #define	VKI_SIGSYS	SIGSYS
    483 #define	VKI_SIGPIPE	SIGPIPE
    484 #define	VKI_SIGALRM	SIGALRM
    485 #define	VKI_SIGTERM	SIGTERM
    486 #define	VKI_SIGURG	SIGURG
    487 #define	VKI_SIGSTOP	SIGSTOP
    488 #define	VKI_SIGTSTP	SIGTSTP
    489 #define	VKI_SIGCONT	SIGCONT
    490 #define	VKI_SIGCHLD	SIGCHLD
    491 #define	VKI_SIGTTIN	SIGTTIN
    492 #define	VKI_SIGTTOU	SIGTTOU
    493 #define	VKI_SIGIO	SIGIO
    494 #define	VKI_SIGXCPU	SIGXCPU
    495 #define	VKI_SIGXFSZ	SIGXFSZ
    496 #define	VKI_SIGVTALRM	SIGVTALRM
    497 #define	VKI_SIGPROF	SIGPROF
    498 #define VKI_SIGWINCH	SIGWINCH
    499 #define VKI_SIGINFO	SIGINFO
    500 #define VKI_SIGUSR1	SIGUSR1
    501 #define VKI_SIGUSR2	SIGUSR2
    502 
    503 #define VKI_SIG_DFL     SIG_DFL
    504 #define VKI_SIG_IGN     SIG_IGN
    505 
    506 
    507 #define VKI_SI_USER      SI_USER
    508 #define VKI_SEGV_MAPERR  SEGV_MAPERR
    509 #define VKI_SEGV_ACCERR  SEGV_ACCERR
    510 #define VKI_ILL_ILLOPC   ILL_ILLOPC
    511 #define VKI_ILL_ILLOPN   ILL_ILLOPN
    512 #define VKI_ILL_ILLADR   ILL_ILLADR
    513 #define VKI_ILL_ILLTRP   ILL_ILLTRP
    514 #define VKI_ILL_PRVOPC   ILL_PRVOPC
    515 #define VKI_ILL_PRVREG   ILL_PRVREG
    516 #define VKI_ILL_COPROC   ILL_COPROC
    517 #define VKI_ILL_BADSTK   ILL_BADSTK
    518 #define VKI_FPE_INTDIV   FPE_INTDIV
    519 #define VKI_FPE_INTOVF   FPE_INTOVF
    520 #define VKI_FPE_FLTDIV   FPE_FLTDIV
    521 #define VKI_FPE_FLTOVF   FPE_FLTOVF
    522 #define VKI_FPE_FLTUND   FPE_FLTUND
    523 #define VKI_FPE_FLTRES   FPE_FLTRES
    524 #define VKI_FPE_FLTINV   FPE_FLTINV
    525 #define VKI_FPE_FLTSUB   FPE_FLTSUB
    526 #define VKI_BUS_ADRALN   BUS_ADRALN
    527 #define VKI_BUS_ADRERR   BUS_ADRERR
    528 #define VKI_BUS_OBJERR   BUS_OBJERR
    529 #define VKI_TRAP_BRKPT   TRAP_BRKPT
    530 
    531 /* JRS: not 100% sure, but I think these two are correct */
    532 #define VKI_SA_ONESHOT   SA_RESETHAND
    533 #define VKI_SA_NOMASK    SA_NODEFER
    534 
    535 #define VKI_UC_SET_ALT_STACK   0x40000000
    536 #define VKI_UC_RESET_ALT_STACK 0x80000000
    537 
    538 
    539 #include <sys/errno.h>
    540 
    541 #define VKI_EPERM		EPERM
    542 #define VKI_ENOENT		ENOENT
    543 #define VKI_ESRCH		ESRCH
    544 #define VKI_EINTR		EINTR
    545 #define VKI_EIO			EIO
    546 #define VKI_ENXIO		ENXIO
    547 #define VKI_E2BIG		E2BIG
    548 #define VKI_ENOEXEC		ENOEXEC
    549 #define VKI_EBADF		EBADF
    550 #define VKI_ECHILD		ECHILD
    551 #define VKI_EDEADLK		EDEADLK
    552 #define VKI_ENOMEM		ENOMEM
    553 #define VKI_EACCES		EACCES
    554 #define VKI_EFAULT		EFAULT
    555 #define VKI_ENOTBLK		ENOTBLK
    556 #define VKI_EBUSY		EBUSY
    557 #define VKI_EEXIST		EEXIST
    558 #define VKI_EXDEV		EXDEV
    559 #define VKI_ENODEV		ENODEV
    560 #define VKI_ENOTDIR		ENOTDIR
    561 #define VKI_EISDIR		EISDIR
    562 #define VKI_EINVAL		EINVAL
    563 #define VKI_ENFILE		ENFILE
    564 #define VKI_EMFILE		EMFILE
    565 #define VKI_ENOTTY		ENOTTY
    566 #define VKI_ETXTBSY		ETXTBSY
    567 #define VKI_EFBIG		EFBIG
    568 #define VKI_ENOSPC		ENOSPC
    569 #define VKI_ESPIPE		ESPIPE
    570 #define VKI_EROFS		EROFS
    571 #define VKI_EMLINK		EMLINK
    572 #define VKI_EPIPE		EPIPE
    573 #define VKI_EDOM		EDOM
    574 #define VKI_ERANGE		ERANGE
    575 #define VKI_EAGAIN		EAGAIN
    576 #define VKI_EWOULDBLOCK		EAGAIN
    577 #define VKI_EINPROGRESS		EINPROGRESS
    578 #define VKI_EALREADY		EALREADY
    579 #define VKI_ENOTSOCK		ENOTSOCK
    580 #define VKI_EDESTADDRREQ	EDESTADDRREQ
    581 #define VKI_EMSGSIZE		EMSGSIZE
    582 #define VKI_EPROTOTYPE		EPROTOTYPE
    583 #define VKI_ENOPROTOOPT		ENOPROTOOPT
    584 #define VKI_EPROTONOSUPPORT	EPROTONOSUPPORT
    585 #define VKI_ESOCKTNOSUPPORT	ESOCKTNOSUPPORT
    586 #define VKI_ENOTSUP		ENOTSUP
    587 #define VKI_EPFNOSUPPORT	EPFNOSUPPORT
    588 #define VKI_EAFNOSUPPORT	EAFNOSUPPORT
    589 #define VKI_EADDRINUSE		EADDRINUSE
    590 #define VKI_EADDRNOTAVAIL	EADDRNOTAVAIL
    591 #define VKI_ENETDOWN		ENETDOWN
    592 #define VKI_ENETUNREACH		ENETUNREACH
    593 #define VKI_ENETRESET		ENETRESET
    594 #define VKI_ECONNABORTED	ECONNABORTED
    595 #define VKI_ECONNRESET		ECONNRESET
    596 #define VKI_ENOBUFS		ENOBUFS
    597 #define VKI_EISCONN		EISCONN
    598 #define VKI_ENOTCONN		ENOTCONN
    599 #define VKI_ESHUTDOWN		ESHUTDOWN
    600 #define VKI_ETOOMANYREFS	ETOOMANYREFS
    601 #define VKI_ETIMEDOUT		ETIMEDOUT
    602 #define VKI_ECONNREFUSED	ECONNREFUSED
    603 #define VKI_ELOOP		ELOOP
    604 #define VKI_ENAMETOOLONG	ENAMETOOLONG
    605 #define VKI_EHOSTDOWN		EHOSTDOWN
    606 #define VKI_EHOSTUNREACH	EHOSTUNREACH
    607 #define VKI_ENOTEMPTY		ENOTEMPTY
    608 #define VKI_EPROCLIM		EPROCLIM
    609 #define VKI_EUSERS		EUSERS
    610 #define VKI_EDQUOT		EDQUOT
    611 #define VKI_ESTALE		ESTALE
    612 #define VKI_EREMOTE		EREMOTE
    613 #define VKI_EBADRPC		EBADRPC
    614 #define VKI_ERPCMISMATCH	ERPCMISMATCH
    615 #define VKI_EPROGUNAVAIL	EPROGUNAVAIL
    616 #define VKI_EPROGMISMATCH	EPROGMISMATCH
    617 #define VKI_EPROCUNAVAIL	EPROCUNAVAIL
    618 #define VKI_ENOLCK		ENOLCK
    619 #define VKI_ENOSYS		ENOSYS
    620 #define VKI_EFTYPE		EFTYPE
    621 #define VKI_EAUTH		EAUTH
    622 #define VKI_ENEEDAUTH		ENEEDAUTH
    623 #define VKI_EPWROFF		EPWROFF
    624 #define VKI_EDEVERR		EDEVERR
    625 #define VKI_EOVERFLOW		EOVERFLOW
    626 #define VKI_EBADEXEC		EBADEXEC
    627 #define VKI_EBADARCH		EBADARCH
    628 #define VKI_ESHLIBVERS		ESHLIBVERS
    629 #define VKI_EBADMACHO		EBADMACHO
    630 #define VKI_ECANCELED		ECANCELED
    631 #define VKI_EIDRM		EIDRM
    632 #define VKI_ENOMSG		ENOMSG
    633 #define VKI_EILSEQ		EILSEQ
    634 #define VKI_ENOATTR		ENOATTR
    635 #define VKI_EBADMSG		EBADMSG
    636 #define VKI_EMULTIHOP		EMULTIHOP
    637 #define VKI_ENODATA		ENODATA
    638 #define VKI_ENOLINK		ENOLINK
    639 #define VKI_ENOSR		ENOSR
    640 #define VKI_ENOSTR		ENOSTR
    641 #define VKI_EPROTO		EPROTO
    642 #define VKI_ETIME		ETIME
    643 #define VKI_EOPNOTSUPP		EOPNOTSUPP
    644 #define VKI_ELAST		ELAST
    645 
    646 
    647 #include <sys/resource.h>
    648 
    649 #define	VKI_RLIMIT_CPU		RLIMIT_CPU
    650 #define	VKI_RLIMIT_FSIZE	RLIMIT_FSIZE
    651 #define	VKI_RLIMIT_DATA		RLIMIT_DATA
    652 #define	VKI_RLIMIT_STACK	RLIMIT_STACK
    653 #define	VKI_RLIMIT_CORE		RLIMIT_CORE
    654 #define	VKI_RLIMIT_AS		RLIMIT_AD
    655 #define	VKI_RLIMIT_RSS		RLIMIT_AS
    656 #define	VKI_RLIMIT_MEMLOCK	RLIMIT_MEMLOCK
    657 #define	VKI_RLIMIT_NPROC	RLIMIT_NPROC
    658 #define	VKI_RLIMIT_NOFILE	RLIMIT_NOFILE
    659 #define	VKI_RLIM_NLIMITS	RLIM_NLIMITS
    660 
    661 #define vki_rlim_t rlim_t
    662 #define vki_rlimit rlimit
    663 #define vki_rusage rusage
    664 
    665 
    666 #include <sys/poll.h>
    667 
    668 #define vki_pollfd pollfd
    669 
    670 
    671 #include <sys/ipc.h>
    672 
    673 #define	VKI_IPC_RMID	IPC_RMID
    674 #define	VKI_IPC_SET	IPC_SET
    675 #define	VKI_IPC_STAT	IPC_STAT
    676 
    677 #define vki_key_t key_t
    678 #define vki_ipc_perm ipc_perm
    679 
    680 
    681 #include <sys/sem.h>
    682 
    683 #define VKI_GETNCNT	GETNCNT
    684 #define VKI_GETPID	GETPID
    685 #define VKI_GETVAL	GETVAL
    686 #define VKI_GETALL	GETALL
    687 #define VKI_GETZCNT	GETZCNT
    688 #define VKI_SETVAL	SETVAL
    689 #define VKI_SETALL	SETALL
    690 
    691 #define vki_sembuf sembuf
    692 #define vki_semid_ds semid_ds
    693 #define vki_semun semun
    694 
    695 
    696 #include <sys/semaphore.h>
    697 
    698 #define vki_sem_t sem_t
    699 
    700 
    701 #include <sys/mount.h>
    702 
    703 #define	VKI_MFSNAMELEN	MFSNAMELEN
    704 #define	VKI_MNAMELEN	MNAMELEN
    705 
    706 #define vki_fsid fsid
    707 #define vki_fsid_t fsid_t
    708 #define vki_statfs statfs
    709 #define vki_statfs64 statfs64
    710 
    711 
    712 #include <sys/select.h>
    713 
    714 #define vki_fd_set fd_set
    715 
    716 
    717 #include <sys/msgbuf.h>
    718 
    719 #define	VKI_MSG_BSIZE	MSG_BSIZE
    720 #define VKI_MSG_MAGIC	MSG_MAGIC
    721 #define vki_msgbuf msgbuf
    722 
    723 
    724 #include <sys/shm.h>
    725 
    726 #define VKI_SHM_RDONLY	SHM_RDONLY
    727 #define VKI_SHM_RND	SHM_RND
    728 #define VKI_SHMLBA	SHMLBA
    729 
    730 #define vki_shmid_ds shmid_ds
    731 
    732 
    733 #include <sys/times.h>
    734 
    735 #define vki_tms tms
    736 
    737 
    738 #include <sys/utsname.h>
    739 
    740 #define	_VKI_SYS_NAMELEN	_SYS_NAMELEN
    741 #define vki_new_utsname utsname
    742 
    743 
    744 #include <sys/unistd.h>
    745 
    746 #define	VKI_F_OK	F_OK
    747 #define	VKI_X_OK	X_OK
    748 #define	VKI_W_OK	W_OK
    749 #define	VKI_R_OK	R_OK
    750 
    751 #define vki_accessx_descriptor         accessx_descriptor
    752 #define VKI_ACCESSX_MAX_DESCRIPTORS    ACCESSX_MAX_DESCRIPTORS
    753 
    754 #include <sys/sysctl.h>
    755 
    756 #define VKI_CTL_MAXNAME		CTL_MAXNAME
    757 
    758 #define	VKI_CTL_UNSPEC		CTL_UNSPEC
    759 #define	VKI_CTL_KERN		CTL_KERN
    760 #define	VKI_CTL_VM		CTL_VM
    761 #define	VKI_CTL_VFS		CTL_VFS
    762 #define	VKI_CTL_NET		CTL_NET
    763 #define	VKI_CTL_DEBUG		CTL_DEBUG
    764 #define	VKI_CTL_HW		CTL_HW
    765 #define	VKI_CTL_MACHDEP		CTL_MACHDEP
    766 #define	VKI_CTL_USER		CTL_USER
    767 #define	VKI_CTL_MAXID		CTL_MAXID
    768 
    769 #define	VKI_HW_MACHINE		HW_MACHINE
    770 #define	VKI_HW_MODEL		HW_MODEL
    771 #define	VKI_HW_NCPU		HW_NCPU
    772 #define	VKI_HW_BYTEORDER	HW_BYTEORDER
    773 #define	VKI_HW_PHYSMEM		HW_PHYSMEM
    774 #define	VKI_HW_USERMEM		HW_USERMEM
    775 #define	VKI_HW_PAGESIZE		HW_PAGESIZE
    776 #define	VKI_HW_DISKNAMES	HW_DISKNAMES
    777 #define	VKI_HW_DISKSTATS	HW_DISKSTATS
    778 #define	VKI_HW_EPOCH  		HW_EPOCH
    779 #define VKI_HW_FLOATINGPT	HW_FLOATINGPT
    780 #define VKI_HW_MACHINE_ARCH	HW_MACHINE_ARCH
    781 #define VKI_HW_VECTORUNIT	HW_VECTORUNIT
    782 #define VKI_HW_BUS_FREQ		HW_BUS_FREQ
    783 #define VKI_HW_CPU_FREQ		HW_CPU_FREQ
    784 #define VKI_HW_CACHELINE	HW_CACHELINE
    785 #define VKI_HW_L1ICACHESIZE	HW_L1ICACHESIZE
    786 #define VKI_HW_L1DCACHESIZE	HW_L1DCACHESIZE
    787 #define VKI_HW_L2SETTINGS	HW_L2SETTINGS
    788 #define VKI_HW_L2CACHESIZE	HW_L2CACHESIZE
    789 #define VKI_HW_L3SETTINGS	HW_L3SETTINGS
    790 #define VKI_HW_L3CACHESIZE	HW_L3CACHESIZE
    791 #define VKI_HW_TB_FREQ		HW_TB_FREQ
    792 #define VKI_HW_MEMSIZE		HW_MEMSIZE
    793 #define VKI_HW_AVAILCPU		MW_AVAILCPU
    794 #define	VKI_HW_MAXID		MW_MAXID
    795 
    796 #define	VKI_KERN_USRSTACK32	KERN_USRSTACK32
    797 #define	VKI_KERN_USRSTACK64	KERN_USRSTACK64
    798 
    799 
    800 #include <sys/attr.h>
    801 
    802 #define vki_attrlist attrlist
    803 
    804 
    805 #include <sys/event.h>
    806 
    807 #define vki_kevent kevent
    808 #define vki_kevent64 kevent64_s
    809 
    810 
    811 #include <sys/ev.h>
    812 
    813 typedef struct eventreq vki_eventreq;
    814 
    815 
    816 #include <sys/acl.h>
    817 
    818 #define vki_kauth_filesec kauth_filesec
    819 
    820 
    821 #include <sys/ptrace.h>
    822 
    823 #define VKI_PTRACE_TRACEME   PT_TRACE_ME
    824 #define VKI_PTRACE_DETACH    PT_DETACH
    825 
    826 
    827 // sqlite/src/os_unix.c
    828 
    829 struct ByteRangeLockPB2
    830 {
    831     unsigned long long offset;        /* offset to first byte to lock */
    832     unsigned long long length;        /* nbr of bytes to lock */
    833     unsigned long long retRangeStart; /* nbr of 1st byte locked if successful */
    834     unsigned char unLockFlag;         /* 1 = unlock, 0 = lock */
    835     unsigned char startEndFlag;       /* 1=rel to end of fork, 0=rel to start */
    836     int fd;                           /* file desc to assoc this lock with */
    837 };
    838 
    839 #define afpfsByteRangeLock2FSCTL _IOWR('z', 23, struct ByteRangeLockPB2)
    840 
    841 #define vki_ByteRangeLockPB2 ByteRangeLockPB2
    842 #define VKI_afpfsByteRangeLock2FSCTL afpfsByteRangeLock2FSCTL
    843 
    844 
    845 // xnu/bsd/sys/fsctl.h
    846 
    847 #define VKI_FSIOC_SYNC_VOLUME        _IOW('A', 1, uint32_t)
    848 
    849 
    850 // Libc/pthreads/pthread.c
    851 
    852 #define VKI_WQOPS_QUEUE_ADD          1
    853 #define VKI_WQOPS_QUEUE_REMOVE       2
    854 #define VKI_WQOPS_THREAD_RETURN      4
    855 #define VKI_WQOPS_THREAD_SETCONC     8
    856 #define VKI_WQOPS_QUEUE_NEWSPISUPP  16  /* check for newer SPI support */
    857 #define VKI_WQOPS_QUEUE_REQTHREADS  32  /* request number of threads of a prio */
    858 
    859 
    860 #include <sys/ttycom.h>
    861 
    862 #define vki_winsize winsize
    863 
    864 #define	VKI_TIOCMODG	TIOCMODG
    865 #define	VKI_TIOCMODS	TIOCMODS
    866 #define	VKI_TIOCEXCL	TIOCEXCL
    867 #define	VKI_TIOCNXCL	TIOCNXCL
    868 #define	VKI_TIOCFLUSH	TIOCFLUSH
    869 #define	VKI_TIOCGETA	TIOCGETA
    870 #define	VKI_TIOCSETA	TIOCSETA
    871 #define	VKI_TIOCSETAW	TIOCSETAW
    872 #define	VKI_TIOCSETAF	TIOCSETAF
    873 #define	VKI_TIOCGETD	TIOCGETD
    874 #define	VKI_TIOCSETD	TIOCSETD
    875 #define	VKI_TIOCSBRK	TIOCSBRK
    876 #define	VKI_TIOCCBRK	TIOCCBRK
    877 #define	VKI_TIOCSDTR	TIOCSDTR
    878 #define	VKI_TIOCCDTR	TIOCCDTR
    879 #define	VKI_TIOCGPGRP	TIOCGPGRP
    880 #define	VKI_TIOCSPGRP	TIOCSPGRP
    881 #define	VKI_TIOCOUTQ	TIOCOUTQ
    882 #define	VKI_TIOCSTI	TIOCSTI
    883 #define	VKI_TIOCNOTTY	TIOCNOTTY
    884 #define	VKI_TIOCPKT	TIOCPKT
    885 #define	VKI_TIOCSTOP	TIOCSTOP
    886 #define	VKI_TIOCSTART	TIOCSTART
    887 #define	VKI_TIOCMSET	TIOCMSET
    888 #define	VKI_TIOCMBIS	TIOCMBIS
    889 #define	VKI_TIOCMBIC	TIOCMBIC
    890 #define	VKI_TIOCMGET	TIOCMGET
    891 #define	VKI_TIOCREMOTE	TIOCREMOTE
    892 #define	VKI_TIOCGWINSZ	TIOCGWINSZ
    893 #define	VKI_TIOCSWINSZ	TIOCSWINSZ
    894 #define	VKI_TIOCUCNTL	TIOCUCNTL
    895 #define	VKI_TIOCSTAT	TIOCSTAT
    896 #define	VKI_UIOCCMD(n)	UIOCCMD(n)
    897 #define	VKI_TIOCSCONS	TIOCSCONS
    898 #define	VKI_TIOCCONS	TIOCCONS
    899 #define	VKI_TIOCSCTTY	TIOCSCTTY
    900 #define	VKI_TIOCEXT	TIOCEXT
    901 #define	VKI_TIOCSIG	TIOCSIG
    902 #define	VKI_TIOCDRAIN	TIOCDRAIN
    903 #define	VKI_TIOCMSDTRWAIT	TIOCMSDTRWAIT
    904 #define	VKI_TIOCMGDTRWAIT	TIOCMGDTRWAIT
    905 #define	VKI_TIOCTIMESTAMP	TIOCTIMESTAMP
    906 #define	VKI_TIOCDCDTIMESTAMP	TIOCDCDTIMESTAMP
    907 #define	VKI_TIOCSDRAINWAIT	TIOCSDRAINWAIT
    908 #define	VKI_TIOCGDRAINWAIT	TIOCGDRAINWAIT
    909 #define	VKI_TIOCDSIMICROCODE	TIOCDSIMICROCODE
    910 #define VKI_TIOCPTYGRANT	TIOCPTYGRANT
    911 #define VKI_TIOCPTYGNAME	TIOCPTYGNAME
    912 #define VKI_TIOCPTYUNLK	TIOCPTYUNLK
    913 
    914 
    915 #include <sys/filio.h>
    916 
    917 #define	VKI_FIOCLEX	FIOCLEX
    918 #define	VKI_FIONCLEX	FIONCLEX
    919 #define	VKI_FIONREAD	FIONREAD
    920 #define	VKI_FIONBIO	FIONBIO
    921 #define	VKI_FIOASYNC	FIOASYNC
    922 #define	VKI_FIOSETOWN	FIOSETOWN
    923 #define	VKI_FIOGETOWN	FIOGETOWN
    924 #define	VKI_FIODTYPE	FIODTYPE
    925 
    926 
    927 #include <sys/sockio.h>
    928 
    929 #define	VKI_SIOCSHIWAT	SIOCSHIWAT
    930 #define	VKI_SIOCGHIWAT	SIOCGHIWAT
    931 #define	VKI_SIOCSLOWAT	SIOCSLOWAT
    932 #define	VKI_SIOCGLOWAT	SIOCGLOWAT
    933 #define	VKI_SIOCATMARK	SIOCATMARK
    934 #define	VKI_SIOCSPGRP	SIOCSPGRP
    935 #define	VKI_SIOCGPGRP	SIOCGPGRP
    936 
    937 #define	VKI_SIOCSIFADDR		SIOCSIFADDR
    938 #define	VKI_OSIOCGIFADDR	OSIOCGIFADDR
    939 #define	VKI_SIOCSIFDSTADDR	SIOCSIFDSTADDR
    940 #define	VKI_OSIOCGIFDSTADDR	OSIOCGIFDSTADDR
    941 #define	VKI_SIOCSIFFLAGS	SIOCSIFFLAGS
    942 #define	VKI_SIOCGIFFLAGS	SIOCGIFFLAGS
    943 #define	VKI_OSIOCGIFBRDADDR	OSIOCGIFBRDADDR
    944 #define	VKI_SIOCSIFBRDADDR	SIOCSIFBRDADDR
    945 #define	VKI_OSIOCGIFCONF	OSIOCGIFCONF
    946 #define	VKI_OSIOCGIFNETMASK	OSIOCGIFNETMASK
    947 #define	VKI_SIOCSIFNETMASK	SIOCSIFNETMASK
    948 #define	VKI_SIOCGIFMETRIC	SIOCGIFMETRIC
    949 #define	VKI_SIOCSIFMETRIC	SIOCSIFMETRIC
    950 #define	VKI_SIOCDIFADDR		SIOCDIFADDR
    951 #define	VKI_SIOCAIFADDR		SIOCAIFADDR
    952 #define	VKI_SIOCGETVIFCNT	SIOCGETVIFCNT
    953 #define	VKI_SIOCGETSGCNT	SIOCGETSGCNT
    954 #define VKI_SIOCALIFADDR	SIOCALIFADDR
    955 #define VKI_SIOCGLIFADDR	SIOCGLIFADDR
    956 #define VKI_SIOCDLIFADDR	SIOCDLIFADDR
    957 
    958 #define	VKI_SIOCGIFADDR		SIOCGIFADDR
    959 #define	VKI_SIOCGIFDSTADDR	SIOCGIFDSTADDR
    960 #define	VKI_SIOCGIFBRDADDR	SIOCGIFBRDADDR
    961 #define	VKI_SIOCGIFCONF		SIOCGIFCONF
    962 #define	VKI_SIOCGIFNETMASK	SIOCGIFNETMASK
    963 #define VKI_SIOCAUTOADDR	SIOCAUTOADDR
    964 #define VKI_SIOCAUTONETMASK	SIOCAUTONETMASK
    965 #define VKI_SIOCARPIPLL		SIOCARPIPLL
    966 
    967 #define	VKI_SIOCADDMULTI	SIOCADDMULTI
    968 #define	VKI_SIOCDELMULTI	SIOCDELMULTI
    969 #define	VKI_SIOCGIFMTU		SIOCGIFMTU
    970 #define	VKI_SIOCSIFMTU	 	SIOCSIFMTU
    971 #define	VKI_SIOCGIFPHYS		SIOCGIFPHYS
    972 #define	VKI_SIOCSIFPHYS	 	SIOCSIFPHYS
    973 #define	VKI_SIOCSIFMEDIA	SIOCSIFMEDIA
    974 #define	VKI_SIOCGIFMEDIA	SIOCGIFMEDIA
    975 #define	VKI_SIOCSIFGENERIC	SIOCSIFGENERIC
    976 #define	VKI_SIOCGIFGENERIC	SIOCGIFGENERIC
    977 #define VKI_SIOCRSLVMULTI   	SIOCRSLVMULTI
    978 
    979 #define	VKI_SIOCSIFLLADDR	SIOCSIFLLADDR
    980 #define	VKI_SIOCGIFSTATUS	SIOCGIFSTATUS
    981 #define	VKI_SIOCSIFPHYADDR   	SIOCSIFPHYADDR
    982 #define	VKI_SIOCGIFPSRCADDR	SIOCGIFPSRCADDR
    983 #define	VKI_SIOCGIFPDSTADDR	SIOCGIFPDSTADDR
    984 #define	VKI_SIOCDIFPHYADDR	SIOCDIFPHYADDR
    985 #define	VKI_SIOCSLIFPHYADDR	SIOCSLIFPHYADDR
    986 #define	VKI_SIOCGLIFPHYADDR	SIOCGLIFPHYADDR
    987 
    988 #define	VKI_SIOCGIFDEVMTU	SIOCGIFDEVMTU
    989 #define	VKI_SIOCSIFALTMTU	SIOCSIFALTMTU
    990 #define VKI_SIOCGIFALTMTU	SIOCGIFALTMTU
    991 #define VKI_SIOCSIFBOND	 	SIOCSIFBOND
    992 #define VKI_SIOCGIFBOND		SIOCGIFBOND
    993 #define	VKI_SIOCIFCREATE	SIOCIFCREATE
    994 #define	VKI_SIOCIFDESTROY	SIOCIFDESTROY
    995 #define	VKI_SIOCSIFVLAN	 	SIOCSIFVLAN
    996 #define	VKI_SIOCGIFVLAN		SIOCGIFVLAN
    997 
    998 #define	VKI_SIOCSETVLAN		SIOCSIFVLAN
    999 #define	VKI_SIOCGETVLAN		SIOCGIFVLAN
   1000 
   1001 #define	VKI_SIOCGIFASYNCMAP 	SIOCGIFASYNCMAP
   1002 #define	VKI_SIOCSIFASYNCMAP 	SIOCSIGASYNCMAP
   1003 
   1004 
   1005 #include <sys/dtrace.h>
   1006 
   1007 #define VKI_DTRACEHIOC_REMOVE   DTRACEHIOC_REMOVE
   1008 #define VKI_DTRACEHIOC_ADDDOF   DTRACEHIOC_ADDDOF
   1009 
   1010 
   1011 #include <net/bpf.h>
   1012 
   1013 #define vki_bpf_program bpf_program
   1014 #define vki_bf_len bf_len
   1015 #define vki_bf_insns bf_insns
   1016 #define vki_bpf_dltlist bpf_dltlist
   1017 #define vki_bfl_len bfl_len
   1018 #define vki_bfl_list bfl_list
   1019 
   1020 #define VKI_BIOCSETF        BIOCSETF
   1021 #define VKI_BIOCFLUSH       BIOCFLUSH
   1022 #define VKI_BIOCPROMISC     BIOCPROMISC
   1023 #define VKI_BIOCSETIF       BIOCSETIF
   1024 #define VKI_BIOCSRTIMEOUT   BIOCSRTIMEOUT
   1025 #define VKI_BIOCGDLTLIST    BIOCGDLTLIST
   1026 
   1027 
   1028 #include <sys/ucontext.h>
   1029 
   1030 /* quite why sys/ucontext.h provides a 'struct __darwin_ucontext'
   1031    but no 'struct ucontext' beats me. -- JRS */
   1032 #define vki_ucontext __darwin_ucontext
   1033 
   1034 
   1035 #include <sys/termios.h>
   1036 
   1037 #define vki_termios termios
   1038 
   1039 
   1040 #include <uuid/uuid.h>
   1041 
   1042 #define vki_uuid_t uuid_t
   1043 
   1044 
   1045 #include <bsm/audit.h>
   1046 
   1047 #define	VKI_A_GETPOLICY	A_GETPOLICY
   1048 #define	VKI_A_SETPOLICY	A_SETPOLICY
   1049 #define	VKI_A_GETKMASK	A_GETKMASK
   1050 #define	VKI_A_SETKMASK	A_SETKMASK
   1051 #define	VKI_A_GETQCTRL	A_GETQCTRL
   1052 #define	VKI_A_SETQCTRL	A_SETQCTRL
   1053 #define	VKI_A_GETCWD	A_GETCWD
   1054 #define	VKI_A_GETCAR	A_GETCAR
   1055 #define	VKI_A_GETSTAT	A_GETSTAT
   1056 #define	VKI_A_SETSTAT	A_SETSTAT
   1057 #define	VKI_A_SETUMASK	A_SETUMASK
   1058 #define	VKI_A_SETSMASK	A_SETSMASK
   1059 #define	VKI_A_GETCOND	A_GETCOND
   1060 #define	VKI_A_SETCOND	A_SETCOND
   1061 #define	VKI_A_GETCLASS	A_GETCLASS
   1062 #define	VKI_A_SETCLASS	A_SETCLASS
   1063 #define	VKI_A_GETPINFO	A_GETPINFO
   1064 #define	VKI_A_SETPMASK	A_SETPMASK
   1065 #define	VKI_A_SETFSIZE	A_SETFSIZE
   1066 #define	VKI_A_GETFSIZE	A_GETFSIZE
   1067 #define	VKI_A_GETPINFO_ADDR	A_GETPINFO_ADDR
   1068 #define	VKI_A_GETKAUDIT	A_GETKAUDIT
   1069 #define	VKI_A_SETKAUDIT	A_SETKAUDIT
   1070 #if DARWIN_VERS >= DARWIN_10_6
   1071 #define VKI_A_SENDTRIGGER A_SENDTRIGGER
   1072 #define VKI_A_GETSINFO_ADDR A_GETSINFO_ADDR
   1073 #endif
   1074 
   1075 
   1076 #include <sys/aio.h>
   1077 
   1078 #define vki_aiocb aiocb
   1079 
   1080 
   1081 #include <netinet/tcp.h>
   1082 
   1083 #define VKI_TCP_NODELAY  TCP_NODELAY
   1084 
   1085 
   1086 #include <netinet/in.h>
   1087 
   1088 #define VKI_IPPROTO_TCP  IPPROTO_TCP
   1089 
   1090 
   1091 // XXX: for some reason when I #include <sys/kernel_types.h> I get a syntax
   1092 // error.  Hmm.  So just define things ourselves.
   1093 //#include <sys/kernel_types.h>
   1094 
   1095 //#define vki_errno_t
   1096 typedef int vki_errno_t;
   1097 
   1098 
   1099 /* necp stuff.  This doesn't appear to exist in any user space include
   1100    file. */
   1101 #if DARWIN_VERS == DARWIN_10_10
   1102 struct vki_necp_aggregate_result {
   1103    vki_u_int32_t field1;
   1104    unsigned int  field2;
   1105    vki_u_int32_t field3;
   1106    vki_u_int32_t field4;
   1107    vki_uuid_t    field5;
   1108    u_int32_t     field6;
   1109    u_int32_t     field7;
   1110 };
   1111 #endif /* DARWIN_VERS == DARWIN_10_10 */
   1112 
   1113 
   1114 #endif
   1115