-
-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathvki-darwin.h
1433 lines (1170 loc) · 40.7 KB
/
vki-darwin.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*--------------------------------------------------------------------*/
/*--- Darwin-specific kernel interface. vki-darwin.h ---*/
/*--------------------------------------------------------------------*/
/*
This file is part of Valgrind, a dynamic binary instrumentation
framework.
Copyright (C) 2007-2017 Apple Inc.
Greg Parker gparker@apple.com
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
The GNU General Public License is contained in the file COPYING.
*/
/* Unlike vki-linux, this Darwin kernel interface includes system headers
directly, to avoid copyright complexity. */
#ifndef __VKI_DARWIN_H
#define __VKI_DARWIN_H
/* struct __darwin_ucontext isn't fully declared without
* this definition. It's crazy but there it is. */
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 0500
#endif
#include <stdint.h>
#define vki_int8_t int8_t
#define vki_uint8_t uint8_t
#define vki_int16_t int16_t
#define vki_uint16_t uint16_t
#define vki_int32_t int32_t
#define vki_uint32_t uint32_t
#define vki_int64_t int64_t
#define vki_uint64_t uint64_t
#define vki_intptr_t intptr_t
#define vki_uintptr_t uintptr_t
#include <sys/types.h>
#define vki_dev_t dev_t
#if defined(VGP_arm64_darwin)
// kernel uses 16bit, but somehow it's defined as 32bit in userland
#define vki_mode_t uint16_t
#else
#define vki_mode_t mode_t
#endif
#define vki_ino_t ino_t
#define vki_ino64_t ino64_t
#define vki_nlink_t nlink_t
#define vki_uid_t uid_t
#define vki_gid_t gid_t
#define vki_time_t time_t
#define vki_off_t off_t
#define vki_blkcnt_t blkcnt_t
#define vki_blksize_t blksize_t
#define vki_size_t size_t
#define vki_ssize_t ssize_t
#define vki_pid_t pid_t
#define vki_socklen_t socklen_t
#define vki_suseconds_t suseconds_t
#define vki_caddr_t caddr_t
#define vki_u_long u_long
#define vki_u_short u_short
#define vki_clock_t clock_t
#define vki_u_int32_t u_int32_t
#define vki_u_int16_t u_int16_t
#define vki_pthread_t pthread_t
// valgrind special
// magic mmap() flags
#define VKI_MAP_ANONYMOUS MAP_ANON // linux synonym
// See xnu/osfmk/mach/vm_statistics.h
#define VKI_VM_MEMORY_MALLOC 1
#define VKI_VM_MEMORY_MALLOC_SMALL 2
#define VKI_VM_MEMORY_MALLOC_LARGE 3
#define VKI_VM_MEMORY_MALLOC_HUGE 4
#define VKI_VM_MEMORY_BRK 5
#define VKI_VM_MEMORY_REALLOC 6
#define VKI_VM_MEMORY_MALLOC_TINY 7
#define VKI_VM_MEMORY_MALLOC_LARGE_REUSABLE 8
#define VKI_VM_MEMORY_MALLOC_LARGE_REUSED 9
#define VKI_VM_MEMORY_ANALYSIS_TOOL 10
#define VKI_VM_MEMORY_MALLOC_NANO 11
#define VKI_VM_MEMORY_MALLOC_MEDIUM 12
#define VKI_VM_MEMORY_MALLOC_PROB_GUARD 13
#define VKI_VM_MEMORY_MACH_MSG 20
#define VKI_VM_MEMORY_IOKIT 21
#define VKI_VM_MEMORY_STACK 30
#define VKI_VM_MEMORY_GUARD 31
#define VKI_VM_MEMORY_SHARED_PMAP 32
#define VKI_VM_MEMORY_DYLIB 33
#define VKI_VM_MEMORY_OBJC_DISPATCHERS 34
#define VKI_VM_MEMORY_UNSHARED_PMAP 35
#define VKI_VM_MEMORY_APPKIT 40
#define VKI_VM_MEMORY_FOUNDATION 41
#define VKI_VM_MEMORY_COREGRAPHICS 42
#define VKI_VM_MEMORY_CORESERVICES 43
#define VKI_VM_MEMORY_JAVA 44
#define VKI_VM_MEMORY_COREDATA 45
#define VKI_VM_MEMORY_COREDATA_OBJECTIDS 46
#define VKI_VM_MEMORY_ATS 50
#define VKI_VM_MEMORY_LAYERKIT 51
#define VKI_VM_MEMORY_CGIMAGE 52
#define VKI_VM_MEMORY_TCMALLOC 53
#define VKI_VM_MEMORY_COREGRAPHICS_DATA 54
#define VKI_VM_MEMORY_COREGRAPHICS_SHARED 55
#define VKI_VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS 56
#define VKI_VM_MEMORY_COREGRAPHICS_BACKINGSTORES 57
#define VKI_VM_MEMORY_COREGRAPHICS_XALLOC 58
#define VKI_VM_MEMORY_DYLD 60
#define VKI_VM_MEMORY_DYLD_MALLOC 61
#define VKI_VM_MEMORY_SQLITE 62
#define VKI_VM_MEMORY_JAVASCRIPT_CORE 63
#define VKI_VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR 64
#define VKI_VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE 65
#define VKI_VM_MEMORY_GLSL 66
#define VKI_VM_MEMORY_OPENCL 67
#define VKI_VM_MEMORY_COREIMAGE 68
#define VKI_VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS 69
#define VKI_VM_MEMORY_IMAGEIO 70
#define VKI_VM_MEMORY_COREPROFILE 71
#define VKI_VM_MEMORY_ASSETSD 72
#define VKI_VM_MEMORY_OS_ALLOC_ONCE 73
#define VKI_VM_MEMORY_LIBDISPATCH 74
#define VKI_VM_MEMORY_ACCELERATE 75
#define VKI_VM_MEMORY_COREUI 76
#define VKI_VM_MEMORY_COREUIFILE 77
#define VKI_VM_MEMORY_GENEALOGY 78
#define VKI_VM_MEMORY_RAWCAMERA 79
#define VKI_VM_MEMORY_CORPSEINFO 80
#define VKI_VM_MEMORY_ASL 81
#define VKI_VM_MEMORY_SWIFT_RUNTIME 82
#define VKI_VM_MEMORY_SWIFT_METADATA 83
#define VKI_VM_MEMORY_DHMM 84
#define VKI_VM_MEMORY_SCENEKIT 86
#define VKI_VM_MEMORY_SKYWALK 87
#define VKI_VM_MEMORY_IOSURFACE 88
#define VKI_VM_MEMORY_LIBNETWORK 89
#define VKI_VM_MEMORY_AUDIO 90
#define VKI_VM_MEMORY_VIDEOBITSTREAM 91
#define VKI_VM_MEMORY_CM_XPC 92
#define VKI_VM_MEMORY_CM_RPC 93
#define VKI_VM_MEMORY_CM_MEMORYPOOL 94
#define VKI_VM_MEMORY_CM_READCACHE 95
#define VKI_VM_MEMORY_CM_CRABS 96
#define VKI_VM_MEMORY_QUICKLOOK_THUMBNAILS 97
#define VKI_VM_MEMORY_ACCOUNTS 98
#define VKI_VM_MEMORY_SANITIZER 99
#define VKI_VM_MEMORY_IOACCELERATOR 100
#define VKI_VM_MEMORY_CM_REGWARP 101
#define VKI_VM_MEMORY_EAR_DECODER 102
#define VKI_VM_MEMORY_COREUI_CACHED_IMAGE_DATA 103
#define VKI_VM_MEMORY_COLORSYNC 104
#define VKI_VM_MEMORY_BTINFO 105
#define VKI_VM_MEMORY_CM_HLS 106
#define VKI_VM_MEMORY_ROSETTA 230
#define VKI_VM_MEMORY_ROSETTA_THREAD_CONTEXT 231
#define VKI_VM_MEMORY_ROSETTA_INDIRECT_BRANCH_MAP 232
#define VKI_VM_MEMORY_ROSETTA_RETURN_STACK 233
#define VKI_VM_MEMORY_ROSETTA_EXECUTABLE_HEAP 234
#define VKI_VM_MEMORY_ROSETTA_USER_LDT 235
#define VKI_VM_MEMORY_ROSETTA_ARENA 236
#define VKI_VM_MEMORY_ROSETTA_10 239
#define VKI_VM_MEMORY_APPLICATION_SPECIFIC_1 240
#define VKI_VM_MEMORY_VALGRIND 242
#define VKI_VM_MEMORY_APPLICATION_SPECIFIC_16 255
// fds for mmap(MAP_ANON), displayed by vmmap
#define VM_TAG_VALGRIND VM_MAKE_TAG(VKI_VM_MEMORY_VALGRIND) // SkAnonV
// page sizes
#define VKI_MAX_PAGE_SHIFT VKI_PAGE_SHIFT
#define VKI_MAX_PAGE_SIZE VKI_PAGE_SIZE
// pthread
#define VKI_PTHREAD_START_CUSTOM 0x01000000
// types
typedef uint32_t vki_u32;
// linux-like ioctl flags
#define _VKI_IOC_DIR(x) ((x) & IOC_DIRMASK)
#define _VKI_IOC_SIZE(x) IOCPARM_LEN(x)
#define _VKI_IOC_NONE IOC_VOID /* GrP fixme correct? */
#define _VKI_IOC_READ IOC_OUT
#define _VKI_IOC_WRITE IOC_IN
#include <malloc/malloc.h>
#define vki_malloc_zone_t malloc_zone_t
#include <sys/time.h>
#define vki_timeval timeval
#define vki_timeval32 timeval32
#define vki_tv_sec tv_sec
#define vki_tv_usec tv_usec
#define vki_timespec timespec
#define vki_itimerval itimerval
#define vki_timezone timezone
#include <sys/stat.h>
#define VKI_S_ISBLK(m) S_ISBLK(m)
#define VKI_S_ISCHR(m) S_ISCHR(m)
#define VKI_S_ISDIR(m) S_ISDIR(m)
#define VKI_S_ISFIFO(m) S_ISFIFO(m)
#define VKI_S_ISREG(m) S_ISREG(m)
#define VKI_S_ISLNK(m) S_ISLNK(m)
#define VKI_S_ISSOCK(m) S_ISSOCK(m)
#define VKI_S_ISWHT(m) S_ISWHT(m)
#define VKI_S_ISXATTR(m) S_ISXATTR(m)
#define VKI_S_IRWXU S_IRWXU
#define VKI_S_IRUSR S_IRUSR
#define VKI_S_IWUSR S_IWUSR
#define VKI_S_IXUSR S_IXUSR
#define VKI_S_IRWXG S_IRWXG
#define VKI_S_IRGRP S_IRGRP
#define VKI_S_IWGRP S_IWGRP
#define VKI_S_IXGRP S_IXGRP
#define VKI_S_IRWXO S_IRWXO
#define VKI_S_IROTH S_IROTH
#define VKI_S_IWOTH S_IWOTH
#define VKI_S_IXOTH S_IXOTH
#define VKI_S_ISUID S_ISUID
#define VKI_S_ISGID S_ISGID
#define VKI_S_ISVTX S_ISVTX
#define vki_stat stat
#define vki_stat64 stat64
#define st_atime st_atimespec.tv_sec
#define st_atime_nsec st_atimespec.tv_nsec
#define st_mtime st_mtimespec.tv_sec
#define st_mtime_nsec st_mtimespec.tv_nsec
#define st_ctime st_ctimespec.tv_sec
#define st_ctime_nsec st_ctimespec.tv_nsec
#include <sys/dirent.h>
#define VKI_MAXNAMLEN MAXNAMLEN
#define vki_dirent dirent
#include <sys/socket.h>
#define VKI_SOCK_STREAM SOCK_STREAM
#define VKI_SOCK_DGRAM SOCK_DGRAM
#define VKI_SOCK_RAW SOCK_RAW
#define VKI_AF_UNIX AF_UNIX
#define VKI_AF_INET AF_INET
#define VKI_AF_INET6 AF_INET6
#define VKI_SOL_SOCKET SOL_SOCKET
#define VKI_SO_REUSEADDR SO_REUSEADDR
#define VKI_SO_SNDBUF SO_SNDBUF
#define VKI_SO_RCVBUF SO_RCVBUF
#define VKI_SO_SNDLOWAT SO_SNDLOWAT
#define VKI_SO_RCVLOWAT SO_RCVLOWAT
#define VKI_SO_SNDTIMEO SO_SNDTIMEO
#define VKI_SO_RCVTIMEO SO_RCVTIMEO
#define VKI_SO_ERROR SO_ERROR
#define VKI_SO_TYPE SO_TYPE
#define VKI_SO_NREAD SO_NREAD
#define VKI_SO_NKE SO_NKE
#define VKI_SO_NOSIGPIPE SO_NOSIGPIPE
#define VKI_SO_NOADDRERR SO_NOADDRERR
#define VKI_SO_NWRITE SO_NWRITE
#define VKI_SO_LINGER_SEC SO_LINGER_SEC
#define vki_sa_family_t sa_family_t
#define vki_sockaddr sockaddr
#define vki_iovec iovec
#define vki_msghdr msghdr
#define vki_cmsghdr cmsghdr
#define VKI_CMSG_ALIGN(a) ALIGN(a)
#define VKI_CMSG_DATA(cmsg) CMSG_DATA(cmsg)
#define VKI_CMSG_FIRSTHDR(mhdr) CMSG_FIRSTHDR(mhdr)
#define VKI_CMSG_NXTHDR(mhdr, cmsg) CMSG_NXTHDR(mhdr, cmsg)
#define VKI_SCM_RIGHTS SCM_RIGHTS
#define VKI_SCM_TIMESTAMP SCM_TIMESTAMP
#define VKI_SCM_CREDS SCM_CREDS
#include <sys/un.h>
#define vki_sockaddr_un sockaddr_un
#include <netinet/in.h>
#define vki_in_addr_t in_addr_t
#define vki_in_port_t in_port_t
#define vki_in_addr in_addr
#define vki_sockaddr_in sockaddr_in
#define VKI_INADDR_LOOPBACK INADDR_LOOPBACK
// #include <netinet6/in6.h>
#define vki_in6_addr in6_addr
#define vki_sockaddr_in6 sockaddr_in6
#include <net/if.h>
#define VKI_IFNAMSIZ IFNAMSIZ
#define vki_ifdevmtu ifdevmtu
#define vki_ifreq ifreq
#define vki_ifr_name ifr_name
#define vki_ifr_addr ifr_addr
#define vki_ifr_dstaddr ifr_dstaddr
#define vki_ifr_broadaddr ifr_broadaddr
#define vki_ifr_flags ifr_flags
#define vki_ifr_metric ifr_metric
#define vki_ifr_mtu ifr_mtu
#define vki_ifr_phys ifr_phys
#define vki_ifr_media ifr_media
#define vki_ifr_data ifr_data
#define vki_ifr_devmtu ifr_devmtu
#define vki_ifr_intval ifr_intval
#define vki_ifconf ifconf
#define vki_ifc_buf ifc_buf
#define vki_ifc_req ifc_req
#include <sys/fcntl.h>
#define VKI_SEEK_SET SEEK_SET
#define VKI_SEEK_CUR SEEK_CUR
#define VKI_SEEK_END SEEK_END
#define VKI_O_RDONLY O_RDONLY
#define VKI_O_WRONLY O_WRONLY
#define VKI_O_RDWR O_RDWR
#define VKI_O_ACCMODE O_ACCMODE
#define VKI_O_NONBLOCK O_NONBLOCK
#define VKI_O_APPEND O_APPEND
#define VKI_O_SYNC O_SYN
#define VKI_O_SHLOCK O_SHLOCK
#define VKI_O_EXLOCK O_EXLOCK
#define VKI_O_ASYNC O_ASYNC
#define VKI_O_NOFOLLOW O_NOFOLLOW
#define VKI_O_CREAT O_CREAT
#define VKI_O_TRUNC O_TRUNC
#define VKI_O_EXCL O_EXCL
#define VKI_O_EVTONLY O_EVTONLY
#define VKI_AT_FDCWD AT_FDCWD
#define VKI_F_DUPFD F_DUPFD
#define VKI_F_GETFD F_GETFD
#define VKI_F_SETFD F_SETFD
#define VKI_F_GETFL F_GETFL
#define VKI_F_SETFL F_SETFL
#define VKI_F_GETOWN F_GETOWN
#define VKI_F_SETOWN F_SETOWN
#define VKI_F_GETLK F_GETLK
#define VKI_F_SETLK F_SETLK
#define VKI_F_SETLKW F_SETLKW
#if DARWIN_VERS >= DARWIN_10_10
#define VKI_F_SETLKWTIMEOUT F_SETLKWTIMEOUT
#endif
#define VKI_F_CHKCLEAN F_CHKCLEAN
#define VKI_F_PREALLOCATE F_PREALLOCATE
#define VKI_F_SETSIZE F_SETSIZE
#define VKI_F_RDADVISE F_RDADVISE
#define VKI_F_RDAHEAD F_RDAHEAD
#define VKI_F_READBOOTSTRAP F_READBOOTSTRAP
#define VKI_F_WRITEBOOTSTRAP F_WRITEBOOTSTRAP
#define VKI_F_NOCACHE F_NOCACHE
#define VKI_F_LOG2PHYS F_LOG2PHYS
#define VKI_F_GETPATH F_GETPATH
#define VKI_F_ADDSIGS F_ADDSIGS
#if DARWIN_VERS >= DARWIN_10_9
# define VKI_F_ADDFILESIGS F_ADDFILESIGS
#endif
#if DARWIN_VERS >= DARWIN_10_11
# define VKI_F_ADDFILESIGS_FOR_DYLD_SIM F_ADDFILESIGS_FOR_DYLD_SIM
# define VKI_F_BARRIERFSYNC F_BARRIERFSYNC
# define VKI_F_ADDFILESIGS_RETURN F_ADDFILESIGS_RETURN
#endif
#if DARWIN_VERS >= DARWIN_10_14
# define VKI_F_CHECK_LV F_CHECK_LV
#endif
#if DARWIN_VERS >= DARWIN_10_15
# define VKI_F_SPECULATIVE_READ F_SPECULATIVE_READ
#endif
#if DARWIN_VERS >= DARWIN_14_00
# define VKI_F_GETPROTECTIONCLASS F_GETPROTECTIONCLASS
# define VKI_F_OFD_SETLK F_OFD_SETLK
# define VKI_F_OFD_GETLK F_OFD_GETLK
# define VKI_F_OFD_SETLKWTIMEOUT F_OFD_SETLKWTIMEOUT
# define VKI_F_SETCONFINED 95
#endif
#define VKI_F_FULLFSYNC F_FULLFSYNC
#define VKI_F_PATHPKG_CHECK F_PATHPKG_CHECK
#define VKI_F_FREEZE_FS F_FREEZE_FS
#define VKI_F_THAW_FS F_THAW_FS
#define VKI_F_GLOBAL_NOCACHE F_GLOBAL_NOCACHE
#define VKI_FD_CLOEXEC FD_CLOEXEC
#define vki_radvisory radvisory
#define vki_fstore fstore
#define vki_fbootstraptransfer fbootstraptransfer
#define vki_log2phys log2phys
#define vki_fsignatures_t fsignatures_t
// These constants aren't in a standard header, they are from the kernel code:
// xnu-1228.3.13/bsd/sys/codesign.h
// Mac OS X 10.5.6 - Darwin 9.6
#define VKI_CS_OPS_STATUS 0 /* return status */
#define VKI_CS_OPS_MARKINVALID 1 /* invalidate process */
#define VKI_CS_OPS_MARKHARD 2 /* set HARD flag */
#define VKI_CS_OPS_MARKKILL 3 /* set KILL flag (sticky) */
#define VKI_CS_OPS_PIDPATH 4 /* get executable's pathname */
#define VKI_CS_OPS_CDHASH 5 /* get code directory hash */
#include <sys/mman.h>
#define VKI_PROT_NONE PROT_NONE
#define VKI_PROT_READ PROT_READ
#define VKI_PROT_WRITE PROT_WRITE
#define VKI_PROT_EXEC PROT_EXEC
#define VKI_MAP_SHARED MAP_SHARED
#define VKI_MAP_PRIVATE MAP_PRIVATE
#define VKI_MAP_FIXED MAP_FIXED
#define VKI_MAP_RENAME MAP_RENAME
#define VKI_MAP_NORESERVE MAP_NORESERVE
#define VKI_MAP_RESERVED0080 MAP_RESERVED0080
#define VKI_MAP_NOEXTEND MAP_NOEXTEND
#define VKI_MAP_HASSEMAPHORE MAP_HASSEMAPHORE
#if DARWIN_VERS >= DARWIN_11_00
#define VKI_MAP_NOCACHE MAP_NOCACHE
#define VKI_MAP_JIT MAP_JIT
#endif
#define VKI_MAP_FILE MAP_FILE
#define VKI_MAP_ANON MAP_ANON
#define VKI_MAP_FAILED MAP_FAILED
#include <mach/vm_param.h>
#define VKI_PAGE_SHIFT PAGE_SHIFT
#define VKI_PAGE_SIZE PAGE_SIZE
#define VKI_PAGE_MASK PAGE_MASK
#include <sys/vmparam.h>
#define VKI_USRSTACK USRSTACK
#define VKI_USRSTACK64 USRSTACK64
#include <mach/mach_time.h>
#define vki_mach_timebase_info mach_timebase_info
#include <sys/syslimits.h>
#define VKI_PATH_MAX PATH_MAX
#include <sys/param.h>
#define VKI_MAXPATHLEN MAXPATHLEN
#include <sys/signal.h>
/* While we fully intend to make 'vki_sigset_t' match the native
Darwin 'sigset_t', we can't just clone the Darwin sigset_t type,
because it isn't an array, and the VG_(sigfillset) etc functions
assume it is. So instead define another isomorphic type, and check
in VG_(vki_do_initial_consistency_checks) that it really is
correct. */
/* #define vki_sigset_t sigset_t */
#define _VKI_NSIG_BPW 32
#define _VKI_NSIG 32
#define _VKI_NSIG_WORDS (_VKI_NSIG / _VKI_NSIG_BPW)
typedef struct {
UInt sig[_VKI_NSIG_WORDS];
} vki_sigset_t;
/* and now let VG_(vki_do_initial_consistency_checks) make sure it
matches 'sigset_t'. */
#define VKI_SS_ONSTACK SS_ONSTACK
#define VKI_SS_DISABLE SS_DISABLE
#define VKI_MINSIGSTKSZ MINSIGSTKSZ
#define VKI_SIGSTKSZ SIGSTKSZ
#define vki_stack_t stack_t
#define vki_siginfo_t siginfo_t
/* There are two versions of this. 'struct __sigaction' is used for
passing sigactions to the kernel interface, and has the added
complexity of requiring an extra pointer to a new demultiplexing
function to be run in user space. 'struct sigaction' is used for
receiving old sigactions from the kernel, and lacks this
demux-function pointer. So the type of the second and third
parameters in Darwin's sys_sigaction appear to be different,
respectively 'struct __sigaction*' and 'struct sigaction*'.
*/
//#define vki_sigaction __sigaction
//#define vki_user_sigaction sigaction
//#define vki_sigaltstack sigaltstack
//#define vki_sigval sigval
//#define vki_sigaction_u sigaction_u
//#define vki_sigaction sigaction
//typedef struct __sigaction vki_sigaction_toK_t;
//typedef struct sigaction vki_sigaction_fromK_t;
#define VKI_UC_TRAD 1
#define VKI_UC_FLAVOR 30
typedef
struct {
void* ksa_handler;
// see sendsig_set_thread_state/sendsig in XNU for details
#if defined(VGP_arm64_darwin)
// arm64 adds a token argument which needs to be passed to sigreturn
void (*sa_tramp)(void* catcher, UWord infostyle, UWord sig, void* p_sinfo, void* p_uctx, void* token);
#else
void (*sa_tramp)(void* ua_catcher, UWord infostyle, UWord sig, void* ua_sip, void* ua_uctxp);
#endif
vki_sigset_t sa_mask;
int sa_flags;
}
vki_sigaction_toK_t;
typedef
struct {
void* ksa_handler;
vki_sigset_t sa_mask;
int sa_flags;
}
vki_sigaction_fromK_t;
/* and /usr/include/sys/signal.c in turn defines 'sa_handler' to
be '__sigaction_u.__sa_handler' */
//#define ksa_handler sa_handler
//#define vki_sa_sigaction sa_sigaction
#define VKI_SA_ONSTACK SA_ONSTACK
#define VKI_SA_RESTART SA_RESTART
#define VKI_SA_DISABLE SA_DISABLE
#define VKI_SA_RESETHAND SA_RESETHAND
#define VKI_SA_NOCLDSTOP SA_NOCLDSTOP
#define VKI_SA_NODEFER SA_NODEFER
#define VKI_SA_NOCLDWAIT SA_NOCLDWAIT
#define VKI_SA_SIGINFO SA_SIGINFO
#define VKI_SA_USERTRAMP SA_USERTRAMP
#define VKI_SA_64REGSET SA_64REGSET
#define VKI_SA_RESTORER 0 /* Darwin doesn't have this */
#define VKI_SIG_BLOCK SIG_BLOCK
#define VKI_SIG_UNBLOCK SIG_UNBLOCK
#define VKI_SIG_SETMASK SIG_SETMASK
#define VKI_SIGHUP SIGHUP
#define VKI_SIGINT SIGINT
#define VKI_SIGQUIT SIGQUIT
#define VKI_SIGILL SIGILL
#define VKI_SIGTRAP SIGTRAP
#define VKI_SIGABRT SIGABRT
#define VKI_SIGPOLL SIGPOLL
#define VKI_SIGFPE SIGFPE
#define VKI_SIGKILL SIGKILL
#define VKI_SIGBUS SIGBUS
#define VKI_SIGSEGV SIGSEGV
#define VKI_SIGSYS SIGSYS
#define VKI_SIGPIPE SIGPIPE
#define VKI_SIGALRM SIGALRM
#define VKI_SIGTERM SIGTERM
#define VKI_SIGURG SIGURG
#define VKI_SIGSTOP SIGSTOP
#define VKI_SIGTSTP SIGTSTP
#define VKI_SIGCONT SIGCONT
#define VKI_SIGCHLD SIGCHLD
#define VKI_SIGTTIN SIGTTIN
#define VKI_SIGTTOU SIGTTOU
#define VKI_SIGIO SIGIO
#define VKI_SIGXCPU SIGXCPU
#define VKI_SIGXFSZ SIGXFSZ
#define VKI_SIGVTALRM SIGVTALRM
#define VKI_SIGPROF SIGPROF
#define VKI_SIGWINCH SIGWINCH
#define VKI_SIGINFO SIGINFO
#define VKI_SIGUSR1 SIGUSR1
#define VKI_SIGUSR2 SIGUSR2
#define VKI_SIG_DFL SIG_DFL
#define VKI_SIG_IGN SIG_IGN
#define VKI_SI_USER SI_USER
#define VKI_SEGV_MAPERR SEGV_MAPERR
#define VKI_SEGV_ACCERR SEGV_ACCERR
#define VKI_ILL_ILLOPC ILL_ILLOPC
#define VKI_ILL_ILLOPN ILL_ILLOPN
#define VKI_ILL_ILLADR ILL_ILLADR
#define VKI_ILL_ILLTRP ILL_ILLTRP
#define VKI_ILL_PRVOPC ILL_PRVOPC
#define VKI_ILL_PRVREG ILL_PRVREG
#define VKI_ILL_COPROC ILL_COPROC
#define VKI_ILL_BADSTK ILL_BADSTK
#define VKI_FPE_INTDIV FPE_INTDIV
#define VKI_FPE_INTOVF FPE_INTOVF
#define VKI_FPE_FLTDIV FPE_FLTDIV
#define VKI_FPE_FLTOVF FPE_FLTOVF
#define VKI_FPE_FLTUND FPE_FLTUND
#define VKI_FPE_FLTRES FPE_FLTRES
#define VKI_FPE_FLTINV FPE_FLTINV
#define VKI_FPE_FLTSUB FPE_FLTSUB
#define VKI_BUS_ADRALN BUS_ADRALN
#define VKI_BUS_ADRERR BUS_ADRERR
#define VKI_BUS_OBJERR BUS_OBJERR
#define VKI_TRAP_BRKPT TRAP_BRKPT
#define VKI_CLD_EXITED CLD_EXITED
#define VKI_CLD_KILLED CLD_KILLED
#define VKI_CLD_DUMPED CLD_DUMPED
#define VKI_CLD_TRAPPED CLD_TRAPPED
#define VKI_CLD_STOPPED CLD_STOPPED
#define VKI_CLD_CONTINUED CLD_CONTINUED
/* JRS: not 100% sure, but I think these two are correct */
#define VKI_SA_ONESHOT SA_RESETHAND
#define VKI_SA_NOMASK SA_NODEFER
#define VKI_UC_SET_ALT_STACK 0x40000000
#define VKI_UC_RESET_ALT_STACK 0x80000000
#include <sys/errno.h>
#define VKI_EPERM EPERM
#define VKI_ENOENT ENOENT
#define VKI_ESRCH ESRCH
#define VKI_EINTR EINTR
#define VKI_EIO EIO
#define VKI_ENXIO ENXIO
#define VKI_E2BIG E2BIG
#define VKI_ENOEXEC ENOEXEC
#define VKI_EBADF EBADF
#define VKI_ECHILD ECHILD
#define VKI_EDEADLK EDEADLK
#define VKI_ENOMEM ENOMEM
#define VKI_EACCES EACCES
#define VKI_EFAULT EFAULT
#define VKI_ENOTBLK ENOTBLK
#define VKI_EBUSY EBUSY
#define VKI_EEXIST EEXIST
#define VKI_EXDEV EXDEV
#define VKI_ENODEV ENODEV
#define VKI_ENOTDIR ENOTDIR
#define VKI_EISDIR EISDIR
#define VKI_EINVAL EINVAL
#define VKI_ENFILE ENFILE
#define VKI_EMFILE EMFILE
#define VKI_ENOTTY ENOTTY
#define VKI_ETXTBSY ETXTBSY
#define VKI_EFBIG EFBIG
#define VKI_ENOSPC ENOSPC
#define VKI_ESPIPE ESPIPE
#define VKI_EROFS EROFS
#define VKI_EMLINK EMLINK
#define VKI_EPIPE EPIPE
#define VKI_EDOM EDOM
#define VKI_ERANGE ERANGE
#define VKI_EAGAIN EAGAIN
#define VKI_EWOULDBLOCK EAGAIN
#define VKI_EINPROGRESS EINPROGRESS
#define VKI_EALREADY EALREADY
#define VKI_ENOTSOCK ENOTSOCK
#define VKI_EDESTADDRREQ EDESTADDRREQ
#define VKI_EMSGSIZE EMSGSIZE
#define VKI_EPROTOTYPE EPROTOTYPE
#define VKI_ENOPROTOOPT ENOPROTOOPT
#define VKI_EPROTONOSUPPORT EPROTONOSUPPORT
#define VKI_ESOCKTNOSUPPORT ESOCKTNOSUPPORT
#define VKI_ENOTSUP ENOTSUP
#define VKI_EPFNOSUPPORT EPFNOSUPPORT
#define VKI_EAFNOSUPPORT EAFNOSUPPORT
#define VKI_EADDRINUSE EADDRINUSE
#define VKI_EADDRNOTAVAIL EADDRNOTAVAIL
#define VKI_ENETDOWN ENETDOWN
#define VKI_ENETUNREACH ENETUNREACH
#define VKI_ENETRESET ENETRESET
#define VKI_ECONNABORTED ECONNABORTED
#define VKI_ECONNRESET ECONNRESET
#define VKI_ENOBUFS ENOBUFS
#define VKI_EISCONN EISCONN
#define VKI_ENOTCONN ENOTCONN
#define VKI_ESHUTDOWN ESHUTDOWN
#define VKI_ETOOMANYREFS ETOOMANYREFS
#define VKI_ETIMEDOUT ETIMEDOUT
#define VKI_ECONNREFUSED ECONNREFUSED
#define VKI_ELOOP ELOOP
#define VKI_ENAMETOOLONG ENAMETOOLONG
#define VKI_EHOSTDOWN EHOSTDOWN
#define VKI_EHOSTUNREACH EHOSTUNREACH
#define VKI_ENOTEMPTY ENOTEMPTY
#define VKI_EPROCLIM EPROCLIM
#define VKI_EUSERS EUSERS
#define VKI_EDQUOT EDQUOT
#define VKI_ESTALE ESTALE
#define VKI_EREMOTE EREMOTE
#define VKI_EBADRPC EBADRPC
#define VKI_ERPCMISMATCH ERPCMISMATCH
#define VKI_EPROGUNAVAIL EPROGUNAVAIL
#define VKI_EPROGMISMATCH EPROGMISMATCH
#define VKI_EPROCUNAVAIL EPROCUNAVAIL
#define VKI_ENOLCK ENOLCK
#define VKI_ENOSYS ENOSYS
#define VKI_EFTYPE EFTYPE
#define VKI_EAUTH EAUTH
#define VKI_ENEEDAUTH ENEEDAUTH
#define VKI_EPWROFF EPWROFF
#define VKI_EDEVERR EDEVERR
#define VKI_EOVERFLOW EOVERFLOW
#define VKI_EBADEXEC EBADEXEC
#define VKI_EBADARCH EBADARCH
#define VKI_ESHLIBVERS ESHLIBVERS
#define VKI_EBADMACHO EBADMACHO
#define VKI_ECANCELED ECANCELED
#define VKI_EIDRM EIDRM
#define VKI_ENOMSG ENOMSG
#define VKI_EILSEQ EILSEQ
#define VKI_ENOATTR ENOATTR
#define VKI_EBADMSG EBADMSG
#define VKI_EMULTIHOP EMULTIHOP
#define VKI_ENODATA ENODATA
#define VKI_ENOLINK ENOLINK
#define VKI_ENOSR ENOSR
#define VKI_ENOSTR ENOSTR
#define VKI_EPROTO EPROTO
#define VKI_ETIME ETIME
#define VKI_EOPNOTSUPP EOPNOTSUPP
#define VKI_ELAST ELAST
#include <sys/resource.h>
#define VKI_RLIMIT_CPU RLIMIT_CPU
#define VKI_RLIMIT_FSIZE RLIMIT_FSIZE
#define VKI_RLIMIT_DATA RLIMIT_DATA
#define VKI_RLIMIT_STACK RLIMIT_STACK
#define VKI_RLIMIT_CORE RLIMIT_CORE
#define VKI_RLIMIT_AS RLIMIT_AD
#define VKI_RLIMIT_RSS RLIMIT_AS
#define VKI_RLIMIT_MEMLOCK RLIMIT_MEMLOCK
#define VKI_RLIMIT_NPROC RLIMIT_NPROC
#define VKI_RLIMIT_NOFILE RLIMIT_NOFILE
#define VKI_RLIM_NLIMITS RLIM_NLIMITS
#define vki_rlim_t rlim_t
#define vki_rlimit rlimit
#define vki_rusage rusage
#include <sys/poll.h>
#define vki_pollfd pollfd
#include <sys/ipc.h>
#define VKI_IPC_RMID IPC_RMID
#define VKI_IPC_SET IPC_SET
#define VKI_IPC_STAT IPC_STAT
#define vki_key_t key_t
#define vki_ipc_perm ipc_perm
#include <sys/sem.h>
#define VKI_GETNCNT GETNCNT
#define VKI_GETPID GETPID
#define VKI_GETVAL GETVAL
#define VKI_GETALL GETALL
#define VKI_GETZCNT GETZCNT
#define VKI_SETVAL SETVAL
#define VKI_SETALL SETALL
#define vki_sembuf sembuf
#define vki_semid_ds semid_ds
#define vki_semun semun
#include <sys/semaphore.h>
#define vki_sem_t sem_t
#include <sys/mount.h>
#define VKI_MFSNAMELEN MFSNAMELEN
#define VKI_MNAMELEN MNAMELEN
#define vki_fsid fsid
#define vki_fsid_t fsid_t
#define vki_statfs statfs
#define vki_statfs64 statfs64
#include <sys/select.h>
#define vki_fd_set fd_set
#include <sys/msgbuf.h>
#define VKI_MSG_BSIZE MSG_BSIZE
#define VKI_MSG_MAGIC MSG_MAGIC
#define vki_msgbuf msgbuf
#include <sys/shm.h>
#define VKI_SHM_RDONLY SHM_RDONLY
#define VKI_SHM_RND SHM_RND
#define VKI_SHMLBA SHMLBA
#define vki_shmid_ds shmid_ds
#include <sys/times.h>
#define vki_tms tms
#include <sys/utsname.h>
#define _VKI_SYS_NAMELEN _SYS_NAMELEN
#define vki_new_utsname utsname
#include <sys/unistd.h>
#define VKI_F_OK F_OK
#define VKI_X_OK X_OK
#define VKI_W_OK W_OK
#define VKI_R_OK R_OK
#define vki_accessx_descriptor accessx_descriptor
#define VKI_ACCESSX_MAX_DESCRIPTORS ACCESSX_MAX_DESCRIPTORS
#include <sys/sysctl.h>
#define VKI_CTL_MAXNAME CTL_MAXNAME
#define VKI_CTL_UNSPEC CTL_UNSPEC
#define VKI_CTL_KERN CTL_KERN
#define VKI_CTL_VM CTL_VM
#define VKI_CTL_VFS CTL_VFS
#define VKI_CTL_NET CTL_NET
#define VKI_CTL_DEBUG CTL_DEBUG
#define VKI_CTL_HW CTL_HW
#define VKI_CTL_MACHDEP CTL_MACHDEP
#define VKI_CTL_USER CTL_USER
#define VKI_CTL_MAXID CTL_MAXID
#define VKI_HW_MACHINE HW_MACHINE
#define VKI_HW_MODEL HW_MODEL
#define VKI_HW_NCPU HW_NCPU
#define VKI_HW_BYTEORDER HW_BYTEORDER
#define VKI_HW_PHYSMEM HW_PHYSMEM
#define VKI_HW_USERMEM HW_USERMEM
#define VKI_HW_PAGESIZE HW_PAGESIZE
#define VKI_HW_DISKNAMES HW_DISKNAMES
#define VKI_HW_DISKSTATS HW_DISKSTATS
#define VKI_HW_EPOCH HW_EPOCH
#define VKI_HW_FLOATINGPT HW_FLOATINGPT
#define VKI_HW_MACHINE_ARCH HW_MACHINE_ARCH
#define VKI_HW_VECTORUNIT HW_VECTORUNIT
#define VKI_HW_BUS_FREQ HW_BUS_FREQ
#define VKI_HW_CPU_FREQ HW_CPU_FREQ
#define VKI_HW_CACHELINE HW_CACHELINE
#define VKI_HW_L1ICACHESIZE HW_L1ICACHESIZE
#define VKI_HW_L1DCACHESIZE HW_L1DCACHESIZE
#define VKI_HW_L2SETTINGS HW_L2SETTINGS
#define VKI_HW_L2CACHESIZE HW_L2CACHESIZE
#define VKI_HW_L3SETTINGS HW_L3SETTINGS
#define VKI_HW_L3CACHESIZE HW_L3CACHESIZE
#define VKI_HW_TB_FREQ HW_TB_FREQ
#define VKI_HW_MEMSIZE HW_MEMSIZE
#define VKI_HW_AVAILCPU MW_AVAILCPU
#define VKI_HW_MAXID MW_MAXID
// seemingly private?
#define VKI_HW_ARM 100
#define VKI_HW_OPTIONAL 102
#define VKI_HW_FEAT_SHA3 104
#define VKI_HW_CPUTYPE 108
#define VKI_HW_CPUSUBTYPE 109
#define VKI_HW_FEAT_SB 113
#define VKI_HW_FEAT_LRCPC 115
#define VKI_HW_FEAT_PAUTH 119
#define VKI_HW_FEAT_DIT 130
#define VKI_HW_FEAT_FP16 131
#define VKI_KERN_USRSTACK32 KERN_USRSTACK32
#define VKI_KERN_USRSTACK64 KERN_USRSTACK64
#include <sys/attr.h>
#define vki_attrlist attrlist
#include <sys/event.h>
#define vki_kevent kevent
#define vki_kevent64 kevent64_s
// xnu_root/bsd/sys/event.h
struct vki_kevent_qos_s {
uint64_t ident; /* identifier for this event */
int16_t filter; /* filter for event */
uint16_t flags; /* general flags */
int32_t qos; /* quality of service */
uint64_t udata; /* opaque user data identifier */
uint32_t fflags; /* filter-specific flags */
uint32_t xflags; /* extra filter-specific flags */
int64_t data; /* filter-specific data */
uint64_t ext[4]; /* filter-specific extensions */
};
#include <sys/ev.h>
typedef struct eventreq vki_eventreq;
#include <sys/acl.h>
#define vki_kauth_filesec kauth_filesec
#include <sys/ptrace.h>
#define VKI_PTRACE_TRACEME PT_TRACE_ME
#define VKI_PTRACE_DETACH PT_DETACH
// sqlite/src/os_unix.c
struct ByteRangeLockPB2
{
unsigned long long offset; /* offset to first byte to lock */
unsigned long long length; /* nbr of bytes to lock */
unsigned long long retRangeStart; /* nbr of 1st byte locked if successful */
unsigned char unLockFlag; /* 1 = unlock, 0 = lock */
unsigned char startEndFlag; /* 1=rel to end of fork, 0=rel to start */
int fd; /* file desc to assoc this lock with */
};
#define afpfsByteRangeLock2FSCTL _IOWR('z', 23, struct ByteRangeLockPB2)