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