| ... | @@ -15,6 +15,131 @@ const arch_bits = switch (native_arch) { | ... | @@ -15,6 +15,131 @@ const arch_bits = switch (native_arch) { |
| 15 | else => struct {}, | 15 | else => struct {}, |
| 16 | }; | 16 | }; |
| 17 | | 17 | |
| | 18 | pub const EXC_TYPES_COUNT = arch_bits.EXC_TYPES_COUNT; |
| | 19 | pub const THREAD_STATE_NONE = arch_bits.THREAD_STATE_NONE; |
| | 20 | |
| | 21 | pub const EXC = enum(exception_type_t) { |
| | 22 | NULL = 0, |
| | 23 | /// Could not access memory |
| | 24 | BAD_ACCESS = 1, |
| | 25 | /// Instruction failed |
| | 26 | BAD_INSTRUCTION = 2, |
| | 27 | /// Arithmetic exception |
| | 28 | ARITHMETIC = 3, |
| | 29 | /// Emulation instruction |
| | 30 | EMULATION = 4, |
| | 31 | /// Software generated exception |
| | 32 | SOFTWARE = 5, |
| | 33 | /// Trace, breakpoint, etc. |
| | 34 | BREAKPOINT = 6, |
| | 35 | /// System calls. |
| | 36 | SYSCALL = 7, |
| | 37 | /// Mach system calls. |
| | 38 | MACH_SYSCALL = 8, |
| | 39 | /// RPC alert |
| | 40 | RPC_ALERT = 9, |
| | 41 | /// Abnormal process exit |
| | 42 | CRASH = 10, |
| | 43 | /// Hit resource consumption limit |
| | 44 | RESOURCE = 11, |
| | 45 | /// Violated guarded resource protections |
| | 46 | GUARD = 12, |
| | 47 | /// Abnormal process exited to corpse state |
| | 48 | CORPSE_NOTIFY = 13, |
| | 49 | }; |
| | 50 | |
| | 51 | pub const EXC_SOFT_SIGNAL = 0x10003; |
| | 52 | |
| | 53 | pub const EXC_MASK_BAD_ACCESS = 1 << @enumToInt(EXC.BAD_ACCESS); |
| | 54 | pub const EXC_MASK_BAD_INSTRUCTION = 1 << @enumToInt(EXC.BAD_INSTRUCTION); |
| | 55 | pub const EXC_MASK_ARITHMETIC = 1 << @enumToInt(EXC.ARITHMETIC); |
| | 56 | pub const EXC_MASK_EMULATION = 1 << @enumToInt(EXC.EMULATION); |
| | 57 | pub const EXC_MASK_SOFTWARE = 1 << @enumToInt(EXC.SOFTWARE); |
| | 58 | pub const EXC_MASK_BREAKPOINT = 1 << @enumToInt(EXC.BREAKPOINT); |
| | 59 | pub const EXC_MASK_SYSCALL = 1 << @enumToInt(EXC.SYSCALL); |
| | 60 | pub const EXC_MASK_MACH_SYSCALL = 1 << @enumToInt(EXC.MACH_SYSCALL); |
| | 61 | pub const EXC_MASK_RPC_ALERT = 1 << @enumToInt(EXC.RPC_ALERT); |
| | 62 | pub const EXC_MASK_CRASH = 1 << @enumToInt(EXC.CRASH); |
| | 63 | pub const EXC_MASK_RESOURCE = 1 << @enumToInt(EXC.RESOURCE); |
| | 64 | pub const EXC_MASK_GUARD = 1 << @enumToInt(EXC.GUARD); |
| | 65 | pub const EXC_MASK_CORPSE_NOTIFY = 1 << @enumToInt(EXC.CORPSE_NOTIFY); |
| | 66 | pub const EXC_MASK_MACHINE = arch_bits.EXC_MASK_MACHINE; |
| | 67 | |
| | 68 | pub const EXC_MASK_ALL = EXC_MASK_BAD_ACCESS | |
| | 69 | EXC_MASK_BAD_INSTRUCTION | |
| | 70 | EXC_MASK_ARITHMETIC | |
| | 71 | EXC_MASK_EMULATION | |
| | 72 | EXC_MASK_SOFTWARE | |
| | 73 | EXC_MASK_BREAKPOINT | |
| | 74 | EXC_MASK_SYSCALL | |
| | 75 | EXC_MASK_MACH_SYSCALL | |
| | 76 | EXC_MASK_RPC_ALERT | |
| | 77 | EXC_MASK_RESOURCE | |
| | 78 | EXC_MASK_GUARD | |
| | 79 | EXC_MASK_MACHINE; |
| | 80 | |
| | 81 | /// Send a catch_exception_raise message including the identity. |
| | 82 | pub const EXCEPTION_DEFAULT = 1; |
| | 83 | /// Send a catch_exception_raise_state message including the |
| | 84 | /// thread state. |
| | 85 | pub const EXCEPTION_STATE = 2; |
| | 86 | /// Send a catch_exception_raise_state_identity message including |
| | 87 | /// the thread identity and state. |
| | 88 | pub const EXCEPTION_STATE_IDENTITY = 3; |
| | 89 | /// Send a catch_exception_raise_identity_protected message including protected task |
| | 90 | /// and thread identity. |
| | 91 | pub const EXCEPTION_IDENTITY_PROTECTED = 4; |
| | 92 | /// Prefer sending a catch_exception_raice_backtrace message, if applicable. |
| | 93 | pub const MACH_EXCEPTION_BACKTRACE_PREFERRED = 0x20000000; |
| | 94 | /// include additional exception specific errors, not used yet. |
| | 95 | pub const MACH_EXCEPTION_ERRORS = 0x40000000; |
| | 96 | /// Send 64-bit code and subcode in the exception header */ |
| | 97 | pub const MACH_EXCEPTION_CODES = 0x80000000; |
| | 98 | |
| | 99 | pub const MACH_EXCEPTION_MASK = MACH_EXCEPTION_CODES | |
| | 100 | MACH_EXCEPTION_ERRORS | |
| | 101 | MACH_EXCEPTION_BACKTRACE_PREFERRED; |
| | 102 | |
| | 103 | pub const TASK_NULL: task_t = 0; |
| | 104 | pub const THREAD_NULL: thread_t = 0; |
| | 105 | pub const MACH_PORT_NULL: mach_port_t = 0; |
| | 106 | pub const MACH_MSG_TIMEOUT_NONE: mach_msg_timeout_t = 0; |
| | 107 | |
| | 108 | pub const MACH_MSG_OPTION_NONE = 0x00000000; |
| | 109 | |
| | 110 | pub const MACH_SEND_MSG = 0x00000001; |
| | 111 | pub const MACH_RCV_MSG = 0x00000002; |
| | 112 | |
| | 113 | pub const MACH_RCV_LARGE = 0x00000004; |
| | 114 | pub const MACH_RCV_LARGE_IDENTITY = 0x00000008; |
| | 115 | |
| | 116 | pub const MACH_SEND_TIMEOUT = 0x00000010; |
| | 117 | pub const MACH_SEND_OVERRIDE = 0x00000020; |
| | 118 | pub const MACH_SEND_INTERRUPT = 0x00000040; |
| | 119 | pub const MACH_SEND_NOTIFY = 0x00000080; |
| | 120 | pub const MACH_SEND_ALWAYS = 0x00010000; |
| | 121 | pub const MACH_SEND_FILTER_NONFATAL = 0x00010000; |
| | 122 | pub const MACH_SEND_TRAILER = 0x00020000; |
| | 123 | pub const MACH_SEND_NOIMPORTANCE = 0x00040000; |
| | 124 | pub const MACH_SEND_NODENAP = MACH_SEND_NOIMPORTANCE; |
| | 125 | pub const MACH_SEND_IMPORTANCE = 0x00080000; |
| | 126 | pub const MACH_SEND_SYNC_OVERRIDE = 0x00100000; |
| | 127 | pub const MACH_SEND_PROPAGATE_QOS = 0x00200000; |
| | 128 | pub const MACH_SEND_SYNC_USE_THRPRI = MACH_SEND_PROPAGATE_QOS; |
| | 129 | pub const MACH_SEND_KERNEL = 0x00400000; |
| | 130 | pub const MACH_SEND_SYNC_BOOTSTRAP_CHECKIN = 0x00800000; |
| | 131 | |
| | 132 | pub const MACH_RCV_TIMEOUT = 0x00000100; |
| | 133 | pub const MACH_RCV_NOTIFY = 0x00000000; |
| | 134 | pub const MACH_RCV_INTERRUPT = 0x00000400; |
| | 135 | pub const MACH_RCV_VOUCHER = 0x00000800; |
| | 136 | pub const MACH_RCV_OVERWRITE = 0x00000000; |
| | 137 | pub const MACH_RCV_GUARDED_DESC = 0x00001000; |
| | 138 | pub const MACH_RCV_SYNC_WAIT = 0x00004000; |
| | 139 | pub const MACH_RCV_SYNC_PEEK = 0x00008000; |
| | 140 | |
| | 141 | pub const MACH_MSG_STRICT_REPLY = 0x00000200; |
| | 142 | |
| 18 | pub const ucontext_t = extern struct { | 143 | pub const ucontext_t = extern struct { |
| 19 | onstack: c_int, | 144 | onstack: c_int, |
| 20 | sigmask: sigset_t, | 145 | sigmask: sigset_t, |
| ... | @@ -155,6 +280,11 @@ pub extern "c" fn @"close$NOCANCEL"(fd: fd_t) c_int; | ... | @@ -155,6 +280,11 @@ pub extern "c" fn @"close$NOCANCEL"(fd: fd_t) c_int; |
| 155 | pub extern "c" fn mach_host_self() mach_port_t; | 280 | pub extern "c" fn mach_host_self() mach_port_t; |
| 156 | pub extern "c" fn clock_get_time(clock_serv: clock_serv_t, cur_time: *mach_timespec_t) kern_return_t; | 281 | pub extern "c" fn clock_get_time(clock_serv: clock_serv_t, cur_time: *mach_timespec_t) kern_return_t; |
| 157 | | 282 | |
| | 283 | pub const exception_type_t = c_int; |
| | 284 | pub const exception_data_type_t = integer_t; |
| | 285 | pub const exception_data_t = ?*mach_exception_data_type_t; |
| | 286 | pub const mach_exception_data_type_t = i64; |
| | 287 | pub const mach_exception_data_t = ?*mach_exception_data_type_t; |
| 158 | pub const vm_map_t = mach_port_t; | 288 | pub const vm_map_t = mach_port_t; |
| 159 | pub const vm_map_read_t = mach_port_t; | 289 | pub const vm_map_read_t = mach_port_t; |
| 160 | pub const vm_region_flavor_t = c_int; | 290 | pub const vm_region_flavor_t = c_int; |
| ... | @@ -163,19 +293,122 @@ pub const vm_region_recurse_info_t = *c_int; | ... | @@ -163,19 +293,122 @@ pub const vm_region_recurse_info_t = *c_int; |
| 163 | pub const mach_vm_address_t = usize; | 293 | pub const mach_vm_address_t = usize; |
| 164 | pub const vm_offset_t = usize; | 294 | pub const vm_offset_t = usize; |
| 165 | pub const mach_vm_size_t = u64; | 295 | pub const mach_vm_size_t = u64; |
| | 296 | pub const mach_msg_bits_t = c_uint; |
| | 297 | pub const mach_msg_id_t = integer_t; |
| 166 | pub const mach_msg_type_number_t = natural_t; | 298 | pub const mach_msg_type_number_t = natural_t; |
| | 299 | pub const mach_msg_type_name_t = c_uint; |
| | 300 | pub const mach_msg_option_t = integer_t; |
| | 301 | pub const mach_msg_size_t = natural_t; |
| | 302 | pub const mach_msg_timeout_t = natural_t; |
| | 303 | pub const mach_port_right_t = natural_t; |
| | 304 | pub const task_t = mach_port_t; |
| | 305 | pub const thread_port_t = task_t; |
| | 306 | pub const thread_t = thread_port_t; |
| | 307 | pub const exception_mask_t = c_uint; |
| | 308 | pub const exception_mask_array_t = [*]exception_mask_t; |
| | 309 | pub const exception_handler_t = mach_port_t; |
| | 310 | pub const exception_handler_array_t = [*]exception_handler_t; |
| | 311 | pub const exception_port_t = exception_handler_t; |
| | 312 | pub const exception_port_array_t = exception_handler_array_t; |
| | 313 | pub const exception_flavor_array_t = [*]thread_state_flavor_t; |
| | 314 | pub const exception_behavior_t = c_uint; |
| | 315 | pub const exception_behavior_array_t = [*]exception_behavior_t; |
| | 316 | pub const thread_state_flavor_t = c_int; |
| | 317 | pub const ipc_space_t = mach_port_t; |
| | 318 | pub const ipc_space_port_t = ipc_space_t; |
| | 319 | |
| | 320 | pub const MACH_PORT_RIGHT = enum(mach_port_right_t) { |
| | 321 | SEND = 0, |
| | 322 | RECEIVE = 1, |
| | 323 | SEND_ONCE = 2, |
| | 324 | PORT_SET = 3, |
| | 325 | DEAD_NAME = 4, |
| | 326 | /// Obsolete right |
| | 327 | LABELH = 5, |
| | 328 | /// Right not implemented |
| | 329 | NUMBER = 6, |
| | 330 | }; |
| | 331 | |
| | 332 | pub const MACH_MSG_TYPE = enum(mach_msg_type_name_t) { |
| | 333 | /// Must hold receive right |
| | 334 | MOVE_RECEIVE = 16, |
| | 335 | |
| | 336 | /// Must hold send right(s) |
| | 337 | MOVE_SEND = 17, |
| | 338 | |
| | 339 | /// Must hold sendonce right |
| | 340 | MOVE_SEND_ONCE = 18, |
| | 341 | |
| | 342 | /// Must hold send right(s) |
| | 343 | COPY_SEND = 19, |
| | 344 | |
| | 345 | /// Must hold receive right |
| | 346 | MAKE_SEND = 20, |
| | 347 | |
| | 348 | /// Must hold receive right |
| | 349 | MAKE_SEND_ONCE = 21, |
| | 350 | |
| | 351 | /// NOT VALID |
| | 352 | COPY_RECEIVE = 22, |
| | 353 | |
| | 354 | /// Must hold receive right |
| | 355 | DISPOSE_RECEIVE = 24, |
| | 356 | |
| | 357 | /// Must hold send right(s) |
| | 358 | DISPOSE_SEND = 25, |
| | 359 | |
| | 360 | /// Must hold sendonce right |
| | 361 | DISPOSE_SEND_ONCE = 26, |
| | 362 | }; |
| 167 | | 363 | |
| 168 | extern "c" var mach_task_self_: mach_port_t; | 364 | extern "c" var mach_task_self_: mach_port_t; |
| 169 | pub fn mach_task_self() callconv(.C) mach_port_t { | 365 | pub fn mach_task_self() callconv(.C) mach_port_t { |
| 170 | return mach_task_self_; | 366 | return mach_task_self_; |
| 171 | } | 367 | } |
| 172 | | 368 | |
| | 369 | pub extern "c" fn mach_msg( |
| | 370 | msg: ?*mach_msg_header_t, |
| | 371 | option: mach_msg_option_t, |
| | 372 | send_size: mach_msg_size_t, |
| | 373 | rcv_size: mach_msg_size_t, |
| | 374 | rcv_name: mach_port_name_t, |
| | 375 | timeout: mach_msg_timeout_t, |
| | 376 | notify: mach_port_name_t, |
| | 377 | ) kern_return_t; |
| | 378 | |
| | 379 | pub const mach_msg_header_t = extern struct { |
| | 380 | msgh_bits: mach_msg_bits_t, |
| | 381 | msgh_size: mach_msg_size_t, |
| | 382 | msgh_remote_port: mach_port_t, |
| | 383 | msgh_local_port: mach_port_t, |
| | 384 | msgh_voucher_port: mach_port_name_t, |
| | 385 | msgh_id: mach_msg_id_t, |
| | 386 | }; |
| | 387 | |
| | 388 | pub extern "c" fn task_get_exception_ports( |
| | 389 | task: task_t, |
| | 390 | exception_mask: exception_mask_t, |
| | 391 | masks: exception_mask_array_t, |
| | 392 | masks_cnt: *mach_msg_type_number_t, |
| | 393 | old_handlers: exception_handler_array_t, |
| | 394 | old_behaviors: exception_behavior_array_t, |
| | 395 | old_flavors: exception_flavor_array_t, |
| | 396 | ) kern_return_t; |
| | 397 | pub extern "c" fn task_set_exception_ports( |
| | 398 | task: task_t, |
| | 399 | exception_mask: exception_mask_t, |
| | 400 | new_port: mach_port_t, |
| | 401 | behavior: exception_behavior_t, |
| | 402 | new_flavor: thread_state_flavor_t, |
| | 403 | ) kern_return_t; |
| | 404 | |
| 173 | pub const task_read_t = mach_port_t; | 405 | pub const task_read_t = mach_port_t; |
| 174 | | 406 | |
| 175 | pub extern "c" fn task_resume(target_task: task_read_t) kern_return_t; | 407 | pub extern "c" fn task_resume(target_task: task_read_t) kern_return_t; |
| 176 | pub extern "c" fn task_suspend(target_task: task_read_t) kern_return_t; | 408 | pub extern "c" fn task_suspend(target_task: task_read_t) kern_return_t; |
| 177 | | 409 | |
| 178 | pub extern "c" fn task_for_pid(target_tport: mach_port_name_t, pid: pid_t, t: *mach_port_name_t) kern_return_t; | 410 | pub extern "c" fn task_for_pid(target_tport: mach_port_name_t, pid: pid_t, t: *mach_port_name_t) kern_return_t; |
| | 411 | pub extern "c" fn pid_for_task(target_tport: mach_port_name_t, pid: *pid_t) kern_return_t; |
| 179 | pub extern "c" fn mach_vm_read( | 412 | pub extern "c" fn mach_vm_read( |
| 180 | target_task: vm_map_read_t, | 413 | target_task: vm_map_read_t, |
| 181 | address: mach_vm_address_t, | 414 | address: mach_vm_address_t, |
| ... | @@ -343,7 +576,7 @@ pub const vm_region_submap_short_info_64 = extern struct { | ... | @@ -343,7 +576,7 @@ pub const vm_region_submap_short_info_64 = extern struct { |
| 343 | | 576 | |
| 344 | pub const thread_act_t = mach_port_t; | 577 | pub const thread_act_t = mach_port_t; |
| 345 | pub const thread_state_t = *natural_t; | 578 | pub const thread_state_t = *natural_t; |
| 346 | pub const mach_port_array_t = *mach_port_t; | 579 | pub const mach_port_array_t = [*]mach_port_t; |
| 347 | | 580 | |
| 348 | pub extern "c" fn task_threads( | 581 | pub extern "c" fn task_threads( |
| 349 | target_task: mach_port_t, | 582 | target_task: mach_port_t, |
| ... | @@ -373,6 +606,9 @@ pub extern "c" fn thread_resume(thread: thread_act_t) kern_return_t; | ... | @@ -373,6 +606,9 @@ pub extern "c" fn thread_resume(thread: thread_act_t) kern_return_t; |
| 373 | pub const THREAD_BASIC_INFO = 3; | 606 | pub const THREAD_BASIC_INFO = 3; |
| 374 | pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t = @sizeOf(thread_basic_info) / @sizeOf(natural_t); | 607 | pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t = @sizeOf(thread_basic_info) / @sizeOf(natural_t); |
| 375 | | 608 | |
| | 609 | pub const THREAD_IDENTIFIER_INFO = 4; |
| | 610 | pub const THREAD_IDENTIFIER_INFO_COUNT: mach_msg_type_number_t = @sizeOf(thread_identifier_info) / @sizeOf(natural_t); |
| | 611 | |
| 376 | pub const thread_flavor_t = natural_t; | 612 | pub const thread_flavor_t = natural_t; |
| 377 | pub const thread_info_t = *integer_t; | 613 | pub const thread_info_t = *integer_t; |
| 378 | pub const time_value_t = time_value; | 614 | pub const time_value_t = time_value; |
| ... | @@ -404,6 +640,17 @@ pub const thread_basic_info = extern struct { | ... | @@ -404,6 +640,17 @@ pub const thread_basic_info = extern struct { |
| 404 | sleep_time: integer_t, | 640 | sleep_time: integer_t, |
| 405 | }; | 641 | }; |
| 406 | | 642 | |
| | 643 | pub const thread_identifier_info = extern struct { |
| | 644 | /// System-wide unique 64-bit thread id |
| | 645 | thread_id: u64, |
| | 646 | |
| | 647 | /// Handle to be used by libproc |
| | 648 | thread_handle: u64, |
| | 649 | |
| | 650 | /// libdispatch queue address |
| | 651 | dispatch_qaddr: u64, |
| | 652 | }; |
| | 653 | |
| 407 | /// Cachability | 654 | /// Cachability |
| 408 | pub const MATTR_CACHE = 1; | 655 | pub const MATTR_CACHE = 1; |
| 409 | /// Migrability | 656 | /// Migrability |
| ... | @@ -506,7 +753,18 @@ pub extern "c" fn mach_vm_protect( | ... | @@ -506,7 +753,18 @@ pub extern "c" fn mach_vm_protect( |
| 506 | new_protection: vm_prot_t, | 753 | new_protection: vm_prot_t, |
| 507 | ) kern_return_t; | 754 | ) kern_return_t; |
| 508 | | 755 | |
| 509 | pub extern "c" fn mach_port_deallocate(target_tport: mach_port_name_t, task: mach_port_name_t) kern_return_t; | 756 | pub extern "c" fn mach_port_allocate( |
| | 757 | task: ipc_space_t, |
| | 758 | right: mach_port_right_t, |
| | 759 | name: *mach_port_name_t, |
| | 760 | ) kern_return_t; |
| | 761 | pub extern "c" fn mach_port_deallocate(task: ipc_space_t, name: mach_port_name_t) kern_return_t; |
| | 762 | pub extern "c" fn mach_port_insert_right( |
| | 763 | task: ipc_space_t, |
| | 764 | name: mach_port_name_t, |
| | 765 | poly: mach_port_t, |
| | 766 | poly_poly: mach_msg_type_name_t, |
| | 767 | ) kern_return_t; |
| 510 | | 768 | |
| 511 | pub extern "c" fn task_info( | 769 | pub extern "c" fn task_info( |
| 512 | target_task: task_name_t, | 770 | target_task: task_name_t, |
| ... | @@ -514,6 +772,30 @@ pub extern "c" fn task_info( | ... | @@ -514,6 +772,30 @@ pub extern "c" fn task_info( |
| 514 | task_info_out: task_info_t, | 772 | task_info_out: task_info_t, |
| 515 | task_info_outCnt: *mach_msg_type_number_t, | 773 | task_info_outCnt: *mach_msg_type_number_t, |
| 516 | ) kern_return_t; | 774 | ) kern_return_t; |
| | 775 | |
| | 776 | pub const mach_task_basic_info = extern struct { |
| | 777 | /// Virtual memory size (bytes) |
| | 778 | virtual_size: mach_vm_size_t, |
| | 779 | |
| | 780 | /// Resident memory size (bytes) |
| | 781 | resident_size: mach_vm_size_t, |
| | 782 | |
| | 783 | /// Total user run time for terminated threads |
| | 784 | user_time: time_value_t, |
| | 785 | |
| | 786 | /// Total system run time for terminated threads |
| | 787 | system_time: time_value_t, |
| | 788 | |
| | 789 | /// Default policy for new threads |
| | 790 | policy: policy_t, |
| | 791 | |
| | 792 | /// Suspend count for task |
| | 793 | suspend_count: mach_vm_size_t, |
| | 794 | }; |
| | 795 | |
| | 796 | pub const MACH_TASK_BASIC_INFO = 20; |
| | 797 | pub const MACH_TASK_BASIC_INFO_COUNT: mach_msg_type_number_t = @sizeOf(mach_task_basic_info) / @sizeOf(natural_t); |
| | 798 | |
| 517 | pub extern "c" fn _host_page_size(task: mach_port_t, size: *vm_size_t) kern_return_t; | 799 | pub extern "c" fn _host_page_size(task: mach_port_t, size: *vm_size_t) kern_return_t; |
| 518 | pub extern "c" fn vm_deallocate(target_task: vm_map_t, address: vm_address_t, size: vm_size_t) kern_return_t; | 800 | pub extern "c" fn vm_deallocate(target_task: vm_map_t, address: vm_address_t, size: vm_size_t) kern_return_t; |
| 519 | pub extern "c" fn vm_machine_attribute( | 801 | pub extern "c" fn vm_machine_attribute( |
| ... | @@ -1885,11 +2167,11 @@ pub const E = enum(u16) { | ... | @@ -1885,11 +2167,11 @@ pub const E = enum(u16) { |
| 1885 | }; | 2167 | }; |
| 1886 | | 2168 | |
| 1887 | pub fn getKernError(err: kern_return_t) KernE { | 2169 | pub fn getKernError(err: kern_return_t) KernE { |
| 1888 | return @intToEnum(KernE, @truncate(u8, @intCast(usize, err))); | 2170 | return @intToEnum(KernE, @truncate(u32, @intCast(usize, err))); |
| 1889 | } | 2171 | } |
| 1890 | | 2172 | |
| 1891 | /// Kernel return values | 2173 | /// Kernel return values |
| 1892 | pub const KernE = enum(u8) { | 2174 | pub const KernE = enum(u32) { |
| 1893 | SUCCESS = 0, | 2175 | SUCCESS = 0, |
| 1894 | | 2176 | |
| 1895 | /// Specified address is not currently valid | 2177 | /// Specified address is not currently valid |
| ... | @@ -2108,6 +2390,104 @@ pub const KernE = enum(u8) { | ... | @@ -2108,6 +2390,104 @@ pub const KernE = enum(u8) { |
| 2108 | _, | 2390 | _, |
| 2109 | }; | 2391 | }; |
| 2110 | | 2392 | |
| | 2393 | pub const mach_msg_return_t = kern_return_t; |
| | 2394 | |
| | 2395 | pub fn getMachMsgError(err: mach_msg_return_t) MachMsgE { |
| | 2396 | return @intToEnum(MachMsgE, @truncate(u32, @intCast(usize, err))); |
| | 2397 | } |
| | 2398 | |
| | 2399 | /// All special error code bits defined below. |
| | 2400 | pub const MACH_MSG_MASK: u32 = 0x3e00; |
| | 2401 | /// No room in IPC name space for another capability name. |
| | 2402 | pub const MACH_MSG_IPC_SPACE: u32 = 0x2000; |
| | 2403 | /// No room in VM address space for out-of-line memory. |
| | 2404 | pub const MACH_MSG_VM_SPACE: u32 = 0x1000; |
| | 2405 | /// Kernel resource shortage handling out-of-line memory. |
| | 2406 | pub const MACH_MSG_IPC_KERNEL: u32 = 0x800; |
| | 2407 | /// Kernel resource shortage handling an IPC capability. |
| | 2408 | pub const MACH_MSG_VM_KERNEL: u32 = 0x400; |
| | 2409 | |
| | 2410 | /// Mach msg return values |
| | 2411 | pub const MachMsgE = enum(u32) { |
| | 2412 | SUCCESS = 0x00000000, |
| | 2413 | |
| | 2414 | /// Thread is waiting to send. (Internal use only.) |
| | 2415 | SEND_IN_PROGRESS = 0x10000001, |
| | 2416 | /// Bogus in-line data. |
| | 2417 | SEND_INVALID_DATA = 0x10000002, |
| | 2418 | /// Bogus destination port. |
| | 2419 | SEND_INVALID_DEST = 0x10000003, |
| | 2420 | /// Message not sent before timeout expired. |
| | 2421 | SEND_TIMED_OUT = 0x10000004, |
| | 2422 | /// Bogus voucher port. |
| | 2423 | SEND_INVALID_VOUCHER = 0x10000005, |
| | 2424 | /// Software interrupt. |
| | 2425 | SEND_INTERRUPTED = 0x10000007, |
| | 2426 | /// Data doesn't contain a complete message. |
| | 2427 | SEND_MSG_TOO_SMALL = 0x10000008, |
| | 2428 | /// Bogus reply port. |
| | 2429 | SEND_INVALID_REPLY = 0x10000009, |
| | 2430 | /// Bogus port rights in the message body. |
| | 2431 | SEND_INVALID_RIGHT = 0x1000000a, |
| | 2432 | /// Bogus notify port argument. |
| | 2433 | SEND_INVALID_NOTIFY = 0x1000000b, |
| | 2434 | /// Invalid out-of-line memory pointer. |
| | 2435 | SEND_INVALID_MEMORY = 0x1000000c, |
| | 2436 | /// No message buffer is available. |
| | 2437 | SEND_NO_BUFFER = 0x1000000d, |
| | 2438 | /// Send is too large for port |
| | 2439 | SEND_TOO_LARGE = 0x1000000e, |
| | 2440 | /// Invalid msg-type specification. |
| | 2441 | SEND_INVALID_TYPE = 0x1000000f, |
| | 2442 | /// A field in the header had a bad value. |
| | 2443 | SEND_INVALID_HEADER = 0x10000010, |
| | 2444 | /// The trailer to be sent does not match kernel format. |
| | 2445 | SEND_INVALID_TRAILER = 0x10000011, |
| | 2446 | /// The sending thread context did not match the context on the dest port |
| | 2447 | SEND_INVALID_CONTEXT = 0x10000012, |
| | 2448 | /// compatibility: no longer a returned error |
| | 2449 | SEND_INVALID_RT_OOL_SIZE = 0x10000015, |
| | 2450 | /// The destination port doesn't accept ports in body |
| | 2451 | SEND_NO_GRANT_DEST = 0x10000016, |
| | 2452 | /// Message send was rejected by message filter |
| | 2453 | SEND_MSG_FILTERED = 0x10000017, |
| | 2454 | |
| | 2455 | /// Thread is waiting for receive. (Internal use only.) |
| | 2456 | RCV_IN_PROGRESS = 0x10004001, |
| | 2457 | /// Bogus name for receive port/port-set. |
| | 2458 | RCV_INVALID_NAME = 0x10004002, |
| | 2459 | /// Didn't get a message within the timeout value. |
| | 2460 | RCV_TIMED_OUT = 0x10004003, |
| | 2461 | /// Message buffer is not large enough for inline data. |
| | 2462 | RCV_TOO_LARGE = 0x10004004, |
| | 2463 | /// Software interrupt. |
| | 2464 | RCV_INTERRUPTED = 0x10004005, |
| | 2465 | /// compatibility: no longer a returned error |
| | 2466 | RCV_PORT_CHANGED = 0x10004006, |
| | 2467 | /// Bogus notify port argument. |
| | 2468 | RCV_INVALID_NOTIFY = 0x10004007, |
| | 2469 | /// Bogus message buffer for inline data. |
| | 2470 | RCV_INVALID_DATA = 0x10004008, |
| | 2471 | /// Port/set was sent away/died during receive. |
| | 2472 | RCV_PORT_DIED = 0x10004009, |
| | 2473 | /// compatibility: no longer a returned error |
| | 2474 | RCV_IN_SET = 0x1000400a, |
| | 2475 | /// Error receiving message header. See special bits. |
| | 2476 | RCV_HEADER_ERROR = 0x1000400b, |
| | 2477 | /// Error receiving message body. See special bits. |
| | 2478 | RCV_BODY_ERROR = 0x1000400c, |
| | 2479 | /// Invalid msg-type specification in scatter list. |
| | 2480 | RCV_INVALID_TYPE = 0x1000400d, |
| | 2481 | /// Out-of-line overwrite region is not large enough |
| | 2482 | RCV_SCATTER_SMALL = 0x1000400e, |
| | 2483 | /// trailer type or number of trailer elements not supported |
| | 2484 | RCV_INVALID_TRAILER = 0x1000400f, |
| | 2485 | /// Waiting for receive with timeout. (Internal use only.) |
| | 2486 | RCV_IN_PROGRESS_TIMED = 0x10004011, |
| | 2487 | /// invalid reply port used in a STRICT_REPLY message |
| | 2488 | RCV_INVALID_REPLY = 0x10004012, |
| | 2489 | }; |
| | 2490 | |
| 2111 | pub const SIGSTKSZ = 131072; | 2491 | pub const SIGSTKSZ = 131072; |
| 2112 | pub const MINSIGSTKSZ = 32768; | 2492 | pub const MINSIGSTKSZ = 32768; |
| 2113 | | 2493 | |
| ... | @@ -2677,11 +3057,20 @@ pub const _POSIX_SPAWN_RESLIDE = 0x0800; | ... | @@ -2677,11 +3057,20 @@ pub const _POSIX_SPAWN_RESLIDE = 0x0800; |
| 2677 | pub const POSIX_SPAWN_CLOEXEC_DEFAULT = 0x4000; | 3057 | pub const POSIX_SPAWN_CLOEXEC_DEFAULT = 0x4000; |
| 2678 | | 3058 | |
| 2679 | pub const PT_TRACE_ME = 0; | 3059 | pub const PT_TRACE_ME = 0; |
| | 3060 | pub const PT_READ_I = 1; |
| | 3061 | pub const PT_READ_D = 2; |
| | 3062 | pub const PT_READ_U = 3; |
| | 3063 | pub const PT_WRITE_I = 4; |
| | 3064 | pub const PT_WRITE_D = 5; |
| | 3065 | pub const PT_WRITE_U = 6; |
| 2680 | pub const PT_CONTINUE = 7; | 3066 | pub const PT_CONTINUE = 7; |
| 2681 | pub const PT_KILL = 8; | 3067 | pub const PT_KILL = 8; |
| 2682 | pub const PT_STEP = 9; | 3068 | pub const PT_STEP = 9; |
| 2683 | pub const PT_DETACH = 11; | 3069 | pub const PT_DETACH = 11; |
| | 3070 | pub const PT_SIGEXC = 12; |
| | 3071 | pub const PT_THUPDATE = 13; |
| 2684 | pub const PT_ATTACHEXC = 14; | 3072 | pub const PT_ATTACHEXC = 14; |
| | 3073 | pub const PT_FORCEQUOTA = 30; |
| 2685 | pub const PT_DENY_ATTACH = 31; | 3074 | pub const PT_DENY_ATTACH = 31; |
| 2686 | | 3075 | |
| 2687 | pub const caddr_t = ?[*]u8; | 3076 | pub const caddr_t = ?[*]u8; |