vki-darwin.h 31 KB

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