Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-03 09:32:23

0001 
0002 /*--------------------------------------------------------------------*/
0003 /*--- Darwin-specific kernel interface.               vki-darwin.h ---*/
0004 /*--------------------------------------------------------------------*/
0005 
0006 /*
0007    This file is part of Valgrind, a dynamic binary instrumentation
0008    framework.
0009 
0010    Copyright (C) 2007-2017 Apple Inc.
0011       Greg Parker  gparker@apple.com
0012 
0013    This program is free software; you can redistribute it and/or
0014    modify it under the terms of the GNU General Public License as
0015    published by the Free Software Foundation; either version 3 of the
0016    License, or (at your option) any later version.
0017 
0018    This program is distributed in the hope that it will be useful, but
0019    WITHOUT ANY WARRANTY; without even the implied warranty of
0020    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0021    General Public License for more details.
0022 
0023    You should have received a copy of the GNU General Public License
0024    along with this program; if not, see <http://www.gnu.org/licenses/>.
0025 
0026    The GNU General Public License is contained in the file COPYING.
0027 */
0028 
0029 /* Unlike vki-linux, this Darwin kernel interface includes system headers
0030    directly, to avoid copyright complexity. */
0031 
0032 #ifndef __VKI_DARWIN_H
0033 #define __VKI_DARWIN_H
0034 
0035 /* struct __darwin_ucontext isn't fully declared without
0036  * this definition.  It's crazy but there it is.  */
0037 #ifndef _XOPEN_SOURCE
0038 #define _XOPEN_SOURCE 0500
0039 #endif
0040 
0041 #include <stdint.h>
0042 
0043 #define vki_int8_t int8_t
0044 #define vki_uint8_t uint8_t
0045 #define vki_int16_t int16_t
0046 #define vki_uint16_t uint16_t
0047 #define vki_int32_t int32_t
0048 #define vki_uint32_t uint32_t
0049 #define vki_int64_t int64_t
0050 #define vki_uint64_t uint64_t
0051 #define vki_intptr_t intptr_t
0052 #define vki_uintptr_t uintptr_t
0053 
0054 #include <sys/types.h>
0055 
0056 #define vki_dev_t dev_t
0057 #define vki_mode_t mode_t
0058 #define vki_ino_t ino_t
0059 #define vki_ino64_t ino64_t
0060 #define vki_nlink_t nlink_t
0061 #define vki_uid_t uid_t
0062 #define vki_gid_t gid_t
0063 #define vki_time_t time_t
0064 #define vki_off_t off_t
0065 #define vki_blkcnt_t blkcnt_t
0066 #define vki_blksize_t blksize_t
0067 #define vki_size_t size_t
0068 #define vki_ssize_t ssize_t
0069 #define vki_pid_t pid_t
0070 #define vki_socklen_t socklen_t
0071 #define vki_suseconds_t suseconds_t
0072 #define vki_caddr_t caddr_t
0073 #define vki_u_long u_long
0074 #define vki_u_short u_short
0075 #define vki_clock_t clock_t
0076 #define vki_u_int32_t u_int32_t
0077 #define vki_u_int16_t u_int16_t
0078 #define vki_pthread_t pthread_t
0079 
0080 
0081 // valgrind special
0082 
0083 // magic mmap() flags
0084 #define VKI_MAP_ANONYMOUS MAP_ANON  // linux synonym
0085 
0086 // See xnu/osfmk/mach/vm_statistics.h
0087 #define VKI_VM_MEMORY_MALLOC 1
0088 #define VKI_VM_MEMORY_MALLOC_SMALL 2
0089 #define VKI_VM_MEMORY_MALLOC_LARGE 3
0090 #define VKI_VM_MEMORY_MALLOC_HUGE 4
0091 #define VKI_VM_MEMORY_BRK 5
0092 #define VKI_VM_MEMORY_REALLOC 6
0093 #define VKI_VM_MEMORY_MALLOC_TINY 7
0094 #define VKI_VM_MEMORY_MALLOC_LARGE_REUSABLE 8
0095 #define VKI_VM_MEMORY_MALLOC_LARGE_REUSED 9
0096 #define VKI_VM_MEMORY_ANALYSIS_TOOL 10
0097 #define VKI_VM_MEMORY_MALLOC_NANO 11
0098 #define VKI_VM_MEMORY_MALLOC_MEDIUM 12
0099 #define VKI_VM_MEMORY_MALLOC_PROB_GUARD 13
0100 #define VKI_VM_MEMORY_MACH_MSG 20
0101 #define VKI_VM_MEMORY_IOKIT 21
0102 #define VKI_VM_MEMORY_STACK 30
0103 #define VKI_VM_MEMORY_GUARD  31
0104 #define VKI_VM_MEMORY_SHARED_PMAP 32
0105 #define VKI_VM_MEMORY_DYLIB 33
0106 #define VKI_VM_MEMORY_OBJC_DISPATCHERS 34
0107 #define VKI_VM_MEMORY_UNSHARED_PMAP 35
0108 #define VKI_VM_MEMORY_APPKIT 40
0109 #define VKI_VM_MEMORY_FOUNDATION 41
0110 #define VKI_VM_MEMORY_COREGRAPHICS 42
0111 #define VKI_VM_MEMORY_CORESERVICES 43
0112 #define VKI_VM_MEMORY_JAVA 44
0113 #define VKI_VM_MEMORY_COREDATA 45
0114 #define VKI_VM_MEMORY_COREDATA_OBJECTIDS 46
0115 #define VKI_VM_MEMORY_ATS 50
0116 #define VKI_VM_MEMORY_LAYERKIT 51
0117 #define VKI_VM_MEMORY_CGIMAGE 52
0118 #define VKI_VM_MEMORY_TCMALLOC 53
0119 #define VKI_VM_MEMORY_COREGRAPHICS_DATA     54
0120 #define VKI_VM_MEMORY_COREGRAPHICS_SHARED   55
0121 #define VKI_VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS     56
0122 #define VKI_VM_MEMORY_COREGRAPHICS_BACKINGSTORES    57
0123 #define VKI_VM_MEMORY_COREGRAPHICS_XALLOC 58
0124 #define VKI_VM_MEMORY_DYLD 60
0125 #define VKI_VM_MEMORY_DYLD_MALLOC 61
0126 #define VKI_VM_MEMORY_SQLITE 62
0127 #define VKI_VM_MEMORY_JAVASCRIPT_CORE 63
0128 #define VKI_VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR 64
0129 #define VKI_VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE 65
0130 #define VKI_VM_MEMORY_GLSL  66
0131 #define VKI_VM_MEMORY_OPENCL    67
0132 #define VKI_VM_MEMORY_COREIMAGE 68
0133 #define VKI_VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS 69
0134 #define VKI_VM_MEMORY_IMAGEIO       70
0135 #define VKI_VM_MEMORY_COREPROFILE   71
0136 #define VKI_VM_MEMORY_ASSETSD       72
0137 #define VKI_VM_MEMORY_OS_ALLOC_ONCE 73
0138 #define VKI_VM_MEMORY_LIBDISPATCH 74
0139 #define VKI_VM_MEMORY_ACCELERATE 75
0140 #define VKI_VM_MEMORY_COREUI 76
0141 #define VKI_VM_MEMORY_COREUIFILE 77
0142 #define VKI_VM_MEMORY_GENEALOGY 78
0143 #define VKI_VM_MEMORY_RAWCAMERA 79
0144 #define VKI_VM_MEMORY_CORPSEINFO 80
0145 #define VKI_VM_MEMORY_ASL 81
0146 #define VKI_VM_MEMORY_SWIFT_RUNTIME 82
0147 #define VKI_VM_MEMORY_SWIFT_METADATA 83
0148 #define VKI_VM_MEMORY_DHMM 84
0149 #define VKI_VM_MEMORY_SCENEKIT 86
0150 #define VKI_VM_MEMORY_SKYWALK 87
0151 #define VKI_VM_MEMORY_IOSURFACE 88
0152 #define VKI_VM_MEMORY_LIBNETWORK 89
0153 #define VKI_VM_MEMORY_AUDIO 90
0154 #define VKI_VM_MEMORY_VIDEOBITSTREAM 91
0155 #define VKI_VM_MEMORY_CM_XPC 92
0156 #define VKI_VM_MEMORY_CM_RPC 93
0157 #define VKI_VM_MEMORY_CM_MEMORYPOOL 94
0158 #define VKI_VM_MEMORY_CM_READCACHE 95
0159 #define VKI_VM_MEMORY_CM_CRABS 96
0160 #define VKI_VM_MEMORY_QUICKLOOK_THUMBNAILS 97
0161 #define VKI_VM_MEMORY_ACCOUNTS 98
0162 #define VKI_VM_MEMORY_SANITIZER 99
0163 #define VKI_VM_MEMORY_IOACCELERATOR 100
0164 #define VKI_VM_MEMORY_CM_REGWARP 101
0165 #define VKI_VM_MEMORY_EAR_DECODER 102
0166 #define VKI_VM_MEMORY_COREUI_CACHED_IMAGE_DATA 103
0167 #define VKI_VM_MEMORY_COLORSYNC 104
0168 #define VKI_VM_MEMORY_BTINFO 105
0169 #define VKI_VM_MEMORY_CM_HLS 106
0170 #define VKI_VM_MEMORY_ROSETTA 230
0171 #define VKI_VM_MEMORY_ROSETTA_THREAD_CONTEXT 231
0172 #define VKI_VM_MEMORY_ROSETTA_INDIRECT_BRANCH_MAP 232
0173 #define VKI_VM_MEMORY_ROSETTA_RETURN_STACK 233
0174 #define VKI_VM_MEMORY_ROSETTA_EXECUTABLE_HEAP 234
0175 #define VKI_VM_MEMORY_ROSETTA_USER_LDT 235
0176 #define VKI_VM_MEMORY_ROSETTA_ARENA 236
0177 #define VKI_VM_MEMORY_ROSETTA_10 239
0178 #define VKI_VM_MEMORY_APPLICATION_SPECIFIC_1 240
0179 #define VKI_VM_MEMORY_VALGRIND 242
0180 #define VKI_VM_MEMORY_APPLICATION_SPECIFIC_16 255
0181 
0182 // fds for mmap(MAP_ANON), displayed by vmmap
0183 #define VM_TAG_VALGRIND VM_MAKE_TAG(VKI_VM_MEMORY_VALGRIND)  // SkAnonV
0184 
0185 // page sizes
0186 #define VKI_MAX_PAGE_SHIFT VKI_PAGE_SHIFT
0187 #define VKI_MAX_PAGE_SIZE VKI_PAGE_SIZE
0188 
0189 // pthread
0190 #define VKI_PTHREAD_START_CUSTOM 0x01000000
0191 
0192 // types
0193 typedef uint32_t vki_u32;
0194 
0195 // linux-like ioctl flags
0196 #define _VKI_IOC_DIR(x)     ((x) & IOC_DIRMASK)
0197 #define _VKI_IOC_SIZE(x)    IOCPARM_LEN(x)
0198 #define _VKI_IOC_NONE       IOC_VOID  /* GrP fixme correct? */
0199 #define _VKI_IOC_READ       IOC_OUT
0200 #define _VKI_IOC_WRITE      IOC_IN
0201 
0202 
0203 #include <malloc/malloc.h>
0204 
0205 #define vki_malloc_zone_t malloc_zone_t
0206 
0207 
0208 #include <sys/time.h>
0209 
0210 #define vki_timeval timeval
0211 #define vki_timeval32 timeval32
0212 #define vki_tv_sec tv_sec
0213 #define vki_tv_usec tv_usec
0214 #define vki_timespec timespec
0215 #define vki_itimerval itimerval
0216 #define vki_timezone timezone
0217 
0218 
0219 #include <sys/stat.h>
0220 
0221 #define VKI_S_ISBLK(m)  S_ISBLK(m)
0222 #define VKI_S_ISCHR(m)  S_ISCHR(m)
0223 #define VKI_S_ISDIR(m)  S_ISDIR(m)
0224 #define VKI_S_ISFIFO(m) S_ISFIFO(m)
0225 #define VKI_S_ISREG(m)  S_ISREG(m)
0226 #define VKI_S_ISLNK(m)  S_ISLNK(m)
0227 #define VKI_S_ISSOCK(m) S_ISSOCK(m)
0228 #define VKI_S_ISWHT(m)  S_ISWHT(m)
0229 #define VKI_S_ISXATTR(m) S_ISXATTR(m)
0230 
0231 #define VKI_S_IRWXU S_IRWXU
0232 #define VKI_S_IRUSR S_IRUSR
0233 #define VKI_S_IWUSR S_IWUSR
0234 #define VKI_S_IXUSR S_IXUSR
0235 #define VKI_S_IRWXG S_IRWXG
0236 #define VKI_S_IRGRP S_IRGRP
0237 #define VKI_S_IWGRP S_IWGRP
0238 #define VKI_S_IXGRP S_IXGRP
0239 #define VKI_S_IRWXO S_IRWXO
0240 #define VKI_S_IROTH S_IROTH
0241 #define VKI_S_IWOTH S_IWOTH
0242 #define VKI_S_IXOTH S_IXOTH
0243 #define VKI_S_ISUID S_ISUID
0244 #define VKI_S_ISGID S_ISGID
0245 #define VKI_S_ISVTX S_ISVTX
0246 
0247 #define vki_stat stat
0248 #define vki_stat64 stat64
0249 
0250 #define st_atime      st_atimespec.tv_sec
0251 #define st_atime_nsec st_atimespec.tv_nsec
0252 #define st_mtime      st_mtimespec.tv_sec
0253 #define st_mtime_nsec st_mtimespec.tv_nsec
0254 #define st_ctime      st_ctimespec.tv_sec
0255 #define st_ctime_nsec st_ctimespec.tv_nsec
0256 
0257 
0258 #include <sys/dirent.h>
0259 
0260 #define VKI_MAXNAMLEN MAXNAMLEN
0261 #define vki_dirent dirent
0262 
0263 
0264 #include <sys/socket.h>
0265 #define VKI_SOCK_STREAM SOCK_STREAM
0266 #define VKI_SOCK_DGRAM  SOCK_DGRAM
0267 #define VKI_SOCK_RAW    SOCK_RAW
0268 
0269 #define VKI_AF_UNIX AF_UNIX
0270 #define VKI_AF_INET AF_INET
0271 #define VKI_AF_INET6    AF_INET6
0272 
0273 #define VKI_SOL_SOCKET  SOL_SOCKET
0274 
0275 #define VKI_SO_REUSEADDR SO_REUSEADDR
0276 
0277 #define VKI_SO_SNDBUF   SO_SNDBUF
0278 #define VKI_SO_RCVBUF   SO_RCVBUF
0279 #define VKI_SO_SNDLOWAT SO_SNDLOWAT
0280 #define VKI_SO_RCVLOWAT SO_RCVLOWAT
0281 #define VKI_SO_SNDTIMEO SO_SNDTIMEO
0282 #define VKI_SO_RCVTIMEO SO_RCVTIMEO
0283 #define VKI_SO_ERROR    SO_ERROR
0284 #define VKI_SO_TYPE SO_TYPE
0285 #define VKI_SO_NREAD    SO_NREAD
0286 #define VKI_SO_NKE  SO_NKE
0287 #define VKI_SO_NOSIGPIPE    SO_NOSIGPIPE
0288 #define VKI_SO_NOADDRERR    SO_NOADDRERR
0289 #define VKI_SO_NWRITE   SO_NWRITE
0290 #define VKI_SO_LINGER_SEC   SO_LINGER_SEC
0291 
0292 #define vki_sa_family_t sa_family_t
0293 #define vki_sockaddr sockaddr
0294 #define vki_iovec iovec
0295 #define vki_msghdr msghdr
0296 #define vki_cmsghdr cmsghdr
0297 
0298 
0299 #define VKI_CMSG_ALIGN(a)   __DARWIN_ALIGN32(a)
0300 #define VKI_CMSG_DATA(cmsg) CMSG_DATA(cmsg)
0301 #define VKI_CMSG_FIRSTHDR(mhdr) CMSG_FIRSTHDR(mhdr)
0302 #define VKI_CMSG_NXTHDR(mhdr, cmsg) CMSG_NXTHDR(mhdr, cmsg)
0303 
0304 #define VKI_SCM_RIGHTS      SCM_RIGHTS
0305 #define VKI_SCM_TIMESTAMP   SCM_TIMESTAMP
0306 #define VKI_SCM_CREDS       SCM_CREDS
0307 
0308 
0309 #include <sys/un.h>
0310 
0311 #define vki_sockaddr_un sockaddr_un
0312 
0313 
0314 #include <netinet/in.h>
0315 
0316 #define vki_in_addr_t in_addr_t
0317 #define vki_in_port_t in_port_t
0318 #define vki_in_addr in_addr
0319 #define vki_sockaddr_in sockaddr_in
0320 
0321 #define VKI_INADDR_LOOPBACK INADDR_LOOPBACK
0322 
0323 
0324 // #include <netinet6/in6.h>
0325 
0326 #define vki_in6_addr in6_addr
0327 #define vki_sockaddr_in6 sockaddr_in6
0328 
0329 
0330 #include <net/if.h>
0331 
0332 #define VKI_IFNAMSIZ    IFNAMSIZ
0333 
0334 #define vki_ifdevmtu ifdevmtu
0335 #define vki_ifreq ifreq
0336 #define vki_ifr_name    ifr_name
0337 #define vki_ifr_addr    ifr_addr
0338 #define vki_ifr_dstaddr ifr_dstaddr
0339 #define vki_ifr_broadaddr   ifr_broadaddr
0340 #define vki_ifr_flags   ifr_flags
0341 #define vki_ifr_metric  ifr_metric
0342 #define vki_ifr_mtu ifr_mtu
0343 #define vki_ifr_phys    ifr_phys
0344 #define vki_ifr_media   ifr_media
0345 #define vki_ifr_data    ifr_data
0346 #define vki_ifr_devmtu  ifr_devmtu
0347 #define vki_ifr_intval  ifr_intval
0348 
0349 #define vki_ifconf ifconf
0350 #define vki_ifc_buf     ifc_buf
0351 #define vki_ifc_req     ifc_req
0352 
0353 
0354 #include <sys/fcntl.h>
0355 
0356 #define VKI_SEEK_SET    SEEK_SET
0357 #define VKI_SEEK_CUR    SEEK_CUR
0358 #define VKI_SEEK_END    SEEK_END
0359 
0360 #define VKI_O_RDONLY    O_RDONLY
0361 #define VKI_O_WRONLY    O_WRONLY
0362 #define VKI_O_RDWR  O_RDWR
0363 #define VKI_O_ACCMODE   O_ACCMODE
0364 #define VKI_O_NONBLOCK  O_NONBLOCK
0365 #define VKI_O_APPEND    O_APPEND
0366 #define VKI_O_SYNC  O_SYN
0367 #define VKI_O_SHLOCK    O_SHLOCK
0368 #define VKI_O_EXLOCK    O_EXLOCK
0369 #define VKI_O_ASYNC O_ASYNC
0370 #define VKI_O_NOFOLLOW  O_NOFOLLOW
0371 #define VKI_O_CREAT O_CREAT
0372 #define VKI_O_TRUNC O_TRUNC
0373 #define VKI_O_EXCL  O_EXCL
0374 #define VKI_O_EVTONLY   O_EVTONLY
0375 
0376 #define VKI_AT_FDCWD AT_FDCWD
0377 
0378 #define VKI_F_DUPFD F_DUPFD
0379 #define VKI_F_GETFD F_GETFD
0380 #define VKI_F_SETFD F_SETFD
0381 #define VKI_F_GETFL F_GETFL
0382 #define VKI_F_SETFL F_SETFL
0383 #define VKI_F_GETOWN    F_GETOWN
0384 #define VKI_F_SETOWN    F_SETOWN
0385 #define VKI_F_GETLK F_GETLK
0386 #define VKI_F_SETLK F_SETLK
0387 #define VKI_F_SETLKW    F_SETLKW
0388 #if DARWIN_VERS >= DARWIN_10_10
0389 #define VKI_F_SETLKWTIMEOUT F_SETLKWTIMEOUT
0390 #endif
0391 
0392 #define VKI_F_CHKCLEAN  F_CHKCLEAN
0393 #define VKI_F_PREALLOCATE   F_PREALLOCATE
0394 #define VKI_F_SETSIZE   F_SETSIZE
0395 #define VKI_F_RDADVISE  F_RDADVISE
0396 #define VKI_F_RDAHEAD   F_RDAHEAD
0397 #define VKI_F_READBOOTSTRAP F_READBOOTSTRAP
0398 #define VKI_F_WRITEBOOTSTRAP    F_WRITEBOOTSTRAP
0399 #define VKI_F_NOCACHE   F_NOCACHE
0400 #define VKI_F_LOG2PHYS  F_LOG2PHYS
0401 #define VKI_F_GETPATH   F_GETPATH
0402 #define VKI_F_ADDSIGS   F_ADDSIGS
0403 #if DARWIN_VERS >= DARWIN_10_9
0404 # define VKI_F_ADDFILESIGS  F_ADDFILESIGS
0405 #endif
0406 #if DARWIN_VERS >= DARWIN_10_11
0407 # define VKI_F_ADDFILESIGS_FOR_DYLD_SIM  F_ADDFILESIGS_FOR_DYLD_SIM
0408 # define VKI_F_BARRIERFSYNC              F_BARRIERFSYNC
0409 # define VKI_F_ADDFILESIGS_RETURN        F_ADDFILESIGS_RETURN
0410 #endif
0411 #if DARWIN_VERS >= DARWIN_10_14
0412 # define VKI_F_CHECK_LV                  F_CHECK_LV
0413 #endif
0414 #if DARWIN_VERS >= DARWIN_10_15
0415 # define VKI_F_SPECULATIVE_READ          F_SPECULATIVE_READ
0416 #endif
0417 #define VKI_F_FULLFSYNC F_FULLFSYNC
0418 #define VKI_F_PATHPKG_CHECK F_PATHPKG_CHECK
0419 #define VKI_F_FREEZE_FS F_FREEZE_FS
0420 #define VKI_F_THAW_FS   F_THAW_FS
0421 #define VKI_F_GLOBAL_NOCACHE    F_GLOBAL_NOCACHE
0422 #if defined(F_GETPROTECTIONCLASS)
0423 #define VKI_F_GETPROTECTIONCLASS F_GETPROTECTIONCLASS
0424 #endif
0425 
0426 #define VKI_FD_CLOEXEC  FD_CLOEXEC
0427 
0428 #define vki_radvisory radvisory
0429 #define vki_fstore fstore
0430 #define vki_fbootstraptransfer fbootstraptransfer
0431 #define vki_log2phys log2phys
0432 #define vki_fsignatures_t fsignatures_t
0433 
0434 // These constants aren't in a standard header, they are from the kernel code:
0435 // xnu-1228.3.13/bsd/sys/codesign.h
0436 // Mac OS X 10.5.6 - Darwin 9.6
0437 #define VKI_CS_OPS_STATUS           0       /* return status */
0438 #define VKI_CS_OPS_MARKINVALID      1       /* invalidate process */
0439 #define VKI_CS_OPS_MARKHARD         2       /* set HARD flag */
0440 #define VKI_CS_OPS_MARKKILL         3       /* set KILL flag (sticky) */
0441 #define VKI_CS_OPS_PIDPATH          4       /* get executable's pathname */
0442 #define VKI_CS_OPS_CDHASH           5       /* get code directory hash */
0443 
0444 #include <sys/mman.h>
0445 
0446 #define VKI_PROT_NONE   PROT_NONE
0447 #define VKI_PROT_READ   PROT_READ
0448 #define VKI_PROT_WRITE  PROT_WRITE
0449 #define VKI_PROT_EXEC   PROT_EXEC
0450 
0451 #define VKI_MAP_SHARED  MAP_SHARED
0452 #define VKI_MAP_PRIVATE MAP_PRIVATE
0453 #define VKI_MAP_FIXED   MAP_FIXED
0454 #define VKI_MAP_RENAME  MAP_RENAME
0455 #define VKI_MAP_NORESERVE   MAP_NORESERVE
0456 #define VKI_MAP_RESERVED0080    MAP_RESERVED0080
0457 #define VKI_MAP_NOEXTEND    MAP_NOEXTEND
0458 #define VKI_MAP_HASSEMAPHORE    MAP_HASSEMAPHORE
0459 #if DARWIN_VERS >= DARWIN_11_00
0460 #define VKI_MAP_NOCACHE MAP_NOCACHE
0461 #define VKI_MAP_JIT MAP_JIT
0462 #endif
0463 #define VKI_MAP_FILE    MAP_FILE
0464 #define VKI_MAP_ANON    MAP_ANON
0465 #define VKI_MAP_FAILED  MAP_FAILED
0466 
0467 
0468 #include <mach/vm_param.h>
0469 
0470 #define VKI_PAGE_SHIFT PAGE_SHIFT
0471 #define VKI_PAGE_SIZE PAGE_SIZE
0472 #define VKI_PAGE_MASK PAGE_MASK
0473 
0474 
0475 #include <sys/vmparam.h>
0476 
0477 #define VKI_USRSTACK USRSTACK
0478 #define VKI_USRSTACK64 USRSTACK64
0479 
0480 
0481 #include <mach/mach_time.h>
0482 
0483 #define vki_mach_timebase_info mach_timebase_info
0484 
0485 
0486 #include <sys/syslimits.h>
0487 
0488 #define VKI_PATH_MAX PATH_MAX
0489 
0490 
0491 #include <sys/param.h>
0492 
0493 #define VKI_MAXPATHLEN MAXPATHLEN
0494 
0495 
0496 #include <sys/signal.h>
0497 
0498 /* While we fully intend to make 'vki_sigset_t' match the native
0499    Darwin 'sigset_t', we can't just clone the Darwin sigset_t type,
0500    because it isn't an array, and the VG_(sigfillset) etc functions
0501    assume it is.  So instead define another isomorphic type, and check
0502    in VG_(vki_do_initial_consistency_checks) that it really is
0503    correct. */
0504 /* #define vki_sigset_t sigset_t */
0505 #define _VKI_NSIG_BPW   32
0506 #define _VKI_NSIG       32
0507 #define _VKI_NSIG_WORDS (_VKI_NSIG / _VKI_NSIG_BPW)
0508 typedef struct {
0509    UInt sig[_VKI_NSIG_WORDS];
0510 } vki_sigset_t;
0511 /* and now let VG_(vki_do_initial_consistency_checks) make sure it
0512    matches 'sigset_t'. */
0513 
0514 
0515 #define VKI_SS_ONSTACK  SS_ONSTACK
0516 #define VKI_SS_DISABLE  SS_DISABLE
0517 #define VKI_MINSIGSTKSZ MINSIGSTKSZ
0518 #define VKI_SIGSTKSZ    SIGSTKSZ
0519 
0520 #define vki_stack_t        stack_t
0521 #define vki_siginfo_t      siginfo_t
0522 
0523 /* There are two versions of this.  'struct __sigaction' is used for
0524    passing sigactions to the kernel interface, and has the added
0525    complexity of requiring an extra pointer to a new demultiplexing
0526    function to be run in user space.  'struct sigaction' is used for
0527    receiving old sigactions from the kernel, and lacks this
0528    demux-function pointer.  So the type of the second and third
0529    parameters in Darwin's sys_sigaction appear to be different,
0530    respectively 'struct __sigaction*' and 'struct sigaction*'.
0531 */
0532 //#define vki_sigaction      __sigaction
0533 //#define vki_user_sigaction sigaction
0534 //#define vki_sigaltstack    sigaltstack
0535 //#define vki_sigval         sigval
0536 //#define vki_sigaction_u    sigaction_u
0537 //#define vki_sigaction     sigaction
0538 
0539 //typedef  struct __sigaction  vki_sigaction_toK_t;
0540 //typedef  struct sigaction    vki_sigaction_fromK_t;
0541 
0542 #define VKI_UC_TRAD        1
0543 #define VKI_UC_FLAVOR     30
0544 
0545 typedef
0546    struct {
0547       void* ksa_handler;
0548       void (*sa_tramp)(void*,UWord,UWord,void*,void*);
0549       vki_sigset_t sa_mask;
0550       int sa_flags;
0551    }
0552    vki_sigaction_toK_t;
0553 
0554 typedef
0555    struct {
0556       void* ksa_handler;
0557       vki_sigset_t sa_mask;
0558       int sa_flags;
0559    }
0560    vki_sigaction_fromK_t;
0561 
0562 
0563 
0564 /* and /usr/include/sys/signal.c in turn defines 'sa_handler' to
0565    be '__sigaction_u.__sa_handler' */
0566 //#define   ksa_handler      sa_handler
0567 
0568 //#define   vki_sa_sigaction sa_sigaction
0569 
0570 #define VKI_SA_ONSTACK  SA_ONSTACK
0571 #define VKI_SA_RESTART  SA_RESTART
0572 #define VKI_SA_DISABLE  SA_DISABLE
0573 #define VKI_SA_RESETHAND    SA_RESETHAND
0574 #define VKI_SA_NOCLDSTOP    SA_NOCLDSTOP
0575 #define VKI_SA_NODEFER  SA_NODEFER
0576 #define VKI_SA_NOCLDWAIT    SA_NOCLDWAIT
0577 #define VKI_SA_SIGINFO  SA_SIGINFO
0578 #define VKI_SA_USERTRAMP    SA_USERTRAMP
0579 #define VKI_SA_64REGSET SA_64REGSET
0580 #define VKI_SA_RESTORER  0 /* Darwin doesn't have this */
0581 
0582 #define VKI_SIG_BLOCK   SIG_BLOCK
0583 #define VKI_SIG_UNBLOCK SIG_UNBLOCK
0584 #define VKI_SIG_SETMASK SIG_SETMASK
0585 
0586 #define VKI_SIGHUP  SIGHUP
0587 #define VKI_SIGINT  SIGINT
0588 #define VKI_SIGQUIT SIGQUIT
0589 #define VKI_SIGILL  SIGILL
0590 #define VKI_SIGTRAP SIGTRAP
0591 #define VKI_SIGABRT SIGABRT
0592 #define VKI_SIGPOLL SIGPOLL
0593 #define VKI_SIGFPE  SIGFPE
0594 #define VKI_SIGKILL SIGKILL
0595 #define VKI_SIGBUS  SIGBUS
0596 #define VKI_SIGSEGV SIGSEGV
0597 #define VKI_SIGSYS  SIGSYS
0598 #define VKI_SIGPIPE SIGPIPE
0599 #define VKI_SIGALRM SIGALRM
0600 #define VKI_SIGTERM SIGTERM
0601 #define VKI_SIGURG  SIGURG
0602 #define VKI_SIGSTOP SIGSTOP
0603 #define VKI_SIGTSTP SIGTSTP
0604 #define VKI_SIGCONT SIGCONT
0605 #define VKI_SIGCHLD SIGCHLD
0606 #define VKI_SIGTTIN SIGTTIN
0607 #define VKI_SIGTTOU SIGTTOU
0608 #define VKI_SIGIO   SIGIO
0609 #define VKI_SIGXCPU SIGXCPU
0610 #define VKI_SIGXFSZ SIGXFSZ
0611 #define VKI_SIGVTALRM   SIGVTALRM
0612 #define VKI_SIGPROF SIGPROF
0613 #define VKI_SIGWINCH    SIGWINCH
0614 #define VKI_SIGINFO SIGINFO
0615 #define VKI_SIGUSR1 SIGUSR1
0616 #define VKI_SIGUSR2 SIGUSR2
0617 
0618 #define VKI_SIG_DFL     SIG_DFL
0619 #define VKI_SIG_IGN     SIG_IGN
0620 
0621 
0622 #define VKI_SI_USER      SI_USER
0623 #define VKI_SEGV_MAPERR  SEGV_MAPERR
0624 #define VKI_SEGV_ACCERR  SEGV_ACCERR
0625 #define VKI_ILL_ILLOPC   ILL_ILLOPC
0626 #define VKI_ILL_ILLOPN   ILL_ILLOPN
0627 #define VKI_ILL_ILLADR   ILL_ILLADR
0628 #define VKI_ILL_ILLTRP   ILL_ILLTRP
0629 #define VKI_ILL_PRVOPC   ILL_PRVOPC
0630 #define VKI_ILL_PRVREG   ILL_PRVREG
0631 #define VKI_ILL_COPROC   ILL_COPROC
0632 #define VKI_ILL_BADSTK   ILL_BADSTK
0633 #define VKI_FPE_INTDIV   FPE_INTDIV
0634 #define VKI_FPE_INTOVF   FPE_INTOVF
0635 #define VKI_FPE_FLTDIV   FPE_FLTDIV
0636 #define VKI_FPE_FLTOVF   FPE_FLTOVF
0637 #define VKI_FPE_FLTUND   FPE_FLTUND
0638 #define VKI_FPE_FLTRES   FPE_FLTRES
0639 #define VKI_FPE_FLTINV   FPE_FLTINV
0640 #define VKI_FPE_FLTSUB   FPE_FLTSUB
0641 #define VKI_BUS_ADRALN   BUS_ADRALN
0642 #define VKI_BUS_ADRERR   BUS_ADRERR
0643 #define VKI_BUS_OBJERR   BUS_OBJERR
0644 #define VKI_TRAP_BRKPT   TRAP_BRKPT
0645 #define VKI_CLD_EXITED   CLD_EXITED
0646 #define VKI_CLD_KILLED   CLD_KILLED
0647 #define VKI_CLD_DUMPED   CLD_DUMPED
0648 #define VKI_CLD_TRAPPED  CLD_TRAPPED
0649 #define VKI_CLD_STOPPED  CLD_STOPPED
0650 #define VKI_CLD_CONTINUED CLD_CONTINUED
0651 
0652 /* JRS: not 100% sure, but I think these two are correct */
0653 #define VKI_SA_ONESHOT   SA_RESETHAND
0654 #define VKI_SA_NOMASK    SA_NODEFER
0655 
0656 #define VKI_UC_SET_ALT_STACK   0x40000000
0657 #define VKI_UC_RESET_ALT_STACK 0x80000000
0658 
0659 
0660 #include <sys/errno.h>
0661 
0662 #define VKI_EPERM       EPERM
0663 #define VKI_ENOENT      ENOENT
0664 #define VKI_ESRCH       ESRCH
0665 #define VKI_EINTR       EINTR
0666 #define VKI_EIO         EIO
0667 #define VKI_ENXIO       ENXIO
0668 #define VKI_E2BIG       E2BIG
0669 #define VKI_ENOEXEC     ENOEXEC
0670 #define VKI_EBADF       EBADF
0671 #define VKI_ECHILD      ECHILD
0672 #define VKI_EDEADLK     EDEADLK
0673 #define VKI_ENOMEM      ENOMEM
0674 #define VKI_EACCES      EACCES
0675 #define VKI_EFAULT      EFAULT
0676 #define VKI_ENOTBLK     ENOTBLK
0677 #define VKI_EBUSY       EBUSY
0678 #define VKI_EEXIST      EEXIST
0679 #define VKI_EXDEV       EXDEV
0680 #define VKI_ENODEV      ENODEV
0681 #define VKI_ENOTDIR     ENOTDIR
0682 #define VKI_EISDIR      EISDIR
0683 #define VKI_EINVAL      EINVAL
0684 #define VKI_ENFILE      ENFILE
0685 #define VKI_EMFILE      EMFILE
0686 #define VKI_ENOTTY      ENOTTY
0687 #define VKI_ETXTBSY     ETXTBSY
0688 #define VKI_EFBIG       EFBIG
0689 #define VKI_ENOSPC      ENOSPC
0690 #define VKI_ESPIPE      ESPIPE
0691 #define VKI_EROFS       EROFS
0692 #define VKI_EMLINK      EMLINK
0693 #define VKI_EPIPE       EPIPE
0694 #define VKI_EDOM        EDOM
0695 #define VKI_ERANGE      ERANGE
0696 #define VKI_EAGAIN      EAGAIN
0697 #define VKI_EWOULDBLOCK     EAGAIN
0698 #define VKI_EINPROGRESS     EINPROGRESS
0699 #define VKI_EALREADY        EALREADY
0700 #define VKI_ENOTSOCK        ENOTSOCK
0701 #define VKI_EDESTADDRREQ    EDESTADDRREQ
0702 #define VKI_EMSGSIZE        EMSGSIZE
0703 #define VKI_EPROTOTYPE      EPROTOTYPE
0704 #define VKI_ENOPROTOOPT     ENOPROTOOPT
0705 #define VKI_EPROTONOSUPPORT EPROTONOSUPPORT
0706 #define VKI_ESOCKTNOSUPPORT ESOCKTNOSUPPORT
0707 #define VKI_ENOTSUP     ENOTSUP
0708 #define VKI_EPFNOSUPPORT    EPFNOSUPPORT
0709 #define VKI_EAFNOSUPPORT    EAFNOSUPPORT
0710 #define VKI_EADDRINUSE      EADDRINUSE
0711 #define VKI_EADDRNOTAVAIL   EADDRNOTAVAIL
0712 #define VKI_ENETDOWN        ENETDOWN
0713 #define VKI_ENETUNREACH     ENETUNREACH
0714 #define VKI_ENETRESET       ENETRESET
0715 #define VKI_ECONNABORTED    ECONNABORTED
0716 #define VKI_ECONNRESET      ECONNRESET
0717 #define VKI_ENOBUFS     ENOBUFS
0718 #define VKI_EISCONN     EISCONN
0719 #define VKI_ENOTCONN        ENOTCONN
0720 #define VKI_ESHUTDOWN       ESHUTDOWN
0721 #define VKI_ETOOMANYREFS    ETOOMANYREFS
0722 #define VKI_ETIMEDOUT       ETIMEDOUT
0723 #define VKI_ECONNREFUSED    ECONNREFUSED
0724 #define VKI_ELOOP       ELOOP
0725 #define VKI_ENAMETOOLONG    ENAMETOOLONG
0726 #define VKI_EHOSTDOWN       EHOSTDOWN
0727 #define VKI_EHOSTUNREACH    EHOSTUNREACH
0728 #define VKI_ENOTEMPTY       ENOTEMPTY
0729 #define VKI_EPROCLIM        EPROCLIM
0730 #define VKI_EUSERS      EUSERS
0731 #define VKI_EDQUOT      EDQUOT
0732 #define VKI_ESTALE      ESTALE
0733 #define VKI_EREMOTE     EREMOTE
0734 #define VKI_EBADRPC     EBADRPC
0735 #define VKI_ERPCMISMATCH    ERPCMISMATCH
0736 #define VKI_EPROGUNAVAIL    EPROGUNAVAIL
0737 #define VKI_EPROGMISMATCH   EPROGMISMATCH
0738 #define VKI_EPROCUNAVAIL    EPROCUNAVAIL
0739 #define VKI_ENOLCK      ENOLCK
0740 #define VKI_ENOSYS      ENOSYS
0741 #define VKI_EFTYPE      EFTYPE
0742 #define VKI_EAUTH       EAUTH
0743 #define VKI_ENEEDAUTH       ENEEDAUTH
0744 #define VKI_EPWROFF     EPWROFF
0745 #define VKI_EDEVERR     EDEVERR
0746 #define VKI_EOVERFLOW       EOVERFLOW
0747 #define VKI_EBADEXEC        EBADEXEC
0748 #define VKI_EBADARCH        EBADARCH
0749 #define VKI_ESHLIBVERS      ESHLIBVERS
0750 #define VKI_EBADMACHO       EBADMACHO
0751 #define VKI_ECANCELED       ECANCELED
0752 #define VKI_EIDRM       EIDRM
0753 #define VKI_ENOMSG      ENOMSG
0754 #define VKI_EILSEQ      EILSEQ
0755 #define VKI_ENOATTR     ENOATTR
0756 #define VKI_EBADMSG     EBADMSG
0757 #define VKI_EMULTIHOP       EMULTIHOP
0758 #define VKI_ENODATA     ENODATA
0759 #define VKI_ENOLINK     ENOLINK
0760 #define VKI_ENOSR       ENOSR
0761 #define VKI_ENOSTR      ENOSTR
0762 #define VKI_EPROTO      EPROTO
0763 #define VKI_ETIME       ETIME
0764 #define VKI_EOPNOTSUPP      EOPNOTSUPP
0765 #define VKI_ELAST       ELAST
0766 
0767 
0768 #include <sys/resource.h>
0769 
0770 #define VKI_RLIMIT_CPU      RLIMIT_CPU
0771 #define VKI_RLIMIT_FSIZE    RLIMIT_FSIZE
0772 #define VKI_RLIMIT_DATA     RLIMIT_DATA
0773 #define VKI_RLIMIT_STACK    RLIMIT_STACK
0774 #define VKI_RLIMIT_CORE     RLIMIT_CORE
0775 #define VKI_RLIMIT_AS       RLIMIT_AD
0776 #define VKI_RLIMIT_RSS      RLIMIT_AS
0777 #define VKI_RLIMIT_MEMLOCK  RLIMIT_MEMLOCK
0778 #define VKI_RLIMIT_NPROC    RLIMIT_NPROC
0779 #define VKI_RLIMIT_NOFILE   RLIMIT_NOFILE
0780 #define VKI_RLIM_NLIMITS    RLIM_NLIMITS
0781 
0782 #define vki_rlim_t rlim_t
0783 #define vki_rlimit rlimit
0784 #define vki_rusage rusage
0785 
0786 
0787 #include <sys/poll.h>
0788 
0789 #define vki_pollfd pollfd
0790 
0791 
0792 #include <sys/ipc.h>
0793 
0794 #define VKI_IPC_RMID    IPC_RMID
0795 #define VKI_IPC_SET IPC_SET
0796 #define VKI_IPC_STAT    IPC_STAT
0797 
0798 #define vki_key_t key_t
0799 #define vki_ipc_perm ipc_perm
0800 
0801 
0802 #include <sys/sem.h>
0803 
0804 #define VKI_GETNCNT GETNCNT
0805 #define VKI_GETPID  GETPID
0806 #define VKI_GETVAL  GETVAL
0807 #define VKI_GETALL  GETALL
0808 #define VKI_GETZCNT GETZCNT
0809 #define VKI_SETVAL  SETVAL
0810 #define VKI_SETALL  SETALL
0811 
0812 #define vki_sembuf sembuf
0813 #define vki_semid_ds semid_ds
0814 #define vki_semun semun
0815 
0816 
0817 #include <sys/semaphore.h>
0818 
0819 #define vki_sem_t sem_t
0820 
0821 
0822 #include <sys/mount.h>
0823 
0824 #define VKI_MFSNAMELEN  MFSNAMELEN
0825 #define VKI_MNAMELEN    MNAMELEN
0826 
0827 #define vki_fsid fsid
0828 #define vki_fsid_t fsid_t
0829 #define vki_statfs statfs
0830 #define vki_statfs64 statfs64
0831 
0832 
0833 #include <sys/select.h>
0834 
0835 #define vki_fd_set fd_set
0836 
0837 
0838 #include <sys/msgbuf.h>
0839 
0840 #define VKI_MSG_BSIZE   MSG_BSIZE
0841 #define VKI_MSG_MAGIC   MSG_MAGIC
0842 #define vki_msgbuf msgbuf
0843 
0844 
0845 #include <sys/shm.h>
0846 
0847 #define VKI_SHM_RDONLY  SHM_RDONLY
0848 #define VKI_SHM_RND SHM_RND
0849 #define VKI_SHMLBA  SHMLBA
0850 
0851 #define vki_shmid_ds shmid_ds
0852 
0853 
0854 #include <sys/times.h>
0855 
0856 #define vki_tms tms
0857 
0858 
0859 #include <sys/utsname.h>
0860 
0861 #define _VKI_SYS_NAMELEN    _SYS_NAMELEN
0862 #define vki_new_utsname utsname
0863 
0864 
0865 #include <sys/unistd.h>
0866 
0867 #define VKI_F_OK    F_OK
0868 #define VKI_X_OK    X_OK
0869 #define VKI_W_OK    W_OK
0870 #define VKI_R_OK    R_OK
0871 
0872 #define vki_accessx_descriptor         accessx_descriptor
0873 #define VKI_ACCESSX_MAX_DESCRIPTORS    ACCESSX_MAX_DESCRIPTORS
0874 
0875 #include <sys/sysctl.h>
0876 
0877 #define VKI_CTL_MAXNAME     CTL_MAXNAME
0878 
0879 #define VKI_CTL_UNSPEC      CTL_UNSPEC
0880 #define VKI_CTL_KERN        CTL_KERN
0881 #define VKI_CTL_VM      CTL_VM
0882 #define VKI_CTL_VFS     CTL_VFS
0883 #define VKI_CTL_NET     CTL_NET
0884 #define VKI_CTL_DEBUG       CTL_DEBUG
0885 #define VKI_CTL_HW      CTL_HW
0886 #define VKI_CTL_MACHDEP     CTL_MACHDEP
0887 #define VKI_CTL_USER        CTL_USER
0888 #define VKI_CTL_MAXID       CTL_MAXID
0889 
0890 #define VKI_HW_MACHINE      HW_MACHINE
0891 #define VKI_HW_MODEL        HW_MODEL
0892 #define VKI_HW_NCPU     HW_NCPU
0893 #define VKI_HW_BYTEORDER    HW_BYTEORDER
0894 #define VKI_HW_PHYSMEM      HW_PHYSMEM
0895 #define VKI_HW_USERMEM      HW_USERMEM
0896 #define VKI_HW_PAGESIZE     HW_PAGESIZE
0897 #define VKI_HW_DISKNAMES    HW_DISKNAMES
0898 #define VKI_HW_DISKSTATS    HW_DISKSTATS
0899 #define VKI_HW_EPOCH        HW_EPOCH
0900 #define VKI_HW_FLOATINGPT   HW_FLOATINGPT
0901 #define VKI_HW_MACHINE_ARCH HW_MACHINE_ARCH
0902 #define VKI_HW_VECTORUNIT   HW_VECTORUNIT
0903 #define VKI_HW_BUS_FREQ     HW_BUS_FREQ
0904 #define VKI_HW_CPU_FREQ     HW_CPU_FREQ
0905 #define VKI_HW_CACHELINE    HW_CACHELINE
0906 #define VKI_HW_L1ICACHESIZE HW_L1ICACHESIZE
0907 #define VKI_HW_L1DCACHESIZE HW_L1DCACHESIZE
0908 #define VKI_HW_L2SETTINGS   HW_L2SETTINGS
0909 #define VKI_HW_L2CACHESIZE  HW_L2CACHESIZE
0910 #define VKI_HW_L3SETTINGS   HW_L3SETTINGS
0911 #define VKI_HW_L3CACHESIZE  HW_L3CACHESIZE
0912 #define VKI_HW_TB_FREQ      HW_TB_FREQ
0913 #define VKI_HW_MEMSIZE      HW_MEMSIZE
0914 #define VKI_HW_AVAILCPU     MW_AVAILCPU
0915 #define VKI_HW_MAXID        MW_MAXID
0916 
0917 #define VKI_KERN_USRSTACK32 KERN_USRSTACK32
0918 #define VKI_KERN_USRSTACK64 KERN_USRSTACK64
0919 
0920 
0921 #include <sys/attr.h>
0922 
0923 #define vki_attrlist attrlist
0924 
0925 
0926 #include <sys/event.h>
0927 
0928 #define vki_kevent kevent
0929 #define vki_kevent64 kevent64_s
0930 
0931 // xnu_root/bsd/sys/event.h
0932 
0933 struct vki_kevent_qos_s {
0934     uint64_t    ident;      /* identifier for this event */
0935     int16_t     filter;     /* filter for event */
0936     uint16_t    flags;      /* general flags */
0937     int32_t     qos;        /* quality of service */
0938     uint64_t    udata;      /* opaque user data identifier */
0939     uint32_t    fflags;     /* filter-specific flags */
0940     uint32_t    xflags;     /* extra filter-specific flags */
0941     int64_t     data;       /* filter-specific data */
0942     uint64_t    ext[4];     /* filter-specific extensions */
0943 };
0944 
0945 #include <sys/ev.h>
0946 
0947 typedef struct eventreq vki_eventreq;
0948 
0949 
0950 #include <sys/acl.h>
0951 
0952 #define vki_kauth_filesec kauth_filesec
0953 
0954 
0955 #include <sys/ptrace.h>
0956 
0957 #define VKI_PTRACE_TRACEME   PT_TRACE_ME
0958 #define VKI_PTRACE_DETACH    PT_DETACH
0959 
0960 
0961 // sqlite/src/os_unix.c
0962 
0963 struct ByteRangeLockPB2
0964 {
0965     unsigned long long offset;        /* offset to first byte to lock */
0966     unsigned long long length;        /* nbr of bytes to lock */
0967     unsigned long long retRangeStart; /* nbr of 1st byte locked if successful */
0968     unsigned char unLockFlag;         /* 1 = unlock, 0 = lock */
0969     unsigned char startEndFlag;       /* 1=rel to end of fork, 0=rel to start */
0970     int fd;                           /* file desc to assoc this lock with */
0971 };
0972 
0973 #define afpfsByteRangeLock2FSCTL _IOWR('z', 23, struct ByteRangeLockPB2)
0974 
0975 #define vki_ByteRangeLockPB2 ByteRangeLockPB2
0976 #define VKI_afpfsByteRangeLock2FSCTL afpfsByteRangeLock2FSCTL
0977 
0978 
0979 // xnu/bsd/sys/fsctl.h
0980 
0981 #define VKI_FSIOC_SYNC_VOLUME        _IOW('A', 1, uint32_t)
0982 
0983 
0984 // libpthread/kern/workqueue_internal.h
0985 
0986 #define VKI_WQOPS_QUEUE_ADD                    1
0987 #define VKI_WQOPS_QUEUE_REMOVE                 2
0988 #define VKI_WQOPS_THREAD_RETURN                4  /* parks the thread back into the kernel */
0989 #define VKI_WQOPS_THREAD_SETCONC               8
0990 #define VKI_WQOPS_QUEUE_NEWSPISUPP            16  /* check for newer SPI support */
0991 #define VKI_WQOPS_QUEUE_REQTHREADS            32  /* request number of threads of a prio */
0992 #define VKI_WQOPS_QUEUE_REQTHREADS2           48  /* request a number of threads in a given priority bucket */
0993 #define VKI_WQOPS_THREAD_KEVENT_RETURN        64  /* parks the thread after delivering the passed kevent array */
0994 #define VKI_WQOPS_SET_EVENT_MANAGER_PRIORITY 128  /* max() in the provided priority in the the priority of the event manager */
0995 #define VKI_WQOPS_THREAD_WORKLOOP_RETURN     256  /* parks the thread after delivering the passed kevent array */
0996 #define VKI_WQOPS_SHOULD_NARROW              512  /* checks whether we should narrow our concurrency */
0997 #define VKI_WQOPS_SETUP_DISPATCH            1024  /* setup pthread workqueue-related operations */
0998 
0999 #define VKI_WORKQ_DISPATCH_CONFIG_VERSION        2
1000 #define VKI_WORKQ_DISPATCH_MIN_SUPPORTED_VERSION 1
1001 #define VKI_WORKQ_DISPATCH_SUPPORTED_FLAGS       0
1002 
1003 
1004 #include <sys/ttycom.h>
1005 
1006 #define vki_winsize winsize
1007 
1008 #define VKI_TIOCMODG    TIOCMODG
1009 #define VKI_TIOCMODS    TIOCMODS
1010 #define VKI_TIOCEXCL    TIOCEXCL
1011 #define VKI_TIOCNXCL    TIOCNXCL
1012 #define VKI_TIOCFLUSH   TIOCFLUSH
1013 #define VKI_TIOCGETA    TIOCGETA
1014 #define VKI_TIOCSETA    TIOCSETA
1015 #define VKI_TIOCSETAW   TIOCSETAW
1016 #define VKI_TIOCSETAF   TIOCSETAF
1017 #define VKI_TIOCGETD    TIOCGETD
1018 #define VKI_TIOCSETD    TIOCSETD
1019 #define VKI_TIOCSBRK    TIOCSBRK
1020 #define VKI_TIOCCBRK    TIOCCBRK
1021 #define VKI_TIOCSDTR    TIOCSDTR
1022 #define VKI_TIOCCDTR    TIOCCDTR
1023 #define VKI_TIOCGPGRP   TIOCGPGRP
1024 #define VKI_TIOCSPGRP   TIOCSPGRP
1025 #define VKI_TIOCOUTQ    TIOCOUTQ
1026 #define VKI_TIOCSTI TIOCSTI
1027 #define VKI_TIOCNOTTY   TIOCNOTTY
1028 #define VKI_TIOCPKT TIOCPKT
1029 #define VKI_TIOCSTOP    TIOCSTOP
1030 #define VKI_TIOCSTART   TIOCSTART
1031 #define VKI_TIOCMSET    TIOCMSET
1032 #define VKI_TIOCMBIS    TIOCMBIS
1033 #define VKI_TIOCMBIC    TIOCMBIC
1034 #define VKI_TIOCMGET    TIOCMGET
1035 #define VKI_TIOCREMOTE  TIOCREMOTE
1036 #define VKI_TIOCGWINSZ  TIOCGWINSZ
1037 #define VKI_TIOCSWINSZ  TIOCSWINSZ
1038 #define VKI_TIOCUCNTL   TIOCUCNTL
1039 #define VKI_TIOCSTAT    TIOCSTAT
1040 #define VKI_UIOCCMD(n)  UIOCCMD(n)
1041 #define VKI_TIOCSCONS   TIOCSCONS
1042 #define VKI_TIOCCONS    TIOCCONS
1043 #define VKI_TIOCSCTTY   TIOCSCTTY
1044 #define VKI_TIOCEXT TIOCEXT
1045 #define VKI_TIOCSIG TIOCSIG
1046 #define VKI_TIOCDRAIN   TIOCDRAIN
1047 #define VKI_TIOCMSDTRWAIT   TIOCMSDTRWAIT
1048 #define VKI_TIOCMGDTRWAIT   TIOCMGDTRWAIT
1049 #define VKI_TIOCTIMESTAMP   TIOCTIMESTAMP
1050 #define VKI_TIOCDCDTIMESTAMP    TIOCDCDTIMESTAMP
1051 #define VKI_TIOCSDRAINWAIT  TIOCSDRAINWAIT
1052 #define VKI_TIOCGDRAINWAIT  TIOCGDRAINWAIT
1053 #define VKI_TIOCDSIMICROCODE    TIOCDSIMICROCODE
1054 #define VKI_TIOCPTYGRANT    TIOCPTYGRANT
1055 #define VKI_TIOCPTYGNAME    TIOCPTYGNAME
1056 #define VKI_TIOCPTYUNLK TIOCPTYUNLK
1057 
1058 
1059 #include <sys/filio.h>
1060 
1061 #define VKI_FIOCLEX FIOCLEX
1062 #define VKI_FIONCLEX    FIONCLEX
1063 #define VKI_FIONREAD    FIONREAD
1064 #define VKI_FIONBIO FIONBIO
1065 #define VKI_FIOASYNC    FIOASYNC
1066 #define VKI_FIOSETOWN   FIOSETOWN
1067 #define VKI_FIOGETOWN   FIOGETOWN
1068 #define VKI_FIODTYPE    FIODTYPE
1069 
1070 
1071 #include <sys/sockio.h>
1072 
1073 #define VKI_SIOCSHIWAT  SIOCSHIWAT
1074 #define VKI_SIOCGHIWAT  SIOCGHIWAT
1075 #define VKI_SIOCSLOWAT  SIOCSLOWAT
1076 #define VKI_SIOCGLOWAT  SIOCGLOWAT
1077 #define VKI_SIOCATMARK  SIOCATMARK
1078 #define VKI_SIOCSPGRP   SIOCSPGRP
1079 #define VKI_SIOCGPGRP   SIOCGPGRP
1080 
1081 #define VKI_SIOCSIFADDR     SIOCSIFADDR
1082 #define VKI_OSIOCGIFADDR    OSIOCGIFADDR
1083 #define VKI_SIOCSIFDSTADDR  SIOCSIFDSTADDR
1084 #define VKI_OSIOCGIFDSTADDR OSIOCGIFDSTADDR
1085 #define VKI_SIOCSIFFLAGS    SIOCSIFFLAGS
1086 #define VKI_SIOCGIFFLAGS    SIOCGIFFLAGS
1087 #define VKI_OSIOCGIFBRDADDR OSIOCGIFBRDADDR
1088 #define VKI_SIOCSIFBRDADDR  SIOCSIFBRDADDR
1089 #define VKI_OSIOCGIFCONF    OSIOCGIFCONF
1090 #define VKI_OSIOCGIFNETMASK OSIOCGIFNETMASK
1091 #define VKI_SIOCSIFNETMASK  SIOCSIFNETMASK
1092 #define VKI_SIOCGIFMETRIC   SIOCGIFMETRIC
1093 #define VKI_SIOCSIFMETRIC   SIOCSIFMETRIC
1094 #define VKI_SIOCDIFADDR     SIOCDIFADDR
1095 #define VKI_SIOCAIFADDR     SIOCAIFADDR
1096 #define VKI_SIOCGETVIFCNT   SIOCGETVIFCNT
1097 #define VKI_SIOCGETSGCNT    SIOCGETSGCNT
1098 #define VKI_SIOCALIFADDR    SIOCALIFADDR
1099 #define VKI_SIOCGLIFADDR    SIOCGLIFADDR
1100 #define VKI_SIOCDLIFADDR    SIOCDLIFADDR
1101 
1102 #define VKI_SIOCGIFADDR     SIOCGIFADDR
1103 #define VKI_SIOCGIFDSTADDR  SIOCGIFDSTADDR
1104 #define VKI_SIOCGIFBRDADDR  SIOCGIFBRDADDR
1105 #define VKI_SIOCGIFCONF     SIOCGIFCONF
1106 #define VKI_SIOCGIFNETMASK  SIOCGIFNETMASK
1107 #define VKI_SIOCAUTOADDR    SIOCAUTOADDR
1108 #define VKI_SIOCAUTONETMASK SIOCAUTONETMASK
1109 #define VKI_SIOCARPIPLL     SIOCARPIPLL
1110 
1111 #define VKI_SIOCADDMULTI    SIOCADDMULTI
1112 #define VKI_SIOCDELMULTI    SIOCDELMULTI
1113 #define VKI_SIOCGIFMTU      SIOCGIFMTU
1114 #define VKI_SIOCSIFMTU      SIOCSIFMTU
1115 #define VKI_SIOCGIFPHYS     SIOCGIFPHYS
1116 #define VKI_SIOCSIFPHYS     SIOCSIFPHYS
1117 #define VKI_SIOCSIFMEDIA    SIOCSIFMEDIA
1118 #define VKI_SIOCGIFMEDIA    SIOCGIFMEDIA
1119 #define VKI_SIOCSIFGENERIC  SIOCSIFGENERIC
1120 #define VKI_SIOCGIFGENERIC  SIOCGIFGENERIC
1121 #define VKI_SIOCRSLVMULTI       SIOCRSLVMULTI
1122 
1123 #define VKI_SIOCSIFLLADDR   SIOCSIFLLADDR
1124 #define VKI_SIOCGIFSTATUS   SIOCGIFSTATUS
1125 #define VKI_SIOCSIFPHYADDR      SIOCSIFPHYADDR
1126 #define VKI_SIOCGIFPSRCADDR SIOCGIFPSRCADDR
1127 #define VKI_SIOCGIFPDSTADDR SIOCGIFPDSTADDR
1128 #define VKI_SIOCDIFPHYADDR  SIOCDIFPHYADDR
1129 #define VKI_SIOCSLIFPHYADDR SIOCSLIFPHYADDR
1130 #define VKI_SIOCGLIFPHYADDR SIOCGLIFPHYADDR
1131 
1132 #define VKI_SIOCGIFDEVMTU   SIOCGIFDEVMTU
1133 #define VKI_SIOCSIFALTMTU   SIOCSIFALTMTU
1134 #define VKI_SIOCGIFALTMTU   SIOCGIFALTMTU
1135 #define VKI_SIOCSIFBOND     SIOCSIFBOND
1136 #define VKI_SIOCGIFBOND     SIOCGIFBOND
1137 #define VKI_SIOCIFCREATE    SIOCIFCREATE
1138 #define VKI_SIOCIFDESTROY   SIOCIFDESTROY
1139 #define VKI_SIOCSIFVLAN     SIOCSIFVLAN
1140 #define VKI_SIOCGIFVLAN     SIOCGIFVLAN
1141 
1142 #define VKI_SIOCSETVLAN     SIOCSIFVLAN
1143 #define VKI_SIOCGETVLAN     SIOCGIFVLAN
1144 
1145 #define VKI_SIOCGIFASYNCMAP     SIOCGIFASYNCMAP
1146 #define VKI_SIOCSIFASYNCMAP     SIOCSIGASYNCMAP
1147 
1148 
1149 #include <sys/dtrace.h>
1150 
1151 #define VKI_DTRACEHIOC_REMOVE   DTRACEHIOC_REMOVE
1152 #define VKI_DTRACEHIOC_ADDDOF   DTRACEHIOC_ADDDOF
1153 
1154 
1155 #include <net/bpf.h>
1156 
1157 #define vki_bpf_program bpf_program
1158 #define vki_bf_len bf_len
1159 #define vki_bf_insns bf_insns
1160 #define vki_bpf_dltlist bpf_dltlist
1161 #define vki_bfl_len bfl_len
1162 #define vki_bfl_list bfl_list
1163 
1164 #define VKI_BIOCSETF        BIOCSETF
1165 #define VKI_BIOCFLUSH       BIOCFLUSH
1166 #define VKI_BIOCPROMISC     BIOCPROMISC
1167 #define VKI_BIOCSETIF       BIOCSETIF
1168 #define VKI_BIOCSRTIMEOUT   BIOCSRTIMEOUT
1169 #define VKI_BIOCGDLTLIST    BIOCGDLTLIST
1170 
1171 
1172 #include <sys/ucontext.h>
1173 
1174 /* quite why sys/ucontext.h provides a 'struct __darwin_ucontext'
1175    but no 'struct ucontext' beats me. -- JRS */
1176 #define vki_ucontext __darwin_ucontext
1177 
1178 
1179 #include <sys/termios.h>
1180 
1181 #define vki_termios termios
1182 
1183 
1184 #include <uuid/uuid.h>
1185 
1186 #define vki_uuid_t uuid_t
1187 
1188 
1189 #include <bsm/audit.h>
1190 
1191 #define VKI_A_GETPOLICY A_GETPOLICY 
1192 #define VKI_A_SETPOLICY A_SETPOLICY 
1193 #define VKI_A_GETKMASK  A_GETKMASK  
1194 #define VKI_A_SETKMASK  A_SETKMASK  
1195 #define VKI_A_GETQCTRL  A_GETQCTRL  
1196 #define VKI_A_SETQCTRL  A_SETQCTRL  
1197 #define VKI_A_GETCWD    A_GETCWD    
1198 #define VKI_A_GETCAR    A_GETCAR    
1199 #define VKI_A_GETSTAT   A_GETSTAT   
1200 #define VKI_A_SETSTAT   A_SETSTAT   
1201 #define VKI_A_SETUMASK  A_SETUMASK  
1202 #define VKI_A_SETSMASK  A_SETSMASK  
1203 #define VKI_A_GETCOND   A_GETCOND   
1204 #define VKI_A_SETCOND   A_SETCOND   
1205 #define VKI_A_GETCLASS  A_GETCLASS  
1206 #define VKI_A_SETCLASS  A_SETCLASS  
1207 #define VKI_A_GETPINFO  A_GETPINFO  
1208 #define VKI_A_SETPMASK  A_SETPMASK  
1209 #define VKI_A_SETFSIZE  A_SETFSIZE  
1210 #define VKI_A_GETFSIZE  A_GETFSIZE  
1211 #define VKI_A_GETPINFO_ADDR A_GETPINFO_ADDR 
1212 #define VKI_A_GETKAUDIT A_GETKAUDIT 
1213 #define VKI_A_SETKAUDIT A_SETKAUDIT 
1214 #if DARWIN_VERS >= DARWIN_10_6
1215 #define VKI_A_SENDTRIGGER A_SENDTRIGGER
1216 #define VKI_A_GETSINFO_ADDR A_GETSINFO_ADDR
1217 #endif
1218 
1219 
1220 #include <sys/aio.h>
1221 
1222 #define vki_aiocb aiocb
1223 
1224 
1225 #include <netinet/tcp.h>
1226 
1227 #define VKI_TCP_NODELAY  TCP_NODELAY
1228 
1229 
1230 #include <netinet/in.h>
1231 
1232 #define VKI_IPPROTO_TCP  IPPROTO_TCP
1233 
1234 
1235 // XXX: for some reason when I #include <sys/kernel_types.h> I get a syntax
1236 // error.  Hmm.  So just define things ourselves.
1237 //#include <sys/kernel_types.h>
1238 
1239 //#define vki_errno_t
1240 typedef int vki_errno_t;
1241 
1242 
1243 /* necp stuff.  This doesn't appear to exist in any user space include
1244    file. */
1245 #if DARWIN_VERS >= DARWIN_10_10
1246 struct vki_necp_aggregate_result {
1247    vki_u_int32_t field1;
1248    unsigned int  field2;
1249    vki_u_int32_t field3;
1250    vki_u_int32_t field4;
1251    vki_uuid_t    field5;
1252    u_int32_t     field6;
1253    u_int32_t     field7;
1254 };
1255 
1256 #define VKI_CSR_CHECK 0
1257 #define VKI_CSR_GET_ACTIVE_CONFIG 1
1258 #endif /* DARWIN_VERS >= DARWIN_10_10 */
1259 
1260 #if DARWIN_VERS >= DARWIN_10_12
1261 // ulock_wake & ulock_wait operations
1262 #define VKI_UL_OPCODE_MASK      0x000000FF
1263 #define VKI_UL_FLAGS_MASK       0xFFFFFF00
1264 #define VKI_UL_COMPARE_AND_WAIT 1
1265 #define VKI_UL_UNFAIR_LOCK      2
1266 // ulock_wake & ulock_wait flags
1267 #define ULF_NO_ERRNO            0x01000000
1268 
1269 // ulock_wake flags
1270 #define VKI_ULF_WAKE_ALL          0x00000100
1271 #define VKI_ULF_WAKE_THREAD       0x00000200
1272 
1273 // ulock_wait flags
1274 #define WKI_ULF_WAIT_WORKQ_DATA_CONTENTION  0x00010000
1275 
1276 #define VKI_NECP_CLIENT_ACTION_ADD                     1
1277 #define VKI_NECP_CLIENT_ACTION_REMOVE                  2
1278 #define VKI_NECP_CLIENT_ACTION_COPY_PARAMETERS         3
1279 #define VKI_NECP_CLIENT_ACTION_COPY_RESULT             4
1280 #define VKI_NECP_CLIENT_ACTION_COPY_LIST               5
1281 #define VKI_NECP_CLIENT_ACTION_AGENT                   7
1282 #define VKI_NECP_CLIENT_ACTION_COPY_AGENT              8
1283 #define VKI_NECP_CLIENT_ACTION_COPY_INTERFACE          9
1284 #define VKI_NECP_CLIENT_ACTION_COPY_ROUTE_STATISTICS  11
1285 #define VKI_NECP_CLIENT_ACTION_AGENT_USE              12
1286 #define VKI_NECP_CLIENT_ACTION_UPDATE_CACHE           14
1287 #define VKI_NECP_CLIENT_ACTION_COPY_CLIENT_UPDATE     15
1288 #define VKI_NECP_CLIENT_ACTION_COPY_UPDATED_RESULT    16
1289 #define VKI_NECP_CLIENT_ACTION_CLAIM                  19
1290 #define VKI_NECP_CLIENT_ACTION_SIGN                   20
1291 
1292 #define VKI_NECP_MAX_CLIENT_PARAMETERS_SIZE    1024
1293 #define VKI_NECP_CLIENT_ACTION_SIGN_TAG_LENGTH   32
1294 
1295 #define VKI_IFXNAMSIZ     IFNAMSIZ + 8
1296 #define VKI_IFNET_SIGNATURELEN      20
1297 
1298 #define VKI_UL_COMPARE_AND_WAIT             1
1299 #define VKI_UL_UNFAIR_LOCK                  2
1300 #define VKI_UL_COMPARE_AND_WAIT_SHARED      3
1301 #define VKI_UL_UNFAIR_LOCK64_SHARED         4
1302 #define VKI_UL_COMPARE_AND_WAIT64           5
1303 #define VKI_UL_COMPARE_AND_WAIT64_SHARED    6
1304 
1305 struct vki_necp_client_signable {
1306     uuid_t client_id;
1307     u_int32_t sign_type;
1308 } __attribute__((__packed__));
1309 
1310 struct vki_necp_cache_buffer {
1311     u_int8_t                necp_cache_buf_type;    //  NECP_CLIENT_CACHE_TYPE_*
1312     u_int8_t                necp_cache_buf_ver;     //  NECP_CLIENT_CACHE_TYPE_*_VER
1313     u_int32_t               necp_cache_buf_size;
1314     mach_vm_address_t       necp_cache_buf_addr;
1315 };
1316 
1317 struct vki_necp_interface_signature {
1318   u_int8_t signature[VKI_IFNET_SIGNATURELEN];
1319   u_int8_t signature_len;
1320 };
1321 
1322 struct vki_necp_interface_details_legacy {
1323     char name[VKI_IFXNAMSIZ];
1324     u_int32_t index;
1325     u_int32_t generation;
1326     u_int32_t functional_type;
1327     u_int32_t delegate_index;
1328     u_int32_t flags; // see NECP_INTERFACE_FLAG_*
1329     u_int32_t mtu;
1330     struct vki_necp_interface_signature ipv4_signature;
1331     struct vki_necp_interface_signature ipv6_signature;
1332 };
1333 
1334 struct vki_necp_agent_use_parameters {
1335     uuid_t agent_uuid;
1336     uint64_t out_use_count;
1337 };
1338 
1339 // Precalculated as the struct are really big
1340 #define VKI_IFNET_STATS_PER_FLOW_SIZE 96
1341 #define VKI_NECP_STAT_COUNTS_SIZE 68
1342 
1343 #endif /* DARWIN_VERS >= DARWIN_10_12 */
1344 
1345 #include <spawn.h>
1346 
1347 typedef posix_spawn_file_actions_t vki_posix_spawn_file_actions_t;
1348 typedef posix_spawnattr_t vki_posix_spawnattr_t;
1349 
1350 // from sys/persona.h, not public
1351 #define VKI_PERSONA_INFO_V1       1
1352 #define VKI_PERSONA_INFO_V2       2
1353 #define VKI_PERSONA_OP_ALLOC    1
1354 #define VKI_PERSONA_OP_PALLOC   2
1355 #define VKI_PERSONA_OP_DEALLOC  3
1356 #define VKI_PERSONA_OP_GET      4
1357 #define VKI_PERSONA_OP_INFO     5
1358 #define VKI_PERSONA_OP_PIDINFO  6
1359 #define VKI_PERSONA_OP_FIND     7
1360 #define VKI_PERSONA_OP_GETPATH  8
1361 #define VKI_PERSONA_OP_FIND_BY_TYPE  9
1362 
1363 #define VKI_MAXLOGNAME      255
1364 
1365 struct vki_kpersona_info {
1366    /* v1 fields */
1367    vki_uint32_t persona_info_version;
1368 
1369    uid_t    persona_id;
1370    Int      persona_type;
1371    vki_gid_t    persona_gid; /* unused */
1372    vki_uint32_t persona_ngroups; /* unused */
1373    vki_gid_t    persona_groups[NGROUPS]; /* unused */
1374    vki_uid_t    persona_gmuid; /* unused */
1375    HChar     persona_name[VKI_MAXLOGNAME + 1];
1376 
1377    /* v2 fields */
1378    vki_uid_t    persona_uid;
1379 } __attribute__((packed));
1380 
1381 
1382 #endif