2 /*--------------------------------------------------------------------*/
3 /*--- Private syscalls header for Darwin. priv_syswrap-darwin.h ---*/
4 /*--------------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2005-2017 Apple Inc.
11 Greg Parker gparker@apple.com
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.
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.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
29 #ifndef __PRIV_SYSWRAP_DARWIN_H
30 #define __PRIV_SYSWRAP_DARWIN_H
32 #include "pub_core_basics.h" // ThreadId
33 #include "priv_types_n_macros.h" // DECL_TEMPLATE
36 Addr
allocstack ( ThreadId tid
);
37 void find_stack_segment ( ThreadId tid
, Addr sp
);
38 void start_thread_NORETURN ( Word arg
);
39 void assign_port_name(mach_port_t port
, const char *name
);
40 void record_named_port(ThreadId tid
, mach_port_t port
, mach_port_right_t right
, const char *name
);
42 extern const SyscallTableEntry
ML_(mach_trap_table
)[];
43 extern const SyscallTableEntry
ML_(syscall_table
)[];
44 extern const SyscallTableEntry
ML_(mdep_trap_table
)[];
46 extern const UInt
ML_(syscall_table_size
);
47 extern const UInt
ML_(mach_trap_table_size
);
48 extern const UInt
ML_(mdep_trap_table_size
);
50 void VG_(show_open_ports
)(void);
52 Bool
ML_(sync_mappings
)(const HChar
*when
, const HChar
*where
, UWord num
);
55 // GEN = it uses the generic wrapper
56 // NYI = wrapper not yet implemented in Valgrind
57 // NOC = the non-"_nocancel" wrapper is used
58 // old = the syscall no longer exists in Darwin
59 DECL_TEMPLATE(darwin
, exit
); // 1
76 DECL_TEMPLATE(darwin
, getfsstat
); // 18
84 DECL_TEMPLATE(darwin
, ptrace
); // 26
85 DECL_TEMPLATE(darwin
, recvmsg
); // 27
86 DECL_TEMPLATE(darwin
, sendmsg
); // 28
87 DECL_TEMPLATE(darwin
, recvfrom
); // 29
88 DECL_TEMPLATE(darwin
, accept
); // 30
89 DECL_TEMPLATE(darwin
, getpeername
); // 31
90 DECL_TEMPLATE(darwin
, getsockname
); // 32
92 DECL_TEMPLATE(darwin
, chflags
); // 34
93 DECL_TEMPLATE(darwin
, fchflags
); // 35
100 DECL_TEMPLATE(darwin
, pipe
); // 42
104 DECL_TEMPLATE(darwin
, sigaction
); // 46
106 DECL_TEMPLATE(darwin
, sigprocmask
); // 48
107 DECL_TEMPLATE(darwin
, getlogin
); // 49
110 DECL_TEMPLATE(darwin
, sigpending
); // 52
111 // GEN sigaltstack 53
112 DECL_TEMPLATE(darwin
, ioctl
); // 54
121 // 63 used internally, reserved
122 // old getpagesize 64
147 DECL_TEMPLATE(darwin
, getdtablesize
); // 89
150 DECL_TEMPLATE(darwin
, fcntl
); // 92
154 // GEN setpriority 96
155 DECL_TEMPLATE(darwin
, socket
); // 97
156 DECL_TEMPLATE(darwin
, connect
); // 98
158 // GEN getpriority 100
162 DECL_TEMPLATE(darwin
, bind
); // 104
163 DECL_TEMPLATE(darwin
, setsockopt
); // 105
164 DECL_TEMPLATE(darwin
, listen
); // 106
169 DECL_TEMPLATE(darwin
, sigsuspend
); // 111
174 // GEN gettimeofday 116
176 DECL_TEMPLATE(darwin
, getsockopt
); // 118
180 // NYI settimeofday 122
190 DECL_TEMPLATE(darwin
, mkfifo
); // 132
191 DECL_TEMPLATE(darwin
, sendto
); // 133
192 DECL_TEMPLATE(darwin
, shutdown
); // 134
193 DECL_TEMPLATE(darwin
, socketpair
); // 135
197 DECL_TEMPLATE(darwin
, futimes
); // 139
200 DECL_TEMPLATE(darwin
, gethostuuid
); // 142
210 // NYI setprivexec 152
225 DECL_TEMPLATE(darwin
, mount
); // 167
227 DECL_TEMPLATE(darwin
, csops
); // 169
234 // NYI add_profil 176
235 #if DARWIN_VERS >= DARWIN_10_12
236 // NYI kdebug_typefilter // 177
237 #endif /* DARWIN_VERS >= DARWIN_10_12 */
238 #if DARWIN_VERS >= DARWIN_10_11
239 // NYI kdebug_trace_string // 178
240 #endif /* DARWIN_VERS >= DARWIN_10_11 */
242 DECL_TEMPLATE(darwin
, kdebug_trace
); // 180
244 DECL_TEMPLATE(darwin
, setegid
); // 182
245 DECL_TEMPLATE(darwin
, seteuid
); // 183
246 DECL_TEMPLATE(darwin
, sigreturn
); // 184
247 DECL_TEMPLATE(darwin
, FAKE_SIGRETURN
);
249 #if DARWIN_VERS >= DARWIN_10_13
250 // NYI thread_selfcounts // 186
251 #endif /* DARWIN_VERS >= DARWIN_10_13 */
256 DECL_TEMPLATE(darwin
, pathconf
); // 191
257 DECL_TEMPLATE(darwin
, fpathconf
); // 192
261 DECL_TEMPLATE(darwin
, getdirentries
); // 196
262 DECL_TEMPLATE(darwin
, mmap
); // 197
264 DECL_TEMPLATE(darwin
, lseek
); // 199 (was UX64)
267 DECL_TEMPLATE(darwin
, __sysctl
); // 202
278 // 213 Reserved for AppleTalk
279 // NYI kqueue_from_portset_np 214
280 // NYI kqueue_portset_np 215
285 DECL_TEMPLATE(darwin
, getattrlist
); // 220
286 DECL_TEMPLATE(darwin
, setattrlist
); // 221
287 DECL_TEMPLATE(darwin
, getdirentriesattr
); // 222
288 DECL_TEMPLATE(darwin
, exchangedata
); // 223
289 // 224 checkuseraccess
296 DECL_TEMPLATE(darwin
, watchevent
); // 231
297 DECL_TEMPLATE(darwin
, waitevent
); // 232
298 DECL_TEMPLATE(darwin
, modwatch
); // 233
299 DECL_TEMPLATE(darwin
, getxattr
); // 234
300 DECL_TEMPLATE(darwin
, fgetxattr
); // 235
301 DECL_TEMPLATE(darwin
, setxattr
); // 236
302 DECL_TEMPLATE(darwin
, fsetxattr
); // 237
303 DECL_TEMPLATE(darwin
, removexattr
); // 238
304 DECL_TEMPLATE(darwin
, fremovexattr
); // 239
305 DECL_TEMPLATE(darwin
, listxattr
); // 240
306 DECL_TEMPLATE(darwin
, flistxattr
); // 241
307 DECL_TEMPLATE(darwin
, fsctl
); // 242
308 DECL_TEMPLATE(darwin
, initgroups
); // 243
309 DECL_TEMPLATE(darwin
, posix_spawn
); // 244
319 DECL_TEMPLATE(darwin
, semctl
); // 254
320 DECL_TEMPLATE(darwin
, semget
); // 255
321 DECL_TEMPLATE(darwin
, semop
); // 256
327 DECL_TEMPLATE(darwin
, shmat
); // 262
328 DECL_TEMPLATE(darwin
, shmctl
); // 263
329 DECL_TEMPLATE(darwin
, shmdt
); // 264
330 DECL_TEMPLATE(darwin
, shmget
); // 265
331 DECL_TEMPLATE(darwin
, shm_open
); // 266
332 DECL_TEMPLATE(darwin
, shm_unlink
); // 267
333 DECL_TEMPLATE(darwin
, sem_open
); // 268
334 DECL_TEMPLATE(darwin
, sem_close
); // 269
335 DECL_TEMPLATE(darwin
, sem_unlink
); // 270
336 DECL_TEMPLATE(darwin
, sem_wait
); // 271
337 DECL_TEMPLATE(darwin
, sem_trywait
); // 272
338 DECL_TEMPLATE(darwin
, sem_post
); // 273
340 #if DARWIN_VERS < DARWIN_10_10
341 // NYI sem_getvalue 274
342 #elif DARWIN_VERS >= DARWIN_10_10
343 DECL_TEMPLATE(darwin
, sysctlbyname
); // 274
346 DECL_TEMPLATE(darwin
, sem_init
); // 275
347 DECL_TEMPLATE(darwin
, sem_destroy
); // 276
348 DECL_TEMPLATE(darwin
, open_extended
) // 277
349 // NYI umask_extended 278
350 DECL_TEMPLATE(darwin
, stat_extended
); // 279
351 DECL_TEMPLATE(darwin
, lstat_extended
); // 280
352 DECL_TEMPLATE(darwin
, fstat_extended
); // 281
353 DECL_TEMPLATE(darwin
, chmod_extended
); // 282
354 DECL_TEMPLATE(darwin
, fchmod_extended
); // 283
355 DECL_TEMPLATE(darwin
, access_extended
); // 284
356 DECL_TEMPLATE(darwin
, settid
); // 285
357 #if DARWIN_VERS >= DARWIN_10_6
358 DECL_TEMPLATE(darwin
, gettid
); // 286
360 // NYI setsgroups 287
361 // NYI getsgroups 288
362 // NYI setwgroups 289
363 // NYI getwgroups 290
364 // NYI mkfifo_extended 291
365 // NYI mkdir_extended 292
366 // NYI identitysvc 293
367 // NYI shared_region_check_np 294
368 // NYI shared_region_map_np 295
369 #if DARWIN_VERS >= DARWIN_10_6
370 // NYI vm_pressure_monitor 296
371 // NYI psynch_rw_longrdlock 297
372 // NYI psynch_rw_yieldwrlock 298
373 // NYI psynch_rw_downgrade 299
374 // NYI psynch_rw_upgrade 300
375 DECL_TEMPLATE(darwin
, psynch_mutexwait
); // 301
376 DECL_TEMPLATE(darwin
, psynch_mutexdrop
); // 302
377 DECL_TEMPLATE(darwin
, psynch_cvbroad
); // 303
378 DECL_TEMPLATE(darwin
, psynch_cvsignal
); // 304
379 DECL_TEMPLATE(darwin
, psynch_cvwait
); // 305
380 DECL_TEMPLATE(darwin
, psynch_rw_rdlock
); // 306
381 DECL_TEMPLATE(darwin
, psynch_rw_wrlock
); // 307
382 DECL_TEMPLATE(darwin
, psynch_rw_unlock
); // 308
383 // NYI psynch_rw_unlock2 309
385 // old load_shared_file
386 // old reset_shared_file
387 // old new_system_shared_regions
388 // old shared_region_map_file_np
389 // old shared_region_make_private_np
390 // NYI __pthread_mutex_destroy 301
391 // NYI __pthread_mutex_init 302
392 // NYI __pthread_mutex_lock 303
393 // NYI __pthread_mutex_trylock 304
394 // NYI __pthread_mutex_unlock 305
395 // NYI __pthread_cond_init 306
396 // NYI __pthread_cond_destroy 307
397 // NYI __pthread_cond_broadcast 308
398 // NYI __pthread_cond_signal 309
401 // NYI settid_with_pid 311
402 #if DARWIN_VERS >= DARWIN_10_7
403 DECL_TEMPLATE(darwin
, psynch_cvclrprepost
); // 312
405 // NYI __pthread_cond_timedwait 312
408 DECL_TEMPLATE(darwin
, aio_return
); // 314
409 DECL_TEMPLATE(darwin
, aio_suspend
); // 315
410 // NYI aio_cancel 316
411 DECL_TEMPLATE(darwin
, aio_error
); // 317
412 DECL_TEMPLATE(darwin
, aio_read
); // 318
413 DECL_TEMPLATE(darwin
, aio_write
); // 319
414 // NYI lio_listio 320
415 // NYI __pthread_cond_wait 321
416 // NYI iopolicysys 322
417 // NYI process_policy 323
419 // NYI munlockall 325
421 DECL_TEMPLATE(darwin
, issetugid
); // 327
422 DECL_TEMPLATE(darwin
, __pthread_kill
); // 328
423 DECL_TEMPLATE(darwin
, __pthread_sigmask
); // 329
425 DECL_TEMPLATE(darwin
, __disable_threadsignal
); // 331
426 DECL_TEMPLATE(darwin
, __pthread_markcancel
); // 332
427 DECL_TEMPLATE(darwin
, __pthread_canceled
); // 333
428 DECL_TEMPLATE(darwin
, __semwait_signal
); // 334
430 DECL_TEMPLATE(darwin
, proc_info
); // 336
431 DECL_TEMPLATE(darwin
, sendfile
); // 337
432 DECL_TEMPLATE(darwin
, stat64
); // 338
433 DECL_TEMPLATE(darwin
, fstat64
); // 339
434 DECL_TEMPLATE(darwin
, lstat64
); // 340
435 DECL_TEMPLATE(darwin
, stat64_extended
); // 341
436 DECL_TEMPLATE(darwin
, lstat64_extended
); // 342
437 DECL_TEMPLATE(darwin
, fstat64_extended
); // 343
438 DECL_TEMPLATE(darwin
, getdirentries64
); // 344
439 DECL_TEMPLATE(darwin
, statfs64
); // 345
440 DECL_TEMPLATE(darwin
, fstatfs64
); // 346
441 DECL_TEMPLATE(darwin
, getfsstat64
); // 347
442 DECL_TEMPLATE(darwin
, __pthread_chdir
); // 348
443 DECL_TEMPLATE(darwin
, __pthread_fchdir
); // 349
445 DECL_TEMPLATE(darwin
, auditon
); // 351
451 DECL_TEMPLATE(darwin
, getaudit_addr
) // 357
452 // NYI setaudit_addr 358
454 DECL_TEMPLATE(darwin
, bsdthread_create
); // 360
455 DECL_TEMPLATE(darwin
, bsdthread_terminate
); // 361
456 DECL_TEMPLATE(darwin
, kqueue
); // 362
457 DECL_TEMPLATE(darwin
, kevent
); // 363
459 // NYI stack_snapshot 365
460 DECL_TEMPLATE(darwin
, bsdthread_register
); // 366
461 DECL_TEMPLATE(darwin
, workq_open
); // 367
462 DECL_TEMPLATE(darwin
, workq_ops
); // 368
463 DECL_TEMPLATE(darwin
, kevent64
); // 369
466 #if DARWIN_VERS >= DARWIN_10_6
467 DECL_TEMPLATE(darwin
, __thread_selfid
); // 372
470 #if DARWIN_VERS >= DARWIN_10_11
471 DECL_TEMPLATE(darwin
, kevent_qos
); // 374
472 #endif /* DARWIN_VERS >= DARWIN_10_11 */
473 #if DARWIN_VERS >= DARWIN_10_13
474 // NYI kevent_id // 375
475 #endif /* DARWIN_VERS >= DARWIN_10_13 */
480 // NYI __mac_execve 380
481 DECL_TEMPLATE(darwin
, __mac_syscall
); // 381
482 // NYI __mac_get_file 382
483 // NYI __mac_set_file 383
484 // NYI __mac_get_link 384
485 // NYI __mac_set_link 385
486 // NYI __mac_get_proc 386
487 // NYI __mac_set_proc 387
488 // NYI __mac_get_fd 388
489 // NYI __mac_set_fd 389
490 // NYI __mac_get_pid 390
491 // NYI __mac_get_lcid 391
492 // NYI __mac_get_lctx 392
493 // NYI __mac_set_lctx 393
494 #if DARWIN_VERS >= DARWIN_10_11
495 DECL_TEMPLATE(darwin
, pselect
); // 394
498 #endif /* DARWIN_VERS >= DARWIN_10_11 */
500 // GEN read_nocancel 396
501 // GEN write_nocancel 397
502 // GEN open_nocancel 398
503 // GEN close_nocancel 399
504 // GEN wait4_nocancel 400
505 // NOC recvmsg_nocancel 401
506 // NOC sendmsg_nocancel 402
507 // NOC recvfrom_nocancel 403
508 // NOC accept_nocancel 404
509 // GEN msync_nocancel 405
510 // NOC fcntl_nocancel 406
511 // GEN select_nocancel 407
512 // GEN fsync_nocancel 408
513 // NOC connect_nocancel 409
514 // NYI sigsuspend_nocancel 410
515 // GEN readv_nocancel 411
516 // GEN writev_nocancel 412
517 // NOC sendto_nocancel 413
518 // GEN pread_nocancel 414
519 // GEN pwrite_nocancel 415
520 // NYI waitid_nocancel 416
521 // GEN poll_nocancel 417
522 // NYI msgsnd_nocancel 418
523 // NYI msgrcv_nocancel 419
524 // NOC sem_wait_nocancel 420
525 // NYI aio_suspend_nocancel 421
526 // NYI __sigwait_nocancel 422
527 // NOC __semwait_signal_nocancel 423
528 // NYI __mac_mount 424
529 // NYI __mac_get_mount 425
530 // NYI __mac_getfsstat 426
531 DECL_TEMPLATE(darwin
, fsgetpath
); // 427
532 DECL_TEMPLATE(darwin
, audit_session_self
); // 428
533 // NYI audit_session_join 429
534 DECL_TEMPLATE(darwin
, fileport_makeport
); // 430
536 // NYI fileport_makefd 431
537 // NYI audit_session_port 432
538 // NYI pid_suspend 433
539 // NYI pid_resume 434
540 #if DARWIN_VERS >= DARWIN_10_10
541 // NYI pid_hibernate 435
542 // NYI pid_shutdown_sockets 436
543 #endif /* DARWIN_VERS >= DARWIN_10_10 */
544 // old old shared_region_slide_np 437
545 // NYI shared_region_map_and_slide_np // 438
546 // NYI kas_info // 439
547 // NYI memorystatus_control // 440
548 DECL_TEMPLATE(darwin
, guarded_open_np
); // 441
549 DECL_TEMPLATE(darwin
, guarded_close_np
); // 442
550 DECL_TEMPLATE(darwin
, guarded_kqueue_np
); // 443
551 DECL_TEMPLATE(darwin
, change_fdguard_np
); // 444
552 // old __proc_suppress 445
553 // NYI proc_rlimit_control // 446
554 DECL_TEMPLATE(darwin
, connectx
); // 447
555 DECL_TEMPLATE(darwin
, disconnectx
); // 448
556 // NYI peeloff // 449
557 // NYI socket_delegate // 450
558 // NYI telemetry // 451
559 // NYI proc_uuid_policy // 452
560 // NYI memorystatus_get_level // 453
561 // NYI system_override // 454
562 // NYI vfs_purge // 455
563 #if DARWIN_VERS >= DARWIN_10_10
564 // NYI sfi_ctl // 456
565 // NYI sfi_pidctl // 457
566 // NYI coalition // 458
567 // NYI coalition_info // 459
568 DECL_TEMPLATE(darwin
, necp_match_policy
); // 460
569 DECL_TEMPLATE(darwin
, getattrlistbulk
); // 461
570 #endif /* DARWIN_VERS >= DARWIN_10_10 */
571 #if DARWIN_VERS >= DARWIN_10_12
572 // NYI clonefileat // 462
573 #endif /* DARWIN_VERS >= DARWIN_10_12 */
574 #if DARWIN_VERS >= DARWIN_10_10
576 // NYI openat_nocancel // 464
577 // NYI renameat // 465
578 DECL_TEMPLATE(darwin
, faccessat
); // 466
579 // NYI fchmodat // 467
580 // NYI fchownat // 468
581 // NYI fstatat // 469
582 DECL_TEMPLATE(darwin
, fstatat64
); // 470
584 // NYI unlinkat // 472
585 DECL_TEMPLATE(darwin
, readlinkat
); // 473
586 // NYI symlinkat // 474
587 // NYI mkdirat // 475
588 // NYI getattrlistat // 476
589 // NYI proc_trace_log // 477
590 DECL_TEMPLATE(darwin
, bsdthread_ctl
); // 478
591 // NYI openbyid_np // 479
592 // NYI recvmsg_x // 480
593 // NYI sendmsg_x // 481
594 // NYI thread_selfusage // 482
595 DECL_TEMPLATE(darwin
, csrctl
); // 483
596 DECL_TEMPLATE(darwin
, guarded_open_dprotected_np
); // 484
597 DECL_TEMPLATE(darwin
, guarded_write_np
); // 485
598 DECL_TEMPLATE(darwin
, guarded_pwrite_np
); // 486
599 DECL_TEMPLATE(darwin
, guarded_writev_np
); // 487
600 // NYI renameatx_np // 488
601 // NYI mremap_encrypted // 489
602 #endif /* DARWIN_VERS >= DARWIN_10_10 */
603 #if DARWIN_VERS >= DARWIN_10_11
604 // NYI netagent_trigger // 490
605 // NYI stack_snapshot_with_config // 491
606 // NYI microstackshot // 492
607 // NYI grab_pgo_data // 493
608 // NYI persona // 494
613 // NYI work_interval_ctl // 499
614 #endif /* DARWIN_VERS >= DARWIN_10_11 */
615 #if DARWIN_VERS >= DARWIN_10_12
616 DECL_TEMPLATE(darwin
, getentropy
); // 500
617 // NYI necp_open // 501
618 // NYI necp_client_action // 502
631 DECL_TEMPLATE(darwin
, ulock_wait
); // 515
632 DECL_TEMPLATE(darwin
, ulock_wake
); // 516
633 // NYI fclonefileat // 517
634 // NYI fs_snapshot // 518
636 // NYI terminate_with_payload // 520
637 // NYI abort_with_payload // 521
638 #endif /* DARWIN_VERS >= DARWIN_10_12 */
639 #if DARWIN_VERS >= DARWIN_10_13
640 // NYI necp_session_open // 522
641 // NYI necp_session_action // 523
642 // NYI setattrlistat // 524
643 // NYI net_qos_guideline // 525
645 // NYI ntp_adjtime // 527
646 // NYI ntp_gettime // 528
647 // NYI os_fault_with_payload // 529
648 #endif /* DARWIN_VERS >= DARWIN_10_13 */
650 // Mach message helpers
651 DECL_TEMPLATE(darwin
, mach_port_set_context
);
652 DECL_TEMPLATE(darwin
, host_info
);
653 DECL_TEMPLATE(darwin
, host_page_size
);
654 DECL_TEMPLATE(darwin
, host_get_io_master
);
655 DECL_TEMPLATE(darwin
, host_get_clock_service
);
656 DECL_TEMPLATE(darwin
, host_request_notification
);
657 DECL_TEMPLATE(darwin
, host_create_mach_voucher
);
658 DECL_TEMPLATE(darwin
, host_get_special_port
);
659 DECL_TEMPLATE(darwin
, mach_port_type
);
660 DECL_TEMPLATE(darwin
, mach_port_extract_member
);
661 DECL_TEMPLATE(darwin
, mach_port_allocate
);
662 DECL_TEMPLATE(darwin
, mach_port_deallocate
);
663 DECL_TEMPLATE(darwin
, mach_port_get_refs
);
664 DECL_TEMPLATE(darwin
, mach_port_mod_refs
);
665 DECL_TEMPLATE(darwin
, mach_port_get_set_status
);
666 DECL_TEMPLATE(darwin
, mach_port_move_member
);
667 DECL_TEMPLATE(darwin
, mach_port_destroy
);
668 DECL_TEMPLATE(darwin
, mach_port_request_notification
);
669 DECL_TEMPLATE(darwin
, mach_port_insert_right
);
670 DECL_TEMPLATE(darwin
, mach_port_extract_right
);
671 DECL_TEMPLATE(darwin
, mach_port_get_attributes
);
672 DECL_TEMPLATE(darwin
, mach_port_set_attributes
);
673 DECL_TEMPLATE(darwin
, mach_port_insert_member
);
674 DECL_TEMPLATE(darwin
, task_get_special_port
);
675 DECL_TEMPLATE(darwin
, task_set_special_port
);
676 DECL_TEMPLATE(darwin
, task_get_exception_ports
);
677 DECL_TEMPLATE(darwin
, semaphore_create
);
678 DECL_TEMPLATE(darwin
, semaphore_destroy
);
679 DECL_TEMPLATE(darwin
, task_policy_set
);
680 DECL_TEMPLATE(darwin
, mach_ports_register
);
681 DECL_TEMPLATE(darwin
, mach_ports_lookup
);
682 DECL_TEMPLATE(darwin
, task_info
);
683 DECL_TEMPLATE(darwin
, task_set_info
);
684 DECL_TEMPLATE(darwin
, task_threads
);
685 DECL_TEMPLATE(darwin
, task_suspend
);
686 DECL_TEMPLATE(darwin
, task_resume
);
687 DECL_TEMPLATE(darwin
, vm_allocate
);
688 DECL_TEMPLATE(darwin
, vm_deallocate
);
689 DECL_TEMPLATE(darwin
, vm_protect
);
690 DECL_TEMPLATE(darwin
, vm_inherit
);
691 DECL_TEMPLATE(darwin
, vm_read
);
692 DECL_TEMPLATE(darwin
, mach_vm_read
);
693 DECL_TEMPLATE(darwin
, vm_copy
);
694 DECL_TEMPLATE(darwin
, vm_read_overwrite
);
695 DECL_TEMPLATE(darwin
, vm_map
);
696 DECL_TEMPLATE(darwin
, vm_remap
);
697 DECL_TEMPLATE(darwin
, mach_make_memory_entry_64
);
698 DECL_TEMPLATE(darwin
, vm_purgable_control
);
699 DECL_TEMPLATE(darwin
, mach_vm_purgable_control
);
700 DECL_TEMPLATE(darwin
, mach_vm_allocate
);
701 DECL_TEMPLATE(darwin
, mach_vm_deallocate
);
702 DECL_TEMPLATE(darwin
, mach_vm_protect
);
703 DECL_TEMPLATE(darwin
, mach_vm_copy
);
704 DECL_TEMPLATE(darwin
, mach_vm_read_overwrite
);
705 DECL_TEMPLATE(darwin
, mach_vm_inherit
);
706 DECL_TEMPLATE(darwin
, mach_vm_map
);
707 DECL_TEMPLATE(darwin
, mach_vm_remap
);
708 DECL_TEMPLATE(darwin
, mach_vm_region_recurse
);
709 DECL_TEMPLATE(darwin
, thread_terminate
);
710 DECL_TEMPLATE(darwin
, thread_create
);
711 DECL_TEMPLATE(darwin
, thread_create_running
);
712 DECL_TEMPLATE(darwin
, thread_suspend
);
713 DECL_TEMPLATE(darwin
, thread_resume
);
714 DECL_TEMPLATE(darwin
, thread_get_state
);
715 DECL_TEMPLATE(darwin
, thread_policy
);
716 DECL_TEMPLATE(darwin
, thread_policy_set
);
717 DECL_TEMPLATE(darwin
, thread_info
);
718 DECL_TEMPLATE(darwin
, bootstrap_register
);
719 DECL_TEMPLATE(darwin
, bootstrap_look_up
);
720 DECL_TEMPLATE(darwin
, mach_msg_receive
);
721 DECL_TEMPLATE(darwin
, mach_msg_bootstrap
);
722 DECL_TEMPLATE(darwin
, mach_msg_host
);
723 DECL_TEMPLATE(darwin
, mach_msg_task
);
724 DECL_TEMPLATE(darwin
, mach_msg_thread
);
727 #if DARWIN_VERS >= DARWIN_10_8
728 DECL_TEMPLATE(darwin
, kernelrpc_mach_vm_allocate_trap
);
729 DECL_TEMPLATE(darwin
, kernelrpc_mach_vm_deallocate_trap
);
730 DECL_TEMPLATE(darwin
, kernelrpc_mach_vm_protect_trap
);
731 DECL_TEMPLATE(darwin
, kernelrpc_mach_vm_map_trap
);
732 DECL_TEMPLATE(darwin
, kernelrpc_mach_port_allocate_trap
);
733 DECL_TEMPLATE(darwin
, kernelrpc_mach_port_destroy_trap
);
734 DECL_TEMPLATE(darwin
, kernelrpc_mach_port_deallocate_trap
);
735 DECL_TEMPLATE(darwin
, kernelrpc_mach_port_mod_refs_trap
);
736 DECL_TEMPLATE(darwin
, kernelrpc_mach_port_move_member_trap
);
737 DECL_TEMPLATE(darwin
, kernelrpc_mach_port_insert_right_trap
);
738 DECL_TEMPLATE(darwin
, kernelrpc_mach_port_insert_member_trap
);
739 DECL_TEMPLATE(darwin
, kernelrpc_mach_port_extract_member_trap
);
740 DECL_TEMPLATE(darwin
, kernelrpc_mach_port_construct_trap
);
741 DECL_TEMPLATE(darwin
, kernelrpc_mach_port_destruct_trap
);
742 DECL_TEMPLATE(darwin
, kernelrpc_mach_port_guard_trap
);
743 DECL_TEMPLATE(darwin
, kernelrpc_mach_port_unguard_trap
);
744 DECL_TEMPLATE(darwin
, iopolicysys
);
745 DECL_TEMPLATE(darwin
, process_policy
);
746 #endif /* DARWIN_VERS >= DARWIN_10_8 */
747 DECL_TEMPLATE(darwin
, mach_msg_unhandled
);
748 DECL_TEMPLATE(darwin
, mach_msg_unhandled_check
);
749 DECL_TEMPLATE(darwin
, mach_msg
);
750 DECL_TEMPLATE(darwin
, mach_reply_port
);
751 DECL_TEMPLATE(darwin
, mach_thread_self
);
752 DECL_TEMPLATE(darwin
, mach_host_self
);
753 DECL_TEMPLATE(darwin
, mach_task_self
);
754 DECL_TEMPLATE(darwin
, syscall_thread_switch
);
755 DECL_TEMPLATE(darwin
, semaphore_signal
);
756 DECL_TEMPLATE(darwin
, semaphore_signal_all
);
757 DECL_TEMPLATE(darwin
, semaphore_signal_thread
);
758 DECL_TEMPLATE(darwin
, semaphore_wait
);
759 DECL_TEMPLATE(darwin
, semaphore_wait_signal
);
760 DECL_TEMPLATE(darwin
, semaphore_timedwait
);
761 DECL_TEMPLATE(darwin
, semaphore_timedwait_signal
);
762 DECL_TEMPLATE(darwin
, task_for_pid
);
763 DECL_TEMPLATE(darwin
, pid_for_task
);
765 #if DARWIN_VERS >= DARWIN_10_13
766 // NYI thread_get_special_reply_port // 50
767 #endif /* DARWIN_VERS >= DARWIN_10_13 */
769 #if DARWIN_VERS >= DARWIN_10_12
770 DECL_TEMPLATE(darwin
, host_create_mach_voucher_trap
);
771 DECL_TEMPLATE(darwin
, task_register_dyld_image_infos
);
772 DECL_TEMPLATE(darwin
, task_register_dyld_shared_cache_image_info
);
773 DECL_TEMPLATE(darwin
, mach_generate_activity_id
);
774 #endif /* DARWIN_VERS >= DARWIN_10_12 */
776 DECL_TEMPLATE(darwin
, mach_timebase_info
);
777 DECL_TEMPLATE(darwin
, mach_wait_until
);
778 DECL_TEMPLATE(darwin
, mk_timer_create
);
779 DECL_TEMPLATE(darwin
, mk_timer_destroy
);
780 DECL_TEMPLATE(darwin
, mk_timer_arm
);
781 DECL_TEMPLATE(darwin
, mk_timer_cancel
);
782 DECL_TEMPLATE(darwin
, iokit_user_client_trap
);
783 DECL_TEMPLATE(darwin
, swtch
);
784 DECL_TEMPLATE(darwin
, swtch_pri
);
786 // Machine-dependent traps
787 DECL_TEMPLATE(darwin
, thread_fast_set_cthread_self
);
789 // syswrap-<arch>-darwin.c
790 #include <mach/mach.h>
792 void thread_state_from_vex(thread_state_t mach_generic
,
793 thread_state_flavor_t flavor
,
794 mach_msg_type_number_t count
,
795 VexGuestArchState
*vex_generic
);
797 void thread_state_to_vex(const thread_state_t mach_generic
,
798 thread_state_flavor_t flavor
,
799 mach_msg_type_number_t count
,
800 VexGuestArchState
*vex_generic
);
802 ThreadState
*build_thread(const thread_state_t state
,
803 thread_state_flavor_t flavor
,
804 mach_msg_type_number_t count
);
806 void hijack_thread_state(thread_state_t mach_generic
,
807 thread_state_flavor_t flavor
,
808 mach_msg_type_number_t count
,
811 __attribute__((noreturn
))
812 void call_on_new_stack_0_1 ( Addr stack
,
817 extern void pthread_hijack_asm(void);
818 extern void pthread_hijack(Addr self
, Addr kport
, Addr func
, Addr func_arg
,
819 Addr stacksize
, Addr flags
, Addr sp
);
820 extern void wqthread_hijack_asm(void);
821 extern void wqthread_hijack(Addr self
, Addr kport
, Addr stackaddr
, Addr workitem
, Int reuse
, Addr sp
);
823 extern Addr pthread_starter
;
824 extern Addr wqthread_starter
;
825 extern SizeT pthread_structsize
;
830 /*--------------------------------------------------------------------*/
832 /*--------------------------------------------------------------------*/