Skip to main content

libc/unix/bsd/apple/
mod.rs

1//! Apple (ios/darwin)-specific definitions
2//!
3//! This covers *-apple-* triples currently
4
5use crate::prelude::*;
6use crate::{
7    cmsghdr,
8    off_t,
9};
10
11pub type wchar_t = i32;
12pub type clock_t = c_ulong;
13pub type time_t = c_long;
14pub type suseconds_t = i32;
15pub type dev_t = i32;
16pub type ino_t = u64;
17pub type mode_t = u16;
18pub type nlink_t = u16;
19pub type blksize_t = i32;
20pub type rlim_t = u64;
21pub type sigset_t = u32;
22pub type clockid_t = c_uint;
23pub type fsblkcnt_t = c_uint;
24pub type fsfilcnt_t = c_uint;
25pub type speed_t = c_ulong;
26pub type tcflag_t = c_ulong;
27pub type nl_item = c_int;
28pub type id_t = c_uint;
29pub type sem_t = c_int;
30pub type idtype_t = c_uint;
31pub type integer_t = c_int;
32pub type cpu_type_t = integer_t;
33pub type cpu_subtype_t = integer_t;
34pub type natural_t = u32;
35pub type mach_msg_type_number_t = natural_t;
36pub type kern_return_t = c_int;
37pub type uuid_t = [u8; 16];
38pub type task_info_t = *mut integer_t;
39pub type host_info_t = *mut integer_t;
40pub type task_flavor_t = natural_t;
41pub type rusage_info_t = *mut c_void;
42pub type vm_offset_t = crate::uintptr_t;
43pub type vm_size_t = crate::uintptr_t;
44pub type vm_address_t = vm_offset_t;
45pub type quad_t = i64;
46pub type u_quad_t = u64;
47
48pub type posix_spawnattr_t = *mut c_void;
49pub type posix_spawn_file_actions_t = *mut c_void;
50pub type key_t = c_int;
51pub type shmatt_t = c_ushort;
52
53pub type sae_associd_t = u32;
54pub type sae_connid_t = u32;
55
56pub type mach_port_t = c_uint;
57pub type host_t = c_uint;
58pub type host_flavor_t = integer_t;
59pub type host_info64_t = *mut integer_t;
60pub type processor_flavor_t = c_int;
61pub type thread_flavor_t = natural_t;
62pub type thread_inspect_t = crate::mach_port_t;
63pub type thread_act_t = crate::mach_port_t;
64pub type thread_act_array_t = *mut crate::thread_act_t;
65pub type policy_t = c_int;
66pub type mach_error_t = crate::kern_return_t;
67pub type mach_vm_address_t = u64;
68pub type mach_vm_offset_t = u64;
69pub type mach_vm_size_t = u64;
70pub type vm_map_t = crate::mach_port_t;
71pub type mem_entry_name_port_t = crate::mach_port_t;
72pub type memory_object_t = crate::mach_port_t;
73pub type memory_object_offset_t = c_ulonglong;
74pub type vm_inherit_t = c_uint;
75pub type vm_prot_t = c_int;
76
77pub type ledger_t = crate::mach_port_t;
78pub type ledger_array_t = *mut crate::ledger_t;
79
80pub type iconv_t = *mut c_void;
81
82// mach/host_info.h
83pub type host_cpu_load_info_t = *mut host_cpu_load_info;
84pub type host_cpu_load_info_data_t = host_cpu_load_info;
85
86// mach/processor_info.h
87pub type processor_cpu_load_info_t = *mut processor_cpu_load_info;
88pub type processor_cpu_load_info_data_t = processor_cpu_load_info;
89pub type processor_basic_info_t = *mut processor_basic_info;
90pub type processor_basic_info_data_t = processor_basic_info;
91pub type processor_set_basic_info_data_t = processor_set_basic_info;
92pub type processor_set_basic_info_t = *mut processor_set_basic_info;
93pub type processor_set_load_info_data_t = processor_set_load_info;
94pub type processor_set_load_info_t = *mut processor_set_load_info;
95pub type processor_info_t = *mut integer_t;
96pub type processor_info_array_t = *mut integer_t;
97
98pub type mach_task_basic_info_data_t = mach_task_basic_info;
99pub type mach_task_basic_info_t = *mut mach_task_basic_info;
100pub type task_thread_times_info_data_t = task_thread_times_info;
101pub type task_thread_times_info_t = *mut task_thread_times_info;
102
103pub type thread_info_t = *mut integer_t;
104pub type thread_basic_info_t = *mut thread_basic_info;
105pub type thread_basic_info_data_t = thread_basic_info;
106pub type thread_identifier_info_t = *mut thread_identifier_info;
107pub type thread_identifier_info_data_t = thread_identifier_info;
108pub type thread_extended_info_t = *mut thread_extended_info;
109pub type thread_extended_info_data_t = thread_extended_info;
110
111pub type thread_t = crate::mach_port_t;
112pub type thread_policy_flavor_t = natural_t;
113pub type thread_policy_t = *mut integer_t;
114pub type thread_latency_qos_t = integer_t;
115pub type thread_throughput_qos_t = integer_t;
116pub type thread_standard_policy_data_t = thread_standard_policy;
117pub type thread_standard_policy_t = *mut thread_standard_policy;
118pub type thread_extended_policy_data_t = thread_extended_policy;
119pub type thread_extended_policy_t = *mut thread_extended_policy;
120pub type thread_time_constraint_policy_data_t = thread_time_constraint_policy;
121pub type thread_time_constraint_policy_t = *mut thread_time_constraint_policy;
122pub type thread_precedence_policy_data_t = thread_precedence_policy;
123pub type thread_precedence_policy_t = *mut thread_precedence_policy;
124pub type thread_affinity_policy_data_t = thread_affinity_policy;
125pub type thread_affinity_policy_t = *mut thread_affinity_policy;
126pub type thread_background_policy_data_t = thread_background_policy;
127pub type thread_background_policy_t = *mut thread_background_policy;
128pub type thread_latency_qos_policy_data_t = thread_latency_qos_policy;
129pub type thread_latency_qos_policy_t = *mut thread_latency_qos_policy;
130pub type thread_throughput_qos_policy_data_t = thread_throughput_qos_policy;
131pub type thread_throughput_qos_policy_t = *mut thread_throughput_qos_policy;
132
133pub type pthread_jit_write_callback_t = Option<extern "C" fn(ctx: *mut c_void) -> c_int>;
134
135pub type os_clockid_t = u32;
136
137pub type os_sync_wait_on_address_flags_t = u32;
138pub type os_sync_wake_by_address_flags_t = u32;
139
140pub type os_unfair_lock = os_unfair_lock_s;
141pub type os_unfair_lock_t = *mut os_unfair_lock;
142
143pub type os_log_t = *mut c_void;
144pub type os_log_type_t = u8;
145pub type os_signpost_id_t = u64;
146pub type os_signpost_type_t = u8;
147
148pub type vm_statistics_t = *mut vm_statistics;
149pub type vm_statistics_data_t = vm_statistics;
150pub type vm_statistics64_t = *mut vm_statistics64;
151pub type vm_statistics64_data_t = vm_statistics64;
152
153pub type task_t = crate::mach_port_t;
154pub type task_inspect_t = crate::mach_port_t;
155
156pub type sysdir_search_path_enumeration_state = c_uint;
157
158pub type CCStatus = i32;
159pub type CCCryptorStatus = i32;
160pub type CCRNGStatus = crate::CCCryptorStatus;
161
162pub type copyfile_state_t = *mut c_void;
163pub type copyfile_flags_t = u32;
164pub type copyfile_callback_t = Option<
165    extern "C" fn(
166        c_int,
167        c_int,
168        copyfile_state_t,
169        *const c_char,
170        *const c_char,
171        *mut c_void,
172    ) -> c_int,
173>;
174
175pub type attrgroup_t = u32;
176pub type vol_capabilities_set_t = [u32; 4];
177
178deprecated_mach! {
179    pub type mach_timebase_info_data_t = mach_timebase_info;
180}
181
182extern_ty! {
183    pub type timezone;
184}
185
186#[derive(Debug)]
187#[repr(u32)]
188pub enum sysdir_search_path_directory_t {
189    SYSDIR_DIRECTORY_APPLICATION = 1,
190    SYSDIR_DIRECTORY_DEMO_APPLICATION = 2,
191    SYSDIR_DIRECTORY_DEVELOPER_APPLICATION = 3,
192    SYSDIR_DIRECTORY_ADMIN_APPLICATION = 4,
193    SYSDIR_DIRECTORY_LIBRARY = 5,
194    SYSDIR_DIRECTORY_DEVELOPER = 6,
195    SYSDIR_DIRECTORY_USER = 7,
196    SYSDIR_DIRECTORY_DOCUMENTATION = 8,
197    SYSDIR_DIRECTORY_DOCUMENT = 9,
198    SYSDIR_DIRECTORY_CORESERVICE = 10,
199    SYSDIR_DIRECTORY_AUTOSAVED_INFORMATION = 11,
200    SYSDIR_DIRECTORY_DESKTOP = 12,
201    SYSDIR_DIRECTORY_CACHES = 13,
202    SYSDIR_DIRECTORY_APPLICATION_SUPPORT = 14,
203    SYSDIR_DIRECTORY_DOWNLOADS = 15,
204    SYSDIR_DIRECTORY_INPUT_METHODS = 16,
205    SYSDIR_DIRECTORY_MOVIES = 17,
206    SYSDIR_DIRECTORY_MUSIC = 18,
207    SYSDIR_DIRECTORY_PICTURES = 19,
208    SYSDIR_DIRECTORY_PRINTER_DESCRIPTION = 20,
209    SYSDIR_DIRECTORY_SHARED_PUBLIC = 21,
210    SYSDIR_DIRECTORY_PREFERENCE_PANES = 22,
211    SYSDIR_DIRECTORY_ALL_APPLICATIONS = 100,
212    SYSDIR_DIRECTORY_ALL_LIBRARIES = 101,
213}
214impl Copy for sysdir_search_path_directory_t {}
215impl Clone for sysdir_search_path_directory_t {
216    fn clone(&self) -> sysdir_search_path_directory_t {
217        *self
218    }
219}
220
221#[derive(Debug)]
222#[repr(u32)]
223pub enum sysdir_search_path_domain_mask_t {
224    SYSDIR_DOMAIN_MASK_USER = (1 << 0),
225    SYSDIR_DOMAIN_MASK_LOCAL = (1 << 1),
226    SYSDIR_DOMAIN_MASK_NETWORK = (1 << 2),
227    SYSDIR_DOMAIN_MASK_SYSTEM = (1 << 3),
228    SYSDIR_DOMAIN_MASK_ALL = 0x0ffff,
229}
230impl Copy for sysdir_search_path_domain_mask_t {}
231impl Clone for sysdir_search_path_domain_mask_t {
232    fn clone(&self) -> sysdir_search_path_domain_mask_t {
233        *self
234    }
235}
236
237s! {
238    pub struct ip_mreq {
239        pub imr_multiaddr: in_addr,
240        pub imr_interface: in_addr,
241    }
242
243    pub struct ip_mreqn {
244        pub imr_multiaddr: in_addr,
245        pub imr_address: in_addr,
246        pub imr_ifindex: c_int,
247    }
248
249    pub struct ip_mreq_source {
250        pub imr_multiaddr: in_addr,
251        pub imr_sourceaddr: in_addr,
252        pub imr_interface: in_addr,
253    }
254
255    pub struct aiocb {
256        pub aio_fildes: c_int,
257        pub aio_offset: off_t,
258        pub aio_buf: *mut c_void,
259        pub aio_nbytes: size_t,
260        pub aio_reqprio: c_int,
261        pub aio_sigevent: sigevent,
262        pub aio_lio_opcode: c_int,
263    }
264
265    pub struct glob_t {
266        pub gl_pathc: size_t,
267        __unused1: Padding<c_int>,
268        pub gl_offs: size_t,
269        __unused2: Padding<c_int>,
270        pub gl_pathv: *mut *mut c_char,
271
272        __unused3: Padding<*mut c_void>,
273
274        __unused4: Padding<*mut c_void>,
275        __unused5: Padding<*mut c_void>,
276        __unused6: Padding<*mut c_void>,
277        __unused7: Padding<*mut c_void>,
278        __unused8: Padding<*mut c_void>,
279    }
280
281    pub struct tm {
282        pub tm_sec: c_int,
283        pub tm_min: c_int,
284        pub tm_hour: c_int,
285        pub tm_mday: c_int,
286        pub tm_mon: c_int,
287        pub tm_year: c_int,
288        pub tm_wday: c_int,
289        pub tm_yday: c_int,
290        pub tm_isdst: c_int,
291        pub tm_gmtoff: c_long,
292        pub tm_zone: *mut c_char,
293    }
294
295    pub struct addrinfo {
296        pub ai_flags: c_int,
297        pub ai_family: c_int,
298        pub ai_socktype: c_int,
299        pub ai_protocol: c_int,
300        pub ai_addrlen: crate::socklen_t,
301        pub ai_canonname: *mut c_char,
302        pub ai_addr: *mut crate::sockaddr,
303        pub ai_next: *mut addrinfo,
304    }
305
306    #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")]
307    pub struct mach_timebase_info {
308        pub numer: u32,
309        pub denom: u32,
310    }
311
312    pub struct stat {
313        pub st_dev: dev_t,
314        pub st_mode: mode_t,
315        pub st_nlink: nlink_t,
316        pub st_ino: ino_t,
317        pub st_uid: crate::uid_t,
318        pub st_gid: crate::gid_t,
319        pub st_rdev: dev_t,
320        pub st_atime: time_t,
321        pub st_atime_nsec: c_long,
322        pub st_mtime: time_t,
323        pub st_mtime_nsec: c_long,
324        pub st_ctime: time_t,
325        pub st_ctime_nsec: c_long,
326        pub st_birthtime: time_t,
327        pub st_birthtime_nsec: c_long,
328        pub st_size: off_t,
329        pub st_blocks: crate::blkcnt_t,
330        pub st_blksize: blksize_t,
331        pub st_flags: u32,
332        pub st_gen: u32,
333        pub st_lspare: i32,
334        pub st_qspare: [i64; 2],
335    }
336
337    pub struct siginfo_t {
338        pub si_signo: c_int,
339        pub si_errno: c_int,
340        pub si_code: c_int,
341        pub si_pid: crate::pid_t,
342        pub si_uid: crate::uid_t,
343        pub si_status: c_int,
344        pub si_addr: *mut c_void,
345        //Requires it to be union for tests
346        //pub si_value: crate::sigval,
347        _pad: Padding<[usize; 9]>,
348    }
349
350    pub struct sigaction {
351        // FIXME(union): this field is actually a union
352        pub sa_sigaction: crate::sighandler_t,
353        pub sa_mask: sigset_t,
354        pub sa_flags: c_int,
355    }
356
357    pub struct stack_t {
358        pub ss_sp: *mut c_void,
359        pub ss_size: size_t,
360        pub ss_flags: c_int,
361    }
362
363    pub struct fstore_t {
364        pub fst_flags: c_uint,
365        pub fst_posmode: c_int,
366        pub fst_offset: off_t,
367        pub fst_length: off_t,
368        pub fst_bytesalloc: off_t,
369    }
370
371    pub struct fpunchhole_t {
372        pub fp_flags: c_uint, /* unused */
373        pub reserved: c_uint, /* (to maintain 8-byte alignment) */
374        pub fp_offset: off_t, /* IN: start of the region */
375        pub fp_length: off_t, /* IN: size of the region */
376    }
377
378    pub struct ftrimactivefile_t {
379        pub fta_offset: off_t,
380        pub fta_length: off_t,
381    }
382
383    pub struct fspecread_t {
384        pub fsr_flags: c_uint,
385        pub reserved: c_uint,
386        pub fsr_offset: off_t,
387        pub fsr_length: off_t,
388    }
389
390    pub struct radvisory {
391        pub ra_offset: off_t,
392        pub ra_count: c_int,
393    }
394
395    pub struct statvfs {
396        pub f_bsize: c_ulong,
397        pub f_frsize: c_ulong,
398        pub f_blocks: crate::fsblkcnt_t,
399        pub f_bfree: crate::fsblkcnt_t,
400        pub f_bavail: crate::fsblkcnt_t,
401        pub f_files: crate::fsfilcnt_t,
402        pub f_ffree: crate::fsfilcnt_t,
403        pub f_favail: crate::fsfilcnt_t,
404        pub f_fsid: c_ulong,
405        pub f_flag: c_ulong,
406        pub f_namemax: c_ulong,
407    }
408
409    pub struct Dl_info {
410        pub dli_fname: *const c_char,
411        pub dli_fbase: *mut c_void,
412        pub dli_sname: *const c_char,
413        pub dli_saddr: *mut c_void,
414    }
415
416    pub struct sockaddr_in {
417        pub sin_len: u8,
418        pub sin_family: crate::sa_family_t,
419        pub sin_port: crate::in_port_t,
420        pub sin_addr: crate::in_addr,
421        pub sin_zero: [c_char; 8],
422    }
423
424    pub struct kevent64_s {
425        pub ident: u64,
426        pub filter: i16,
427        pub flags: u16,
428        pub fflags: u32,
429        pub data: i64,
430        pub udata: u64,
431        pub ext: [u64; 2],
432    }
433
434    pub struct dqblk {
435        pub dqb_bhardlimit: u64,
436        pub dqb_bsoftlimit: u64,
437        pub dqb_curbytes: u64,
438        pub dqb_ihardlimit: u32,
439        pub dqb_isoftlimit: u32,
440        pub dqb_curinodes: u32,
441        pub dqb_btime: u32,
442        pub dqb_itime: u32,
443        pub dqb_id: u32,
444        pub dqb_spare: [u32; 4],
445    }
446
447    pub struct if_msghdr {
448        pub ifm_msglen: c_ushort,
449        pub ifm_version: c_uchar,
450        pub ifm_type: c_uchar,
451        pub ifm_addrs: c_int,
452        pub ifm_flags: c_int,
453        pub ifm_index: c_ushort,
454        pub ifm_data: if_data,
455    }
456
457    pub struct ifa_msghdr {
458        pub ifam_msglen: c_ushort,
459        pub ifam_version: c_uchar,
460        pub ifam_type: c_uchar,
461        pub ifam_addrs: c_int,
462        pub ifam_flags: c_int,
463        pub ifam_index: c_ushort,
464        pub ifam_metric: c_int,
465    }
466
467    pub struct ifma_msghdr {
468        pub ifmam_msglen: c_ushort,
469        pub ifmam_version: c_uchar,
470        pub ifmam_type: c_uchar,
471        pub ifmam_addrs: c_int,
472        pub ifmam_flags: c_int,
473        pub ifmam_index: c_ushort,
474    }
475
476    pub struct ifma_msghdr2 {
477        pub ifmam_msglen: c_ushort,
478        pub ifmam_version: c_uchar,
479        pub ifmam_type: c_uchar,
480        pub ifmam_addrs: c_int,
481        pub ifmam_flags: c_int,
482        pub ifmam_index: c_ushort,
483        pub ifmam_refcount: i32,
484    }
485
486    pub struct rt_metrics {
487        pub rmx_locks: u32,
488        pub rmx_mtu: u32,
489        pub rmx_hopcount: u32,
490        pub rmx_expire: i32,
491        pub rmx_recvpipe: u32,
492        pub rmx_sendpipe: u32,
493        pub rmx_ssthresh: u32,
494        pub rmx_rtt: u32,
495        pub rmx_rttvar: u32,
496        pub rmx_pksent: u32,
497        /// This field does not exist anymore, the u32 is now part of a resized
498        /// `rmx_filler` array.
499        pub rmx_state: u32,
500        pub rmx_filler: [u32; 3],
501    }
502
503    pub struct rt_msghdr {
504        pub rtm_msglen: c_ushort,
505        pub rtm_version: c_uchar,
506        pub rtm_type: c_uchar,
507        pub rtm_index: c_ushort,
508        pub rtm_flags: c_int,
509        pub rtm_addrs: c_int,
510        pub rtm_pid: crate::pid_t,
511        pub rtm_seq: c_int,
512        pub rtm_errno: c_int,
513        pub rtm_use: c_int,
514        pub rtm_inits: u32,
515        pub rtm_rmx: rt_metrics,
516    }
517
518    pub struct rt_msghdr2 {
519        pub rtm_msglen: c_ushort,
520        pub rtm_version: c_uchar,
521        pub rtm_type: c_uchar,
522        pub rtm_index: c_ushort,
523        pub rtm_flags: c_int,
524        pub rtm_addrs: c_int,
525        pub rtm_refcnt: i32,
526        pub rtm_parentflags: c_int,
527        pub rtm_reserved: c_int,
528        pub rtm_use: c_int,
529        pub rtm_inits: u32,
530        pub rtm_rmx: rt_metrics,
531    }
532
533    pub struct termios {
534        pub c_iflag: crate::tcflag_t,
535        pub c_oflag: crate::tcflag_t,
536        pub c_cflag: crate::tcflag_t,
537        pub c_lflag: crate::tcflag_t,
538        pub c_cc: [crate::cc_t; crate::NCCS],
539        pub c_ispeed: crate::speed_t,
540        pub c_ospeed: crate::speed_t,
541    }
542
543    pub struct flock {
544        pub l_start: off_t,
545        pub l_len: off_t,
546        pub l_pid: crate::pid_t,
547        pub l_type: c_short,
548        pub l_whence: c_short,
549    }
550
551    pub struct sf_hdtr {
552        pub headers: *mut crate::iovec,
553        pub hdr_cnt: c_int,
554        pub trailers: *mut crate::iovec,
555        pub trl_cnt: c_int,
556    }
557
558    pub struct lconv {
559        pub decimal_point: *mut c_char,
560        pub thousands_sep: *mut c_char,
561        pub grouping: *mut c_char,
562        pub int_curr_symbol: *mut c_char,
563        pub currency_symbol: *mut c_char,
564        pub mon_decimal_point: *mut c_char,
565        pub mon_thousands_sep: *mut c_char,
566        pub mon_grouping: *mut c_char,
567        pub positive_sign: *mut c_char,
568        pub negative_sign: *mut c_char,
569        pub int_frac_digits: c_char,
570        pub frac_digits: c_char,
571        pub p_cs_precedes: c_char,
572        pub p_sep_by_space: c_char,
573        pub n_cs_precedes: c_char,
574        pub n_sep_by_space: c_char,
575        pub p_sign_posn: c_char,
576        pub n_sign_posn: c_char,
577        pub int_p_cs_precedes: c_char,
578        pub int_n_cs_precedes: c_char,
579        pub int_p_sep_by_space: c_char,
580        pub int_n_sep_by_space: c_char,
581        pub int_p_sign_posn: c_char,
582        pub int_n_sign_posn: c_char,
583    }
584
585    pub struct proc_taskinfo {
586        pub pti_virtual_size: u64,
587        pub pti_resident_size: u64,
588        pub pti_total_user: u64,
589        pub pti_total_system: u64,
590        pub pti_threads_user: u64,
591        pub pti_threads_system: u64,
592        pub pti_policy: i32,
593        pub pti_faults: i32,
594        pub pti_pageins: i32,
595        pub pti_cow_faults: i32,
596        pub pti_messages_sent: i32,
597        pub pti_messages_received: i32,
598        pub pti_syscalls_mach: i32,
599        pub pti_syscalls_unix: i32,
600        pub pti_csw: i32,
601        pub pti_threadnum: i32,
602        pub pti_numrunning: i32,
603        pub pti_priority: i32,
604    }
605
606    pub struct proc_bsdinfo {
607        pub pbi_flags: u32,
608        pub pbi_status: u32,
609        pub pbi_xstatus: u32,
610        pub pbi_pid: u32,
611        pub pbi_ppid: u32,
612        pub pbi_uid: crate::uid_t,
613        pub pbi_gid: crate::gid_t,
614        pub pbi_ruid: crate::uid_t,
615        pub pbi_rgid: crate::gid_t,
616        pub pbi_svuid: crate::uid_t,
617        pub pbi_svgid: crate::gid_t,
618        pub rfu_1: u32,
619        pub pbi_comm: [c_char; MAXCOMLEN],
620        pub pbi_name: [c_char; 32], // MAXCOMLEN * 2, but macro isn't happy...
621        pub pbi_nfiles: u32,
622        pub pbi_pgid: u32,
623        pub pbi_pjobc: u32,
624        pub e_tdev: u32,
625        pub e_tpgid: u32,
626        pub pbi_nice: i32,
627        pub pbi_start_tvsec: u64,
628        pub pbi_start_tvusec: u64,
629    }
630
631    pub struct proc_bsdshortinfo {
632        /// Process ID.
633        pub pbsi_pid: u32,
634        /// Process parent ID.
635        pub pbsi_ppid: u32,
636        /// Process perp ID.
637        pub pbsi_pgid: u32,
638        /// `p_stat` value: `SZOMB`, `SRUN`, etc.
639        pub pbsi_status: u32,
640        /// Up to 16 characters of process name.
641        pub pbsi_comm: [c_char; MAXCOMLEN],
642        /// 64bit, emulated, etc.
643        pub pbsi_flags: u32,
644        /// Current UID on process.
645        pub pbsi_uid: crate::uid_t,
646        /// Current GID on process.
647        pub pbsi_gid: crate::gid_t,
648        /// Current RUID on process.
649        pub pbsi_ruid: crate::uid_t,
650        /// Current RGID on process.
651        pub pbsi_rgid: crate::gid_t,
652        /// Current SVUID on process.
653        pub pbsi_svuid: crate::uid_t,
654        /// Current SVGID on process.
655        pub pbsi_svgid: crate::gid_t,
656        /// Reserved for future use.
657        pbsi_rfu: u32,
658    }
659
660    pub struct proc_taskallinfo {
661        pub pbsd: proc_bsdinfo,
662        pub ptinfo: proc_taskinfo,
663    }
664
665    pub struct xsw_usage {
666        pub xsu_total: u64,
667        pub xsu_avail: u64,
668        pub xsu_used: u64,
669        pub xsu_pagesize: u32,
670        pub xsu_encrypted: crate::boolean_t,
671    }
672
673    pub struct xucred {
674        pub cr_version: c_uint,
675        pub cr_uid: crate::uid_t,
676        pub cr_ngroups: c_short,
677        pub cr_groups: [crate::gid_t; 16],
678    }
679
680    #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")]
681    pub struct mach_header {
682        pub magic: u32,
683        pub cputype: cpu_type_t,
684        pub cpusubtype: cpu_subtype_t,
685        pub filetype: u32,
686        pub ncmds: u32,
687        pub sizeofcmds: u32,
688        pub flags: u32,
689    }
690
691    #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")]
692    pub struct mach_header_64 {
693        pub magic: u32,
694        pub cputype: cpu_type_t,
695        pub cpusubtype: cpu_subtype_t,
696        pub filetype: u32,
697        pub ncmds: u32,
698        pub sizeofcmds: u32,
699        pub flags: u32,
700        pub reserved: u32,
701    }
702
703    pub struct segment_command {
704        pub cmd: u32,
705        pub cmdsize: u32,
706        pub segname: [c_char; 16],
707        pub vmaddr: u32,
708        pub vmsize: u32,
709        pub fileoff: u32,
710        pub filesize: u32,
711        pub maxprot: vm_prot_t,
712        pub initprot: vm_prot_t,
713        pub nsects: u32,
714        pub flags: u32,
715    }
716
717    pub struct segment_command_64 {
718        pub cmd: u32,
719        pub cmdsize: u32,
720        pub segname: [c_char; 16],
721        pub vmaddr: u64,
722        pub vmsize: u64,
723        pub fileoff: u64,
724        pub filesize: u64,
725        pub maxprot: vm_prot_t,
726        pub initprot: vm_prot_t,
727        pub nsects: u32,
728        pub flags: u32,
729    }
730
731    pub struct load_command {
732        pub cmd: u32,
733        pub cmdsize: u32,
734    }
735
736    pub struct sockaddr_dl {
737        pub sdl_len: c_uchar,
738        pub sdl_family: c_uchar,
739        pub sdl_index: c_ushort,
740        pub sdl_type: c_uchar,
741        pub sdl_nlen: c_uchar,
742        pub sdl_alen: c_uchar,
743        pub sdl_slen: c_uchar,
744        pub sdl_data: [c_char; 12],
745    }
746
747    pub struct sockaddr_inarp {
748        pub sin_len: c_uchar,
749        pub sin_family: c_uchar,
750        pub sin_port: c_ushort,
751        pub sin_addr: crate::in_addr,
752        pub sin_srcaddr: crate::in_addr,
753        pub sin_tos: c_ushort,
754        pub sin_other: c_ushort,
755    }
756
757    pub struct sockaddr_ctl {
758        pub sc_len: c_uchar,
759        pub sc_family: c_uchar,
760        pub ss_sysaddr: u16,
761        pub sc_id: u32,
762        pub sc_unit: u32,
763        pub sc_reserved: [u32; 5],
764    }
765
766    pub struct in_pktinfo {
767        pub ipi_ifindex: c_uint,
768        pub ipi_spec_dst: crate::in_addr,
769        pub ipi_addr: crate::in_addr,
770    }
771
772    pub struct in6_pktinfo {
773        pub ipi6_addr: crate::in6_addr,
774        pub ipi6_ifindex: c_uint,
775    }
776
777    // sys/ipc.h:
778
779    pub struct ipc_perm {
780        pub uid: crate::uid_t,
781        pub gid: crate::gid_t,
782        pub cuid: crate::uid_t,
783        pub cgid: crate::gid_t,
784        pub mode: mode_t,
785        pub _seq: c_ushort,
786        pub _key: crate::key_t,
787    }
788
789    // sys/sem.h
790
791    pub struct sembuf {
792        pub sem_num: c_ushort,
793        pub sem_op: c_short,
794        pub sem_flg: c_short,
795    }
796
797    // sys/shm.h
798
799    pub struct arphdr {
800        pub ar_hrd: u16,
801        pub ar_pro: u16,
802        pub ar_hln: u8,
803        pub ar_pln: u8,
804        pub ar_op: u16,
805    }
806
807    pub struct in_addr {
808        pub s_addr: crate::in_addr_t,
809    }
810
811    // net/ndrv.h
812    pub struct sockaddr_ndrv {
813        pub snd_len: c_uchar,
814        pub snd_family: c_uchar,
815        pub snd_name: [c_uchar; crate::IFNAMSIZ],
816    }
817
818    // sys/socket.h
819
820    pub struct sa_endpoints_t {
821        pub sae_srcif: c_uint,                   // optional source interface
822        pub sae_srcaddr: *const crate::sockaddr, // optional source address
823        pub sae_srcaddrlen: crate::socklen_t,    // size of source address
824        pub sae_dstaddr: *const crate::sockaddr, // destination address
825        pub sae_dstaddrlen: crate::socklen_t,    // size of destination address
826    }
827
828    pub struct timex {
829        pub modes: c_uint,
830        pub offset: c_long,
831        pub freq: c_long,
832        pub maxerror: c_long,
833        pub esterror: c_long,
834        pub status: c_int,
835        pub constant: c_long,
836        pub precision: c_long,
837        pub tolerance: c_long,
838        pub ppsfreq: c_long,
839        pub jitter: c_long,
840        pub shift: c_int,
841        pub stabil: c_long,
842        pub jitcnt: c_long,
843        pub calcnt: c_long,
844        pub errcnt: c_long,
845        pub stbcnt: c_long,
846    }
847
848    pub struct ntptimeval {
849        pub time: crate::timespec,
850        pub maxerror: c_long,
851        pub esterror: c_long,
852        pub tai: c_long,
853        pub time_state: c_int,
854    }
855
856    pub struct thread_standard_policy {
857        pub no_data: natural_t,
858    }
859
860    pub struct thread_extended_policy {
861        pub timeshare: boolean_t,
862    }
863
864    pub struct thread_time_constraint_policy {
865        pub period: u32,
866        pub computation: u32,
867        pub constraint: u32,
868        pub preemptible: boolean_t,
869    }
870
871    pub struct thread_precedence_policy {
872        pub importance: integer_t,
873    }
874
875    pub struct thread_affinity_policy {
876        pub affinity_tag: integer_t,
877    }
878
879    pub struct thread_background_policy {
880        pub priority: integer_t,
881    }
882
883    pub struct thread_latency_qos_policy {
884        pub thread_latency_qos_tier: thread_latency_qos_t,
885    }
886
887    pub struct thread_throughput_qos_policy {
888        pub thread_throughput_qos_tier: thread_throughput_qos_t,
889    }
890
891    // malloc/malloc.h
892    pub struct malloc_statistics_t {
893        pub blocks_in_use: c_uint,
894        pub size_in_use: size_t,
895        pub max_size_in_use: size_t,
896        pub size_allocated: size_t,
897    }
898
899    pub struct mstats {
900        pub bytes_total: size_t,
901        pub chunks_used: size_t,
902        pub bytes_used: size_t,
903        pub chunks_free: size_t,
904        pub bytes_free: size_t,
905    }
906
907    pub struct vm_range_t {
908        pub address: crate::vm_address_t,
909        pub size: crate::vm_size_t,
910    }
911
912    pub struct vinfo_stat {
913        pub vst_dev: u32,
914        pub vst_mode: u16,
915        pub vst_nlink: u16,
916        pub vst_ino: u64,
917        pub vst_uid: crate::uid_t,
918        pub vst_gid: crate::gid_t,
919        pub vst_atime: i64,
920        pub vst_atimensec: i64,
921        pub vst_mtime: i64,
922        pub vst_mtimensec: i64,
923        pub vst_ctime: i64,
924        pub vst_ctimensec: i64,
925        pub vst_birthtime: i64,
926        pub vst_birthtimensec: i64,
927        pub vst_size: off_t,
928        pub vst_blocks: i64,
929        pub vst_blksize: i32,
930        pub vst_flags: u32,
931        pub vst_gen: u32,
932        pub vst_rdev: u32,
933        pub vst_qspare: [i64; 2],
934    }
935
936    pub struct vnode_info {
937        pub vi_stat: vinfo_stat,
938        pub vi_type: c_int,
939        pub vi_pad: c_int,
940        pub vi_fsid: crate::fsid_t,
941    }
942
943    pub struct vnode_info_path {
944        pub vip_vi: vnode_info,
945        // Normally it's `vip_path: [c_char; MAXPATHLEN]` but because libc supports an old rustc
946        // version, we go around this limitation like this.
947        pub vip_path: [[c_char; 32]; 32],
948    }
949
950    pub struct proc_vnodepathinfo {
951        pub pvi_cdir: vnode_info_path,
952        pub pvi_rdir: vnode_info_path,
953    }
954
955    pub struct vm_statistics {
956        pub free_count: natural_t,
957        pub active_count: natural_t,
958        pub inactive_count: natural_t,
959        pub wire_count: natural_t,
960        pub zero_fill_count: natural_t,
961        pub reactivations: natural_t,
962        pub pageins: natural_t,
963        pub pageouts: natural_t,
964        pub faults: natural_t,
965        pub cow_faults: natural_t,
966        pub lookups: natural_t,
967        pub hits: natural_t,
968        pub purgeable_count: natural_t,
969        pub purges: natural_t,
970        pub speculative_count: natural_t,
971    }
972
973    pub struct task_thread_times_info {
974        pub user_time: time_value_t,
975        pub system_time: time_value_t,
976    }
977
978    pub struct rusage_info_v0 {
979        pub ri_uuid: [u8; 16],
980        pub ri_user_time: u64,
981        pub ri_system_time: u64,
982        pub ri_pkg_idle_wkups: u64,
983        pub ri_interrupt_wkups: u64,
984        pub ri_pageins: u64,
985        pub ri_wired_size: u64,
986        pub ri_resident_size: u64,
987        pub ri_phys_footprint: u64,
988        pub ri_proc_start_abstime: u64,
989        pub ri_proc_exit_abstime: u64,
990    }
991
992    pub struct rusage_info_v1 {
993        pub ri_uuid: [u8; 16],
994        pub ri_user_time: u64,
995        pub ri_system_time: u64,
996        pub ri_pkg_idle_wkups: u64,
997        pub ri_interrupt_wkups: u64,
998        pub ri_pageins: u64,
999        pub ri_wired_size: u64,
1000        pub ri_resident_size: u64,
1001        pub ri_phys_footprint: u64,
1002        pub ri_proc_start_abstime: u64,
1003        pub ri_proc_exit_abstime: u64,
1004        pub ri_child_user_time: u64,
1005        pub ri_child_system_time: u64,
1006        pub ri_child_pkg_idle_wkups: u64,
1007        pub ri_child_interrupt_wkups: u64,
1008        pub ri_child_pageins: u64,
1009        pub ri_child_elapsed_abstime: u64,
1010    }
1011
1012    pub struct rusage_info_v2 {
1013        pub ri_uuid: [u8; 16],
1014        pub ri_user_time: u64,
1015        pub ri_system_time: u64,
1016        pub ri_pkg_idle_wkups: u64,
1017        pub ri_interrupt_wkups: u64,
1018        pub ri_pageins: u64,
1019        pub ri_wired_size: u64,
1020        pub ri_resident_size: u64,
1021        pub ri_phys_footprint: u64,
1022        pub ri_proc_start_abstime: u64,
1023        pub ri_proc_exit_abstime: u64,
1024        pub ri_child_user_time: u64,
1025        pub ri_child_system_time: u64,
1026        pub ri_child_pkg_idle_wkups: u64,
1027        pub ri_child_interrupt_wkups: u64,
1028        pub ri_child_pageins: u64,
1029        pub ri_child_elapsed_abstime: u64,
1030        pub ri_diskio_bytesread: u64,
1031        pub ri_diskio_byteswritten: u64,
1032    }
1033
1034    pub struct rusage_info_v3 {
1035        pub ri_uuid: [u8; 16],
1036        pub ri_user_time: u64,
1037        pub ri_system_time: u64,
1038        pub ri_pkg_idle_wkups: u64,
1039        pub ri_interrupt_wkups: u64,
1040        pub ri_pageins: u64,
1041        pub ri_wired_size: u64,
1042        pub ri_resident_size: u64,
1043        pub ri_phys_footprint: u64,
1044        pub ri_proc_start_abstime: u64,
1045        pub ri_proc_exit_abstime: u64,
1046        pub ri_child_user_time: u64,
1047        pub ri_child_system_time: u64,
1048        pub ri_child_pkg_idle_wkups: u64,
1049        pub ri_child_interrupt_wkups: u64,
1050        pub ri_child_pageins: u64,
1051        pub ri_child_elapsed_abstime: u64,
1052        pub ri_diskio_bytesread: u64,
1053        pub ri_diskio_byteswritten: u64,
1054        pub ri_cpu_time_qos_default: u64,
1055        pub ri_cpu_time_qos_maintenance: u64,
1056        pub ri_cpu_time_qos_background: u64,
1057        pub ri_cpu_time_qos_utility: u64,
1058        pub ri_cpu_time_qos_legacy: u64,
1059        pub ri_cpu_time_qos_user_initiated: u64,
1060        pub ri_cpu_time_qos_user_interactive: u64,
1061        pub ri_billed_system_time: u64,
1062        pub ri_serviced_system_time: u64,
1063    }
1064
1065    pub struct rusage_info_v4 {
1066        pub ri_uuid: [u8; 16],
1067        pub ri_user_time: u64,
1068        pub ri_system_time: u64,
1069        pub ri_pkg_idle_wkups: u64,
1070        pub ri_interrupt_wkups: u64,
1071        pub ri_pageins: u64,
1072        pub ri_wired_size: u64,
1073        pub ri_resident_size: u64,
1074        pub ri_phys_footprint: u64,
1075        pub ri_proc_start_abstime: u64,
1076        pub ri_proc_exit_abstime: u64,
1077        pub ri_child_user_time: u64,
1078        pub ri_child_system_time: u64,
1079        pub ri_child_pkg_idle_wkups: u64,
1080        pub ri_child_interrupt_wkups: u64,
1081        pub ri_child_pageins: u64,
1082        pub ri_child_elapsed_abstime: u64,
1083        pub ri_diskio_bytesread: u64,
1084        pub ri_diskio_byteswritten: u64,
1085        pub ri_cpu_time_qos_default: u64,
1086        pub ri_cpu_time_qos_maintenance: u64,
1087        pub ri_cpu_time_qos_background: u64,
1088        pub ri_cpu_time_qos_utility: u64,
1089        pub ri_cpu_time_qos_legacy: u64,
1090        pub ri_cpu_time_qos_user_initiated: u64,
1091        pub ri_cpu_time_qos_user_interactive: u64,
1092        pub ri_billed_system_time: u64,
1093        pub ri_serviced_system_time: u64,
1094        pub ri_logical_writes: u64,
1095        pub ri_lifetime_max_phys_footprint: u64,
1096        pub ri_instructions: u64,
1097        pub ri_cycles: u64,
1098        pub ri_billed_energy: u64,
1099        pub ri_serviced_energy: u64,
1100        pub ri_interval_max_phys_footprint: u64,
1101        pub ri_runnable_time: u64,
1102    }
1103
1104    pub struct image_offset {
1105        pub uuid: crate::uuid_t,
1106        pub offset: u32,
1107    }
1108
1109    pub struct attrlist {
1110        pub bitmapcount: c_ushort,
1111        pub reserved: u16,
1112        pub commonattr: attrgroup_t,
1113        pub volattr: attrgroup_t,
1114        pub dirattr: attrgroup_t,
1115        pub fileattr: attrgroup_t,
1116        pub forkattr: attrgroup_t,
1117    }
1118
1119    pub struct attrreference_t {
1120        pub attr_dataoffset: i32,
1121        pub attr_length: u32,
1122    }
1123
1124    pub struct vol_capabilities_attr_t {
1125        pub capabilities: vol_capabilities_set_t,
1126        pub valid: vol_capabilities_set_t,
1127    }
1128
1129    pub struct attribute_set_t {
1130        pub commonattr: attrgroup_t,
1131        pub volattr: attrgroup_t,
1132        pub dirattr: attrgroup_t,
1133        pub fileattr: attrgroup_t,
1134        pub forkattr: attrgroup_t,
1135    }
1136
1137    pub struct vol_attributes_attr_t {
1138        pub validattr: attribute_set_t,
1139        pub nativeattr: attribute_set_t,
1140    }
1141
1142    #[repr(align(8))]
1143    pub struct tcp_connection_info {
1144        pub tcpi_state: u8,
1145        pub tcpi_snd_wscale: u8,
1146        pub tcpi_rcv_wscale: u8,
1147        __pad1: Padding<u8>,
1148        pub tcpi_options: u32,
1149        pub tcpi_flags: u32,
1150        pub tcpi_rto: u32,
1151        pub tcpi_maxseg: u32,
1152        pub tcpi_snd_ssthresh: u32,
1153        pub tcpi_snd_cwnd: u32,
1154        pub tcpi_snd_wnd: u32,
1155        pub tcpi_snd_sbbytes: u32,
1156        pub tcpi_rcv_wnd: u32,
1157        pub tcpi_rttcur: u32,
1158        pub tcpi_srtt: u32,
1159        pub tcpi_rttvar: u32,
1160        pub tcpi_tfo_cookie_req: u32,
1161        pub tcpi_tfo_cookie_rcv: u32,
1162        pub tcpi_tfo_syn_loss: u32,
1163        pub tcpi_tfo_syn_data_sent: u32,
1164        pub tcpi_tfo_syn_data_acked: u32,
1165        pub tcpi_tfo_syn_data_rcv: u32,
1166        pub tcpi_tfo_cookie_req_rcv: u32,
1167        pub tcpi_tfo_cookie_sent: u32,
1168        pub tcpi_tfo_cookie_invalid: u32,
1169        pub tcpi_tfo_cookie_wrong: u32,
1170        pub tcpi_tfo_no_cookie_rcv: u32,
1171        pub tcpi_tfo_heuristics_disable: u32,
1172        pub tcpi_tfo_send_blackhole: u32,
1173        pub tcpi_tfo_recv_blackhole: u32,
1174        pub tcpi_tfo_onebyte_proxy: u32,
1175        __pad2: Padding<u32>,
1176        pub tcpi_txpackets: u64,
1177        pub tcpi_txbytes: u64,
1178        pub tcpi_txretransmitbytes: u64,
1179        pub tcpi_rxpackets: u64,
1180        pub tcpi_rxbytes: u64,
1181        pub tcpi_rxoutoforderbytes: u64,
1182        pub tcpi_rxretransmitpackets: u64,
1183    }
1184
1185    pub struct in6_addrlifetime {
1186        pub ia6t_expire: time_t,
1187        pub ia6t_preferred: time_t,
1188        pub ia6t_vltime: u32,
1189        pub ia6t_pltime: u32,
1190    }
1191
1192    pub struct in6_ifstat {
1193        pub ifs6_in_receive: crate::u_quad_t,
1194        pub ifs6_in_hdrerr: crate::u_quad_t,
1195        pub ifs6_in_toobig: crate::u_quad_t,
1196        pub ifs6_in_noroute: crate::u_quad_t,
1197        pub ifs6_in_addrerr: crate::u_quad_t,
1198        pub ifs6_in_protounknown: crate::u_quad_t,
1199        pub ifs6_in_truncated: crate::u_quad_t,
1200        pub ifs6_in_discard: crate::u_quad_t,
1201        pub ifs6_in_deliver: crate::u_quad_t,
1202        pub ifs6_out_forward: crate::u_quad_t,
1203        pub ifs6_out_request: crate::u_quad_t,
1204        pub ifs6_out_discard: crate::u_quad_t,
1205        pub ifs6_out_fragok: crate::u_quad_t,
1206        pub ifs6_out_fragfail: crate::u_quad_t,
1207        pub ifs6_out_fragcreat: crate::u_quad_t,
1208        pub ifs6_reass_reqd: crate::u_quad_t,
1209        pub ifs6_reass_ok: crate::u_quad_t,
1210        pub ifs6_atmfrag_rcvd: crate::u_quad_t,
1211        pub ifs6_reass_fail: crate::u_quad_t,
1212        pub ifs6_in_mcast: crate::u_quad_t,
1213        pub ifs6_out_mcast: crate::u_quad_t,
1214        pub ifs6_cantfoward_icmp6: crate::u_quad_t,
1215        pub ifs6_addr_expiry_cnt: crate::u_quad_t,
1216        pub ifs6_pfx_expiry_cnt: crate::u_quad_t,
1217        pub ifs6_defrtr_expiry_cnt: crate::u_quad_t,
1218    }
1219
1220    pub struct icmp6_ifstat {
1221        pub ifs6_in_msg: crate::u_quad_t,
1222        pub ifs6_in_error: crate::u_quad_t,
1223        pub ifs6_in_dstunreach: crate::u_quad_t,
1224        pub ifs6_in_adminprohib: crate::u_quad_t,
1225        pub ifs6_in_timeexceed: crate::u_quad_t,
1226        pub ifs6_in_paramprob: crate::u_quad_t,
1227        pub ifs6_in_pkttoobig: crate::u_quad_t,
1228        pub ifs6_in_echo: crate::u_quad_t,
1229        pub ifs6_in_echoreply: crate::u_quad_t,
1230        pub ifs6_in_routersolicit: crate::u_quad_t,
1231        pub ifs6_in_routeradvert: crate::u_quad_t,
1232        pub ifs6_in_neighborsolicit: crate::u_quad_t,
1233        pub ifs6_in_neighboradvert: crate::u_quad_t,
1234        pub ifs6_in_redirect: crate::u_quad_t,
1235        pub ifs6_in_mldquery: crate::u_quad_t,
1236        pub ifs6_in_mldreport: crate::u_quad_t,
1237        pub ifs6_in_mlddone: crate::u_quad_t,
1238        pub ifs6_out_msg: crate::u_quad_t,
1239        pub ifs6_out_error: crate::u_quad_t,
1240        pub ifs6_out_dstunreach: crate::u_quad_t,
1241        pub ifs6_out_adminprohib: crate::u_quad_t,
1242        pub ifs6_out_timeexceed: crate::u_quad_t,
1243        pub ifs6_out_paramprob: crate::u_quad_t,
1244        pub ifs6_out_pkttoobig: crate::u_quad_t,
1245        pub ifs6_out_echo: crate::u_quad_t,
1246        pub ifs6_out_echoreply: crate::u_quad_t,
1247        pub ifs6_out_routersolicit: crate::u_quad_t,
1248        pub ifs6_out_routeradvert: crate::u_quad_t,
1249        pub ifs6_out_neighborsolicit: crate::u_quad_t,
1250        pub ifs6_out_neighboradvert: crate::u_quad_t,
1251        pub ifs6_out_redirect: crate::u_quad_t,
1252        pub ifs6_out_mldquery: crate::u_quad_t,
1253        pub ifs6_out_mldreport: crate::u_quad_t,
1254        pub ifs6_out_mlddone: crate::u_quad_t,
1255    }
1256
1257    // mach/host_info.h
1258    pub struct host_cpu_load_info {
1259        pub cpu_ticks: [crate::natural_t; CPU_STATE_MAX as usize],
1260    }
1261
1262    // net/if_mib.h
1263    pub struct ifmibdata {
1264        /// Name of interface
1265        pub ifmd_name: [c_char; crate::IFNAMSIZ],
1266        /// Number of promiscuous listeners
1267        pub ifmd_pcount: c_uint,
1268        /// Interface flags
1269        pub ifmd_flags: c_uint,
1270        /// Instantaneous length of send queue
1271        pub ifmd_snd_len: c_uint,
1272        /// Maximum length of send queue
1273        pub ifmd_snd_maxlen: c_uint,
1274        /// Number of drops in send queue
1275        pub ifmd_snd_drops: c_uint,
1276        /// For future expansion
1277        pub ifmd_filler: [c_uint; 4],
1278        /// Generic information and statistics
1279        pub ifmd_data: if_data64,
1280    }
1281
1282    pub struct ifs_iso_8802_3 {
1283        pub dot3StatsAlignmentErrors: u32,
1284        pub dot3StatsFCSErrors: u32,
1285        pub dot3StatsSingleCollisionFrames: u32,
1286        pub dot3StatsMultipleCollisionFrames: u32,
1287        pub dot3StatsSQETestErrors: u32,
1288        pub dot3StatsDeferredTransmissions: u32,
1289        pub dot3StatsLateCollisions: u32,
1290        pub dot3StatsExcessiveCollisions: u32,
1291        pub dot3StatsInternalMacTransmitErrors: u32,
1292        pub dot3StatsCarrierSenseErrors: u32,
1293        pub dot3StatsFrameTooLongs: u32,
1294        pub dot3StatsInternalMacReceiveErrors: u32,
1295        pub dot3StatsEtherChipSet: u32,
1296        pub dot3StatsMissedFrames: u32,
1297        pub dot3StatsCollFrequencies: [u32; 16],
1298        pub dot3Compliance: u32,
1299    }
1300
1301    // kern_control.h
1302    pub struct ctl_info {
1303        pub ctl_id: u32,
1304        pub ctl_name: [c_char; MAX_KCTL_NAME],
1305    }
1306
1307    // sys/proc_info.h
1308    pub struct proc_fdinfo {
1309        pub proc_fd: i32,
1310        pub proc_fdtype: u32,
1311    }
1312
1313    #[repr(packed(4))]
1314    pub struct kevent {
1315        pub ident: crate::uintptr_t,
1316        pub filter: i16,
1317        pub flags: u16,
1318        pub fflags: u32,
1319        pub data: intptr_t,
1320        pub udata: *mut c_void,
1321    }
1322
1323    #[repr(packed(4))]
1324    pub struct semid_ds {
1325        // Note the manpage shows different types than the system header.
1326        pub sem_perm: ipc_perm,
1327        pub sem_base: i32,
1328        pub sem_nsems: c_ushort,
1329        pub sem_otime: crate::time_t,
1330        pub sem_pad1: i32,
1331        pub sem_ctime: crate::time_t,
1332        pub sem_pad2: i32,
1333        pub sem_pad3: [i32; 4],
1334    }
1335
1336    #[repr(packed(4))]
1337    pub struct shmid_ds {
1338        pub shm_perm: ipc_perm,
1339        pub shm_segsz: size_t,
1340        pub shm_lpid: crate::pid_t,
1341        pub shm_cpid: crate::pid_t,
1342        pub shm_nattch: crate::shmatt_t,
1343        pub shm_atime: crate::time_t, // FIXME(macos): 64-bit wrong align => wrong offset
1344        pub shm_dtime: crate::time_t, // FIXME(macos): 64-bit wrong align => wrong offset
1345        pub shm_ctime: crate::time_t, // FIXME(macos): 64-bit wrong align => wrong offset
1346        // FIXME: 64-bit wrong align => wrong offset:
1347        pub shm_internal: *mut c_void,
1348    }
1349
1350    pub struct proc_threadinfo {
1351        pub pth_user_time: u64,
1352        pub pth_system_time: u64,
1353        pub pth_cpu_usage: i32,
1354        pub pth_policy: i32,
1355        pub pth_run_state: i32,
1356        pub pth_flags: i32,
1357        pub pth_sleep_time: i32,
1358        pub pth_curpri: i32,
1359        pub pth_priority: i32,
1360        pub pth_maxpriority: i32,
1361        pub pth_name: [c_char; MAXTHREADNAMESIZE],
1362    }
1363
1364    pub struct statfs {
1365        pub f_bsize: u32,
1366        pub f_iosize: i32,
1367        pub f_blocks: u64,
1368        pub f_bfree: u64,
1369        pub f_bavail: u64,
1370        pub f_files: u64,
1371        pub f_ffree: u64,
1372        pub f_fsid: crate::fsid_t,
1373        pub f_owner: crate::uid_t,
1374        pub f_type: u32,
1375        pub f_flags: u32,
1376        pub f_fssubtype: u32,
1377        pub f_fstypename: [c_char; 16],
1378        pub f_mntonname: [c_char; 1024],
1379        pub f_mntfromname: [c_char; 1024],
1380        pub f_flags_ext: u32,
1381        pub f_reserved: [u32; 7],
1382    }
1383
1384    pub struct dirent {
1385        pub d_ino: u64,
1386        pub d_seekoff: u64,
1387        pub d_reclen: u16,
1388        pub d_namlen: u16,
1389        pub d_type: u8,
1390        pub d_name: [c_char; 1024],
1391    }
1392
1393    pub struct sockaddr_storage {
1394        pub ss_len: u8,
1395        pub ss_family: crate::sa_family_t,
1396        __ss_pad1: Padding<[u8; 6]>,
1397        __ss_align: i64,
1398        __ss_pad2: Padding<[u8; 112]>,
1399    }
1400
1401    pub struct utmpx {
1402        pub ut_user: [c_char; _UTX_USERSIZE],
1403        pub ut_id: [c_char; _UTX_IDSIZE],
1404        pub ut_line: [c_char; _UTX_LINESIZE],
1405        pub ut_pid: crate::pid_t,
1406        pub ut_type: c_short,
1407        pub ut_tv: crate::timeval,
1408        pub ut_host: [c_char; _UTX_HOSTSIZE],
1409        ut_pad: Padding<[u32; 16]>,
1410    }
1411
1412    pub struct sigevent {
1413        pub sigev_notify: c_int,
1414        pub sigev_signo: c_int,
1415        pub sigev_value: crate::sigval,
1416        __unused1: Padding<*mut c_void>, //actually a function pointer
1417        pub sigev_notify_attributes: *mut crate::pthread_attr_t,
1418    }
1419
1420    pub struct processor_cpu_load_info {
1421        pub cpu_ticks: [c_uint; CPU_STATE_MAX as usize],
1422    }
1423
1424    pub struct processor_basic_info {
1425        pub cpu_type: cpu_type_t,
1426        pub cpu_subtype: cpu_subtype_t,
1427        pub running: crate::boolean_t,
1428        pub slot_num: c_int,
1429        pub is_master: crate::boolean_t,
1430    }
1431
1432    pub struct processor_set_basic_info {
1433        pub processor_count: c_int,
1434        pub default_policy: c_int,
1435    }
1436
1437    pub struct processor_set_load_info {
1438        pub task_count: c_int,
1439        pub thread_count: c_int,
1440        pub load_average: integer_t,
1441        pub mach_factor: integer_t,
1442    }
1443
1444    pub struct time_value_t {
1445        pub seconds: integer_t,
1446        pub microseconds: integer_t,
1447    }
1448
1449    pub struct thread_basic_info {
1450        pub user_time: time_value_t,
1451        pub system_time: time_value_t,
1452        pub cpu_usage: crate::integer_t,
1453        pub policy: crate::policy_t,
1454        pub run_state: crate::integer_t,
1455        pub flags: crate::integer_t,
1456        pub suspend_count: crate::integer_t,
1457        pub sleep_time: crate::integer_t,
1458    }
1459
1460    pub struct thread_identifier_info {
1461        pub thread_id: u64,
1462        pub thread_handle: u64,
1463        pub dispatch_qaddr: u64,
1464    }
1465
1466    pub struct thread_extended_info {
1467        pub pth_user_time: u64,
1468        pub pth_system_time: u64,
1469        pub pth_cpu_usage: i32,
1470        pub pth_policy: i32,
1471        pub pth_run_state: i32,
1472        pub pth_flags: i32,
1473        pub pth_sleep_time: i32,
1474        pub pth_curpri: i32,
1475        pub pth_priority: i32,
1476        pub pth_maxpriority: i32,
1477        pub pth_name: [c_char; MAXTHREADNAMESIZE],
1478    }
1479
1480    #[repr(packed(4))]
1481    pub struct if_data64 {
1482        pub ifi_type: c_uchar,
1483        pub ifi_typelen: c_uchar,
1484        pub ifi_physical: c_uchar,
1485        pub ifi_addrlen: c_uchar,
1486        pub ifi_hdrlen: c_uchar,
1487        pub ifi_recvquota: c_uchar,
1488        pub ifi_xmitquota: c_uchar,
1489        pub ifi_unused1: c_uchar,
1490        pub ifi_mtu: u32,
1491        pub ifi_metric: u32,
1492        pub ifi_baudrate: u64,
1493        pub ifi_ipackets: u64,
1494        pub ifi_ierrors: u64,
1495        pub ifi_opackets: u64,
1496        pub ifi_oerrors: u64,
1497        pub ifi_collisions: u64,
1498        pub ifi_ibytes: u64,
1499        pub ifi_obytes: u64,
1500        pub ifi_imcasts: u64,
1501        pub ifi_omcasts: u64,
1502        pub ifi_iqdrops: u64,
1503        pub ifi_noproto: u64,
1504        pub ifi_recvtiming: u32,
1505        pub ifi_xmittiming: u32,
1506        #[cfg(target_pointer_width = "32")]
1507        pub ifi_lastchange: crate::timeval,
1508        #[cfg(not(target_pointer_width = "32"))]
1509        pub ifi_lastchange: timeval32,
1510    }
1511
1512    #[repr(packed(4))]
1513    pub struct if_msghdr2 {
1514        pub ifm_msglen: c_ushort,
1515        pub ifm_version: c_uchar,
1516        pub ifm_type: c_uchar,
1517        pub ifm_addrs: c_int,
1518        pub ifm_flags: c_int,
1519        pub ifm_index: c_ushort,
1520        pub ifm_snd_len: c_int,
1521        pub ifm_snd_maxlen: c_int,
1522        pub ifm_snd_drops: c_int,
1523        pub ifm_timer: c_int,
1524        pub ifm_data: if_data64,
1525    }
1526
1527    #[repr(packed(8))]
1528    pub struct vm_statistics64 {
1529        pub free_count: natural_t,
1530        pub active_count: natural_t,
1531        pub inactive_count: natural_t,
1532        pub wire_count: natural_t,
1533        pub zero_fill_count: u64,
1534        pub reactivations: u64,
1535        pub pageins: u64,
1536        pub pageouts: u64,
1537        pub faults: u64,
1538        pub cow_faults: u64,
1539        pub lookups: u64,
1540        pub hits: u64,
1541        pub purges: u64,
1542        pub purgeable_count: natural_t,
1543        pub speculative_count: natural_t,
1544        pub decompressions: u64,
1545        pub compressions: u64,
1546        pub swapins: u64,
1547        pub swapouts: u64,
1548        pub compressor_page_count: natural_t,
1549        pub throttled_count: natural_t,
1550        pub external_page_count: natural_t,
1551        pub internal_page_count: natural_t,
1552        pub total_uncompressed_pages_in_compressor: u64,
1553        pub swapped_count: u64,
1554        pub total_tag_storage_pages: u64,
1555        pub nontag_pageable_tag_storage_pages: u64,
1556        pub nontag_wired_tag_storage_pages: u64,
1557        pub free_tag_storage_pages: u64,
1558        pub tag_storing_tag_storage_pages: u64,
1559        pub total_tagged_pages: u64,
1560        pub resident_tagged_pages: u64,
1561        pub compressed_tagged_pages: u64,
1562        pub tagged_compressions: u64,
1563        pub tagged_decompressions: u64,
1564        pub compressed_tag_storage_bytes: u64,
1565        pub speculative_pages_created: u64,
1566        pub speculative_pages_activated: u64,
1567        pub swap_count: u64,
1568        pub empty_tag_storing_tag_storage_pages: u64,
1569        pub executable_count: u64,
1570        pub shared_region_count: u64,
1571        pub boot_stolen_count: u64,
1572        pub secluded_count: u64,
1573        pub active_internal_count: u64,
1574        pub inactive_internal_count: u64,
1575        pub active_external_count: u64,
1576        pub inactive_external_count: u64,
1577        pub purgeable_pageable_count: u64,
1578        pub purgeable_wired_count: u64,
1579        pub background_internal_count: u64,
1580        pub background_external_count: u64,
1581        pub donated_count: u64,
1582        pub realtime_count: u64,
1583        pub max_mem_count: u64,
1584        pub phantom_ghosts_found: u64,
1585        pub phantom_ghosts_added: u64,
1586    }
1587
1588    #[repr(packed(4))]
1589    pub struct mach_task_basic_info {
1590        pub virtual_size: mach_vm_size_t,
1591        pub resident_size: mach_vm_size_t,
1592        pub resident_size_max: mach_vm_size_t,
1593        pub user_time: time_value_t,
1594        pub system_time: time_value_t,
1595        pub policy: crate::policy_t,
1596        pub suspend_count: integer_t,
1597    }
1598
1599    #[repr(packed(4))]
1600    pub struct log2phys {
1601        pub l2p_flags: c_uint,
1602        pub l2p_contigbytes: off_t,
1603        pub l2p_devoffset: off_t,
1604    }
1605
1606    pub struct os_unfair_lock_s {
1607        _os_unfair_lock_opaque: u32,
1608    }
1609
1610    #[repr(packed(1))]
1611    pub struct sockaddr_vm {
1612        pub svm_len: c_uchar,
1613        pub svm_family: crate::sa_family_t,
1614        pub svm_reserved1: c_ushort,
1615        pub svm_port: c_uint,
1616        pub svm_cid: c_uint,
1617    }
1618
1619    pub struct ifdevmtu {
1620        pub ifdm_current: c_int,
1621        pub ifdm_min: c_int,
1622        pub ifdm_max: c_int,
1623    }
1624
1625    #[repr(packed(4))]
1626    pub struct ifkpi {
1627        pub ifk_module_id: c_uint,
1628        pub ifk_type: c_uint,
1629        pub ifk_data: __c_anonymous_ifk_data,
1630    }
1631
1632    pub struct ifreq {
1633        pub ifr_name: [c_char; crate::IFNAMSIZ],
1634        pub ifr_ifru: __c_anonymous_ifr_ifru,
1635    }
1636
1637    pub struct in6_ifreq {
1638        pub ifr_name: [c_char; crate::IFNAMSIZ],
1639        pub ifr_ifru: __c_anonymous_ifr_ifru6,
1640    }
1641}
1642
1643s_no_extra_traits! {
1644    #[repr(packed(4))]
1645    pub struct ifconf {
1646        pub ifc_len: c_int,
1647        pub ifc_ifcu: __c_anonymous_ifc_ifcu,
1648    }
1649    pub union __c_anonymous_ifk_data {
1650        pub ifk_ptr: *mut c_void,
1651        pub ifk_value: c_int,
1652    }
1653
1654    pub union __c_anonymous_ifr_ifru {
1655        pub ifru_addr: crate::sockaddr,
1656        pub ifru_dstaddr: crate::sockaddr,
1657        pub ifru_broadaddr: crate::sockaddr,
1658        pub ifru_flags: c_short,
1659        pub ifru_metrics: c_int,
1660        pub ifru_mtu: c_int,
1661        pub ifru_phys: c_int,
1662        pub ifru_media: c_int,
1663        pub ifru_intval: c_int,
1664        pub ifru_data: *mut c_char,
1665        pub ifru_devmtu: ifdevmtu,
1666        pub ifru_kpi: ifkpi,
1667        pub ifru_wake_flags: u32,
1668        pub ifru_route_refcnt: u32,
1669        pub ifru_cap: [c_int; 2],
1670        pub ifru_functional_type: u32,
1671    }
1672
1673    pub union __c_anonymous_ifc_ifcu {
1674        pub ifcu_buf: *mut c_char,
1675        pub ifcu_req: *mut ifreq,
1676    }
1677
1678    pub union __c_anonymous_ifr_ifru6 {
1679        pub ifru_addr: crate::sockaddr_in6,
1680        pub ifru_dstaddr: crate::sockaddr_in6,
1681        pub ifru_flags: c_int,
1682        pub ifru_flags6: c_int,
1683        pub ifru_metrics: c_int,
1684        pub ifru_intval: c_int,
1685        pub ifru_data: *mut c_char,
1686        pub ifru_lifetime: in6_addrlifetime,
1687        pub ifru_stat: in6_ifstat,
1688        pub ifru_icmp6stat: icmp6_ifstat,
1689        pub ifru_scope_id: [u32; SCOPE6_ID_MAX],
1690    }
1691}
1692
1693impl siginfo_t {
1694    pub unsafe fn si_addr(&self) -> *mut c_void {
1695        self.si_addr
1696    }
1697
1698    pub unsafe fn si_value(&self) -> crate::sigval {
1699        #[repr(C)]
1700        struct siginfo_timer {
1701            _si_signo: c_int,
1702            _si_errno: c_int,
1703            _si_code: c_int,
1704            _si_pid: crate::pid_t,
1705            _si_uid: crate::uid_t,
1706            _si_status: c_int,
1707            _si_addr: *mut c_void,
1708            si_value: crate::sigval,
1709        }
1710
1711        (*(self as *const siginfo_t).cast::<siginfo_timer>()).si_value
1712    }
1713
1714    pub unsafe fn si_pid(&self) -> crate::pid_t {
1715        self.si_pid
1716    }
1717
1718    pub unsafe fn si_uid(&self) -> crate::uid_t {
1719        self.si_uid
1720    }
1721
1722    pub unsafe fn si_status(&self) -> c_int {
1723        self.si_status
1724    }
1725}
1726
1727s_no_extra_traits! {
1728    pub union semun {
1729        pub val: c_int,
1730        pub buf: *mut semid_ds,
1731        pub array: *mut c_ushort,
1732    }
1733}
1734
1735cfg_if! {
1736    if #[cfg(feature = "extra_traits")] {
1737        impl PartialEq for semun {
1738            fn eq(&self, other: &semun) -> bool {
1739                unsafe { self.val == other.val }
1740            }
1741        }
1742        impl Eq for semun {}
1743        impl hash::Hash for semun {
1744            fn hash<H: hash::Hasher>(&self, state: &mut H) {
1745                unsafe { self.val.hash(state) };
1746            }
1747        }
1748    }
1749}
1750
1751cfg_if! {
1752    if #[cfg(feature = "extra_traits")] {
1753        impl PartialEq for ifconf
1754        where
1755            Self: Copy,
1756        {
1757            fn eq(&self, other: &Self) -> bool {
1758                let len_ptr1 = core::ptr::addr_of!(self.ifc_len);
1759                let len_ptr2 = core::ptr::addr_of!(other.ifc_len);
1760                let ifcu_ptr1 = core::ptr::addr_of!(self.ifc_ifcu);
1761                let ifcu_ptr2 = core::ptr::addr_of!(other.ifc_ifcu);
1762
1763                // SAFETY: `ifconf` implements `Copy` so the reads are valid
1764                let len1 = unsafe { len_ptr1.read_unaligned() };
1765                let len2 = unsafe { len_ptr2.read_unaligned() };
1766                let ifcu1 = unsafe { ifcu_ptr1.read_unaligned() };
1767                let ifcu2 = unsafe { ifcu_ptr2.read_unaligned() };
1768
1769                len1 == len2 && ifcu1 == ifcu2
1770            }
1771        }
1772        impl Eq for ifconf {}
1773
1774        impl PartialEq for __c_anonymous_ifk_data {
1775            fn eq(&self, other: &__c_anonymous_ifk_data) -> bool {
1776                unsafe { self.ifk_ptr == other.ifk_ptr && self.ifk_value == other.ifk_value }
1777            }
1778        }
1779
1780        impl Eq for __c_anonymous_ifk_data {}
1781        impl hash::Hash for __c_anonymous_ifk_data {
1782            fn hash<H: hash::Hasher>(&self, state: &mut H) {
1783                unsafe {
1784                    self.ifk_ptr.hash(state);
1785                    self.ifk_value.hash(state);
1786                }
1787            }
1788        }
1789
1790        impl PartialEq for __c_anonymous_ifr_ifru {
1791            fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool {
1792                unsafe {
1793                    self.ifru_addr == other.ifru_addr
1794                        && self.ifru_dstaddr == other.ifru_dstaddr
1795                        && self.ifru_broadaddr == other.ifru_broadaddr
1796                        && self.ifru_flags == other.ifru_flags
1797                        && self.ifru_metrics == other.ifru_metrics
1798                        && self.ifru_mtu == other.ifru_mtu
1799                        && self.ifru_phys == other.ifru_phys
1800                        && self.ifru_media == other.ifru_media
1801                        && self.ifru_intval == other.ifru_intval
1802                        && self.ifru_data == other.ifru_data
1803                        && self.ifru_devmtu == other.ifru_devmtu
1804                        && self.ifru_kpi == other.ifru_kpi
1805                        && self.ifru_wake_flags == other.ifru_wake_flags
1806                        && self.ifru_route_refcnt == other.ifru_route_refcnt
1807                        && self
1808                            .ifru_cap
1809                            .iter()
1810                            .zip(other.ifru_cap.iter())
1811                            .all(|(a, b)| a == b)
1812                        && self.ifru_functional_type == other.ifru_functional_type
1813                }
1814            }
1815        }
1816
1817        impl Eq for __c_anonymous_ifr_ifru {}
1818
1819        impl hash::Hash for __c_anonymous_ifr_ifru {
1820            fn hash<H: hash::Hasher>(&self, state: &mut H) {
1821                unsafe {
1822                    self.ifru_addr.hash(state);
1823                    self.ifru_dstaddr.hash(state);
1824                    self.ifru_broadaddr.hash(state);
1825                    self.ifru_flags.hash(state);
1826                    self.ifru_metrics.hash(state);
1827                    self.ifru_mtu.hash(state);
1828                    self.ifru_phys.hash(state);
1829                    self.ifru_media.hash(state);
1830                    self.ifru_intval.hash(state);
1831                    self.ifru_data.hash(state);
1832                    self.ifru_devmtu.hash(state);
1833                    self.ifru_kpi.hash(state);
1834                    self.ifru_wake_flags.hash(state);
1835                    self.ifru_route_refcnt.hash(state);
1836                    self.ifru_cap.hash(state);
1837                    self.ifru_functional_type.hash(state);
1838                }
1839            }
1840        }
1841
1842        impl Eq for __c_anonymous_ifc_ifcu {}
1843
1844        impl PartialEq for __c_anonymous_ifc_ifcu {
1845            fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool {
1846                unsafe { self.ifcu_buf == other.ifcu_buf && self.ifcu_req == other.ifcu_req }
1847            }
1848        }
1849
1850        impl hash::Hash for __c_anonymous_ifc_ifcu {
1851            fn hash<H: hash::Hasher>(&self, state: &mut H) {
1852                unsafe { self.ifcu_buf.hash(state) };
1853                unsafe { self.ifcu_req.hash(state) };
1854            }
1855        }
1856
1857        impl PartialEq for __c_anonymous_ifr_ifru6 {
1858            fn eq(&self, other: &__c_anonymous_ifr_ifru6) -> bool {
1859                unsafe {
1860                    self.ifru_addr == other.ifru_addr
1861                        && self.ifru_dstaddr == other.ifru_dstaddr
1862                        && self.ifru_flags == other.ifru_flags
1863                        && self.ifru_flags6 == other.ifru_flags6
1864                        && self.ifru_metrics == other.ifru_metrics
1865                        && self.ifru_intval == other.ifru_intval
1866                        && self.ifru_data == other.ifru_data
1867                        && self
1868                            .ifru_scope_id
1869                            .iter()
1870                            .zip(other.ifru_scope_id.iter())
1871                            .all(|(a, b)| a == b)
1872                }
1873            }
1874        }
1875
1876        impl Eq for __c_anonymous_ifr_ifru6 {}
1877
1878        impl hash::Hash for __c_anonymous_ifr_ifru6 {
1879            fn hash<H: hash::Hasher>(&self, state: &mut H) {
1880                unsafe {
1881                    self.ifru_addr.hash(state);
1882                    self.ifru_dstaddr.hash(state);
1883                    self.ifru_flags.hash(state);
1884                    self.ifru_flags6.hash(state);
1885                    self.ifru_metrics.hash(state);
1886                    self.ifru_intval.hash(state);
1887                    self.ifru_data.hash(state);
1888                    self.ifru_scope_id.hash(state);
1889                }
1890            }
1891        }
1892    }
1893}
1894
1895pub const _UTX_USERSIZE: usize = 256;
1896pub const _UTX_LINESIZE: usize = 32;
1897pub const _UTX_IDSIZE: usize = 4;
1898pub const _UTX_HOSTSIZE: usize = 256;
1899
1900pub const EMPTY: c_short = 0;
1901pub const RUN_LVL: c_short = 1;
1902pub const BOOT_TIME: c_short = 2;
1903pub const OLD_TIME: c_short = 3;
1904pub const NEW_TIME: c_short = 4;
1905pub const INIT_PROCESS: c_short = 5;
1906pub const LOGIN_PROCESS: c_short = 6;
1907pub const USER_PROCESS: c_short = 7;
1908pub const DEAD_PROCESS: c_short = 8;
1909pub const ACCOUNTING: c_short = 9;
1910pub const SIGNATURE: c_short = 10;
1911pub const SHUTDOWN_TIME: c_short = 11;
1912
1913pub const LC_COLLATE_MASK: c_int = 1 << 0;
1914pub const LC_CTYPE_MASK: c_int = 1 << 1;
1915pub const LC_MESSAGES_MASK: c_int = 1 << 2;
1916pub const LC_MONETARY_MASK: c_int = 1 << 3;
1917pub const LC_NUMERIC_MASK: c_int = 1 << 4;
1918pub const LC_TIME_MASK: c_int = 1 << 5;
1919pub const LC_ALL_MASK: c_int = LC_COLLATE_MASK
1920    | LC_CTYPE_MASK
1921    | LC_MESSAGES_MASK
1922    | LC_MONETARY_MASK
1923    | LC_NUMERIC_MASK
1924    | LC_TIME_MASK;
1925
1926pub const CODESET: crate::nl_item = 0;
1927pub const D_T_FMT: crate::nl_item = 1;
1928pub const D_FMT: crate::nl_item = 2;
1929pub const T_FMT: crate::nl_item = 3;
1930pub const T_FMT_AMPM: crate::nl_item = 4;
1931pub const AM_STR: crate::nl_item = 5;
1932pub const PM_STR: crate::nl_item = 6;
1933
1934pub const DAY_1: crate::nl_item = 7;
1935pub const DAY_2: crate::nl_item = 8;
1936pub const DAY_3: crate::nl_item = 9;
1937pub const DAY_4: crate::nl_item = 10;
1938pub const DAY_5: crate::nl_item = 11;
1939pub const DAY_6: crate::nl_item = 12;
1940pub const DAY_7: crate::nl_item = 13;
1941
1942pub const ABDAY_1: crate::nl_item = 14;
1943pub const ABDAY_2: crate::nl_item = 15;
1944pub const ABDAY_3: crate::nl_item = 16;
1945pub const ABDAY_4: crate::nl_item = 17;
1946pub const ABDAY_5: crate::nl_item = 18;
1947pub const ABDAY_6: crate::nl_item = 19;
1948pub const ABDAY_7: crate::nl_item = 20;
1949
1950pub const MON_1: crate::nl_item = 21;
1951pub const MON_2: crate::nl_item = 22;
1952pub const MON_3: crate::nl_item = 23;
1953pub const MON_4: crate::nl_item = 24;
1954pub const MON_5: crate::nl_item = 25;
1955pub const MON_6: crate::nl_item = 26;
1956pub const MON_7: crate::nl_item = 27;
1957pub const MON_8: crate::nl_item = 28;
1958pub const MON_9: crate::nl_item = 29;
1959pub const MON_10: crate::nl_item = 30;
1960pub const MON_11: crate::nl_item = 31;
1961pub const MON_12: crate::nl_item = 32;
1962
1963pub const ABMON_1: crate::nl_item = 33;
1964pub const ABMON_2: crate::nl_item = 34;
1965pub const ABMON_3: crate::nl_item = 35;
1966pub const ABMON_4: crate::nl_item = 36;
1967pub const ABMON_5: crate::nl_item = 37;
1968pub const ABMON_6: crate::nl_item = 38;
1969pub const ABMON_7: crate::nl_item = 39;
1970pub const ABMON_8: crate::nl_item = 40;
1971pub const ABMON_9: crate::nl_item = 41;
1972pub const ABMON_10: crate::nl_item = 42;
1973pub const ABMON_11: crate::nl_item = 43;
1974pub const ABMON_12: crate::nl_item = 44;
1975
1976pub const REG_BASIC: c_int = 0o0000;
1977pub const REG_EXTENDED: c_int = 0o0001;
1978pub const REG_ICASE: c_int = 0o0002;
1979pub const REG_NOSUB: c_int = 0o0004;
1980pub const REG_NEWLINE: c_int = 0o0010;
1981pub const REG_NOSPEC: c_int = 0o0020;
1982pub const REG_PEND: c_int = 0o0040;
1983pub const REG_DUMP: c_int = 0o0200;
1984
1985pub const REG_NOMATCH: c_int = 1;
1986pub const REG_BADPAT: c_int = 2;
1987pub const REG_ECOLLATE: c_int = 3;
1988pub const REG_ECTYPE: c_int = 4;
1989pub const REG_EESCAPE: c_int = 5;
1990pub const REG_ESUBREG: c_int = 6;
1991pub const REG_EBRACK: c_int = 7;
1992pub const REG_EPAREN: c_int = 8;
1993pub const REG_EBRACE: c_int = 9;
1994pub const REG_BADBR: c_int = 10;
1995pub const REG_ERANGE: c_int = 11;
1996pub const REG_ESPACE: c_int = 12;
1997pub const REG_BADRPT: c_int = 13;
1998pub const REG_EMPTY: c_int = 14;
1999pub const REG_ASSERT: c_int = 15;
2000pub const REG_INVARG: c_int = 16;
2001pub const REG_ATOI: c_int = 255;
2002pub const REG_ITOA: c_int = 0o0400;
2003
2004pub const REG_NOTBOL: c_int = 0o00001;
2005pub const REG_NOTEOL: c_int = 0o00002;
2006pub const REG_STARTEND: c_int = 0o00004;
2007pub const REG_TRACE: c_int = 0o00400;
2008pub const REG_LARGE: c_int = 0o01000;
2009pub const REG_BACKR: c_int = 0o02000;
2010
2011pub const CLOCK_REALTIME: crate::clockid_t = 0;
2012pub const CLOCK_MONOTONIC_RAW: crate::clockid_t = 4;
2013pub const CLOCK_MONOTONIC_RAW_APPROX: crate::clockid_t = 5;
2014pub const CLOCK_MONOTONIC: crate::clockid_t = 6;
2015pub const CLOCK_UPTIME_RAW: crate::clockid_t = 8;
2016pub const CLOCK_UPTIME_RAW_APPROX: crate::clockid_t = 9;
2017pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 12;
2018pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 16;
2019
2020pub const ERA: crate::nl_item = 45;
2021pub const ERA_D_FMT: crate::nl_item = 46;
2022pub const ERA_D_T_FMT: crate::nl_item = 47;
2023pub const ERA_T_FMT: crate::nl_item = 48;
2024pub const ALT_DIGITS: crate::nl_item = 49;
2025
2026pub const RADIXCHAR: crate::nl_item = 50;
2027pub const THOUSEP: crate::nl_item = 51;
2028
2029pub const YESEXPR: crate::nl_item = 52;
2030pub const NOEXPR: crate::nl_item = 53;
2031
2032pub const YESSTR: crate::nl_item = 54;
2033pub const NOSTR: crate::nl_item = 55;
2034
2035pub const CRNCYSTR: crate::nl_item = 56;
2036
2037pub const D_MD_ORDER: crate::nl_item = 57;
2038
2039pub const EXIT_FAILURE: c_int = 1;
2040pub const EXIT_SUCCESS: c_int = 0;
2041pub const RAND_MAX: c_int = 2147483647;
2042pub const EOF: c_int = -1;
2043pub const SEEK_SET: c_int = 0;
2044pub const SEEK_CUR: c_int = 1;
2045pub const SEEK_END: c_int = 2;
2046pub const SEEK_HOLE: c_int = 3;
2047pub const SEEK_DATA: c_int = 4;
2048pub const _IOFBF: c_int = 0;
2049pub const _IONBF: c_int = 2;
2050pub const _IOLBF: c_int = 1;
2051pub const BUFSIZ: c_uint = 1024;
2052pub const FOPEN_MAX: c_uint = 20;
2053pub const FILENAME_MAX: c_uint = 1024;
2054pub const L_tmpnam: c_uint = 1024;
2055pub const TMP_MAX: c_uint = 308915776;
2056pub const _PC_LINK_MAX: c_int = 1;
2057pub const _PC_MAX_CANON: c_int = 2;
2058pub const _PC_MAX_INPUT: c_int = 3;
2059pub const _PC_NAME_MAX: c_int = 4;
2060pub const _PC_PATH_MAX: c_int = 5;
2061pub const _PC_PIPE_BUF: c_int = 6;
2062pub const _PC_CHOWN_RESTRICTED: c_int = 7;
2063pub const _PC_NO_TRUNC: c_int = 8;
2064pub const _PC_VDISABLE: c_int = 9;
2065pub const _PC_NAME_CHARS_MAX: c_int = 10;
2066pub const _PC_CASE_SENSITIVE: c_int = 11;
2067pub const _PC_CASE_PRESERVING: c_int = 12;
2068pub const _PC_EXTENDED_SECURITY_NP: c_int = 13;
2069pub const _PC_AUTH_OPAQUE_NP: c_int = 14;
2070pub const _PC_2_SYMLINKS: c_int = 15;
2071pub const _PC_ALLOC_SIZE_MIN: c_int = 16;
2072pub const _PC_ASYNC_IO: c_int = 17;
2073pub const _PC_FILESIZEBITS: c_int = 18;
2074pub const _PC_PRIO_IO: c_int = 19;
2075pub const _PC_REC_INCR_XFER_SIZE: c_int = 20;
2076pub const _PC_REC_MAX_XFER_SIZE: c_int = 21;
2077pub const _PC_REC_MIN_XFER_SIZE: c_int = 22;
2078pub const _PC_REC_XFER_ALIGN: c_int = 23;
2079pub const _PC_SYMLINK_MAX: c_int = 24;
2080pub const _PC_SYNC_IO: c_int = 25;
2081pub const _PC_XATTR_SIZE_BITS: c_int = 26;
2082pub const _PC_MIN_HOLE_SIZE: c_int = 27;
2083pub const O_EVTONLY: c_int = 0x00008000;
2084pub const O_NOCTTY: c_int = 0x00020000;
2085pub const O_DIRECTORY: c_int = 0x00100000;
2086pub const O_SYMLINK: c_int = 0x00200000;
2087pub const O_DSYNC: c_int = 0x00400000;
2088pub const O_CLOEXEC: c_int = 0x01000000;
2089pub const O_NOFOLLOW_ANY: c_int = 0x20000000;
2090pub const O_EXEC: c_int = 0x40000000;
2091pub const O_SEARCH: c_int = O_EXEC | O_DIRECTORY;
2092pub const S_IFIFO: mode_t = 0o1_0000;
2093pub const S_IFCHR: mode_t = 0o2_0000;
2094pub const S_IFBLK: mode_t = 0o6_0000;
2095pub const S_IFDIR: mode_t = 0o4_0000;
2096pub const S_IFREG: mode_t = 0o10_0000;
2097pub const S_IFLNK: mode_t = 0o12_0000;
2098pub const S_IFSOCK: mode_t = 0o14_0000;
2099pub const S_IFMT: mode_t = 0o17_0000;
2100pub const S_IEXEC: mode_t = 0o0100;
2101pub const S_IWRITE: mode_t = 0o0200;
2102pub const S_IREAD: mode_t = 0o0400;
2103pub const S_IRWXU: mode_t = 0o0700;
2104pub const S_IXUSR: mode_t = 0o0100;
2105pub const S_IWUSR: mode_t = 0o0200;
2106pub const S_IRUSR: mode_t = 0o0400;
2107pub const S_IRWXG: mode_t = 0o0070;
2108pub const S_IXGRP: mode_t = 0o0010;
2109pub const S_IWGRP: mode_t = 0o0020;
2110pub const S_IRGRP: mode_t = 0o0040;
2111pub const S_IRWXO: mode_t = 0o0007;
2112pub const S_IXOTH: mode_t = 0o0001;
2113pub const S_IWOTH: mode_t = 0o0002;
2114pub const S_IROTH: mode_t = 0o0004;
2115pub const F_OK: c_int = 0;
2116pub const R_OK: c_int = 4;
2117pub const W_OK: c_int = 2;
2118pub const X_OK: c_int = 1;
2119pub const F_LOCK: c_int = 1;
2120pub const F_TEST: c_int = 3;
2121pub const F_TLOCK: c_int = 2;
2122pub const F_ULOCK: c_int = 0;
2123pub const F_GETLK: c_int = 7;
2124pub const F_SETLK: c_int = 8;
2125pub const F_SETLKW: c_int = 9;
2126pub const SIGHUP: c_int = 1;
2127pub const SIGINT: c_int = 2;
2128pub const SIGQUIT: c_int = 3;
2129pub const SIGILL: c_int = 4;
2130pub const SIGABRT: c_int = 6;
2131pub const SIGEMT: c_int = 7;
2132pub const SIGFPE: c_int = 8;
2133pub const SIGKILL: c_int = 9;
2134pub const SIGSEGV: c_int = 11;
2135pub const SIGPIPE: c_int = 13;
2136pub const SIGALRM: c_int = 14;
2137pub const SIGTERM: c_int = 15;
2138
2139pub const PROT_NONE: c_int = 0;
2140pub const PROT_READ: c_int = 1;
2141pub const PROT_WRITE: c_int = 2;
2142pub const PROT_EXEC: c_int = 4;
2143
2144pub const PT_TRACE_ME: c_int = 0;
2145pub const PT_READ_I: c_int = 1;
2146pub const PT_READ_D: c_int = 2;
2147pub const PT_READ_U: c_int = 3;
2148pub const PT_WRITE_I: c_int = 4;
2149pub const PT_WRITE_D: c_int = 5;
2150pub const PT_WRITE_U: c_int = 6;
2151pub const PT_CONTINUE: c_int = 7;
2152pub const PT_KILL: c_int = 8;
2153pub const PT_STEP: c_int = 9;
2154pub const PT_ATTACH: c_int = 10;
2155pub const PT_DETACH: c_int = 11;
2156pub const PT_SIGEXC: c_int = 12;
2157pub const PT_THUPDATE: c_int = 13;
2158pub const PT_ATTACHEXC: c_int = 14;
2159
2160pub const PT_FORCEQUOTA: c_int = 30;
2161pub const PT_DENY_ATTACH: c_int = 31;
2162pub const PT_FIRSTMACH: c_int = 32;
2163
2164pub const MAP_FILE: c_int = 0x0000;
2165pub const MAP_SHARED: c_int = 0x0001;
2166pub const MAP_PRIVATE: c_int = 0x0002;
2167pub const MAP_FIXED: c_int = 0x0010;
2168pub const MAP_ANON: c_int = 0x1000;
2169pub const MAP_ANONYMOUS: c_int = MAP_ANON;
2170
2171pub const CPU_STATE_USER: c_int = 0;
2172pub const CPU_STATE_SYSTEM: c_int = 1;
2173pub const CPU_STATE_IDLE: c_int = 2;
2174pub const CPU_STATE_NICE: c_int = 3;
2175
2176/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
2177/// for details.
2178pub const CPU_STATE_MAX: c_int = 4;
2179
2180pub const PROCESSOR_BASIC_INFO: c_int = 1;
2181pub const PROCESSOR_CPU_LOAD_INFO: c_int = 2;
2182pub const PROCESSOR_PM_REGS_INFO: c_int = 0x10000001;
2183pub const PROCESSOR_TEMPERATURE: c_int = 0x10000002;
2184pub const PROCESSOR_SET_LOAD_INFO: c_int = 4;
2185pub const PROCESSOR_SET_BASIC_INFO: c_int = 5;
2186
2187deprecated_mach! {
2188    pub const VM_FLAGS_FIXED: c_int = 0x0000;
2189    pub const VM_FLAGS_ANYWHERE: c_int = 0x0001;
2190    pub const VM_FLAGS_PURGABLE: c_int = 0x0002;
2191    pub const VM_FLAGS_RANDOM_ADDR: c_int = 0x0008;
2192    pub const VM_FLAGS_NO_CACHE: c_int = 0x0010;
2193    pub const VM_FLAGS_RESILIENT_CODESIGN: c_int = 0x0020;
2194    pub const VM_FLAGS_RESILIENT_MEDIA: c_int = 0x0040;
2195    pub const VM_FLAGS_OVERWRITE: c_int = 0x4000;
2196    pub const VM_FLAGS_SUPERPAGE_MASK: c_int = 0x70000;
2197    pub const VM_FLAGS_RETURN_DATA_ADDR: c_int = 0x100000;
2198    pub const VM_FLAGS_RETURN_4K_DATA_ADDR: c_int = 0x800000;
2199    pub const VM_FLAGS_ALIAS_MASK: c_int = u32_cast_int(0xFF000000);
2200    pub const VM_FLAGS_USER_ALLOCATE: c_int = u32_cast_int(0xff07401f);
2201    pub const VM_FLAGS_USER_MAP: c_int = u32_cast_int(0xff97401f);
2202    pub const VM_FLAGS_USER_REMAP: c_int = VM_FLAGS_FIXED
2203        | VM_FLAGS_ANYWHERE
2204        | VM_FLAGS_RANDOM_ADDR
2205        | VM_FLAGS_OVERWRITE
2206        | VM_FLAGS_RETURN_DATA_ADDR
2207        | VM_FLAGS_RESILIENT_CODESIGN;
2208
2209    pub const VM_FLAGS_SUPERPAGE_SHIFT: c_int = 16;
2210    pub const SUPERPAGE_NONE: c_int = 0;
2211    pub const SUPERPAGE_SIZE_ANY: c_int = 1;
2212    pub const VM_FLAGS_SUPERPAGE_NONE: c_int = SUPERPAGE_NONE << VM_FLAGS_SUPERPAGE_SHIFT;
2213    pub const VM_FLAGS_SUPERPAGE_SIZE_ANY: c_int = SUPERPAGE_SIZE_ANY << VM_FLAGS_SUPERPAGE_SHIFT;
2214    pub const SUPERPAGE_SIZE_2MB: c_int = 2;
2215    pub const VM_FLAGS_SUPERPAGE_SIZE_2MB: c_int = SUPERPAGE_SIZE_2MB << VM_FLAGS_SUPERPAGE_SHIFT;
2216
2217    pub const VM_MEMORY_MALLOC: c_int = 1;
2218    pub const VM_MEMORY_MALLOC_SMALL: c_int = 2;
2219    pub const VM_MEMORY_MALLOC_LARGE: c_int = 3;
2220    pub const VM_MEMORY_MALLOC_HUGE: c_int = 4;
2221    pub const VM_MEMORY_SBRK: c_int = 5;
2222    pub const VM_MEMORY_REALLOC: c_int = 6;
2223    pub const VM_MEMORY_MALLOC_TINY: c_int = 7;
2224    pub const VM_MEMORY_MALLOC_LARGE_REUSABLE: c_int = 8;
2225    pub const VM_MEMORY_MALLOC_LARGE_REUSED: c_int = 9;
2226    pub const VM_MEMORY_ANALYSIS_TOOL: c_int = 10;
2227    pub const VM_MEMORY_MALLOC_NANO: c_int = 11;
2228    pub const VM_MEMORY_MACH_MSG: c_int = 20;
2229    pub const VM_MEMORY_IOKIT: c_int = 21;
2230    pub const VM_MEMORY_STACK: c_int = 30;
2231    pub const VM_MEMORY_GUARD: c_int = 31;
2232    pub const VM_MEMORY_SHARED_PMAP: c_int = 32;
2233    pub const VM_MEMORY_DYLIB: c_int = 33;
2234    pub const VM_MEMORY_OBJC_DISPATCHERS: c_int = 34;
2235    pub const VM_MEMORY_UNSHARED_PMAP: c_int = 35;
2236    pub const VM_MEMORY_APPKIT: c_int = 40;
2237    pub const VM_MEMORY_FOUNDATION: c_int = 41;
2238    pub const VM_MEMORY_COREGRAPHICS: c_int = 42;
2239    pub const VM_MEMORY_CORESERVICES: c_int = 43;
2240    pub const VM_MEMORY_CARBON: c_int = VM_MEMORY_CORESERVICES;
2241    pub const VM_MEMORY_JAVA: c_int = 44;
2242    pub const VM_MEMORY_COREDATA: c_int = 45;
2243    pub const VM_MEMORY_COREDATA_OBJECTIDS: c_int = 46;
2244    pub const VM_MEMORY_ATS: c_int = 50;
2245    pub const VM_MEMORY_LAYERKIT: c_int = 51;
2246    pub const VM_MEMORY_CGIMAGE: c_int = 52;
2247    pub const VM_MEMORY_TCMALLOC: c_int = 53;
2248    pub const VM_MEMORY_COREGRAPHICS_DATA: c_int = 54;
2249    pub const VM_MEMORY_COREGRAPHICS_SHARED: c_int = 55;
2250    pub const VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS: c_int = 56;
2251    pub const VM_MEMORY_COREGRAPHICS_BACKINGSTORES: c_int = 57;
2252    pub const VM_MEMORY_COREGRAPHICS_XALLOC: c_int = 58;
2253    pub const VM_MEMORY_COREGRAPHICS_MISC: c_int = VM_MEMORY_COREGRAPHICS;
2254    pub const VM_MEMORY_DYLD: c_int = 60;
2255    pub const VM_MEMORY_DYLD_MALLOC: c_int = 61;
2256    pub const VM_MEMORY_SQLITE: c_int = 62;
2257    pub const VM_MEMORY_JAVASCRIPT_CORE: c_int = 63;
2258    pub const VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR: c_int = 64;
2259    pub const VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE: c_int = 65;
2260    pub const VM_MEMORY_GLSL: c_int = 66;
2261    pub const VM_MEMORY_OPENCL: c_int = 67;
2262    pub const VM_MEMORY_COREIMAGE: c_int = 68;
2263    pub const VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS: c_int = 69;
2264    pub const VM_MEMORY_IMAGEIO: c_int = 70;
2265    pub const VM_MEMORY_COREPROFILE: c_int = 71;
2266    pub const VM_MEMORY_ASSETSD: c_int = 72;
2267    pub const VM_MEMORY_OS_ALLOC_ONCE: c_int = 73;
2268    pub const VM_MEMORY_LIBDISPATCH: c_int = 74;
2269    pub const VM_MEMORY_ACCELERATE: c_int = 75;
2270    pub const VM_MEMORY_COREUI: c_int = 76;
2271    pub const VM_MEMORY_COREUIFILE: c_int = 77;
2272    pub const VM_MEMORY_GENEALOGY: c_int = 78;
2273    pub const VM_MEMORY_RAWCAMERA: c_int = 79;
2274    pub const VM_MEMORY_CORPSEINFO: c_int = 80;
2275    pub const VM_MEMORY_ASL: c_int = 81;
2276    pub const VM_MEMORY_SWIFT_RUNTIME: c_int = 82;
2277    pub const VM_MEMORY_SWIFT_METADATA: c_int = 83;
2278    pub const VM_MEMORY_DHMM: c_int = 84;
2279    pub const VM_MEMORY_SCENEKIT: c_int = 86;
2280    pub const VM_MEMORY_SKYWALK: c_int = 87;
2281    pub const VM_MEMORY_APPLICATION_SPECIFIC_1: c_int = 240;
2282    pub const VM_MEMORY_APPLICATION_SPECIFIC_16: c_int = 255;
2283}
2284
2285pub const MAP_FAILED: *mut c_void = !0 as *mut c_void;
2286
2287pub const MCL_CURRENT: c_int = 0x0001;
2288pub const MCL_FUTURE: c_int = 0x0002;
2289
2290pub const MS_ASYNC: c_int = 0x0001;
2291pub const MS_INVALIDATE: c_int = 0x0002;
2292pub const MS_SYNC: c_int = 0x0010;
2293
2294pub const MS_KILLPAGES: c_int = 0x0004;
2295pub const MS_DEACTIVATE: c_int = 0x0008;
2296
2297pub const EPERM: c_int = 1;
2298pub const ENOENT: c_int = 2;
2299pub const ESRCH: c_int = 3;
2300pub const EINTR: c_int = 4;
2301pub const EIO: c_int = 5;
2302pub const ENXIO: c_int = 6;
2303pub const E2BIG: c_int = 7;
2304pub const ENOEXEC: c_int = 8;
2305pub const EBADF: c_int = 9;
2306pub const ECHILD: c_int = 10;
2307pub const EDEADLK: c_int = 11;
2308pub const ENOMEM: c_int = 12;
2309pub const EACCES: c_int = 13;
2310pub const EFAULT: c_int = 14;
2311pub const ENOTBLK: c_int = 15;
2312pub const EBUSY: c_int = 16;
2313pub const EEXIST: c_int = 17;
2314pub const EXDEV: c_int = 18;
2315pub const ENODEV: c_int = 19;
2316pub const ENOTDIR: c_int = 20;
2317pub const EISDIR: c_int = 21;
2318pub const EINVAL: c_int = 22;
2319pub const ENFILE: c_int = 23;
2320pub const EMFILE: c_int = 24;
2321pub const ENOTTY: c_int = 25;
2322pub const ETXTBSY: c_int = 26;
2323pub const EFBIG: c_int = 27;
2324pub const ENOSPC: c_int = 28;
2325pub const ESPIPE: c_int = 29;
2326pub const EROFS: c_int = 30;
2327pub const EMLINK: c_int = 31;
2328pub const EPIPE: c_int = 32;
2329pub const EDOM: c_int = 33;
2330pub const ERANGE: c_int = 34;
2331pub const EAGAIN: c_int = 35;
2332pub const EWOULDBLOCK: c_int = EAGAIN;
2333pub const EINPROGRESS: c_int = 36;
2334pub const EALREADY: c_int = 37;
2335pub const ENOTSOCK: c_int = 38;
2336pub const EDESTADDRREQ: c_int = 39;
2337pub const EMSGSIZE: c_int = 40;
2338pub const EPROTOTYPE: c_int = 41;
2339pub const ENOPROTOOPT: c_int = 42;
2340pub const EPROTONOSUPPORT: c_int = 43;
2341pub const ESOCKTNOSUPPORT: c_int = 44;
2342pub const ENOTSUP: c_int = 45;
2343pub const EPFNOSUPPORT: c_int = 46;
2344pub const EAFNOSUPPORT: c_int = 47;
2345pub const EADDRINUSE: c_int = 48;
2346pub const EADDRNOTAVAIL: c_int = 49;
2347pub const ENETDOWN: c_int = 50;
2348pub const ENETUNREACH: c_int = 51;
2349pub const ENETRESET: c_int = 52;
2350pub const ECONNABORTED: c_int = 53;
2351pub const ECONNRESET: c_int = 54;
2352pub const ENOBUFS: c_int = 55;
2353pub const EISCONN: c_int = 56;
2354pub const ENOTCONN: c_int = 57;
2355pub const ESHUTDOWN: c_int = 58;
2356pub const ETOOMANYREFS: c_int = 59;
2357pub const ETIMEDOUT: c_int = 60;
2358pub const ECONNREFUSED: c_int = 61;
2359pub const ELOOP: c_int = 62;
2360pub const ENAMETOOLONG: c_int = 63;
2361pub const EHOSTDOWN: c_int = 64;
2362pub const EHOSTUNREACH: c_int = 65;
2363pub const ENOTEMPTY: c_int = 66;
2364pub const EPROCLIM: c_int = 67;
2365pub const EUSERS: c_int = 68;
2366pub const EDQUOT: c_int = 69;
2367pub const ESTALE: c_int = 70;
2368pub const EREMOTE: c_int = 71;
2369pub const EBADRPC: c_int = 72;
2370pub const ERPCMISMATCH: c_int = 73;
2371pub const EPROGUNAVAIL: c_int = 74;
2372pub const EPROGMISMATCH: c_int = 75;
2373pub const EPROCUNAVAIL: c_int = 76;
2374pub const ENOLCK: c_int = 77;
2375pub const ENOSYS: c_int = 78;
2376pub const EFTYPE: c_int = 79;
2377pub const EAUTH: c_int = 80;
2378pub const ENEEDAUTH: c_int = 81;
2379pub const EPWROFF: c_int = 82;
2380pub const EDEVERR: c_int = 83;
2381pub const EOVERFLOW: c_int = 84;
2382pub const EBADEXEC: c_int = 85;
2383pub const EBADARCH: c_int = 86;
2384pub const ESHLIBVERS: c_int = 87;
2385pub const EBADMACHO: c_int = 88;
2386pub const ECANCELED: c_int = 89;
2387pub const EIDRM: c_int = 90;
2388pub const ENOMSG: c_int = 91;
2389pub const EILSEQ: c_int = 92;
2390pub const ENOATTR: c_int = 93;
2391pub const EBADMSG: c_int = 94;
2392pub const EMULTIHOP: c_int = 95;
2393pub const ENODATA: c_int = 96;
2394pub const ENOLINK: c_int = 97;
2395pub const ENOSR: c_int = 98;
2396pub const ENOSTR: c_int = 99;
2397pub const EPROTO: c_int = 100;
2398pub const ETIME: c_int = 101;
2399pub const EOPNOTSUPP: c_int = 102;
2400pub const ENOPOLICY: c_int = 103;
2401pub const ENOTRECOVERABLE: c_int = 104;
2402pub const EOWNERDEAD: c_int = 105;
2403pub const EQFULL: c_int = 106;
2404pub const ENOTCAPABLE: c_int = 107;
2405
2406/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
2407/// for details.and use.
2408pub const ELAST: c_int = 107;
2409
2410pub const EAI_AGAIN: c_int = 2;
2411pub const EAI_BADFLAGS: c_int = 3;
2412pub const EAI_FAIL: c_int = 4;
2413pub const EAI_FAMILY: c_int = 5;
2414pub const EAI_MEMORY: c_int = 6;
2415pub const EAI_NODATA: c_int = 7;
2416pub const EAI_NONAME: c_int = 8;
2417pub const EAI_SERVICE: c_int = 9;
2418pub const EAI_SOCKTYPE: c_int = 10;
2419pub const EAI_SYSTEM: c_int = 11;
2420pub const EAI_OVERFLOW: c_int = 14;
2421
2422pub const F_DUPFD: c_int = 0;
2423pub const F_DUPFD_CLOEXEC: c_int = 67;
2424pub const F_GETFD: c_int = 1;
2425pub const F_SETFD: c_int = 2;
2426pub const F_GETFL: c_int = 3;
2427pub const F_SETFL: c_int = 4;
2428pub const F_PREALLOCATE: c_int = 42;
2429pub const F_RDADVISE: c_int = 44;
2430pub const F_RDAHEAD: c_int = 45;
2431pub const F_NOCACHE: c_int = 48;
2432pub const F_LOG2PHYS: c_int = 49;
2433pub const F_GETPATH: c_int = 50;
2434pub const F_FULLFSYNC: c_int = 51;
2435pub const F_FREEZE_FS: c_int = 53;
2436pub const F_THAW_FS: c_int = 54;
2437pub const F_GLOBAL_NOCACHE: c_int = 55;
2438pub const F_NODIRECT: c_int = 62;
2439pub const F_LOG2PHYS_EXT: c_int = 65;
2440pub const F_BARRIERFSYNC: c_int = 85;
2441// See https://github.com/apple/darwin-xnu/blob/main/bsd/sys/fcntl.h
2442pub const F_OFD_SETLK: c_int = 90; /* Acquire or release open file description lock */
2443pub const F_OFD_SETLKW: c_int = 91; /* (as F_OFD_SETLK but blocking if conflicting lock) */
2444pub const F_OFD_GETLK: c_int = 92; /* Examine OFD lock */
2445pub const F_PUNCHHOLE: c_int = 99;
2446pub const F_TRIM_ACTIVE_FILE: c_int = 100;
2447pub const F_SPECULATIVE_READ: c_int = 101;
2448pub const F_GETPATH_NOFIRMLINK: c_int = 102;
2449pub const F_TRANSFEREXTENTS: c_int = 110;
2450
2451pub const F_ALLOCATECONTIG: c_uint = 0x02;
2452pub const F_ALLOCATEALL: c_uint = 0x04;
2453pub const F_ALLOCATEPERSIST: c_uint = 0x08;
2454
2455pub const F_PEOFPOSMODE: c_int = 3;
2456pub const F_VOLPOSMODE: c_int = 4;
2457
2458pub const AT_FDCWD: c_int = -2;
2459pub const AT_EACCESS: c_int = 0x0010;
2460pub const AT_SYMLINK_NOFOLLOW: c_int = 0x0020;
2461pub const AT_SYMLINK_FOLLOW: c_int = 0x0040;
2462pub const AT_REMOVEDIR: c_int = 0x0080;
2463
2464pub const FIODTYPE: c_ulong = 0x4004667a;
2465
2466pub const B0: speed_t = 0;
2467pub const B50: speed_t = 50;
2468pub const B75: speed_t = 75;
2469pub const B110: speed_t = 110;
2470pub const B134: speed_t = 134;
2471pub const B150: speed_t = 150;
2472pub const B200: speed_t = 200;
2473pub const B300: speed_t = 300;
2474pub const B600: speed_t = 600;
2475pub const B1200: speed_t = 1200;
2476pub const B1800: speed_t = 1800;
2477pub const B2400: speed_t = 2400;
2478pub const B4800: speed_t = 4800;
2479pub const B9600: speed_t = 9600;
2480pub const B19200: speed_t = 19200;
2481pub const B38400: speed_t = 38400;
2482pub const B7200: speed_t = 7200;
2483pub const B14400: speed_t = 14400;
2484pub const B28800: speed_t = 28800;
2485pub const B57600: speed_t = 57600;
2486pub const B76800: speed_t = 76800;
2487pub const B115200: speed_t = 115200;
2488pub const B230400: speed_t = 230400;
2489pub const EXTA: speed_t = 19200;
2490pub const EXTB: speed_t = 38400;
2491
2492pub const SIGTRAP: c_int = 5;
2493
2494pub const GLOB_APPEND: c_int = 0x0001;
2495pub const GLOB_DOOFFS: c_int = 0x0002;
2496pub const GLOB_ERR: c_int = 0x0004;
2497pub const GLOB_MARK: c_int = 0x0008;
2498pub const GLOB_NOCHECK: c_int = 0x0010;
2499pub const GLOB_NOSORT: c_int = 0x0020;
2500pub const GLOB_NOESCAPE: c_int = 0x2000;
2501
2502pub const GLOB_NOSPACE: c_int = -1;
2503pub const GLOB_ABORTED: c_int = -2;
2504pub const GLOB_NOMATCH: c_int = -3;
2505
2506pub const POSIX_MADV_NORMAL: c_int = 0;
2507pub const POSIX_MADV_RANDOM: c_int = 1;
2508pub const POSIX_MADV_SEQUENTIAL: c_int = 2;
2509pub const POSIX_MADV_WILLNEED: c_int = 3;
2510pub const POSIX_MADV_DONTNEED: c_int = 4;
2511
2512pub const _SC_IOV_MAX: c_int = 56;
2513pub const _SC_GETGR_R_SIZE_MAX: c_int = 70;
2514pub const _SC_GETPW_R_SIZE_MAX: c_int = 71;
2515pub const _SC_LOGIN_NAME_MAX: c_int = 73;
2516pub const _SC_MQ_PRIO_MAX: c_int = 75;
2517pub const _SC_THREAD_ATTR_STACKADDR: c_int = 82;
2518pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 83;
2519pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 85;
2520pub const _SC_THREAD_KEYS_MAX: c_int = 86;
2521pub const _SC_THREAD_PRIO_INHERIT: c_int = 87;
2522pub const _SC_THREAD_PRIO_PROTECT: c_int = 88;
2523pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 89;
2524pub const _SC_THREAD_PROCESS_SHARED: c_int = 90;
2525pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 91;
2526pub const _SC_THREAD_STACK_MIN: c_int = 93;
2527pub const _SC_THREAD_THREADS_MAX: c_int = 94;
2528pub const _SC_THREADS: c_int = 96;
2529pub const _SC_TTY_NAME_MAX: c_int = 101;
2530pub const _SC_ATEXIT_MAX: c_int = 107;
2531pub const _SC_XOPEN_CRYPT: c_int = 108;
2532pub const _SC_XOPEN_ENH_I18N: c_int = 109;
2533pub const _SC_XOPEN_LEGACY: c_int = 110;
2534pub const _SC_XOPEN_REALTIME: c_int = 111;
2535pub const _SC_XOPEN_REALTIME_THREADS: c_int = 112;
2536pub const _SC_XOPEN_SHM: c_int = 113;
2537pub const _SC_XOPEN_UNIX: c_int = 115;
2538pub const _SC_XOPEN_VERSION: c_int = 116;
2539pub const _SC_XOPEN_XCU_VERSION: c_int = 121;
2540pub const _SC_PHYS_PAGES: c_int = 200;
2541
2542#[cfg(target_arch = "aarch64")]
2543pub const PTHREAD_STACK_MIN: size_t = 16384;
2544#[cfg(not(target_arch = "aarch64"))]
2545pub const PTHREAD_STACK_MIN: size_t = 8192;
2546
2547pub const RLIMIT_CPU: c_int = 0;
2548pub const RLIMIT_FSIZE: c_int = 1;
2549pub const RLIMIT_DATA: c_int = 2;
2550pub const RLIMIT_STACK: c_int = 3;
2551pub const RLIMIT_CORE: c_int = 4;
2552pub const RLIMIT_AS: c_int = 5;
2553pub const RLIMIT_RSS: c_int = RLIMIT_AS;
2554pub const RLIMIT_MEMLOCK: c_int = 6;
2555pub const RLIMIT_NPROC: c_int = 7;
2556pub const RLIMIT_NOFILE: c_int = 8;
2557#[deprecated(since = "0.2.64", note = "Not stable across OS versions")]
2558pub const RLIM_NLIMITS: c_int = 9;
2559pub const _RLIMIT_POSIX_FLAG: c_int = 0x1000;
2560
2561pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff;
2562
2563pub const RUSAGE_SELF: c_int = 0;
2564pub const RUSAGE_CHILDREN: c_int = -1;
2565
2566pub const MADV_NORMAL: c_int = 0;
2567pub const MADV_RANDOM: c_int = 1;
2568pub const MADV_SEQUENTIAL: c_int = 2;
2569pub const MADV_WILLNEED: c_int = 3;
2570pub const MADV_DONTNEED: c_int = 4;
2571pub const MADV_FREE: c_int = 5;
2572pub const MADV_ZERO_WIRED_PAGES: c_int = 6;
2573pub const MADV_FREE_REUSABLE: c_int = 7;
2574pub const MADV_FREE_REUSE: c_int = 8;
2575pub const MADV_CAN_REUSE: c_int = 9;
2576pub const MADV_ZERO: c_int = 11;
2577
2578pub const MINCORE_INCORE: c_int = 0x1;
2579pub const MINCORE_REFERENCED: c_int = 0x2;
2580pub const MINCORE_MODIFIED: c_int = 0x4;
2581pub const MINCORE_REFERENCED_OTHER: c_int = 0x8;
2582pub const MINCORE_MODIFIED_OTHER: c_int = 0x10;
2583
2584pub const CTLIOCGINFO: c_ulong = 0xc0644e03;
2585
2586//
2587// sys/netinet/in.h
2588// Protocols (RFC 1700)
2589// NOTE: These are in addition to the constants defined in src/unix/mod.rs
2590
2591// IPPROTO_IP defined in src/unix/mod.rs
2592/// IP6 hop-by-hop options
2593pub const IPPROTO_HOPOPTS: c_int = 0;
2594// IPPROTO_ICMP defined in src/unix/mod.rs
2595/// group mgmt protocol
2596pub const IPPROTO_IGMP: c_int = 2;
2597/// gateway<sup>2</sup> (deprecated)
2598pub const IPPROTO_GGP: c_int = 3;
2599/// for compatibility
2600pub const IPPROTO_IPIP: c_int = 4;
2601// IPPROTO_TCP defined in src/unix/mod.rs
2602/// Stream protocol II.
2603pub const IPPROTO_ST: c_int = 7;
2604/// exterior gateway protocol
2605pub const IPPROTO_EGP: c_int = 8;
2606/// private interior gateway
2607pub const IPPROTO_PIGP: c_int = 9;
2608/// BBN RCC Monitoring
2609pub const IPPROTO_RCCMON: c_int = 10;
2610/// network voice protocol
2611pub const IPPROTO_NVPII: c_int = 11;
2612/// pup
2613pub const IPPROTO_PUP: c_int = 12;
2614/// Argus
2615pub const IPPROTO_ARGUS: c_int = 13;
2616/// EMCON
2617pub const IPPROTO_EMCON: c_int = 14;
2618/// Cross Net Debugger
2619pub const IPPROTO_XNET: c_int = 15;
2620/// Chaos
2621pub const IPPROTO_CHAOS: c_int = 16;
2622// IPPROTO_UDP defined in src/unix/mod.rs
2623/// Multiplexing
2624pub const IPPROTO_MUX: c_int = 18;
2625/// DCN Measurement Subsystems
2626pub const IPPROTO_MEAS: c_int = 19;
2627/// Host Monitoring
2628pub const IPPROTO_HMP: c_int = 20;
2629/// Packet Radio Measurement
2630pub const IPPROTO_PRM: c_int = 21;
2631/// xns idp
2632pub const IPPROTO_IDP: c_int = 22;
2633/// Trunk-1
2634pub const IPPROTO_TRUNK1: c_int = 23;
2635/// Trunk-2
2636pub const IPPROTO_TRUNK2: c_int = 24;
2637/// Leaf-1
2638pub const IPPROTO_LEAF1: c_int = 25;
2639/// Leaf-2
2640pub const IPPROTO_LEAF2: c_int = 26;
2641/// Reliable Data
2642pub const IPPROTO_RDP: c_int = 27;
2643/// Reliable Transaction
2644pub const IPPROTO_IRTP: c_int = 28;
2645/// tp-4 w/ class negotiation
2646pub const IPPROTO_TP: c_int = 29;
2647/// Bulk Data Transfer
2648pub const IPPROTO_BLT: c_int = 30;
2649/// Network Services
2650pub const IPPROTO_NSP: c_int = 31;
2651/// Merit Internodal
2652pub const IPPROTO_INP: c_int = 32;
2653/// Sequential Exchange
2654pub const IPPROTO_SEP: c_int = 33;
2655/// Third Party Connect
2656pub const IPPROTO_3PC: c_int = 34;
2657/// InterDomain Policy Routing
2658pub const IPPROTO_IDPR: c_int = 35;
2659/// XTP
2660pub const IPPROTO_XTP: c_int = 36;
2661/// Datagram Delivery
2662pub const IPPROTO_DDP: c_int = 37;
2663/// Control Message Transport
2664pub const IPPROTO_CMTP: c_int = 38;
2665/// TP++ Transport
2666pub const IPPROTO_TPXX: c_int = 39;
2667/// IL transport protocol
2668pub const IPPROTO_IL: c_int = 40;
2669// IPPROTO_IPV6 defined in src/unix/mod.rs
2670/// Source Demand Routing
2671pub const IPPROTO_SDRP: c_int = 42;
2672/// IP6 routing header
2673pub const IPPROTO_ROUTING: c_int = 43;
2674/// IP6 fragmentation header
2675pub const IPPROTO_FRAGMENT: c_int = 44;
2676/// InterDomain Routing
2677pub const IPPROTO_IDRP: c_int = 45;
2678/// resource reservation
2679pub const IPPROTO_RSVP: c_int = 46;
2680/// General Routing Encap.
2681pub const IPPROTO_GRE: c_int = 47;
2682/// Mobile Host Routing
2683pub const IPPROTO_MHRP: c_int = 48;
2684/// BHA
2685pub const IPPROTO_BHA: c_int = 49;
2686/// IP6 Encap Sec. Payload
2687pub const IPPROTO_ESP: c_int = 50;
2688/// IP6 Auth Header
2689pub const IPPROTO_AH: c_int = 51;
2690/// Integ. Net Layer Security
2691pub const IPPROTO_INLSP: c_int = 52;
2692/// IP with encryption
2693pub const IPPROTO_SWIPE: c_int = 53;
2694/// Next Hop Resolution
2695pub const IPPROTO_NHRP: c_int = 54;
2696/* 55-57: Unassigned */
2697// IPPROTO_ICMPV6 defined in src/unix/mod.rs
2698/// IP6 no next header
2699pub const IPPROTO_NONE: c_int = 59;
2700/// IP6 destination option
2701pub const IPPROTO_DSTOPTS: c_int = 60;
2702/// any host internal protocol
2703pub const IPPROTO_AHIP: c_int = 61;
2704/// CFTP
2705pub const IPPROTO_CFTP: c_int = 62;
2706/// "hello" routing protocol
2707pub const IPPROTO_HELLO: c_int = 63;
2708/// SATNET/Backroom EXPAK
2709pub const IPPROTO_SATEXPAK: c_int = 64;
2710/// Kryptolan
2711pub const IPPROTO_KRYPTOLAN: c_int = 65;
2712/// Remote Virtual Disk
2713pub const IPPROTO_RVD: c_int = 66;
2714/// Pluribus Packet Core
2715pub const IPPROTO_IPPC: c_int = 67;
2716/// Any distributed FS
2717pub const IPPROTO_ADFS: c_int = 68;
2718/// Satnet Monitoring
2719pub const IPPROTO_SATMON: c_int = 69;
2720/// VISA Protocol
2721pub const IPPROTO_VISA: c_int = 70;
2722/// Packet Core Utility
2723pub const IPPROTO_IPCV: c_int = 71;
2724/// Comp. Prot. Net. Executive
2725pub const IPPROTO_CPNX: c_int = 72;
2726/// Comp. Prot. HeartBeat
2727pub const IPPROTO_CPHB: c_int = 73;
2728/// Wang Span Network
2729pub const IPPROTO_WSN: c_int = 74;
2730/// Packet Video Protocol
2731pub const IPPROTO_PVP: c_int = 75;
2732/// BackRoom SATNET Monitoring
2733pub const IPPROTO_BRSATMON: c_int = 76;
2734/// Sun net disk proto (temp.)
2735pub const IPPROTO_ND: c_int = 77;
2736/// WIDEBAND Monitoring
2737pub const IPPROTO_WBMON: c_int = 78;
2738/// WIDEBAND EXPAK
2739pub const IPPROTO_WBEXPAK: c_int = 79;
2740/// ISO cnlp
2741pub const IPPROTO_EON: c_int = 80;
2742/// VMTP
2743pub const IPPROTO_VMTP: c_int = 81;
2744/// Secure VMTP
2745pub const IPPROTO_SVMTP: c_int = 82;
2746/// Banyon VINES
2747pub const IPPROTO_VINES: c_int = 83;
2748/// TTP
2749pub const IPPROTO_TTP: c_int = 84;
2750/// NSFNET-IGP
2751pub const IPPROTO_IGP: c_int = 85;
2752/// dissimilar gateway prot.
2753pub const IPPROTO_DGP: c_int = 86;
2754/// TCF
2755pub const IPPROTO_TCF: c_int = 87;
2756/// Cisco/GXS IGRP
2757pub const IPPROTO_IGRP: c_int = 88;
2758/// OSPFIGP
2759pub const IPPROTO_OSPFIGP: c_int = 89;
2760/// Strite RPC protocol
2761pub const IPPROTO_SRPC: c_int = 90;
2762/// Locus Address Resoloution
2763pub const IPPROTO_LARP: c_int = 91;
2764/// Multicast Transport
2765pub const IPPROTO_MTP: c_int = 92;
2766/// AX.25 Frames
2767pub const IPPROTO_AX25: c_int = 93;
2768/// IP encapsulated in IP
2769pub const IPPROTO_IPEIP: c_int = 94;
2770/// Mobile Int.ing control
2771pub const IPPROTO_MICP: c_int = 95;
2772/// Semaphore Comm. security
2773pub const IPPROTO_SCCSP: c_int = 96;
2774/// Ethernet IP encapsulation
2775pub const IPPROTO_ETHERIP: c_int = 97;
2776/// encapsulation header
2777pub const IPPROTO_ENCAP: c_int = 98;
2778/// any private encr. scheme
2779pub const IPPROTO_APES: c_int = 99;
2780/// GMTP
2781pub const IPPROTO_GMTP: c_int = 100;
2782
2783/* 101-254: Partly Unassigned */
2784/// Protocol Independent Mcast
2785pub const IPPROTO_PIM: c_int = 103;
2786/// payload compression (IPComp)
2787pub const IPPROTO_IPCOMP: c_int = 108;
2788/// PGM
2789pub const IPPROTO_PGM: c_int = 113;
2790/// SCTP
2791pub const IPPROTO_SCTP: c_int = 132;
2792
2793/* 255: Reserved */
2794/* BSD Private, local use, namespace incursion */
2795/// divert pseudo-protocol
2796pub const IPPROTO_DIVERT: c_int = 254;
2797/// raw IP packet
2798pub const IPPROTO_RAW: c_int = 255;
2799pub const IPPROTO_MAX: c_int = 256;
2800/// last return value of *_input(), meaning "all job for this pkt is done".
2801pub const IPPROTO_DONE: c_int = 257;
2802
2803pub const AF_UNSPEC: c_int = 0;
2804pub const AF_LOCAL: c_int = 1;
2805pub const AF_UNIX: c_int = AF_LOCAL;
2806pub const AF_INET: c_int = 2;
2807pub const AF_IMPLINK: c_int = 3;
2808pub const AF_PUP: c_int = 4;
2809pub const AF_CHAOS: c_int = 5;
2810pub const AF_NS: c_int = 6;
2811pub const AF_ISO: c_int = 7;
2812pub const AF_OSI: c_int = AF_ISO;
2813pub const AF_ECMA: c_int = 8;
2814pub const AF_DATAKIT: c_int = 9;
2815pub const AF_CCITT: c_int = 10;
2816pub const AF_SNA: c_int = 11;
2817pub const AF_DECnet: c_int = 12;
2818pub const AF_DLI: c_int = 13;
2819pub const AF_LAT: c_int = 14;
2820pub const AF_HYLINK: c_int = 15;
2821pub const AF_APPLETALK: c_int = 16;
2822pub const AF_ROUTE: c_int = 17;
2823pub const AF_LINK: c_int = 18;
2824pub const pseudo_AF_XTP: c_int = 19;
2825pub const AF_COIP: c_int = 20;
2826pub const AF_CNT: c_int = 21;
2827pub const pseudo_AF_RTIP: c_int = 22;
2828pub const AF_IPX: c_int = 23;
2829pub const AF_SIP: c_int = 24;
2830pub const pseudo_AF_PIP: c_int = 25;
2831pub const AF_NDRV: c_int = 27;
2832pub const AF_ISDN: c_int = 28;
2833pub const AF_E164: c_int = AF_ISDN;
2834pub const pseudo_AF_KEY: c_int = 29;
2835pub const AF_INET6: c_int = 30;
2836pub const AF_NATM: c_int = 31;
2837pub const AF_SYSTEM: c_int = 32;
2838pub const AF_NETBIOS: c_int = 33;
2839pub const AF_PPP: c_int = 34;
2840pub const pseudo_AF_HDRCMPLT: c_int = 35;
2841pub const AF_IEEE80211: c_int = 37;
2842pub const AF_UTUN: c_int = 38;
2843pub const AF_VSOCK: c_int = 40;
2844pub const AF_SYS_CONTROL: c_int = 2;
2845
2846pub const SYSPROTO_EVENT: c_int = 1;
2847pub const SYSPROTO_CONTROL: c_int = 2;
2848
2849pub const PF_UNSPEC: c_int = AF_UNSPEC;
2850pub const PF_LOCAL: c_int = AF_LOCAL;
2851pub const PF_UNIX: c_int = PF_LOCAL;
2852pub const PF_INET: c_int = AF_INET;
2853pub const PF_IMPLINK: c_int = AF_IMPLINK;
2854pub const PF_PUP: c_int = AF_PUP;
2855pub const PF_CHAOS: c_int = AF_CHAOS;
2856pub const PF_NS: c_int = AF_NS;
2857pub const PF_ISO: c_int = AF_ISO;
2858pub const PF_OSI: c_int = AF_ISO;
2859pub const PF_ECMA: c_int = AF_ECMA;
2860pub const PF_DATAKIT: c_int = AF_DATAKIT;
2861pub const PF_CCITT: c_int = AF_CCITT;
2862pub const PF_SNA: c_int = AF_SNA;
2863pub const PF_DECnet: c_int = AF_DECnet;
2864pub const PF_DLI: c_int = AF_DLI;
2865pub const PF_LAT: c_int = AF_LAT;
2866pub const PF_HYLINK: c_int = AF_HYLINK;
2867pub const PF_APPLETALK: c_int = AF_APPLETALK;
2868pub const PF_ROUTE: c_int = AF_ROUTE;
2869pub const PF_LINK: c_int = AF_LINK;
2870pub const PF_XTP: c_int = pseudo_AF_XTP;
2871pub const PF_COIP: c_int = AF_COIP;
2872pub const PF_CNT: c_int = AF_CNT;
2873pub const PF_SIP: c_int = AF_SIP;
2874pub const PF_IPX: c_int = AF_IPX;
2875pub const PF_RTIP: c_int = pseudo_AF_RTIP;
2876pub const PF_PIP: c_int = pseudo_AF_PIP;
2877pub const PF_NDRV: c_int = AF_NDRV;
2878pub const PF_ISDN: c_int = AF_ISDN;
2879pub const PF_KEY: c_int = pseudo_AF_KEY;
2880pub const PF_INET6: c_int = AF_INET6;
2881pub const PF_NATM: c_int = AF_NATM;
2882pub const PF_SYSTEM: c_int = AF_SYSTEM;
2883pub const PF_NETBIOS: c_int = AF_NETBIOS;
2884pub const PF_PPP: c_int = AF_PPP;
2885pub const PF_VSOCK: c_int = AF_VSOCK;
2886
2887pub const NET_RT_DUMP: c_int = 1;
2888pub const NET_RT_FLAGS: c_int = 2;
2889pub const NET_RT_IFLIST: c_int = 3;
2890
2891pub const SOMAXCONN: c_int = 128;
2892
2893pub const SOCK_MAXADDRLEN: c_int = 255;
2894
2895pub const SOCK_STREAM: c_int = 1;
2896pub const SOCK_DGRAM: c_int = 2;
2897pub const SOCK_RAW: c_int = 3;
2898pub const SOCK_RDM: c_int = 4;
2899pub const SOCK_SEQPACKET: c_int = 5;
2900pub const IP_TTL: c_int = 4;
2901pub const IP_HDRINCL: c_int = 2;
2902pub const IP_RECVDSTADDR: c_int = 7;
2903pub const IP_ADD_MEMBERSHIP: c_int = 12;
2904pub const IP_DROP_MEMBERSHIP: c_int = 13;
2905pub const IP_RECVIF: c_int = 20;
2906pub const IP_RECVTTL: c_int = 24;
2907pub const IP_BOUND_IF: c_int = 25;
2908pub const IP_PKTINFO: c_int = 26;
2909pub const IP_RECVTOS: c_int = 27;
2910pub const IP_DONTFRAG: c_int = 28;
2911pub const IPV6_JOIN_GROUP: c_int = 12;
2912pub const IPV6_LEAVE_GROUP: c_int = 13;
2913pub const IPV6_CHECKSUM: c_int = 26;
2914pub const IPV6_RECVTCLASS: c_int = 35;
2915pub const IPV6_TCLASS: c_int = 36;
2916pub const IPV6_RECVHOPLIMIT: c_int = 37;
2917pub const IPV6_PKTINFO: c_int = 46;
2918pub const IPV6_HOPLIMIT: c_int = 47;
2919pub const IPV6_RECVPKTINFO: c_int = 61;
2920pub const IP_ADD_SOURCE_MEMBERSHIP: c_int = 70;
2921pub const IP_DROP_SOURCE_MEMBERSHIP: c_int = 71;
2922pub const IP_BLOCK_SOURCE: c_int = 72;
2923pub const IP_UNBLOCK_SOURCE: c_int = 73;
2924pub const IPV6_BOUND_IF: c_int = 125;
2925
2926pub const TCP_NOPUSH: c_int = 4;
2927pub const TCP_NOOPT: c_int = 8;
2928pub const TCP_KEEPALIVE: c_int = 0x10;
2929pub const TCP_KEEPINTVL: c_int = 0x101;
2930pub const TCP_KEEPCNT: c_int = 0x102;
2931/// Enable/Disable TCP Fastopen on this socket
2932pub const TCP_FASTOPEN: c_int = 0x105;
2933pub const TCP_CONNECTION_INFO: c_int = 0x106;
2934
2935pub const SOL_LOCAL: c_int = 0;
2936
2937/// Retrieve peer credentials.
2938pub const LOCAL_PEERCRED: c_int = 0x001;
2939/// Retrieve peer PID.
2940pub const LOCAL_PEERPID: c_int = 0x002;
2941/// Retrieve effective peer PID.
2942pub const LOCAL_PEEREPID: c_int = 0x003;
2943/// Retrieve peer UUID.
2944pub const LOCAL_PEERUUID: c_int = 0x004;
2945/// Retrieve effective peer UUID.
2946pub const LOCAL_PEEREUUID: c_int = 0x005;
2947/// Retrieve peer audit token.
2948pub const LOCAL_PEERTOKEN: c_int = 0x006;
2949
2950pub const SOL_SOCKET: c_int = 0xffff;
2951
2952pub const SO_DEBUG: c_int = 0x01;
2953pub const SO_ACCEPTCONN: c_int = 0x0002;
2954pub const SO_REUSEADDR: c_int = 0x0004;
2955pub const SO_KEEPALIVE: c_int = 0x0008;
2956pub const SO_DONTROUTE: c_int = 0x0010;
2957pub const SO_BROADCAST: c_int = 0x0020;
2958pub const SO_USELOOPBACK: c_int = 0x0040;
2959pub const SO_LINGER: c_int = 0x0080;
2960pub const SO_OOBINLINE: c_int = 0x0100;
2961pub const SO_REUSEPORT: c_int = 0x0200;
2962pub const SO_TIMESTAMP: c_int = 0x0400;
2963pub const SO_TIMESTAMP_MONOTONIC: c_int = 0x0800;
2964pub const SO_DONTTRUNC: c_int = 0x2000;
2965pub const SO_WANTMORE: c_int = 0x4000;
2966pub const SO_WANTOOBFLAG: c_int = 0x8000;
2967pub const SO_SNDBUF: c_int = 0x1001;
2968pub const SO_RCVBUF: c_int = 0x1002;
2969pub const SO_SNDLOWAT: c_int = 0x1003;
2970pub const SO_RCVLOWAT: c_int = 0x1004;
2971pub const SO_SNDTIMEO: c_int = 0x1005;
2972pub const SO_RCVTIMEO: c_int = 0x1006;
2973pub const SO_ERROR: c_int = 0x1007;
2974pub const SO_TYPE: c_int = 0x1008;
2975pub const SO_LABEL: c_int = 0x1010;
2976pub const SO_PEERLABEL: c_int = 0x1011;
2977pub const SO_NREAD: c_int = 0x1020;
2978pub const SO_NKE: c_int = 0x1021;
2979pub const SO_NOSIGPIPE: c_int = 0x1022;
2980pub const SO_NOADDRERR: c_int = 0x1023;
2981pub const SO_NWRITE: c_int = 0x1024;
2982pub const SO_REUSESHAREUID: c_int = 0x1025;
2983pub const SO_NOTIFYCONFLICT: c_int = 0x1026;
2984pub const SO_LINGER_SEC: c_int = 0x1080;
2985pub const SO_RANDOMPORT: c_int = 0x1082;
2986pub const SO_NP_EXTENSIONS: c_int = 0x1083;
2987
2988pub const MSG_OOB: c_int = 0x1;
2989pub const MSG_PEEK: c_int = 0x2;
2990pub const MSG_DONTROUTE: c_int = 0x4;
2991pub const MSG_EOR: c_int = 0x8;
2992pub const MSG_TRUNC: c_int = 0x10;
2993pub const MSG_CTRUNC: c_int = 0x20;
2994pub const MSG_WAITALL: c_int = 0x40;
2995pub const MSG_DONTWAIT: c_int = 0x80;
2996pub const MSG_EOF: c_int = 0x100;
2997pub const MSG_FLUSH: c_int = 0x400;
2998pub const MSG_HOLD: c_int = 0x800;
2999pub const MSG_SEND: c_int = 0x1000;
3000pub const MSG_HAVEMORE: c_int = 0x2000;
3001pub const MSG_RCVMORE: c_int = 0x4000;
3002pub const MSG_NEEDSA: c_int = 0x10000;
3003pub const MSG_NOSIGNAL: c_int = 0x80000;
3004
3005pub const SCM_TIMESTAMP: c_int = 0x02;
3006pub const SCM_CREDS: c_int = 0x03;
3007
3008// https://github.com/aosm/xnu/blob/HEAD/bsd/net/if.h#L140-L156
3009pub const IFF_UP: c_int = 0x1; // interface is up
3010pub const IFF_BROADCAST: c_int = 0x2; // broadcast address valid
3011pub const IFF_DEBUG: c_int = 0x4; // turn on debugging
3012pub const IFF_LOOPBACK: c_int = 0x8; // is a loopback net
3013pub const IFF_POINTOPOINT: c_int = 0x10; // interface is point-to-point link
3014pub const IFF_NOTRAILERS: c_int = 0x20; // obsolete: avoid use of trailers
3015pub const IFF_RUNNING: c_int = 0x40; // resources allocated
3016pub const IFF_NOARP: c_int = 0x80; // no address resolution protocol
3017pub const IFF_PROMISC: c_int = 0x100; // receive all packets
3018pub const IFF_ALLMULTI: c_int = 0x200; // receive all multicast packets
3019pub const IFF_OACTIVE: c_int = 0x400; // transmission in progress
3020pub const IFF_SIMPLEX: c_int = 0x800; // can't hear own transmissions
3021pub const IFF_LINK0: c_int = 0x1000; // per link layer defined bit
3022pub const IFF_LINK1: c_int = 0x2000; // per link layer defined bit
3023pub const IFF_LINK2: c_int = 0x4000; // per link layer defined bit
3024pub const IFF_ALTPHYS: c_int = IFF_LINK2; // use alternate physical connection
3025pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast
3026
3027pub const SCOPE6_ID_MAX: size_t = 16;
3028
3029pub const SHUT_RD: c_int = 0;
3030pub const SHUT_WR: c_int = 1;
3031pub const SHUT_RDWR: c_int = 2;
3032
3033pub const SAE_ASSOCID_ANY: crate::sae_associd_t = 0;
3034/// ((sae_associd_t)(-1ULL))
3035pub const SAE_ASSOCID_ALL: crate::sae_associd_t = 0xffffffff;
3036
3037pub const SAE_CONNID_ANY: crate::sae_connid_t = 0;
3038/// ((sae_connid_t)(-1ULL))
3039pub const SAE_CONNID_ALL: crate::sae_connid_t = 0xffffffff;
3040
3041// connectx() flag parameters
3042
3043/// resume connect() on read/write
3044pub const CONNECT_RESUME_ON_READ_WRITE: c_uint = 0x1;
3045/// data is idempotent
3046pub const CONNECT_DATA_IDEMPOTENT: c_uint = 0x2;
3047/// data includes security that replaces the TFO-cookie
3048pub const CONNECT_DATA_AUTHENTICATED: c_uint = 0x4;
3049
3050pub const LOCK_SH: c_int = 1;
3051pub const LOCK_EX: c_int = 2;
3052pub const LOCK_NB: c_int = 4;
3053pub const LOCK_UN: c_int = 8;
3054
3055pub const MAP_COPY: c_int = 0x0002;
3056pub const MAP_RENAME: c_int = 0x0020;
3057pub const MAP_NORESERVE: c_int = 0x0040;
3058pub const MAP_NOEXTEND: c_int = 0x0100;
3059pub const MAP_HASSEMAPHORE: c_int = 0x0200;
3060pub const MAP_NOCACHE: c_int = 0x0400;
3061pub const MAP_JIT: c_int = 0x0800;
3062
3063pub const _SC_ARG_MAX: c_int = 1;
3064pub const _SC_CHILD_MAX: c_int = 2;
3065pub const _SC_CLK_TCK: c_int = 3;
3066pub const _SC_NGROUPS_MAX: c_int = 4;
3067pub const _SC_OPEN_MAX: c_int = 5;
3068pub const _SC_JOB_CONTROL: c_int = 6;
3069pub const _SC_SAVED_IDS: c_int = 7;
3070pub const _SC_VERSION: c_int = 8;
3071pub const _SC_BC_BASE_MAX: c_int = 9;
3072pub const _SC_BC_DIM_MAX: c_int = 10;
3073pub const _SC_BC_SCALE_MAX: c_int = 11;
3074pub const _SC_BC_STRING_MAX: c_int = 12;
3075pub const _SC_COLL_WEIGHTS_MAX: c_int = 13;
3076pub const _SC_EXPR_NEST_MAX: c_int = 14;
3077pub const _SC_LINE_MAX: c_int = 15;
3078pub const _SC_RE_DUP_MAX: c_int = 16;
3079pub const _SC_2_VERSION: c_int = 17;
3080pub const _SC_2_C_BIND: c_int = 18;
3081pub const _SC_2_C_DEV: c_int = 19;
3082pub const _SC_2_CHAR_TERM: c_int = 20;
3083pub const _SC_2_FORT_DEV: c_int = 21;
3084pub const _SC_2_FORT_RUN: c_int = 22;
3085pub const _SC_2_LOCALEDEF: c_int = 23;
3086pub const _SC_2_SW_DEV: c_int = 24;
3087pub const _SC_2_UPE: c_int = 25;
3088pub const _SC_STREAM_MAX: c_int = 26;
3089pub const _SC_TZNAME_MAX: c_int = 27;
3090pub const _SC_ASYNCHRONOUS_IO: c_int = 28;
3091pub const _SC_PAGESIZE: c_int = 29;
3092pub const _SC_MEMLOCK: c_int = 30;
3093pub const _SC_MEMLOCK_RANGE: c_int = 31;
3094pub const _SC_MEMORY_PROTECTION: c_int = 32;
3095pub const _SC_MESSAGE_PASSING: c_int = 33;
3096pub const _SC_PRIORITIZED_IO: c_int = 34;
3097pub const _SC_PRIORITY_SCHEDULING: c_int = 35;
3098pub const _SC_REALTIME_SIGNALS: c_int = 36;
3099pub const _SC_SEMAPHORES: c_int = 37;
3100pub const _SC_FSYNC: c_int = 38;
3101pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 39;
3102pub const _SC_SYNCHRONIZED_IO: c_int = 40;
3103pub const _SC_TIMERS: c_int = 41;
3104pub const _SC_AIO_LISTIO_MAX: c_int = 42;
3105pub const _SC_AIO_MAX: c_int = 43;
3106pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 44;
3107pub const _SC_DELAYTIMER_MAX: c_int = 45;
3108pub const _SC_MQ_OPEN_MAX: c_int = 46;
3109pub const _SC_MAPPED_FILES: c_int = 47;
3110pub const _SC_RTSIG_MAX: c_int = 48;
3111pub const _SC_SEM_NSEMS_MAX: c_int = 49;
3112pub const _SC_SEM_VALUE_MAX: c_int = 50;
3113pub const _SC_SIGQUEUE_MAX: c_int = 51;
3114pub const _SC_TIMER_MAX: c_int = 52;
3115pub const _SC_NPROCESSORS_CONF: c_int = 57;
3116pub const _SC_NPROCESSORS_ONLN: c_int = 58;
3117pub const _SC_2_PBS: c_int = 59;
3118pub const _SC_2_PBS_ACCOUNTING: c_int = 60;
3119pub const _SC_2_PBS_CHECKPOINT: c_int = 61;
3120pub const _SC_2_PBS_LOCATE: c_int = 62;
3121pub const _SC_2_PBS_MESSAGE: c_int = 63;
3122pub const _SC_2_PBS_TRACK: c_int = 64;
3123pub const _SC_ADVISORY_INFO: c_int = 65;
3124pub const _SC_BARRIERS: c_int = 66;
3125pub const _SC_CLOCK_SELECTION: c_int = 67;
3126pub const _SC_CPUTIME: c_int = 68;
3127pub const _SC_FILE_LOCKING: c_int = 69;
3128pub const _SC_HOST_NAME_MAX: c_int = 72;
3129pub const _SC_MONOTONIC_CLOCK: c_int = 74;
3130pub const _SC_READER_WRITER_LOCKS: c_int = 76;
3131pub const _SC_REGEXP: c_int = 77;
3132pub const _SC_SHELL: c_int = 78;
3133pub const _SC_SPAWN: c_int = 79;
3134pub const _SC_SPIN_LOCKS: c_int = 80;
3135pub const _SC_SPORADIC_SERVER: c_int = 81;
3136pub const _SC_THREAD_CPUTIME: c_int = 84;
3137pub const _SC_THREAD_SPORADIC_SERVER: c_int = 92;
3138pub const _SC_TIMEOUTS: c_int = 95;
3139pub const _SC_TRACE: c_int = 97;
3140pub const _SC_TRACE_EVENT_FILTER: c_int = 98;
3141pub const _SC_TRACE_INHERIT: c_int = 99;
3142pub const _SC_TRACE_LOG: c_int = 100;
3143pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 102;
3144pub const _SC_V6_ILP32_OFF32: c_int = 103;
3145pub const _SC_V6_ILP32_OFFBIG: c_int = 104;
3146pub const _SC_V6_LP64_OFF64: c_int = 105;
3147pub const _SC_V6_LPBIG_OFFBIG: c_int = 106;
3148pub const _SC_IPV6: c_int = 118;
3149pub const _SC_RAW_SOCKETS: c_int = 119;
3150pub const _SC_SYMLOOP_MAX: c_int = 120;
3151pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE;
3152pub const _SC_XOPEN_STREAMS: c_int = 114;
3153pub const _SC_XBS5_ILP32_OFF32: c_int = 122;
3154pub const _SC_XBS5_ILP32_OFFBIG: c_int = 123;
3155pub const _SC_XBS5_LP64_OFF64: c_int = 124;
3156pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 125;
3157pub const _SC_SS_REPL_MAX: c_int = 126;
3158pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 127;
3159pub const _SC_TRACE_NAME_MAX: c_int = 128;
3160pub const _SC_TRACE_SYS_MAX: c_int = 129;
3161pub const _SC_TRACE_USER_EVENT_MAX: c_int = 130;
3162pub const _SC_PASS_MAX: c_int = 131;
3163// `confstr` keys (only the values guaranteed by `man confstr`).
3164pub const _CS_PATH: c_int = 1;
3165pub const _CS_DARWIN_USER_DIR: c_int = 65536;
3166pub const _CS_DARWIN_USER_TEMP_DIR: c_int = 65537;
3167pub const _CS_DARWIN_USER_CACHE_DIR: c_int = 65538;
3168
3169pub const OS_UNFAIR_LOCK_INIT: os_unfair_lock = os_unfair_lock {
3170    _os_unfair_lock_opaque: 0,
3171};
3172
3173pub const OS_LOG_TYPE_DEFAULT: crate::os_log_type_t = 0x00;
3174pub const OS_LOG_TYPE_INFO: crate::os_log_type_t = 0x01;
3175pub const OS_LOG_TYPE_DEBUG: crate::os_log_type_t = 0x02;
3176pub const OS_LOG_TYPE_ERROR: crate::os_log_type_t = 0x10;
3177pub const OS_LOG_TYPE_FAULT: crate::os_log_type_t = 0x11;
3178
3179pub const OS_SIGNPOST_EVENT: crate::os_signpost_type_t = 0x00;
3180pub const OS_SIGNPOST_INTERVAL_BEGIN: crate::os_signpost_type_t = 0x01;
3181pub const OS_SIGNPOST_INTERVAL_END: crate::os_signpost_type_t = 0x02;
3182
3183pub const MINSIGSTKSZ: size_t = 32768;
3184pub const SIGSTKSZ: size_t = 131072;
3185
3186pub const FD_SETSIZE: usize = 1024;
3187
3188pub const ST_NOSUID: c_ulong = 2;
3189
3190pub const EVFILT_READ: i16 = -1;
3191pub const EVFILT_WRITE: i16 = -2;
3192pub const EVFILT_AIO: i16 = -3;
3193pub const EVFILT_VNODE: i16 = -4;
3194pub const EVFILT_PROC: i16 = -5;
3195pub const EVFILT_SIGNAL: i16 = -6;
3196pub const EVFILT_TIMER: i16 = -7;
3197pub const EVFILT_MACHPORT: i16 = -8;
3198pub const EVFILT_FS: i16 = -9;
3199pub const EVFILT_USER: i16 = -10;
3200pub const EVFILT_VM: i16 = -12;
3201pub const EVFILT_EXCEPT: i16 = -15;
3202
3203pub const EV_ADD: u16 = 0x1;
3204pub const EV_DELETE: u16 = 0x2;
3205pub const EV_ENABLE: u16 = 0x4;
3206pub const EV_DISABLE: u16 = 0x8;
3207pub const EV_ONESHOT: u16 = 0x10;
3208pub const EV_CLEAR: u16 = 0x20;
3209pub const EV_RECEIPT: u16 = 0x40;
3210pub const EV_DISPATCH: u16 = 0x80;
3211pub const EV_UDATA_SPECIFIC: u16 = 0x0100;
3212pub const EV_DISPATCH2: u16 = EV_DISPATCH | EV_UDATA_SPECIFIC;
3213pub const EV_VANISHED: u16 = 0x0200;
3214pub const EV_FLAG0: u16 = 0x1000;
3215pub const EV_POLL: u16 = 0x1000;
3216pub const EV_FLAG1: u16 = 0x2000;
3217pub const EV_OOBAND: u16 = 0x2000;
3218pub const EV_ERROR: u16 = 0x4000;
3219pub const EV_EOF: u16 = 0x8000;
3220pub const EV_SYSFLAGS: u16 = 0xf000;
3221
3222pub const KEVENT_FLAG_NONE: c_uint = 0x000000;
3223pub const KEVENT_FLAG_IMMEDIATE: c_uint = 0x000001;
3224pub const KEVENT_FLAG_ERROR_EVENTS: c_uint = 0x000002;
3225
3226pub const NOTE_TRIGGER: u32 = 0x01000000;
3227pub const NOTE_FFNOP: u32 = 0x00000000;
3228pub const NOTE_FFAND: u32 = 0x40000000;
3229pub const NOTE_FFOR: u32 = 0x80000000;
3230pub const NOTE_FFCOPY: u32 = 0xc0000000;
3231pub const NOTE_FFCTRLMASK: u32 = 0xc0000000;
3232pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff;
3233pub const NOTE_LOWAT: u32 = 0x00000001;
3234pub const NOTE_OOB: u32 = 0x00000002;
3235pub const NOTE_DELETE: u32 = 0x00000001;
3236pub const NOTE_WRITE: u32 = 0x00000002;
3237pub const NOTE_EXTEND: u32 = 0x00000004;
3238pub const NOTE_ATTRIB: u32 = 0x00000008;
3239pub const NOTE_LINK: u32 = 0x00000010;
3240pub const NOTE_RENAME: u32 = 0x00000020;
3241pub const NOTE_REVOKE: u32 = 0x00000040;
3242pub const NOTE_NONE: u32 = 0x00000080;
3243pub const NOTE_FUNLOCK: u32 = 0x00000100;
3244pub const NOTE_LEASE_DOWNGRADE: u32 = 0x00000200;
3245pub const NOTE_LEASE_RELEASE: u32 = 0x00000400;
3246pub const NOTE_EXIT: u32 = 0x80000000;
3247pub const NOTE_FORK: u32 = 0x40000000;
3248pub const NOTE_EXEC: u32 = 0x20000000;
3249#[doc(hidden)]
3250#[deprecated(since = "0.2.49", note = "Deprecated since MacOSX 10.9")]
3251pub const NOTE_REAP: u32 = 0x10000000;
3252pub const NOTE_SIGNAL: u32 = 0x08000000;
3253pub const NOTE_EXITSTATUS: u32 = 0x04000000;
3254pub const NOTE_EXIT_DETAIL: u32 = 0x02000000;
3255pub const NOTE_PDATAMASK: u32 = 0x000fffff;
3256pub const NOTE_PCTRLMASK: u32 = 0xfff00000;
3257#[doc(hidden)]
3258#[deprecated(since = "0.2.49", note = "Deprecated since MacOSX 10.9")]
3259pub const NOTE_EXIT_REPARENTED: u32 = 0x00080000;
3260pub const NOTE_EXIT_DETAIL_MASK: u32 = 0x00070000;
3261pub const NOTE_EXIT_DECRYPTFAIL: u32 = 0x00010000;
3262pub const NOTE_EXIT_MEMORY: u32 = 0x00020000;
3263pub const NOTE_EXIT_CSERROR: u32 = 0x00040000;
3264pub const NOTE_VM_PRESSURE: u32 = 0x80000000;
3265pub const NOTE_VM_PRESSURE_TERMINATE: u32 = 0x40000000;
3266pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE: u32 = 0x20000000;
3267pub const NOTE_VM_ERROR: u32 = 0x10000000;
3268pub const NOTE_SECONDS: u32 = 0x00000001;
3269pub const NOTE_USECONDS: u32 = 0x00000002;
3270pub const NOTE_NSECONDS: u32 = 0x00000004;
3271pub const NOTE_ABSOLUTE: u32 = 0x00000008;
3272pub const NOTE_LEEWAY: u32 = 0x00000010;
3273pub const NOTE_CRITICAL: u32 = 0x00000020;
3274pub const NOTE_BACKGROUND: u32 = 0x00000040;
3275pub const NOTE_MACH_CONTINUOUS_TIME: u32 = 0x00000080;
3276pub const NOTE_MACHTIME: u32 = 0x00000100;
3277pub const NOTE_TRACK: u32 = 0x00000001;
3278pub const NOTE_TRACKERR: u32 = 0x00000002;
3279pub const NOTE_CHILD: u32 = 0x00000004;
3280
3281pub const OCRNL: crate::tcflag_t = 0x00000010;
3282pub const ONOCR: crate::tcflag_t = 0x00000020;
3283pub const ONLRET: crate::tcflag_t = 0x00000040;
3284pub const OFILL: crate::tcflag_t = 0x00000080;
3285pub const NLDLY: crate::tcflag_t = 0x00000300;
3286pub const TABDLY: crate::tcflag_t = 0x00000c04;
3287pub const CRDLY: crate::tcflag_t = 0x00003000;
3288pub const FFDLY: crate::tcflag_t = 0x00004000;
3289pub const BSDLY: crate::tcflag_t = 0x00008000;
3290pub const VTDLY: crate::tcflag_t = 0x00010000;
3291pub const OFDEL: crate::tcflag_t = 0x00020000;
3292
3293pub const NL0: crate::tcflag_t = 0x00000000;
3294pub const NL1: crate::tcflag_t = 0x00000100;
3295pub const TAB0: crate::tcflag_t = 0x00000000;
3296pub const TAB1: crate::tcflag_t = 0x00000400;
3297pub const TAB2: crate::tcflag_t = 0x00000800;
3298pub const CR0: crate::tcflag_t = 0x00000000;
3299pub const CR1: crate::tcflag_t = 0x00001000;
3300pub const CR2: crate::tcflag_t = 0x00002000;
3301pub const CR3: crate::tcflag_t = 0x00003000;
3302pub const FF0: crate::tcflag_t = 0x00000000;
3303pub const FF1: crate::tcflag_t = 0x00004000;
3304pub const BS0: crate::tcflag_t = 0x00000000;
3305pub const BS1: crate::tcflag_t = 0x00008000;
3306pub const TAB3: crate::tcflag_t = 0x00000004;
3307pub const VT0: crate::tcflag_t = 0x00000000;
3308pub const VT1: crate::tcflag_t = 0x00010000;
3309pub const IUTF8: crate::tcflag_t = 0x00004000;
3310pub const CRTSCTS: crate::tcflag_t = 0x00030000;
3311
3312pub const NI_MAXHOST: crate::socklen_t = 1025;
3313pub const NI_MAXSERV: crate::socklen_t = 32;
3314pub const NI_NOFQDN: c_int = 0x00000001;
3315pub const NI_NUMERICHOST: c_int = 0x00000002;
3316pub const NI_NAMEREQD: c_int = 0x00000004;
3317pub const NI_NUMERICSERV: c_int = 0x00000008;
3318pub const NI_NUMERICSCOPE: c_int = 0x00000100;
3319pub const NI_DGRAM: c_int = 0x00000010;
3320
3321pub const Q_GETQUOTA: c_int = 0x300;
3322pub const Q_SETQUOTA: c_int = 0x400;
3323
3324pub const RENAME_SWAP: c_uint = 0x00000002;
3325pub const RENAME_EXCL: c_uint = 0x00000004;
3326
3327pub const RTLD_LOCAL: c_int = 0x4;
3328pub const RTLD_FIRST: c_int = 0x100;
3329pub const RTLD_NODELETE: c_int = 0x80;
3330pub const RTLD_NOLOAD: c_int = 0x10;
3331pub const RTLD_GLOBAL: c_int = 0x8;
3332pub const RTLD_MAIN_ONLY: *mut c_void = -5isize as *mut c_void;
3333
3334pub const _WSTOPPED: c_int = 0o177;
3335
3336pub const LOG_NETINFO: c_int = 12 << 3;
3337pub const LOG_REMOTEAUTH: c_int = 13 << 3;
3338pub const LOG_INSTALL: c_int = 14 << 3;
3339pub const LOG_RAS: c_int = 15 << 3;
3340pub const LOG_LAUNCHD: c_int = 24 << 3;
3341pub const LOG_NFACILITIES: c_int = 25;
3342
3343pub const CTLTYPE: c_int = 0xf;
3344pub const CTLTYPE_NODE: c_int = 1;
3345pub const CTLTYPE_INT: c_int = 2;
3346pub const CTLTYPE_STRING: c_int = 3;
3347pub const CTLTYPE_QUAD: c_int = 4;
3348pub const CTLTYPE_OPAQUE: c_int = 5;
3349pub const CTLTYPE_STRUCT: c_int = CTLTYPE_OPAQUE;
3350pub const CTLFLAG_RD: c_int = u32_cast_int(0x80000000);
3351pub const CTLFLAG_WR: c_int = 0x40000000;
3352pub const CTLFLAG_RW: c_int = CTLFLAG_RD | CTLFLAG_WR;
3353pub const CTLFLAG_NOLOCK: c_int = 0x20000000;
3354pub const CTLFLAG_ANYBODY: c_int = 0x10000000;
3355pub const CTLFLAG_SECURE: c_int = 0x08000000;
3356pub const CTLFLAG_MASKED: c_int = 0x04000000;
3357pub const CTLFLAG_NOAUTO: c_int = 0x02000000;
3358pub const CTLFLAG_KERN: c_int = 0x01000000;
3359pub const CTLFLAG_LOCKED: c_int = 0x00800000;
3360pub const CTLFLAG_OID2: c_int = 0x00400000;
3361pub const CTL_UNSPEC: c_int = 0;
3362pub const CTL_KERN: c_int = 1;
3363pub const CTL_VM: c_int = 2;
3364pub const CTL_VFS: c_int = 3;
3365pub const CTL_NET: c_int = 4;
3366pub const CTL_DEBUG: c_int = 5;
3367pub const CTL_HW: c_int = 6;
3368pub const CTL_MACHDEP: c_int = 7;
3369pub const CTL_USER: c_int = 8;
3370pub const CTL_MAXID: c_int = 9;
3371pub const KERN_OSTYPE: c_int = 1;
3372pub const KERN_OSRELEASE: c_int = 2;
3373pub const KERN_OSREV: c_int = 3;
3374pub const KERN_VERSION: c_int = 4;
3375pub const KERN_MAXVNODES: c_int = 5;
3376pub const KERN_MAXPROC: c_int = 6;
3377pub const KERN_MAXFILES: c_int = 7;
3378pub const KERN_ARGMAX: c_int = 8;
3379pub const KERN_SECURELVL: c_int = 9;
3380pub const KERN_HOSTNAME: c_int = 10;
3381pub const KERN_HOSTID: c_int = 11;
3382pub const KERN_CLOCKRATE: c_int = 12;
3383pub const KERN_VNODE: c_int = 13;
3384pub const KERN_PROC: c_int = 14;
3385pub const KERN_FILE: c_int = 15;
3386pub const KERN_PROF: c_int = 16;
3387pub const KERN_POSIX1: c_int = 17;
3388pub const KERN_NGROUPS: c_int = 18;
3389pub const KERN_JOB_CONTROL: c_int = 19;
3390pub const KERN_SAVED_IDS: c_int = 20;
3391pub const KERN_BOOTTIME: c_int = 21;
3392pub const KERN_NISDOMAINNAME: c_int = 22;
3393pub const KERN_DOMAINNAME: c_int = KERN_NISDOMAINNAME;
3394pub const KERN_MAXPARTITIONS: c_int = 23;
3395pub const KERN_KDEBUG: c_int = 24;
3396pub const KERN_UPDATEINTERVAL: c_int = 25;
3397pub const KERN_OSRELDATE: c_int = 26;
3398pub const KERN_NTP_PLL: c_int = 27;
3399pub const KERN_BOOTFILE: c_int = 28;
3400pub const KERN_MAXFILESPERPROC: c_int = 29;
3401pub const KERN_MAXPROCPERUID: c_int = 30;
3402pub const KERN_DUMPDEV: c_int = 31;
3403pub const KERN_IPC: c_int = 32;
3404pub const KERN_DUMMY: c_int = 33;
3405pub const KERN_PS_STRINGS: c_int = 34;
3406pub const KERN_USRSTACK32: c_int = 35;
3407pub const KERN_LOGSIGEXIT: c_int = 36;
3408pub const KERN_SYMFILE: c_int = 37;
3409pub const KERN_PROCARGS: c_int = 38;
3410pub const KERN_NETBOOT: c_int = 40;
3411pub const KERN_SYSV: c_int = 42;
3412pub const KERN_AFFINITY: c_int = 43;
3413pub const KERN_TRANSLATE: c_int = 44;
3414pub const KERN_CLASSIC: c_int = KERN_TRANSLATE;
3415pub const KERN_EXEC: c_int = 45;
3416pub const KERN_CLASSICHANDLER: c_int = KERN_EXEC;
3417pub const KERN_AIOMAX: c_int = 46;
3418pub const KERN_AIOPROCMAX: c_int = 47;
3419pub const KERN_AIOTHREADS: c_int = 48;
3420pub const KERN_COREFILE: c_int = 50;
3421pub const KERN_COREDUMP: c_int = 51;
3422pub const KERN_SUGID_COREDUMP: c_int = 52;
3423pub const KERN_PROCDELAYTERM: c_int = 53;
3424pub const KERN_SHREG_PRIVATIZABLE: c_int = 54;
3425pub const KERN_LOW_PRI_WINDOW: c_int = 56;
3426pub const KERN_LOW_PRI_DELAY: c_int = 57;
3427pub const KERN_POSIX: c_int = 58;
3428pub const KERN_USRSTACK64: c_int = 59;
3429pub const KERN_NX_PROTECTION: c_int = 60;
3430pub const KERN_TFP: c_int = 61;
3431pub const KERN_PROCNAME: c_int = 62;
3432pub const KERN_THALTSTACK: c_int = 63;
3433pub const KERN_SPECULATIVE_READS: c_int = 64;
3434pub const KERN_OSVERSION: c_int = 65;
3435pub const KERN_SAFEBOOT: c_int = 66;
3436pub const KERN_RAGEVNODE: c_int = 68;
3437pub const KERN_TTY: c_int = 69;
3438pub const KERN_CHECKOPENEVT: c_int = 70;
3439pub const KERN_THREADNAME: c_int = 71;
3440pub const KERN_MAXID: c_int = 72;
3441pub const KERN_RAGE_PROC: c_int = 1;
3442pub const KERN_RAGE_THREAD: c_int = 2;
3443pub const KERN_UNRAGE_PROC: c_int = 3;
3444pub const KERN_UNRAGE_THREAD: c_int = 4;
3445pub const KERN_OPENEVT_PROC: c_int = 1;
3446pub const KERN_UNOPENEVT_PROC: c_int = 2;
3447pub const KERN_TFP_POLICY: c_int = 1;
3448pub const KERN_TFP_POLICY_DENY: c_int = 0;
3449pub const KERN_TFP_POLICY_DEFAULT: c_int = 2;
3450pub const KERN_KDEFLAGS: c_int = 1;
3451pub const KERN_KDDFLAGS: c_int = 2;
3452pub const KERN_KDENABLE: c_int = 3;
3453pub const KERN_KDSETBUF: c_int = 4;
3454pub const KERN_KDGETBUF: c_int = 5;
3455pub const KERN_KDSETUP: c_int = 6;
3456pub const KERN_KDREMOVE: c_int = 7;
3457pub const KERN_KDSETREG: c_int = 8;
3458pub const KERN_KDGETREG: c_int = 9;
3459pub const KERN_KDREADTR: c_int = 10;
3460pub const KERN_KDPIDTR: c_int = 11;
3461pub const KERN_KDTHRMAP: c_int = 12;
3462pub const KERN_KDPIDEX: c_int = 14;
3463pub const KERN_KDSETRTCDEC: c_int = 15;
3464pub const KERN_KDGETENTROPY: c_int = 16;
3465pub const KERN_KDWRITETR: c_int = 17;
3466pub const KERN_KDWRITEMAP: c_int = 18;
3467#[doc(hidden)]
3468#[deprecated(since = "0.2.49", note = "Removed in MacOSX 10.12")]
3469pub const KERN_KDENABLE_BG_TRACE: c_int = 19;
3470#[doc(hidden)]
3471#[deprecated(since = "0.2.49", note = "Removed in MacOSX 10.12")]
3472pub const KERN_KDDISABLE_BG_TRACE: c_int = 20;
3473pub const KERN_KDREADCURTHRMAP: c_int = 21;
3474pub const KERN_KDSET_TYPEFILTER: c_int = 22;
3475pub const KERN_KDBUFWAIT: c_int = 23;
3476pub const KERN_KDCPUMAP: c_int = 24;
3477pub const KERN_PROC_ALL: c_int = 0;
3478pub const KERN_PROC_PID: c_int = 1;
3479pub const KERN_PROC_PGRP: c_int = 2;
3480pub const KERN_PROC_SESSION: c_int = 3;
3481pub const KERN_PROC_TTY: c_int = 4;
3482pub const KERN_PROC_UID: c_int = 5;
3483pub const KERN_PROC_RUID: c_int = 6;
3484pub const KERN_PROC_LCID: c_int = 7;
3485pub const KERN_SUCCESS: c_int = 0;
3486pub const KERN_INVALID_ADDRESS: c_int = 1;
3487pub const KERN_PROTECTION_FAILURE: c_int = 2;
3488pub const KERN_NO_SPACE: c_int = 3;
3489pub const KERN_INVALID_ARGUMENT: c_int = 4;
3490pub const KERN_FAILURE: c_int = 5;
3491pub const KERN_RESOURCE_SHORTAGE: c_int = 6;
3492pub const KERN_NOT_RECEIVER: c_int = 7;
3493pub const KERN_NO_ACCESS: c_int = 8;
3494pub const KERN_MEMORY_FAILURE: c_int = 9;
3495pub const KERN_MEMORY_ERROR: c_int = 10;
3496pub const KERN_ALREADY_IN_SET: c_int = 11;
3497pub const KERN_NOT_IN_SET: c_int = 12;
3498pub const KERN_NAME_EXISTS: c_int = 13;
3499pub const KERN_ABORTED: c_int = 14;
3500pub const KERN_INVALID_NAME: c_int = 15;
3501pub const KERN_INVALID_TASK: c_int = 16;
3502pub const KERN_INVALID_RIGHT: c_int = 17;
3503pub const KERN_INVALID_VALUE: c_int = 18;
3504pub const KERN_UREFS_OVERFLOW: c_int = 19;
3505pub const KERN_INVALID_CAPABILITY: c_int = 20;
3506pub const KERN_RIGHT_EXISTS: c_int = 21;
3507pub const KERN_INVALID_HOST: c_int = 22;
3508pub const KERN_MEMORY_PRESENT: c_int = 23;
3509pub const KERN_MEMORY_DATA_MOVED: c_int = 24;
3510pub const KERN_MEMORY_RESTART_COPY: c_int = 25;
3511pub const KERN_INVALID_PROCESSOR_SET: c_int = 26;
3512pub const KERN_POLICY_LIMIT: c_int = 27;
3513pub const KERN_INVALID_POLICY: c_int = 28;
3514pub const KERN_INVALID_OBJECT: c_int = 29;
3515pub const KERN_ALREADY_WAITING: c_int = 30;
3516pub const KERN_DEFAULT_SET: c_int = 31;
3517pub const KERN_EXCEPTION_PROTECTED: c_int = 32;
3518pub const KERN_INVALID_LEDGER: c_int = 33;
3519pub const KERN_INVALID_MEMORY_CONTROL: c_int = 34;
3520pub const KERN_INVALID_SECURITY: c_int = 35;
3521pub const KERN_NOT_DEPRESSED: c_int = 36;
3522pub const KERN_TERMINATED: c_int = 37;
3523pub const KERN_LOCK_SET_DESTROYED: c_int = 38;
3524pub const KERN_LOCK_UNSTABLE: c_int = 39;
3525pub const KERN_LOCK_OWNED: c_int = 40;
3526pub const KERN_LOCK_OWNED_SELF: c_int = 41;
3527pub const KERN_SEMAPHORE_DESTROYED: c_int = 42;
3528pub const KERN_RPC_SERVER_TERMINATED: c_int = 43;
3529pub const KERN_RPC_TERMINATE_ORPHAN: c_int = 44;
3530pub const KERN_RPC_CONTINUE_ORPHAN: c_int = 45;
3531pub const KERN_NOT_SUPPORTED: c_int = 46;
3532pub const KERN_NODE_DOWN: c_int = 47;
3533pub const KERN_NOT_WAITING: c_int = 48;
3534pub const KERN_OPERATION_TIMED_OUT: c_int = 49;
3535pub const KERN_CODESIGN_ERROR: c_int = 50;
3536pub const KERN_POLICY_STATIC: c_int = 51;
3537pub const KERN_INSUFFICIENT_BUFFER_SIZE: c_int = 52;
3538pub const KIPC_MAXSOCKBUF: c_int = 1;
3539pub const KIPC_SOCKBUF_WASTE: c_int = 2;
3540pub const KIPC_SOMAXCONN: c_int = 3;
3541pub const KIPC_MAX_LINKHDR: c_int = 4;
3542pub const KIPC_MAX_PROTOHDR: c_int = 5;
3543pub const KIPC_MAX_HDR: c_int = 6;
3544pub const KIPC_MAX_DATALEN: c_int = 7;
3545pub const KIPC_MBSTAT: c_int = 8;
3546pub const KIPC_NMBCLUSTERS: c_int = 9;
3547pub const KIPC_SOQLIMITCOMPAT: c_int = 10;
3548pub const VM_METER: c_int = 1;
3549pub const VM_LOADAVG: c_int = 2;
3550pub const VM_MACHFACTOR: c_int = 4;
3551pub const VM_SWAPUSAGE: c_int = 5;
3552pub const VM_MAXID: c_int = 6;
3553pub const VM_PROT_NONE: crate::vm_prot_t = 0x00;
3554pub const VM_PROT_READ: crate::vm_prot_t = 0x01;
3555pub const VM_PROT_WRITE: crate::vm_prot_t = 0x02;
3556pub const VM_PROT_EXECUTE: crate::vm_prot_t = 0x04;
3557pub const MEMORY_OBJECT_NULL: crate::memory_object_t = 0;
3558pub const HW_MACHINE: c_int = 1;
3559pub const HW_MODEL: c_int = 2;
3560pub const HW_NCPU: c_int = 3;
3561pub const HW_BYTEORDER: c_int = 4;
3562pub const HW_PHYSMEM: c_int = 5;
3563pub const HW_USERMEM: c_int = 6;
3564pub const HW_PAGESIZE: c_int = 7;
3565pub const HW_DISKNAMES: c_int = 8;
3566pub const HW_DISKSTATS: c_int = 9;
3567pub const HW_EPOCH: c_int = 10;
3568pub const HW_FLOATINGPT: c_int = 11;
3569pub const HW_MACHINE_ARCH: c_int = 12;
3570pub const HW_VECTORUNIT: c_int = 13;
3571pub const HW_BUS_FREQ: c_int = 14;
3572pub const HW_CPU_FREQ: c_int = 15;
3573pub const HW_CACHELINE: c_int = 16;
3574pub const HW_L1ICACHESIZE: c_int = 17;
3575pub const HW_L1DCACHESIZE: c_int = 18;
3576pub const HW_L2SETTINGS: c_int = 19;
3577pub const HW_L2CACHESIZE: c_int = 20;
3578pub const HW_L3SETTINGS: c_int = 21;
3579pub const HW_L3CACHESIZE: c_int = 22;
3580pub const HW_TB_FREQ: c_int = 23;
3581pub const HW_MEMSIZE: c_int = 24;
3582pub const HW_AVAILCPU: c_int = 25;
3583pub const HW_TARGET: c_int = 26;
3584pub const HW_PRODUCT: c_int = 27;
3585pub const HW_MAXID: c_int = 28;
3586pub const USER_CS_PATH: c_int = 1;
3587
3588/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
3589/// for details.
3590pub const USER_BC_BASE_MAX: c_int = 2;
3591
3592/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
3593/// for details.
3594pub const USER_BC_DIM_MAX: c_int = 3;
3595
3596/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
3597/// for details.
3598pub const USER_BC_SCALE_MAX: c_int = 4;
3599
3600/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
3601/// for details.
3602pub const USER_BC_STRING_MAX: c_int = 5;
3603
3604/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
3605/// for details.
3606pub const USER_COLL_WEIGHTS_MAX: c_int = 6;
3607
3608/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
3609/// for details.
3610pub const USER_EXPR_NEST_MAX: c_int = 7;
3611
3612/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
3613/// for details.
3614pub const USER_LINE_MAX: c_int = 8;
3615
3616/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
3617/// for details.
3618pub const USER_RE_DUP_MAX: c_int = 9;
3619
3620pub const USER_POSIX2_VERSION: c_int = 10;
3621pub const USER_POSIX2_C_BIND: c_int = 11;
3622pub const USER_POSIX2_C_DEV: c_int = 12;
3623pub const USER_POSIX2_CHAR_TERM: c_int = 13;
3624pub const USER_POSIX2_FORT_DEV: c_int = 14;
3625pub const USER_POSIX2_FORT_RUN: c_int = 15;
3626pub const USER_POSIX2_LOCALEDEF: c_int = 16;
3627pub const USER_POSIX2_SW_DEV: c_int = 17;
3628pub const USER_POSIX2_UPE: c_int = 18;
3629pub const USER_STREAM_MAX: c_int = 19;
3630pub const USER_TZNAME_MAX: c_int = 20;
3631pub const USER_MAXID: c_int = 21;
3632pub const CTL_DEBUG_NAME: c_int = 0;
3633pub const CTL_DEBUG_VALUE: c_int = 1;
3634pub const CTL_DEBUG_MAXID: c_int = 20;
3635
3636pub const PRIO_DARWIN_THREAD: c_int = 3;
3637pub const PRIO_DARWIN_PROCESS: c_int = 4;
3638pub const PRIO_DARWIN_BG: c_int = 0x1000;
3639pub const PRIO_DARWIN_NONUI: c_int = 0x1001;
3640
3641pub const SEM_FAILED: *mut sem_t = -1isize as *mut crate::sem_t;
3642
3643pub const AI_PASSIVE: c_int = 0x00000001;
3644pub const AI_CANONNAME: c_int = 0x00000002;
3645pub const AI_NUMERICHOST: c_int = 0x00000004;
3646pub const AI_NUMERICSERV: c_int = 0x00001000;
3647pub const AI_MASK: c_int =
3648    AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_ADDRCONFIG;
3649pub const AI_ALL: c_int = 0x00000100;
3650pub const AI_V4MAPPED_CFG: c_int = 0x00000200;
3651pub const AI_ADDRCONFIG: c_int = 0x00000400;
3652pub const AI_V4MAPPED: c_int = 0x00000800;
3653pub const AI_DEFAULT: c_int = AI_V4MAPPED_CFG | AI_ADDRCONFIG;
3654pub const AI_UNUSABLE: c_int = 0x10000000;
3655
3656pub const SIGEV_NONE: c_int = 0;
3657pub const SIGEV_SIGNAL: c_int = 1;
3658pub const SIGEV_THREAD: c_int = 3;
3659
3660pub const AIO_CANCELED: c_int = 2;
3661pub const AIO_NOTCANCELED: c_int = 4;
3662pub const AIO_ALLDONE: c_int = 1;
3663pub const AIO_LISTIO_MAX: c_int = 32;
3664pub const LIO_NOP: c_int = 0;
3665pub const LIO_WRITE: c_int = 2;
3666pub const LIO_READ: c_int = 1;
3667pub const LIO_WAIT: c_int = 2;
3668pub const LIO_NOWAIT: c_int = 1;
3669
3670pub const WEXITED: c_int = 0x00000004;
3671pub const WSTOPPED: c_int = 0x00000008;
3672pub const WCONTINUED: c_int = 0x00000010;
3673pub const WNOWAIT: c_int = 0x00000020;
3674
3675pub const P_ALL: idtype_t = 0;
3676pub const P_PID: idtype_t = 1;
3677pub const P_PGID: idtype_t = 2;
3678
3679pub const UTIME_OMIT: c_long = -2;
3680pub const UTIME_NOW: c_long = -1;
3681
3682pub const XATTR_NOFOLLOW: c_int = 0x0001;
3683pub const XATTR_CREATE: c_int = 0x0002;
3684pub const XATTR_REPLACE: c_int = 0x0004;
3685pub const XATTR_NOSECURITY: c_int = 0x0008;
3686pub const XATTR_NODEFAULT: c_int = 0x0010;
3687pub const XATTR_SHOWCOMPRESSION: c_int = 0x0020;
3688
3689pub const NET_RT_IFLIST2: c_int = 0x0006;
3690
3691// net/route.h
3692pub const RTF_DELCLONE: c_int = 0x80;
3693pub const RTF_CLONING: c_int = 0x100;
3694pub const RTF_XRESOLVE: c_int = 0x200;
3695pub const RTF_LLINFO: c_int = 0x400;
3696pub const RTF_NOIFREF: c_int = 0x2000;
3697pub const RTF_PRCLONING: c_int = 0x10000;
3698pub const RTF_WASCLONED: c_int = 0x20000;
3699pub const RTF_PROTO3: c_int = 0x40000;
3700pub const RTF_PINNED: c_int = 0x100000;
3701pub const RTF_LOCAL: c_int = 0x200000;
3702pub const RTF_BROADCAST: c_int = 0x400000;
3703pub const RTF_MULTICAST: c_int = 0x800000;
3704pub const RTF_IFSCOPE: c_int = 0x1000000;
3705pub const RTF_CONDEMNED: c_int = 0x2000000;
3706pub const RTF_IFREF: c_int = 0x4000000;
3707pub const RTF_PROXY: c_int = 0x8000000;
3708pub const RTF_ROUTER: c_int = 0x10000000;
3709pub const RTF_DEAD: c_int = 0x20000000;
3710pub const RTF_GLOBAL: c_int = 0x40000000;
3711
3712pub const RTM_VERSION: c_int = 5;
3713
3714// Message types
3715pub const RTM_LOCK: c_int = 0x8;
3716pub const RTM_OLDADD: c_int = 0x9;
3717pub const RTM_OLDDEL: c_int = 0xa;
3718pub const RTM_RESOLVE: c_int = 0xb;
3719pub const RTM_NEWADDR: c_int = 0xc;
3720pub const RTM_DELADDR: c_int = 0xd;
3721pub const RTM_IFINFO: c_int = 0xe;
3722pub const RTM_NEWMADDR: c_int = 0xf;
3723pub const RTM_DELMADDR: c_int = 0x10;
3724pub const RTM_IFINFO2: c_int = 0x12;
3725pub const RTM_NEWMADDR2: c_int = 0x13;
3726pub const RTM_GET2: c_int = 0x14;
3727
3728// Bitmask values for rtm_inits and rmx_locks.
3729pub const RTV_MTU: c_int = 0x1;
3730pub const RTV_HOPCOUNT: c_int = 0x2;
3731pub const RTV_EXPIRE: c_int = 0x4;
3732pub const RTV_RPIPE: c_int = 0x8;
3733pub const RTV_SPIPE: c_int = 0x10;
3734pub const RTV_SSTHRESH: c_int = 0x20;
3735pub const RTV_RTT: c_int = 0x40;
3736pub const RTV_RTTVAR: c_int = 0x80;
3737
3738/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
3739/// for details.
3740pub const RTAX_MAX: c_int = 8;
3741
3742pub const KERN_PROCARGS2: c_int = 49;
3743
3744pub const PROC_PIDTASKALLINFO: c_int = 2;
3745pub const PROC_PIDTBSDINFO: c_int = 3;
3746pub const PROC_PIDTASKINFO: c_int = 4;
3747pub const PROC_PIDTHREADINFO: c_int = 5;
3748pub const PROC_PIDVNODEPATHINFO: c_int = 9;
3749pub const PROC_PIDT_SHORTBSDINFO: c_int = 13;
3750pub const PROC_PIDPATHINFO_MAXSIZE: c_int = 4096;
3751
3752pub const PROC_PIDLISTFDS: c_int = 1;
3753pub const PROC_PIDLISTFD_SIZE: c_int = size_of::<proc_fdinfo>() as c_int;
3754pub const PROX_FDTYPE_ATALK: c_int = 0;
3755pub const PROX_FDTYPE_VNODE: c_int = 1;
3756pub const PROX_FDTYPE_SOCKET: c_int = 2;
3757pub const PROX_FDTYPE_PSHM: c_int = 3;
3758pub const PROX_FDTYPE_PSEM: c_int = 4;
3759pub const PROX_FDTYPE_KQUEUE: c_int = 5;
3760pub const PROX_FDTYPE_PIPE: c_int = 6;
3761pub const PROX_FDTYPE_FSEVENTS: c_int = 7;
3762pub const PROX_FDTYPE_NETPOLICY: c_int = 9;
3763pub const PROX_FDTYPE_CHANNEL: c_int = 10;
3764pub const PROX_FDTYPE_NEXUS: c_int = 11;
3765
3766pub const PROC_CSM_ALL: c_uint = 0x0001;
3767pub const PROC_CSM_NOSMT: c_uint = 0x0002;
3768pub const PROC_CSM_TECS: c_uint = 0x0004;
3769pub const MAXCOMLEN: usize = 16;
3770pub const MAXTHREADNAMESIZE: usize = 64;
3771
3772pub const XUCRED_VERSION: c_uint = 0;
3773
3774pub const LC_SEGMENT: u32 = 0x1;
3775pub const LC_SEGMENT_64: u32 = 0x19;
3776
3777pub const MH_MAGIC: u32 = 0xfeedface;
3778pub const MH_MAGIC_64: u32 = 0xfeedfacf;
3779
3780// net/if_utun.h
3781pub const UTUN_OPT_FLAGS: c_int = 1;
3782pub const UTUN_OPT_IFNAME: c_int = 2;
3783
3784// sys/mount.h
3785pub const MNT_NODEV: c_int = 0x00000010;
3786pub const MNT_UNION: c_int = 0x00000020;
3787pub const MNT_CPROTECT: c_int = 0x00000080;
3788
3789// MAC labeled / "quarantined" flag
3790pub const MNT_QUARANTINE: c_int = 0x00000400;
3791
3792// Flags set by internal operations.
3793pub const MNT_LOCAL: c_int = 0x00001000;
3794pub const MNT_QUOTA: c_int = 0x00002000;
3795pub const MNT_ROOTFS: c_int = 0x00004000;
3796pub const MNT_DOVOLFS: c_int = 0x00008000;
3797
3798pub const MNT_DONTBROWSE: c_int = 0x00100000;
3799pub const MNT_IGNORE_OWNERSHIP: c_int = 0x00200000;
3800pub const MNT_AUTOMOUNTED: c_int = 0x00400000;
3801pub const MNT_JOURNALED: c_int = 0x00800000;
3802pub const MNT_NOUSERXATTR: c_int = 0x01000000;
3803pub const MNT_DEFWRITE: c_int = 0x02000000;
3804pub const MNT_MULTILABEL: c_int = 0x04000000;
3805pub const MNT_NOATIME: c_int = 0x10000000;
3806pub const MNT_SNAPSHOT: c_int = 0x40000000;
3807
3808// External filesystem command modifier flags.
3809pub const MNT_NOBLOCK: c_int = 0x00020000;
3810
3811// sys/spawn.h:
3812// DIFF(main): changed to `c_short` in f62eb023ab
3813pub const POSIX_SPAWN_RESETIDS: c_int = 0x0001;
3814pub const POSIX_SPAWN_SETPGROUP: c_int = 0x0002;
3815pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x0004;
3816pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x0008;
3817pub const POSIX_SPAWN_SETEXEC: c_int = 0x0040;
3818pub const POSIX_SPAWN_START_SUSPENDED: c_int = 0x0080;
3819pub const POSIX_SPAWN_CLOEXEC_DEFAULT: c_int = 0x4000;
3820
3821// sys/ipc.h:
3822pub const IPC_CREAT: c_int = 0x200;
3823pub const IPC_EXCL: c_int = 0x400;
3824pub const IPC_NOWAIT: c_int = 0x800;
3825pub const IPC_PRIVATE: key_t = 0;
3826
3827pub const IPC_RMID: c_int = 0;
3828pub const IPC_SET: c_int = 1;
3829pub const IPC_STAT: c_int = 2;
3830
3831pub const IPC_R: c_int = 0x100;
3832pub const IPC_W: c_int = 0x80;
3833pub const IPC_M: c_int = 0x1000;
3834
3835// sys/sem.h
3836pub const SEM_UNDO: c_int = 0o10000;
3837
3838pub const GETNCNT: c_int = 3;
3839pub const GETPID: c_int = 4;
3840pub const GETVAL: c_int = 5;
3841pub const GETALL: c_int = 6;
3842pub const GETZCNT: c_int = 7;
3843pub const SETVAL: c_int = 8;
3844pub const SETALL: c_int = 9;
3845
3846// sys/shm.h
3847pub const SHM_RDONLY: c_int = 0x1000;
3848pub const SHM_RND: c_int = 0x2000;
3849#[cfg(target_arch = "aarch64")]
3850pub const SHMLBA: c_int = 16 * 1024;
3851#[cfg(not(target_arch = "aarch64"))]
3852pub const SHMLBA: c_int = 4096;
3853pub const SHM_R: c_int = IPC_R;
3854pub const SHM_W: c_int = IPC_W;
3855
3856// Flags for chflags(2)
3857pub const UF_SETTABLE: c_uint = 0x0000ffff;
3858pub const UF_NODUMP: c_uint = 0x00000001;
3859pub const UF_IMMUTABLE: c_uint = 0x00000002;
3860pub const UF_APPEND: c_uint = 0x00000004;
3861pub const UF_OPAQUE: c_uint = 0x00000008;
3862pub const UF_COMPRESSED: c_uint = 0x00000020;
3863pub const UF_TRACKED: c_uint = 0x00000040;
3864pub const SF_SETTABLE: c_uint = 0x3fff0000;
3865pub const SF_ARCHIVED: c_uint = 0x00010000;
3866pub const SF_IMMUTABLE: c_uint = 0x00020000;
3867pub const SF_APPEND: c_uint = 0x00040000;
3868pub const UF_HIDDEN: c_uint = 0x00008000;
3869
3870//<sys/timex.h>
3871pub const NTP_API: c_int = 4;
3872pub const MAXPHASE: c_long = 500000000;
3873pub const MAXFREQ: c_long = 500000;
3874pub const MINSEC: c_int = 256;
3875pub const MAXSEC: c_int = 2048;
3876pub const NANOSECOND: c_long = 1000000000;
3877pub const SCALE_PPM: c_int = 65;
3878pub const MAXTC: c_int = 10;
3879pub const MOD_OFFSET: c_uint = 0x0001;
3880pub const MOD_FREQUENCY: c_uint = 0x0002;
3881pub const MOD_MAXERROR: c_uint = 0x0004;
3882pub const MOD_ESTERROR: c_uint = 0x0008;
3883pub const MOD_STATUS: c_uint = 0x0010;
3884pub const MOD_TIMECONST: c_uint = 0x0020;
3885pub const MOD_PPSMAX: c_uint = 0x0040;
3886pub const MOD_TAI: c_uint = 0x0080;
3887pub const MOD_MICRO: c_uint = 0x1000;
3888pub const MOD_NANO: c_uint = 0x2000;
3889pub const MOD_CLKB: c_uint = 0x4000;
3890pub const MOD_CLKA: c_uint = 0x8000;
3891pub const STA_PLL: c_int = 0x0001;
3892pub const STA_PPSFREQ: c_int = 0x0002;
3893pub const STA_PPSTIME: c_int = 0x0004;
3894pub const STA_FLL: c_int = 0x0008;
3895pub const STA_INS: c_int = 0x0010;
3896pub const STA_DEL: c_int = 0x0020;
3897pub const STA_UNSYNC: c_int = 0x0040;
3898pub const STA_FREQHOLD: c_int = 0x0080;
3899pub const STA_PPSSIGNAL: c_int = 0x0100;
3900pub const STA_PPSJITTER: c_int = 0x0200;
3901pub const STA_PPSWANDER: c_int = 0x0400;
3902pub const STA_PPSERROR: c_int = 0x0800;
3903pub const STA_CLOCKERR: c_int = 0x1000;
3904pub const STA_NANO: c_int = 0x2000;
3905pub const STA_MODE: c_int = 0x4000;
3906pub const STA_CLK: c_int = 0x8000;
3907pub const STA_RONLY: c_int = STA_PPSSIGNAL
3908    | STA_PPSJITTER
3909    | STA_PPSWANDER
3910    | STA_PPSERROR
3911    | STA_CLOCKERR
3912    | STA_NANO
3913    | STA_MODE
3914    | STA_CLK;
3915pub const TIME_OK: c_int = 0;
3916pub const TIME_INS: c_int = 1;
3917pub const TIME_DEL: c_int = 2;
3918pub const TIME_OOP: c_int = 3;
3919pub const TIME_WAIT: c_int = 4;
3920pub const TIME_ERROR: c_int = 5;
3921
3922// <sys/mount.h>
3923pub const MNT_WAIT: c_int = 1;
3924pub const MNT_NOWAIT: c_int = 2;
3925
3926// <mach/thread_policy.h>
3927pub const THREAD_STANDARD_POLICY: c_int = 1;
3928
3929/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
3930/// for details.
3931pub const THREAD_STANDARD_POLICY_COUNT: c_int = 0;
3932
3933pub const THREAD_EXTENDED_POLICY: c_int = 1;
3934pub const THREAD_TIME_CONSTRAINT_POLICY: c_int = 2;
3935pub const THREAD_PRECEDENCE_POLICY: c_int = 3;
3936pub const THREAD_AFFINITY_POLICY: c_int = 4;
3937pub const THREAD_AFFINITY_TAG_NULL: c_int = 0;
3938pub const THREAD_BACKGROUND_POLICY: c_int = 5;
3939pub const THREAD_BACKGROUND_POLICY_DARWIN_BG: c_int = 0x1000;
3940pub const THREAD_LATENCY_QOS_POLICY: c_int = 7;
3941pub const THREAD_THROUGHPUT_QOS_POLICY: c_int = 8;
3942
3943// <mach/thread_info.h>
3944pub const TH_STATE_RUNNING: c_int = 1;
3945pub const TH_STATE_STOPPED: c_int = 2;
3946pub const TH_STATE_WAITING: c_int = 3;
3947pub const TH_STATE_UNINTERRUPTIBLE: c_int = 4;
3948pub const TH_STATE_HALTED: c_int = 5;
3949pub const TH_FLAGS_SWAPPED: c_int = 0x1;
3950pub const TH_FLAGS_IDLE: c_int = 0x2;
3951pub const TH_FLAGS_GLOBAL_FORCED_IDLE: c_int = 0x4;
3952pub const THREAD_BASIC_INFO: c_int = 3;
3953pub const THREAD_IDENTIFIER_INFO: c_int = 4;
3954pub const THREAD_EXTENDED_INFO: c_int = 5;
3955
3956// CommonCrypto/CommonCryptoError.h
3957pub const kCCSuccess: i32 = 0;
3958pub const kCCParamError: i32 = -4300;
3959pub const kCCBufferTooSmall: i32 = -4301;
3960pub const kCCMemoryFailure: i32 = -4302;
3961pub const kCCAlignmentError: i32 = -4303;
3962pub const kCCDecodeError: i32 = -4304;
3963pub const kCCUnimplemented: i32 = -4305;
3964pub const kCCOverflow: i32 = -4306;
3965pub const kCCRNGFailure: i32 = -4307;
3966pub const kCCUnspecifiedError: i32 = -4308;
3967pub const kCCCallSequenceError: i32 = -4309;
3968pub const kCCKeySizeError: i32 = -4310;
3969pub const kCCInvalidKey: i32 = -4311;
3970
3971// mach/host_info.h
3972pub const HOST_LOAD_INFO: i32 = 1;
3973pub const HOST_VM_INFO: i32 = 2;
3974pub const HOST_CPU_LOAD_INFO: i32 = 3;
3975pub const HOST_VM_INFO64: i32 = 4;
3976pub const HOST_EXTMOD_INFO64: i32 = 5;
3977pub const HOST_EXPIRED_TASK_INFO: i32 = 6;
3978
3979// mach/vm_statistics.h
3980pub const VM_PAGE_QUERY_PAGE_PRESENT: i32 = 0x1;
3981pub const VM_PAGE_QUERY_PAGE_FICTITIOUS: i32 = 0x2;
3982pub const VM_PAGE_QUERY_PAGE_REF: i32 = 0x4;
3983pub const VM_PAGE_QUERY_PAGE_DIRTY: i32 = 0x8;
3984pub const VM_PAGE_QUERY_PAGE_PAGED_OUT: i32 = 0x10;
3985pub const VM_PAGE_QUERY_PAGE_COPIED: i32 = 0x20;
3986pub const VM_PAGE_QUERY_PAGE_SPECULATIVE: i32 = 0x40;
3987pub const VM_PAGE_QUERY_PAGE_EXTERNAL: i32 = 0x80;
3988pub const VM_PAGE_QUERY_PAGE_CS_VALIDATED: i32 = 0x100;
3989pub const VM_PAGE_QUERY_PAGE_CS_TAINTED: i32 = 0x200;
3990pub const VM_PAGE_QUERY_PAGE_CS_NX: i32 = 0x400;
3991
3992// mach/task_info.h
3993pub const TASK_THREAD_TIMES_INFO: u32 = 3;
3994
3995/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
3996/// for details.
3997pub const HOST_CPU_LOAD_INFO_COUNT: u32 = 4;
3998
3999pub const MACH_TASK_BASIC_INFO: u32 = 20;
4000
4001pub const MACH_PORT_NULL: i32 = 0;
4002
4003pub const RUSAGE_INFO_V0: c_int = 0;
4004pub const RUSAGE_INFO_V1: c_int = 1;
4005pub const RUSAGE_INFO_V2: c_int = 2;
4006pub const RUSAGE_INFO_V3: c_int = 3;
4007pub const RUSAGE_INFO_V4: c_int = 4;
4008
4009// copyfile.h
4010pub const COPYFILE_ACL: crate::copyfile_flags_t = 1 << 0;
4011pub const COPYFILE_STAT: crate::copyfile_flags_t = 1 << 1;
4012pub const COPYFILE_XATTR: crate::copyfile_flags_t = 1 << 2;
4013pub const COPYFILE_DATA: crate::copyfile_flags_t = 1 << 3;
4014pub const COPYFILE_SECURITY: crate::copyfile_flags_t = COPYFILE_STAT | COPYFILE_ACL;
4015pub const COPYFILE_METADATA: crate::copyfile_flags_t = COPYFILE_SECURITY | COPYFILE_XATTR;
4016pub const COPYFILE_RECURSIVE: crate::copyfile_flags_t = 1 << 15;
4017pub const COPYFILE_CHECK: crate::copyfile_flags_t = 1 << 16;
4018pub const COPYFILE_EXCL: crate::copyfile_flags_t = 1 << 17;
4019pub const COPYFILE_NOFOLLOW_SRC: crate::copyfile_flags_t = 1 << 18;
4020pub const COPYFILE_NOFOLLOW_DST: crate::copyfile_flags_t = 1 << 19;
4021pub const COPYFILE_MOVE: crate::copyfile_flags_t = 1 << 20;
4022pub const COPYFILE_UNLINK: crate::copyfile_flags_t = 1 << 21;
4023pub const COPYFILE_NOFOLLOW: crate::copyfile_flags_t =
4024    COPYFILE_NOFOLLOW_SRC | COPYFILE_NOFOLLOW_DST;
4025pub const COPYFILE_PACK: crate::copyfile_flags_t = 1 << 22;
4026pub const COPYFILE_UNPACK: crate::copyfile_flags_t = 1 << 23;
4027pub const COPYFILE_CLONE: crate::copyfile_flags_t = 1 << 24;
4028pub const COPYFILE_CLONE_FORCE: crate::copyfile_flags_t = 1 << 25;
4029pub const COPYFILE_RUN_IN_PLACE: crate::copyfile_flags_t = 1 << 26;
4030pub const COPYFILE_DATA_SPARSE: crate::copyfile_flags_t = 1 << 27;
4031pub const COPYFILE_PRESERVE_DST_TRACKED: crate::copyfile_flags_t = 1 << 28;
4032pub const COPYFILE_VERBOSE: crate::copyfile_flags_t = 1 << 30;
4033pub const COPYFILE_RECURSE_ERROR: c_int = 0;
4034pub const COPYFILE_RECURSE_FILE: c_int = 1;
4035pub const COPYFILE_RECURSE_DIR: c_int = 2;
4036pub const COPYFILE_RECURSE_DIR_CLEANUP: c_int = 3;
4037pub const COPYFILE_COPY_DATA: c_int = 4;
4038pub const COPYFILE_COPY_XATTR: c_int = 5;
4039pub const COPYFILE_START: c_int = 1;
4040pub const COPYFILE_FINISH: c_int = 2;
4041pub const COPYFILE_ERR: c_int = 3;
4042pub const COPYFILE_PROGRESS: c_int = 4;
4043pub const COPYFILE_CONTINUE: c_int = 0;
4044pub const COPYFILE_SKIP: c_int = 1;
4045pub const COPYFILE_QUIT: c_int = 2;
4046pub const COPYFILE_STATE_SRC_FD: c_int = 1;
4047pub const COPYFILE_STATE_SRC_FILENAME: c_int = 2;
4048pub const COPYFILE_STATE_DST_FD: c_int = 3;
4049pub const COPYFILE_STATE_DST_FILENAME: c_int = 4;
4050pub const COPYFILE_STATE_QUARANTINE: c_int = 5;
4051pub const COPYFILE_STATE_STATUS_CB: c_int = 6;
4052pub const COPYFILE_STATE_STATUS_CTX: c_int = 7;
4053pub const COPYFILE_STATE_COPIED: c_int = 8;
4054pub const COPYFILE_STATE_XATTRNAME: c_int = 9;
4055pub const COPYFILE_STATE_WAS_CLONED: c_int = 10;
4056pub const COPYFILE_STATE_SRC_BSIZE: c_int = 11;
4057pub const COPYFILE_STATE_DST_BSIZE: c_int = 12;
4058pub const COPYFILE_STATE_BSIZE: c_int = 13;
4059
4060// <sys/attr.h>
4061/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
4062/// for details.
4063pub const ATTR_BIT_MAP_COUNT: c_ushort = 5;
4064
4065pub const FSOPT_NOFOLLOW: u32 = 0x1;
4066pub const FSOPT_NOFOLLOW_ANY: u32 = 0x800;
4067pub const FSOPT_REPORT_FULLSIZE: u32 = 0x4;
4068pub const FSOPT_PACK_INVAL_ATTRS: u32 = 0x8;
4069pub const FSOPT_ATTR_CMN_EXTENDED: u32 = 0x20;
4070pub const FSOPT_RETURN_REALDEV: u32 = 0x200;
4071pub const ATTR_CMN_NAME: attrgroup_t = 0x00000001;
4072pub const ATTR_CMN_DEVID: attrgroup_t = 0x00000002;
4073pub const ATTR_CMN_FSID: attrgroup_t = 0x00000004;
4074pub const ATTR_CMN_OBJTYPE: attrgroup_t = 0x00000008;
4075pub const ATTR_CMN_OBJTAG: attrgroup_t = 0x00000010;
4076pub const ATTR_CMN_OBJID: attrgroup_t = 0x00000020;
4077pub const ATTR_CMN_OBJPERMANENTID: attrgroup_t = 0x00000040;
4078pub const ATTR_CMN_PAROBJID: attrgroup_t = 0x00000080;
4079pub const ATTR_CMN_SCRIPT: attrgroup_t = 0x00000100;
4080pub const ATTR_CMN_CRTIME: attrgroup_t = 0x00000200;
4081pub const ATTR_CMN_MODTIME: attrgroup_t = 0x00000400;
4082pub const ATTR_CMN_CHGTIME: attrgroup_t = 0x00000800;
4083pub const ATTR_CMN_ACCTIME: attrgroup_t = 0x00001000;
4084pub const ATTR_CMN_BKUPTIME: attrgroup_t = 0x00002000;
4085pub const ATTR_CMN_FNDRINFO: attrgroup_t = 0x00004000;
4086pub const ATTR_CMN_OWNERID: attrgroup_t = 0x00008000;
4087pub const ATTR_CMN_GRPID: attrgroup_t = 0x00010000;
4088pub const ATTR_CMN_ACCESSMASK: attrgroup_t = 0x00020000;
4089pub const ATTR_CMN_FLAGS: attrgroup_t = 0x00040000;
4090pub const ATTR_CMN_GEN_COUNT: attrgroup_t = 0x00080000;
4091pub const ATTR_CMN_DOCUMENT_ID: attrgroup_t = 0x00100000;
4092pub const ATTR_CMN_USERACCESS: attrgroup_t = 0x00200000;
4093pub const ATTR_CMN_EXTENDED_SECURITY: attrgroup_t = 0x00400000;
4094pub const ATTR_CMN_UUID: attrgroup_t = 0x00800000;
4095pub const ATTR_CMN_GRPUUID: attrgroup_t = 0x01000000;
4096pub const ATTR_CMN_FILEID: attrgroup_t = 0x02000000;
4097pub const ATTR_CMN_PARENTID: attrgroup_t = 0x04000000;
4098pub const ATTR_CMN_FULLPATH: attrgroup_t = 0x08000000;
4099pub const ATTR_CMN_ADDEDTIME: attrgroup_t = 0x10000000;
4100pub const ATTR_CMN_DATA_PROTECT_FLAGS: attrgroup_t = 0x40000000;
4101pub const ATTR_CMN_RETURNED_ATTRS: attrgroup_t = 0x80000000;
4102pub const ATTR_VOL_FSTYPE: attrgroup_t = 0x00000001;
4103pub const ATTR_VOL_SIGNATURE: attrgroup_t = 0x00000002;
4104pub const ATTR_VOL_SIZE: attrgroup_t = 0x00000004;
4105pub const ATTR_VOL_SPACEFREE: attrgroup_t = 0x00000008;
4106pub const ATTR_VOL_SPACEAVAIL: attrgroup_t = 0x00000010;
4107pub const ATTR_VOL_MINALLOCATION: attrgroup_t = 0x00000020;
4108pub const ATTR_VOL_ALLOCATIONCLUMP: attrgroup_t = 0x00000040;
4109pub const ATTR_VOL_IOBLOCKSIZE: attrgroup_t = 0x00000080;
4110pub const ATTR_VOL_OBJCOUNT: attrgroup_t = 0x00000100;
4111pub const ATTR_VOL_FILECOUNT: attrgroup_t = 0x00000200;
4112pub const ATTR_VOL_DIRCOUNT: attrgroup_t = 0x00000400;
4113pub const ATTR_VOL_MAXOBJCOUNT: attrgroup_t = 0x00000800;
4114pub const ATTR_VOL_MOUNTPOINT: attrgroup_t = 0x00001000;
4115pub const ATTR_VOL_NAME: attrgroup_t = 0x00002000;
4116pub const ATTR_VOL_MOUNTFLAGS: attrgroup_t = 0x00004000;
4117pub const ATTR_VOL_MOUNTEDDEVICE: attrgroup_t = 0x00008000;
4118pub const ATTR_VOL_ENCODINGSUSED: attrgroup_t = 0x00010000;
4119pub const ATTR_VOL_CAPABILITIES: attrgroup_t = 0x00020000;
4120pub const ATTR_VOL_UUID: attrgroup_t = 0x00040000;
4121pub const ATTR_VOL_SPACEUSED: attrgroup_t = 0x00800000;
4122pub const ATTR_VOL_QUOTA_SIZE: attrgroup_t = 0x10000000;
4123pub const ATTR_VOL_RESERVED_SIZE: attrgroup_t = 0x20000000;
4124pub const ATTR_VOL_ATTRIBUTES: attrgroup_t = 0x40000000;
4125pub const ATTR_VOL_INFO: attrgroup_t = 0x80000000;
4126pub const ATTR_DIR_LINKCOUNT: attrgroup_t = 0x00000001;
4127pub const ATTR_DIR_ENTRYCOUNT: attrgroup_t = 0x00000002;
4128pub const ATTR_DIR_MOUNTSTATUS: attrgroup_t = 0x00000004;
4129pub const ATTR_DIR_ALLOCSIZE: attrgroup_t = 0x00000008;
4130pub const ATTR_DIR_IOBLOCKSIZE: attrgroup_t = 0x00000010;
4131pub const ATTR_DIR_DATALENGTH: attrgroup_t = 0x00000020;
4132pub const ATTR_FILE_LINKCOUNT: attrgroup_t = 0x00000001;
4133pub const ATTR_FILE_TOTALSIZE: attrgroup_t = 0x00000002;
4134pub const ATTR_FILE_ALLOCSIZE: attrgroup_t = 0x00000004;
4135pub const ATTR_FILE_IOBLOCKSIZE: attrgroup_t = 0x00000008;
4136pub const ATTR_FILE_DEVTYPE: attrgroup_t = 0x00000020;
4137pub const ATTR_FILE_FORKCOUNT: attrgroup_t = 0x00000080;
4138pub const ATTR_FILE_FORKLIST: attrgroup_t = 0x00000100;
4139pub const ATTR_FILE_DATALENGTH: attrgroup_t = 0x00000200;
4140pub const ATTR_FILE_DATAALLOCSIZE: attrgroup_t = 0x00000400;
4141pub const ATTR_FILE_RSRCLENGTH: attrgroup_t = 0x00001000;
4142pub const ATTR_FILE_RSRCALLOCSIZE: attrgroup_t = 0x00002000;
4143pub const ATTR_CMNEXT_RELPATH: attrgroup_t = 0x00000004;
4144pub const ATTR_CMNEXT_PRIVATESIZE: attrgroup_t = 0x00000008;
4145pub const ATTR_CMNEXT_LINKID: attrgroup_t = 0x00000010;
4146pub const ATTR_CMNEXT_NOFIRMLINKPATH: attrgroup_t = 0x00000020;
4147pub const ATTR_CMNEXT_REALDEVID: attrgroup_t = 0x00000040;
4148pub const ATTR_CMNEXT_REALFSID: attrgroup_t = 0x00000080;
4149pub const ATTR_CMNEXT_CLONEID: attrgroup_t = 0x00000100;
4150pub const ATTR_CMNEXT_EXT_FLAGS: attrgroup_t = 0x00000200;
4151pub const ATTR_CMNEXT_RECURSIVE_GENCOUNT: attrgroup_t = 0x00000400;
4152pub const DIR_MNTSTATUS_MNTPOINT: u32 = 0x1;
4153pub const VOL_CAPABILITIES_FORMAT: usize = 0;
4154pub const VOL_CAPABILITIES_INTERFACES: usize = 1;
4155pub const VOL_CAP_FMT_PERSISTENTOBJECTIDS: attrgroup_t = 0x00000001;
4156pub const VOL_CAP_FMT_SYMBOLICLINKS: attrgroup_t = 0x00000002;
4157pub const VOL_CAP_FMT_HARDLINKS: attrgroup_t = 0x00000004;
4158pub const VOL_CAP_FMT_JOURNAL: attrgroup_t = 0x00000008;
4159pub const VOL_CAP_FMT_JOURNAL_ACTIVE: attrgroup_t = 0x00000010;
4160pub const VOL_CAP_FMT_NO_ROOT_TIMES: attrgroup_t = 0x00000020;
4161pub const VOL_CAP_FMT_SPARSE_FILES: attrgroup_t = 0x00000040;
4162pub const VOL_CAP_FMT_ZERO_RUNS: attrgroup_t = 0x00000080;
4163pub const VOL_CAP_FMT_CASE_SENSITIVE: attrgroup_t = 0x00000100;
4164pub const VOL_CAP_FMT_CASE_PRESERVING: attrgroup_t = 0x00000200;
4165pub const VOL_CAP_FMT_FAST_STATFS: attrgroup_t = 0x00000400;
4166pub const VOL_CAP_FMT_2TB_FILESIZE: attrgroup_t = 0x00000800;
4167pub const VOL_CAP_FMT_OPENDENYMODES: attrgroup_t = 0x00001000;
4168pub const VOL_CAP_FMT_HIDDEN_FILES: attrgroup_t = 0x00002000;
4169pub const VOL_CAP_FMT_PATH_FROM_ID: attrgroup_t = 0x00004000;
4170pub const VOL_CAP_FMT_NO_VOLUME_SIZES: attrgroup_t = 0x00008000;
4171pub const VOL_CAP_FMT_DECMPFS_COMPRESSION: attrgroup_t = 0x00010000;
4172pub const VOL_CAP_FMT_64BIT_OBJECT_IDS: attrgroup_t = 0x00020000;
4173pub const VOL_CAP_FMT_DIR_HARDLINKS: attrgroup_t = 0x00040000;
4174pub const VOL_CAP_FMT_DOCUMENT_ID: attrgroup_t = 0x00080000;
4175pub const VOL_CAP_FMT_WRITE_GENERATION_COUNT: attrgroup_t = 0x00100000;
4176pub const VOL_CAP_FMT_NO_IMMUTABLE_FILES: attrgroup_t = 0x00200000;
4177pub const VOL_CAP_FMT_NO_PERMISSIONS: attrgroup_t = 0x00400000;
4178pub const VOL_CAP_FMT_SHARED_SPACE: attrgroup_t = 0x00800000;
4179pub const VOL_CAP_FMT_VOL_GROUPS: attrgroup_t = 0x01000000;
4180pub const VOL_CAP_FMT_SEALED: attrgroup_t = 0x02000000;
4181pub const VOL_CAP_INT_SEARCHFS: attrgroup_t = 0x00000001;
4182pub const VOL_CAP_INT_ATTRLIST: attrgroup_t = 0x00000002;
4183pub const VOL_CAP_INT_NFSEXPORT: attrgroup_t = 0x00000004;
4184pub const VOL_CAP_INT_READDIRATTR: attrgroup_t = 0x00000008;
4185pub const VOL_CAP_INT_EXCHANGEDATA: attrgroup_t = 0x00000010;
4186pub const VOL_CAP_INT_COPYFILE: attrgroup_t = 0x00000020;
4187pub const VOL_CAP_INT_ALLOCATE: attrgroup_t = 0x00000040;
4188pub const VOL_CAP_INT_VOL_RENAME: attrgroup_t = 0x00000080;
4189pub const VOL_CAP_INT_ADVLOCK: attrgroup_t = 0x00000100;
4190pub const VOL_CAP_INT_FLOCK: attrgroup_t = 0x00000200;
4191pub const VOL_CAP_INT_EXTENDED_SECURITY: attrgroup_t = 0x00000400;
4192pub const VOL_CAP_INT_USERACCESS: attrgroup_t = 0x00000800;
4193pub const VOL_CAP_INT_MANLOCK: attrgroup_t = 0x00001000;
4194pub const VOL_CAP_INT_NAMEDSTREAMS: attrgroup_t = 0x00002000;
4195pub const VOL_CAP_INT_EXTENDED_ATTR: attrgroup_t = 0x00004000;
4196pub const VOL_CAP_INT_CLONE: attrgroup_t = 0x00010000;
4197pub const VOL_CAP_INT_SNAPSHOT: attrgroup_t = 0x00020000;
4198pub const VOL_CAP_INT_RENAME_SWAP: attrgroup_t = 0x00040000;
4199pub const VOL_CAP_INT_RENAME_EXCL: attrgroup_t = 0x00080000;
4200pub const VOL_CAP_INT_RENAME_OPENFAIL: attrgroup_t = 0x00100000;
4201
4202// os/clock.h
4203pub const OS_CLOCK_MACH_ABSOLUTE_TIME: os_clockid_t = 32;
4204
4205// os/os_sync_wait_on_address.h
4206pub const OS_SYNC_WAIT_ON_ADDRESS_NONE: os_sync_wait_on_address_flags_t = 0x00000000;
4207pub const OS_SYNC_WAIT_ON_ADDRESS_SHARED: os_sync_wait_on_address_flags_t = 0x00000001;
4208pub const OS_SYNC_WAKE_BY_ADDRESS_NONE: os_sync_wake_by_address_flags_t = 0x00000000;
4209pub const OS_SYNC_WAKE_BY_ADDRESS_SHARED: os_sync_wake_by_address_flags_t = 0x00000001;
4210
4211// <proc.h>
4212/// Process being created by fork.
4213pub const SIDL: u32 = 1;
4214/// Currently runnable.
4215pub const SRUN: u32 = 2;
4216/// Sleeping on an address.
4217pub const SSLEEP: u32 = 3;
4218/// Process debugging or suspension.
4219pub const SSTOP: u32 = 4;
4220/// Awaiting collection by parent.
4221pub const SZOMB: u32 = 5;
4222
4223// sys/vsock.h
4224pub const VMADDR_CID_ANY: c_uint = 0xFFFFFFFF;
4225pub const VMADDR_CID_HYPERVISOR: c_uint = 0;
4226pub const VMADDR_CID_RESERVED: c_uint = 1;
4227pub const VMADDR_CID_HOST: c_uint = 2;
4228pub const VMADDR_PORT_ANY: c_uint = 0xFFFFFFFF;
4229
4230const fn __DARWIN_ALIGN32(p: usize) -> usize {
4231    const __DARWIN_ALIGNBYTES32: usize = size_of::<u32>() - 1;
4232    (p + __DARWIN_ALIGNBYTES32) & !__DARWIN_ALIGNBYTES32
4233}
4234
4235/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
4236/// for details.
4237pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t =
4238    (size_of::<thread_extended_policy_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4239
4240/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
4241/// for details.
4242pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t =
4243    (size_of::<thread_time_constraint_policy_data_t>() / size_of::<integer_t>())
4244        as mach_msg_type_number_t;
4245
4246/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
4247/// for details.
4248pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t =
4249    (size_of::<thread_precedence_policy_data_t>() / size_of::<integer_t>())
4250        as mach_msg_type_number_t;
4251
4252/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
4253/// for details.
4254pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t =
4255    (size_of::<thread_affinity_policy_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4256
4257/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
4258/// for details.
4259pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t =
4260    (size_of::<thread_background_policy_data_t>() / size_of::<integer_t>())
4261        as mach_msg_type_number_t;
4262
4263/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
4264/// for details.
4265pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t =
4266    (size_of::<thread_latency_qos_policy_data_t>() / size_of::<integer_t>())
4267        as mach_msg_type_number_t;
4268
4269/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
4270/// for details.
4271pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t =
4272    (size_of::<thread_throughput_qos_policy_data_t>() / size_of::<integer_t>())
4273        as mach_msg_type_number_t;
4274
4275/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
4276/// for details.
4277pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t =
4278    (size_of::<thread_basic_info_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4279
4280/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
4281/// for details.
4282pub const THREAD_IDENTIFIER_INFO_COUNT: mach_msg_type_number_t =
4283    (size_of::<thread_identifier_info_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4284
4285/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
4286/// for details.
4287pub const THREAD_EXTENDED_INFO_COUNT: mach_msg_type_number_t =
4288    (size_of::<thread_extended_info_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4289
4290/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
4291/// for details.
4292pub const TASK_THREAD_TIMES_INFO_COUNT: u32 =
4293    (size_of::<task_thread_times_info_data_t>() / size_of::<natural_t>()) as u32;
4294
4295/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
4296/// for details.
4297pub const MACH_TASK_BASIC_INFO_COUNT: u32 =
4298    (size_of::<mach_task_basic_info_data_t>() / size_of::<natural_t>()) as u32;
4299
4300/// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines)
4301/// for details.
4302pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t =
4303    (size_of::<vm_statistics64_data_t>() / size_of::<integer_t>()) as mach_msg_type_number_t;
4304
4305// bsd/net/if_mib.h
4306/// Non-interface-specific
4307pub const IFMIB_SYSTEM: c_int = 1;
4308/// Per-interface data table
4309pub const IFMIB_IFDATA: c_int = 2;
4310/// All interfaces data at once
4311pub const IFMIB_IFALLDATA: c_int = 3;
4312
4313/// Generic stats for all kinds of ifaces
4314pub const IFDATA_GENERAL: c_int = 1;
4315/// Specific to the type of interface
4316pub const IFDATA_LINKSPECIFIC: c_int = 2;
4317/// Addresses assigned to interface
4318pub const IFDATA_ADDRS: c_int = 3;
4319/// Multicast addresses assigned to interface
4320pub const IFDATA_MULTIADDRS: c_int = 4;
4321
4322/// Number of interfaces configured
4323pub const IFMIB_IFCOUNT: c_int = 1;
4324
4325/// Functions not specific to a type of iface
4326pub const NETLINK_GENERIC: c_int = 0;
4327
4328pub const DOT3COMPLIANCE_STATS: c_int = 1;
4329pub const DOT3COMPLIANCE_COLLS: c_int = 2;
4330
4331// kern_control.h
4332pub const MAX_KCTL_NAME: usize = 96;
4333
4334f! {
4335    pub unsafe fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr {
4336        if cmsg.is_null() {
4337            return crate::CMSG_FIRSTHDR(mhdr);
4338        }
4339        let cmsg_len = (*cmsg).cmsg_len as usize;
4340        let next = cmsg as usize + __DARWIN_ALIGN32(cmsg_len);
4341        let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize;
4342        if next + __DARWIN_ALIGN32(size_of::<cmsghdr>()) > max {
4343            ptr::null_mut()
4344        } else {
4345            next as *mut cmsghdr
4346        }
4347    }
4348
4349    pub unsafe fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar {
4350        (cmsg as *mut c_uchar).add(__DARWIN_ALIGN32(size_of::<cmsghdr>()))
4351    }
4352
4353    pub const unsafe fn CMSG_SPACE(length: c_uint) -> c_uint {
4354        (__DARWIN_ALIGN32(size_of::<cmsghdr>()) + __DARWIN_ALIGN32(length as usize)) as c_uint
4355    }
4356
4357    pub const unsafe fn CMSG_LEN(length: c_uint) -> c_uint {
4358        (__DARWIN_ALIGN32(size_of::<cmsghdr>()) + length as usize) as c_uint
4359    }
4360
4361    pub const unsafe fn VM_MAKE_TAG(id: u8) -> u32 {
4362        (id as u32) << 24u32
4363    }
4364}
4365
4366safe_f! {
4367    pub const safe fn WSTOPSIG(status: c_int) -> c_int {
4368        status >> 8
4369    }
4370
4371    pub const safe fn _WSTATUS(status: c_int) -> c_int {
4372        status & 0x7f
4373    }
4374
4375    pub const safe fn WIFCONTINUED(status: c_int) -> bool {
4376        _WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) == 0x13
4377    }
4378
4379    pub const safe fn WIFSIGNALED(status: c_int) -> bool {
4380        _WSTATUS(status) != _WSTOPPED && _WSTATUS(status) != 0
4381    }
4382
4383    pub const safe fn WIFSTOPPED(status: c_int) -> bool {
4384        _WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) != 0x13
4385    }
4386
4387    pub const safe fn makedev(major: i32, minor: i32) -> dev_t {
4388        (major << 24) | minor
4389    }
4390
4391    pub const safe fn major(dev: dev_t) -> i32 {
4392        (dev >> 24) & 0xff
4393    }
4394
4395    pub const safe fn minor(dev: dev_t) -> i32 {
4396        dev & 0xffffff
4397    }
4398}
4399
4400extern "C" {
4401    pub fn setgrent();
4402    #[doc(hidden)]
4403    #[deprecated(since = "0.2.49", note = "Deprecated in MacOSX 10.5")]
4404    #[cfg_attr(not(target_arch = "aarch64"), link_name = "daemon$1050")]
4405    pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int;
4406    #[doc(hidden)]
4407    #[deprecated(since = "0.2.49", note = "Deprecated in MacOSX 10.10")]
4408    pub fn sem_destroy(sem: *mut sem_t) -> c_int;
4409    #[doc(hidden)]
4410    #[deprecated(since = "0.2.49", note = "Deprecated in MacOSX 10.10")]
4411    pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int;
4412    pub fn aio_read(aiocbp: *mut aiocb) -> c_int;
4413    pub fn aio_write(aiocbp: *mut aiocb) -> c_int;
4414    pub fn aio_fsync(op: c_int, aiocbp: *mut aiocb) -> c_int;
4415    pub fn aio_error(aiocbp: *const aiocb) -> c_int;
4416    pub fn aio_return(aiocbp: *mut aiocb) -> ssize_t;
4417    #[cfg_attr(
4418        all(target_os = "macos", target_arch = "x86"),
4419        link_name = "aio_suspend$UNIX2003"
4420    )]
4421    pub fn aio_suspend(
4422        aiocb_list: *const *const aiocb,
4423        nitems: c_int,
4424        timeout: *const crate::timespec,
4425    ) -> c_int;
4426    pub fn aio_cancel(fd: c_int, aiocbp: *mut aiocb) -> c_int;
4427    pub fn chflags(path: *const c_char, flags: c_uint) -> c_int;
4428    pub fn fchflags(fd: c_int, flags: c_uint) -> c_int;
4429    pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int;
4430    pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int;
4431    pub fn lio_listio(
4432        mode: c_int,
4433        aiocb_list: *const *mut aiocb,
4434        nitems: c_int,
4435        sevp: *mut sigevent,
4436    ) -> c_int;
4437
4438    pub fn dirfd(dirp: *mut crate::DIR) -> c_int;
4439
4440    pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int;
4441
4442    pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int;
4443    pub fn getutxent() -> *mut utmpx;
4444    pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
4445    pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
4446    pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
4447    pub fn setutxent();
4448    pub fn endutxent();
4449    pub fn utmpxname(file: *const c_char) -> c_int;
4450
4451    pub fn asctime(tm: *const crate::tm) -> *mut c_char;
4452    pub fn ctime(clock: *const time_t) -> *mut c_char;
4453    pub fn getdate(datestr: *const c_char) -> *mut crate::tm;
4454    pub fn strptime(
4455        buf: *const c_char,
4456        format: *const c_char,
4457        timeptr: *mut crate::tm,
4458    ) -> *mut c_char;
4459    pub fn asctime_r(tm: *const crate::tm, result: *mut c_char) -> *mut c_char;
4460    pub fn ctime_r(clock: *const time_t, result: *mut c_char) -> *mut c_char;
4461
4462    pub fn getnameinfo(
4463        sa: *const crate::sockaddr,
4464        salen: crate::socklen_t,
4465        host: *mut c_char,
4466        hostlen: crate::socklen_t,
4467        serv: *mut c_char,
4468        servlen: crate::socklen_t,
4469        flags: c_int,
4470    ) -> c_int;
4471    pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) -> c_int;
4472    pub fn sysctlnametomib(name: *const c_char, mibp: *mut c_int, sizep: *mut size_t) -> c_int;
4473    #[cfg_attr(
4474        all(target_os = "macos", target_arch = "x86"),
4475        link_name = "mprotect$UNIX2003"
4476    )]
4477    pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int;
4478    pub fn semget(key: key_t, nsems: c_int, semflg: c_int) -> c_int;
4479    #[cfg_attr(
4480        all(target_os = "macos", target_arch = "x86"),
4481        link_name = "semctl$UNIX2003"
4482    )]
4483    pub fn semctl(semid: c_int, semnum: c_int, cmd: c_int, ...) -> c_int;
4484    pub fn semop(semid: c_int, sops: *mut sembuf, nsops: size_t) -> c_int;
4485    pub fn shm_open(name: *const c_char, oflag: c_int, ...) -> c_int;
4486    pub fn ftok(pathname: *const c_char, proj_id: c_int) -> key_t;
4487    pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void;
4488    pub fn shmdt(shmaddr: *const c_void) -> c_int;
4489    #[cfg_attr(
4490        all(target_os = "macos", target_arch = "x86"),
4491        link_name = "shmctl$UNIX2003"
4492    )]
4493    pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int;
4494    pub fn shmget(key: key_t, size: size_t, shmflg: c_int) -> c_int;
4495    pub fn sysctl(
4496        name: *mut c_int,
4497        namelen: c_uint,
4498        oldp: *mut c_void,
4499        oldlenp: *mut size_t,
4500        newp: *mut c_void,
4501        newlen: size_t,
4502    ) -> c_int;
4503    pub fn sysctlbyname(
4504        name: *const c_char,
4505        oldp: *mut c_void,
4506        oldlenp: *mut size_t,
4507        newp: *mut c_void,
4508        newlen: size_t,
4509    ) -> c_int;
4510    #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")]
4511    pub fn mach_absolute_time() -> u64;
4512    #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")]
4513    #[allow(deprecated)]
4514    pub fn mach_timebase_info(info: *mut crate::mach_timebase_info) -> c_int;
4515    #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")]
4516    pub fn mach_host_self() -> mach_port_t;
4517    #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")]
4518    pub fn mach_thread_self() -> mach_port_t;
4519    pub fn pthread_cond_timedwait_relative_np(
4520        cond: *mut crate::pthread_cond_t,
4521        lock: *mut crate::pthread_mutex_t,
4522        timeout: *const crate::timespec,
4523    ) -> c_int;
4524    pub fn pthread_attr_getscope(
4525        attr: *const crate::pthread_attr_t,
4526        contentionscope: *mut c_int,
4527    ) -> c_int;
4528    pub fn pthread_attr_getstackaddr(
4529        attr: *const crate::pthread_attr_t,
4530        stackaddr: *mut *mut c_void,
4531    ) -> c_int;
4532    pub fn pthread_attr_getdetachstate(
4533        attr: *const crate::pthread_attr_t,
4534        detachstate: *mut c_int,
4535    ) -> c_int;
4536    pub fn pthread_attr_setscope(attr: *mut crate::pthread_attr_t, contentionscope: c_int)
4537        -> c_int;
4538    pub fn pthread_attr_setstackaddr(
4539        attr: *mut crate::pthread_attr_t,
4540        stackaddr: *mut c_void,
4541    ) -> c_int;
4542    pub fn pthread_setname_np(name: *const c_char) -> c_int;
4543    pub fn pthread_getname_np(thread: crate::pthread_t, name: *mut c_char, len: size_t) -> c_int;
4544    pub fn pthread_mach_thread_np(thread: crate::pthread_t) -> crate::mach_port_t;
4545    pub fn pthread_from_mach_thread_np(port: crate::mach_port_t) -> crate::pthread_t;
4546    pub fn pthread_get_stackaddr_np(thread: crate::pthread_t) -> *mut c_void;
4547    pub fn pthread_get_stacksize_np(thread: crate::pthread_t) -> size_t;
4548    pub fn pthread_main_np() -> c_int;
4549    pub fn pthread_threadid_np(thread: crate::pthread_t, thread_id: *mut u64) -> c_int;
4550
4551    pub fn pthread_jit_write_protect_np(enabled: c_int);
4552    pub fn pthread_jit_write_protect_supported_np() -> c_int;
4553    // An array of pthread_jit_write_with_callback_np must declare
4554    // the list of callbacks e.g.
4555    // #[link_section = "__DATA_CONST,__pth_jit_func"]
4556    // static callbacks: [libc::pthread_jit_write_callback_t; 2] = [native_jit_write_cb,
4557    // std::mem::transmute::<libc::pthread_jit_write_callback_t>(std::ptr::null())];
4558    // (a handy PTHREAD_JIT_WRITE_CALLBACK_NP macro for other languages).
4559    pub fn pthread_jit_write_with_callback_np(
4560        callback: crate::pthread_jit_write_callback_t,
4561        ctx: *mut c_void,
4562    ) -> c_int;
4563    pub fn pthread_jit_write_freeze_callbacks_np();
4564    pub fn pthread_cpu_number_np(cpu_number_out: *mut size_t) -> c_int;
4565
4566    // Available starting with macOS 14.4.
4567    pub fn os_sync_wait_on_address(
4568        addr: *mut c_void,
4569        value: u64,
4570        size: size_t,
4571        flags: os_sync_wait_on_address_flags_t,
4572    ) -> c_int;
4573    pub fn os_sync_wait_on_address_with_deadline(
4574        addr: *mut c_void,
4575        value: u64,
4576        size: size_t,
4577        flags: os_sync_wait_on_address_flags_t,
4578        clockid: os_clockid_t,
4579        deadline: u64,
4580    ) -> c_int;
4581    pub fn os_sync_wait_on_address_with_timeout(
4582        addr: *mut c_void,
4583        value: u64,
4584        size: size_t,
4585        flags: os_sync_wait_on_address_flags_t,
4586        clockid: os_clockid_t,
4587        timeout_ns: u64,
4588    ) -> c_int;
4589    pub fn os_sync_wake_by_address_any(
4590        addr: *mut c_void,
4591        size: size_t,
4592        flags: os_sync_wake_by_address_flags_t,
4593    ) -> c_int;
4594    pub fn os_sync_wake_by_address_all(
4595        addr: *mut c_void,
4596        size: size_t,
4597        flags: os_sync_wake_by_address_flags_t,
4598    ) -> c_int;
4599
4600    pub fn os_unfair_lock_lock(lock: os_unfair_lock_t);
4601    pub fn os_unfair_lock_trylock(lock: os_unfair_lock_t) -> bool;
4602    pub fn os_unfair_lock_unlock(lock: os_unfair_lock_t);
4603    pub fn os_unfair_lock_assert_owner(lock: os_unfair_lock_t);
4604    pub fn os_unfair_lock_assert_not_owner(lock: os_unfair_lock_t);
4605
4606    pub fn os_log_create(subsystem: *const c_char, category: *const c_char) -> crate::os_log_t;
4607    pub fn os_log_type_enabled(oslog: crate::os_log_t, tpe: crate::os_log_type_t) -> bool;
4608    pub fn os_signpost_id_make_with_pointer(
4609        log: crate::os_log_t,
4610        ptr: *const c_void,
4611    ) -> crate::os_signpost_id_t;
4612    pub fn os_signpost_id_generate(log: crate::os_log_t) -> crate::os_signpost_id_t;
4613    pub fn os_signpost_enabled(log: crate::os_log_t) -> bool;
4614
4615    pub fn thread_policy_set(
4616        thread: thread_t,
4617        flavor: thread_policy_flavor_t,
4618        policy_info: thread_policy_t,
4619        count: mach_msg_type_number_t,
4620    ) -> kern_return_t;
4621    pub fn thread_policy_get(
4622        thread: thread_t,
4623        flavor: thread_policy_flavor_t,
4624        policy_info: thread_policy_t,
4625        count: *mut mach_msg_type_number_t,
4626        get_default: *mut boolean_t,
4627    ) -> kern_return_t;
4628    pub fn thread_info(
4629        target_act: thread_inspect_t,
4630        flavor: thread_flavor_t,
4631        thread_info_out: thread_info_t,
4632        thread_info_outCnt: *mut mach_msg_type_number_t,
4633    ) -> kern_return_t;
4634    #[cfg_attr(doc, doc(alias = "__errno_location"))]
4635    #[cfg_attr(doc, doc(alias = "errno"))]
4636    pub fn __error() -> *mut c_int;
4637    pub fn backtrace(buf: *mut *mut c_void, sz: c_int) -> c_int;
4638    pub fn backtrace_symbols(addrs: *const *mut c_void, sz: c_int) -> *mut *mut c_char;
4639    pub fn backtrace_symbols_fd(addrs: *const *mut c_void, sz: c_int, fd: c_int);
4640    pub fn backtrace_from_fp(startfp: *mut c_void, array: *mut *mut c_void, size: c_int) -> c_int;
4641    pub fn backtrace_image_offsets(
4642        array: *const *mut c_void,
4643        image_offsets: *mut image_offset,
4644        size: c_int,
4645    );
4646    pub fn backtrace_async(array: *mut *mut c_void, length: size_t, task_id: *mut u32) -> size_t;
4647    #[cfg_attr(
4648        all(target_os = "macos", not(target_arch = "aarch64")),
4649        link_name = "statfs$INODE64"
4650    )]
4651    pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int;
4652    #[cfg_attr(
4653        all(target_os = "macos", not(target_arch = "aarch64")),
4654        link_name = "fstatfs$INODE64"
4655    )]
4656    pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int;
4657    pub fn kevent(
4658        kq: c_int,
4659        changelist: *const crate::kevent,
4660        nchanges: c_int,
4661        eventlist: *mut crate::kevent,
4662        nevents: c_int,
4663        timeout: *const crate::timespec,
4664    ) -> c_int;
4665    pub fn kevent64(
4666        kq: c_int,
4667        changelist: *const crate::kevent64_s,
4668        nchanges: c_int,
4669        eventlist: *mut crate::kevent64_s,
4670        nevents: c_int,
4671        flags: c_uint,
4672        timeout: *const crate::timespec,
4673    ) -> c_int;
4674    pub fn mount(
4675        src: *const c_char,
4676        target: *const c_char,
4677        flags: c_int,
4678        data: *mut c_void,
4679    ) -> c_int;
4680    pub fn fmount(src: *const c_char, fd: c_int, flags: c_int, data: *mut c_void) -> c_int;
4681    pub fn ptrace(request: c_int, pid: crate::pid_t, addr: *mut c_char, data: c_int) -> c_int;
4682    pub fn quotactl(special: *const c_char, cmd: c_int, id: c_int, data: *mut c_char) -> c_int;
4683    pub fn sethostname(name: *const c_char, len: c_int) -> c_int;
4684    pub fn sendfile(
4685        fd: c_int,
4686        s: c_int,
4687        offset: off_t,
4688        len: *mut off_t,
4689        hdtr: *mut crate::sf_hdtr,
4690        flags: c_int,
4691    ) -> c_int;
4692    pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int;
4693    pub fn utimensat(
4694        dirfd: c_int,
4695        path: *const c_char,
4696        times: *const crate::timespec,
4697        flag: c_int,
4698    ) -> c_int;
4699    pub fn openpty(
4700        amaster: *mut c_int,
4701        aslave: *mut c_int,
4702        name: *mut c_char,
4703        termp: *mut termios,
4704        winp: *mut crate::winsize,
4705    ) -> c_int;
4706    pub fn forkpty(
4707        amaster: *mut c_int,
4708        name: *mut c_char,
4709        termp: *mut termios,
4710        winp: *mut crate::winsize,
4711    ) -> crate::pid_t;
4712    pub fn login_tty(fd: c_int) -> c_int;
4713    pub fn duplocale(base: crate::locale_t) -> crate::locale_t;
4714    pub fn freelocale(loc: crate::locale_t) -> c_int;
4715    pub fn localeconv_l(loc: crate::locale_t) -> *mut lconv;
4716    pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t;
4717    pub fn uselocale(loc: crate::locale_t) -> crate::locale_t;
4718    pub fn querylocale(mask: c_int, loc: crate::locale_t) -> *const c_char;
4719    pub fn getpriority(which: c_int, who: crate::id_t) -> c_int;
4720    pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int;
4721    pub fn getdomainname(name: *mut c_char, len: c_int) -> c_int;
4722    pub fn setdomainname(name: *const c_char, len: c_int) -> c_int;
4723    pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t;
4724    pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t;
4725    pub fn getxattr(
4726        path: *const c_char,
4727        name: *const c_char,
4728        value: *mut c_void,
4729        size: size_t,
4730        position: u32,
4731        flags: c_int,
4732    ) -> ssize_t;
4733    pub fn fgetxattr(
4734        filedes: c_int,
4735        name: *const c_char,
4736        value: *mut c_void,
4737        size: size_t,
4738        position: u32,
4739        flags: c_int,
4740    ) -> ssize_t;
4741    pub fn setxattr(
4742        path: *const c_char,
4743        name: *const c_char,
4744        value: *const c_void,
4745        size: size_t,
4746        position: u32,
4747        flags: c_int,
4748    ) -> c_int;
4749    pub fn fsetxattr(
4750        filedes: c_int,
4751        name: *const c_char,
4752        value: *const c_void,
4753        size: size_t,
4754        position: u32,
4755        flags: c_int,
4756    ) -> c_int;
4757    pub fn listxattr(path: *const c_char, list: *mut c_char, size: size_t, flags: c_int)
4758        -> ssize_t;
4759    pub fn flistxattr(filedes: c_int, list: *mut c_char, size: size_t, flags: c_int) -> ssize_t;
4760    pub fn removexattr(path: *const c_char, name: *const c_char, flags: c_int) -> c_int;
4761    pub fn renamex_np(from: *const c_char, to: *const c_char, flags: c_uint) -> c_int;
4762    pub fn renameatx_np(
4763        fromfd: c_int,
4764        from: *const c_char,
4765        tofd: c_int,
4766        to: *const c_char,
4767        flags: c_uint,
4768    ) -> c_int;
4769    pub fn fremovexattr(filedes: c_int, name: *const c_char, flags: c_int) -> c_int;
4770
4771    pub fn getgrouplist(
4772        name: *const c_char,
4773        basegid: c_int,
4774        groups: *mut c_int,
4775        ngroups: *mut c_int,
4776    ) -> c_int;
4777    pub fn initgroups(user: *const c_char, basegroup: c_int) -> c_int;
4778
4779    #[cfg_attr(
4780        all(target_os = "macos", target_arch = "x86"),
4781        link_name = "waitid$UNIX2003"
4782    )]
4783    pub fn waitid(
4784        idtype: idtype_t,
4785        id: id_t,
4786        infop: *mut crate::siginfo_t,
4787        options: c_int,
4788    ) -> c_int;
4789    pub fn brk(addr: *const c_void) -> *mut c_void;
4790    pub fn sbrk(increment: c_int) -> *mut c_void;
4791    pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int;
4792    #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")]
4793    pub fn _dyld_image_count() -> u32;
4794    #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")]
4795    #[allow(deprecated)]
4796    pub fn _dyld_get_image_header(image_index: u32) -> *const mach_header;
4797    #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")]
4798    pub fn _dyld_get_image_vmaddr_slide(image_index: u32) -> intptr_t;
4799    #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")]
4800    pub fn _dyld_get_image_name(image_index: u32) -> *const c_char;
4801
4802    pub fn posix_spawn(
4803        pid: *mut crate::pid_t,
4804        path: *const c_char,
4805        file_actions: *const crate::posix_spawn_file_actions_t,
4806        attrp: *const crate::posix_spawnattr_t,
4807        argv: *const *mut c_char,
4808        envp: *const *mut c_char,
4809    ) -> c_int;
4810    pub fn posix_spawnp(
4811        pid: *mut crate::pid_t,
4812        file: *const c_char,
4813        file_actions: *const crate::posix_spawn_file_actions_t,
4814        attrp: *const crate::posix_spawnattr_t,
4815        argv: *const *mut c_char,
4816        envp: *const *mut c_char,
4817    ) -> c_int;
4818    pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int;
4819    pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int;
4820    pub fn posix_spawnattr_getsigdefault(
4821        attr: *const posix_spawnattr_t,
4822        default: *mut crate::sigset_t,
4823    ) -> c_int;
4824    pub fn posix_spawnattr_setsigdefault(
4825        attr: *mut posix_spawnattr_t,
4826        default: *const crate::sigset_t,
4827    ) -> c_int;
4828    pub fn posix_spawnattr_getsigmask(
4829        attr: *const posix_spawnattr_t,
4830        default: *mut crate::sigset_t,
4831    ) -> c_int;
4832    pub fn posix_spawnattr_setsigmask(
4833        attr: *mut posix_spawnattr_t,
4834        default: *const crate::sigset_t,
4835    ) -> c_int;
4836    pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int;
4837    pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int;
4838    pub fn posix_spawnattr_getpgroup(
4839        attr: *const posix_spawnattr_t,
4840        flags: *mut crate::pid_t,
4841    ) -> c_int;
4842    pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: crate::pid_t) -> c_int;
4843    pub fn posix_spawnattr_setarchpref_np(
4844        attr: *mut posix_spawnattr_t,
4845        count: size_t,
4846        pref: *mut crate::cpu_type_t,
4847        subpref: *mut crate::cpu_subtype_t,
4848        ocount: *mut size_t,
4849    ) -> c_int;
4850    pub fn posix_spawnattr_getarchpref_np(
4851        attr: *const posix_spawnattr_t,
4852        count: size_t,
4853        pref: *mut crate::cpu_type_t,
4854        subpref: *mut crate::cpu_subtype_t,
4855        ocount: *mut size_t,
4856    ) -> c_int;
4857    pub fn posix_spawnattr_getbinpref_np(
4858        attr: *const posix_spawnattr_t,
4859        count: size_t,
4860        pref: *mut crate::cpu_type_t,
4861        ocount: *mut size_t,
4862    ) -> c_int;
4863    pub fn posix_spawnattr_setbinpref_np(
4864        attr: *mut posix_spawnattr_t,
4865        count: size_t,
4866        pref: *mut crate::cpu_type_t,
4867        ocount: *mut size_t,
4868    ) -> c_int;
4869
4870    pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int;
4871    pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int;
4872    pub fn posix_spawn_file_actions_addopen(
4873        actions: *mut posix_spawn_file_actions_t,
4874        fd: c_int,
4875        path: *const c_char,
4876        oflag: c_int,
4877        mode: mode_t,
4878    ) -> c_int;
4879    pub fn posix_spawn_file_actions_addclose(
4880        actions: *mut posix_spawn_file_actions_t,
4881        fd: c_int,
4882    ) -> c_int;
4883    pub fn posix_spawn_file_actions_adddup2(
4884        actions: *mut posix_spawn_file_actions_t,
4885        fd: c_int,
4886        newfd: c_int,
4887    ) -> c_int;
4888    pub fn uname(buf: *mut crate::utsname) -> c_int;
4889
4890    pub fn connectx(
4891        socket: c_int,
4892        endpoints: *const sa_endpoints_t,
4893        associd: sae_associd_t,
4894        flags: c_uint,
4895        iov: *const crate::iovec,
4896        iovcnt: c_uint,
4897        len: *mut size_t,
4898        connid: *mut sae_connid_t,
4899    ) -> c_int;
4900    pub fn disconnectx(socket: c_int, associd: sae_associd_t, connid: sae_connid_t) -> c_int;
4901
4902    pub fn ntp_adjtime(buf: *mut timex) -> c_int;
4903    pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int;
4904
4905    #[cfg_attr(
4906        all(target_os = "macos", not(target_arch = "aarch64")),
4907        link_name = "getmntinfo$INODE64"
4908    )]
4909    pub fn getmntinfo(mntbufp: *mut *mut statfs, flags: c_int) -> c_int;
4910    #[cfg_attr(
4911        all(target_os = "macos", not(target_arch = "aarch64")),
4912        link_name = "getfsstat$INODE64"
4913    )]
4914    pub fn getfsstat(mntbufp: *mut statfs, bufsize: c_int, flags: c_int) -> c_int;
4915
4916    // Copy-on-write functions.
4917    // According to the man page `flags` is an `int` but in the header
4918    // this is a `uint32_t`.
4919    pub fn clonefile(src: *const c_char, dst: *const c_char, flags: u32) -> c_int;
4920    pub fn clonefileat(
4921        src_dirfd: c_int,
4922        src: *const c_char,
4923        dst_dirfd: c_int,
4924        dst: *const c_char,
4925        flags: u32,
4926    ) -> c_int;
4927    pub fn fclonefileat(srcfd: c_int, dst_dirfd: c_int, dst: *const c_char, flags: u32) -> c_int;
4928
4929    pub fn copyfile(
4930        from: *const c_char,
4931        to: *const c_char,
4932        state: copyfile_state_t,
4933        flags: copyfile_flags_t,
4934    ) -> c_int;
4935    pub fn fcopyfile(
4936        from: c_int,
4937        to: c_int,
4938        state: copyfile_state_t,
4939        flags: copyfile_flags_t,
4940    ) -> c_int;
4941    pub fn copyfile_state_free(s: copyfile_state_t) -> c_int;
4942    pub fn copyfile_state_alloc() -> copyfile_state_t;
4943    pub fn copyfile_state_get(s: copyfile_state_t, flags: u32, dst: *mut c_void) -> c_int;
4944    pub fn copyfile_state_set(s: copyfile_state_t, flags: u32, src: *const c_void) -> c_int;
4945
4946    pub fn mach_error_string(error_value: crate::mach_error_t) -> *mut c_char;
4947
4948    // Added in macOS 10.13
4949    // ISO/IEC 9899:2011 ("ISO C11") K.3.7.4.1
4950    pub fn memset_s(s: *mut c_void, smax: size_t, c: c_int, n: size_t) -> c_int;
4951    // Added in macOS 10.5
4952    pub fn memset_pattern4(b: *mut c_void, pattern4: *const c_void, len: size_t);
4953    pub fn memset_pattern8(b: *mut c_void, pattern8: *const c_void, len: size_t);
4954    pub fn memset_pattern16(b: *mut c_void, pattern16: *const c_void, len: size_t);
4955
4956    // Inherited from BSD but available from Big Sur only
4957    pub fn strtonum(
4958        __numstr: *const c_char,
4959        __minval: c_longlong,
4960        __maxval: c_longlong,
4961        errstrp: *mut *const c_char,
4962    ) -> c_longlong;
4963
4964    pub fn mstats() -> mstats;
4965    pub fn malloc_printf(format: *const c_char, ...);
4966    pub fn malloc_zone_check(zone: *mut crate::malloc_zone_t) -> crate::boolean_t;
4967    pub fn malloc_zone_print(zone: *mut crate::malloc_zone_t, verbose: crate::boolean_t);
4968    pub fn malloc_zone_statistics(zone: *mut crate::malloc_zone_t, stats: *mut malloc_statistics_t);
4969    pub fn malloc_zone_log(zone: *mut crate::malloc_zone_t, address: *mut c_void);
4970    pub fn malloc_zone_print_ptr_info(ptr: *mut c_void);
4971    pub fn malloc_default_zone() -> *mut crate::malloc_zone_t;
4972    pub fn malloc_zone_from_ptr(ptr: *const c_void) -> *mut crate::malloc_zone_t;
4973    pub fn malloc_zone_malloc(zone: *mut crate::malloc_zone_t, size: size_t) -> *mut c_void;
4974    pub fn malloc_zone_valloc(zone: *mut crate::malloc_zone_t, size: size_t) -> *mut c_void;
4975    pub fn malloc_zone_calloc(
4976        zone: *mut crate::malloc_zone_t,
4977        num_items: size_t,
4978        size: size_t,
4979    ) -> *mut c_void;
4980    pub fn malloc_zone_realloc(
4981        zone: *mut crate::malloc_zone_t,
4982        ptr: *mut c_void,
4983        size: size_t,
4984    ) -> *mut c_void;
4985    pub fn malloc_zone_free(zone: *mut crate::malloc_zone_t, ptr: *mut c_void);
4986
4987    pub fn proc_listpids(t: u32, typeinfo: u32, buffer: *mut c_void, buffersize: c_int) -> c_int;
4988    pub fn proc_listallpids(buffer: *mut c_void, buffersize: c_int) -> c_int;
4989    pub fn proc_listpgrppids(pgrpid: crate::pid_t, buffer: *mut c_void, buffersize: c_int)
4990        -> c_int;
4991    pub fn proc_listchildpids(ppid: crate::pid_t, buffer: *mut c_void, buffersize: c_int) -> c_int;
4992    pub fn proc_pidinfo(
4993        pid: c_int,
4994        flavor: c_int,
4995        arg: u64,
4996        buffer: *mut c_void,
4997        buffersize: c_int,
4998    ) -> c_int;
4999    pub fn proc_pidfdinfo(
5000        pid: c_int,
5001        fd: c_int,
5002        flavor: c_int,
5003        buffer: *mut c_void,
5004        buffersize: c_int,
5005    ) -> c_int;
5006    pub fn proc_pidfileportinfo(
5007        pid: c_int,
5008        fileport: u32,
5009        flavor: c_int,
5010        buffer: *mut c_void,
5011        buffersize: c_int,
5012    ) -> c_int;
5013    pub fn proc_pidpath(pid: c_int, buffer: *mut c_void, buffersize: u32) -> c_int;
5014    pub fn proc_name(pid: c_int, buffer: *mut c_void, buffersize: u32) -> c_int;
5015    pub fn proc_regionfilename(
5016        pid: c_int,
5017        address: u64,
5018        buffer: *mut c_void,
5019        buffersize: u32,
5020    ) -> c_int;
5021    pub fn proc_kmsgbuf(buffer: *mut c_void, buffersize: u32) -> c_int;
5022    pub fn proc_libversion(major: *mut c_int, minor: *mut c_int) -> c_int;
5023    pub fn proc_pid_rusage(pid: c_int, flavor: c_int, buffer: *mut rusage_info_t) -> c_int;
5024
5025    // Available from Big Sur
5026    pub fn proc_set_no_smt() -> c_int;
5027    pub fn proc_setthread_no_smt() -> c_int;
5028    pub fn proc_set_csm(flags: u32) -> c_int;
5029    pub fn proc_setthread_csm(flags: u32) -> c_int;
5030    /// # Notes
5031    ///
5032    /// `id` is of type [`uuid_t`].
5033    pub fn gethostuuid(id: *mut u8, timeout: *const crate::timespec) -> c_int;
5034
5035    pub fn gethostid() -> c_long;
5036    pub fn sethostid(hostid: c_long);
5037
5038    pub fn CCRandomGenerateBytes(bytes: *mut c_void, size: size_t) -> crate::CCRNGStatus;
5039    pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int;
5040
5041    // FIXME(1.0): should this actually be deprecated?
5042    #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")]
5043    pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut u32) -> c_int;
5044
5045    // crt_externs.h
5046    pub fn _NSGetArgv() -> *mut *mut *mut c_char;
5047    pub fn _NSGetArgc() -> *mut c_int;
5048    pub fn _NSGetEnviron() -> *mut *mut *mut c_char;
5049    pub fn _NSGetProgname() -> *mut *mut c_char;
5050
5051    #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")]
5052    pub fn mach_vm_map(
5053        target_task: crate::vm_map_t,
5054        address: *mut crate::mach_vm_address_t,
5055        size: crate::mach_vm_size_t,
5056        mask: crate::mach_vm_offset_t,
5057        flags: c_int,
5058        object: crate::mem_entry_name_port_t,
5059        offset: crate::memory_object_offset_t,
5060        copy: crate::boolean_t,
5061        cur_protection: crate::vm_prot_t,
5062        max_protection: crate::vm_prot_t,
5063        inheritance: crate::vm_inherit_t,
5064    ) -> crate::kern_return_t;
5065
5066    pub fn vm_allocate(
5067        target_task: vm_map_t,
5068        address: *mut vm_address_t,
5069        size: vm_size_t,
5070        flags: c_int,
5071    ) -> crate::kern_return_t;
5072
5073    pub fn vm_deallocate(
5074        target_task: vm_map_t,
5075        address: vm_address_t,
5076        size: vm_size_t,
5077    ) -> crate::kern_return_t;
5078
5079    pub fn host_statistics64(
5080        host_priv: host_t,
5081        flavor: host_flavor_t,
5082        host_info64_out: host_info64_t,
5083        host_info64_outCnt: *mut mach_msg_type_number_t,
5084    ) -> crate::kern_return_t;
5085    pub fn host_processor_info(
5086        host: host_t,
5087        flavor: processor_flavor_t,
5088        out_processor_count: *mut natural_t,
5089        out_processor_info: *mut processor_info_array_t,
5090        out_processor_infoCnt: *mut mach_msg_type_number_t,
5091    ) -> crate::kern_return_t;
5092
5093    #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")]
5094    pub static mut mach_task_self_: crate::mach_port_t;
5095    pub fn task_for_pid(
5096        host: crate::mach_port_t,
5097        pid: crate::pid_t,
5098        task: *mut crate::mach_port_t,
5099    ) -> crate::kern_return_t;
5100    pub fn task_info(
5101        host: crate::mach_port_t,
5102        flavor: task_flavor_t,
5103        task_info_out: task_info_t,
5104        task_info_count: *mut mach_msg_type_number_t,
5105    ) -> crate::kern_return_t;
5106    pub fn task_create(
5107        target_task: crate::task_t,
5108        ledgers: crate::ledger_array_t,
5109        ledgersCnt: crate::mach_msg_type_number_t,
5110        inherit_memory: crate::boolean_t,
5111        child_task: *mut crate::task_t,
5112    ) -> crate::kern_return_t;
5113    pub fn task_terminate(target_task: crate::task_t) -> crate::kern_return_t;
5114    pub fn task_threads(
5115        target_task: crate::task_inspect_t,
5116        act_list: *mut crate::thread_act_array_t,
5117        act_listCnt: *mut crate::mach_msg_type_number_t,
5118    ) -> crate::kern_return_t;
5119    pub fn host_statistics(
5120        host_priv: host_t,
5121        flavor: host_flavor_t,
5122        host_info_out: host_info_t,
5123        host_info_outCnt: *mut mach_msg_type_number_t,
5124    ) -> crate::kern_return_t;
5125
5126    // sysdir.h
5127    pub fn sysdir_start_search_path_enumeration(
5128        dir: sysdir_search_path_directory_t,
5129        domainMask: sysdir_search_path_domain_mask_t,
5130    ) -> crate::sysdir_search_path_enumeration_state;
5131    pub fn sysdir_get_next_search_path_enumeration(
5132        state: crate::sysdir_search_path_enumeration_state,
5133        path: *mut c_char,
5134    ) -> crate::sysdir_search_path_enumeration_state;
5135
5136    pub static vm_page_size: vm_size_t;
5137
5138    pub fn getattrlist(
5139        path: *const c_char,
5140        attrList: *mut c_void,
5141        attrBuf: *mut c_void,
5142        attrBufSize: size_t,
5143        options: u32,
5144    ) -> c_int;
5145    pub fn fgetattrlist(
5146        fd: c_int,
5147        attrList: *mut c_void,
5148        attrBuf: *mut c_void,
5149        attrBufSize: size_t,
5150        options: u32,
5151    ) -> c_int;
5152    pub fn getattrlistat(
5153        fd: c_int,
5154        path: *const c_char,
5155        attrList: *mut c_void,
5156        attrBuf: *mut c_void,
5157        attrBufSize: size_t,
5158        options: c_ulong,
5159    ) -> c_int;
5160    pub fn setattrlist(
5161        path: *const c_char,
5162        attrList: *mut c_void,
5163        attrBuf: *mut c_void,
5164        attrBufSize: size_t,
5165        options: u32,
5166    ) -> c_int;
5167    pub fn fsetattrlist(
5168        fd: c_int,
5169        attrList: *mut c_void,
5170        attrBuf: *mut c_void,
5171        attrBufSize: size_t,
5172        options: u32,
5173    ) -> c_int;
5174    pub fn setattrlistat(
5175        dir_fd: c_int,
5176        path: *const c_char,
5177        attrList: *mut c_void,
5178        attrBuf: *mut c_void,
5179        attrBufSize: size_t,
5180        options: u32,
5181    ) -> c_int;
5182    pub fn getattrlistbulk(
5183        dirfd: c_int,
5184        attrList: *mut c_void,
5185        attrBuf: *mut c_void,
5186        attrBufSize: size_t,
5187        options: u64,
5188    ) -> c_int;
5189
5190    pub fn malloc_size(ptr: *const c_void) -> size_t;
5191    pub fn malloc_good_size(size: size_t) -> size_t;
5192
5193    pub fn dirname(path: *mut c_char) -> *mut c_char;
5194    pub fn basename(path: *mut c_char) -> *mut c_char;
5195
5196    pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
5197    pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int;
5198    pub fn freadlink(fd: c_int, buf: *mut c_char, size: size_t) -> c_int;
5199    pub fn execvP(
5200        file: *const c_char,
5201        search_path: *const c_char,
5202        argv: *const *mut c_char,
5203    ) -> c_int;
5204
5205    pub fn qsort_r(
5206        base: *mut c_void,
5207        num: size_t,
5208        size: size_t,
5209        arg: *mut c_void,
5210        compar: Option<unsafe extern "C" fn(*mut c_void, *const c_void, *const c_void) -> c_int>,
5211    );
5212}
5213
5214#[allow(deprecated)]
5215#[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")]
5216pub unsafe fn mach_task_self() -> crate::mach_port_t {
5217    mach_task_self_
5218}
5219
5220cfg_if! {
5221    if #[cfg(target_os = "macos")] {
5222        extern "C" {
5223            pub fn clock_settime(clock_id: crate::clockid_t, tp: *const crate::timespec) -> c_int;
5224        }
5225    }
5226}
5227cfg_if! {
5228    if #[cfg(any(
5229        target_os = "macos",
5230        target_os = "ios",
5231        target_os = "tvos",
5232        target_os = "visionos"
5233    ))] {
5234        extern "C" {
5235            pub fn memmem(
5236                haystack: *const c_void,
5237                haystacklen: size_t,
5238                needle: *const c_void,
5239                needlelen: size_t,
5240            ) -> *mut c_void;
5241            pub fn task_set_info(
5242                target_task: crate::task_t,
5243                flavor: crate::task_flavor_t,
5244                task_info_in: crate::task_info_t,
5245                task_info_inCnt: crate::mach_msg_type_number_t,
5246            ) -> crate::kern_return_t;
5247        }
5248    }
5249}
5250
5251// These require a dependency on `libiconv`, and including this when built as
5252// part of `std` means every Rust program gets it. Ideally we would have a link
5253// modifier to only include these if they are used, but we do not.
5254#[cfg_attr(not(feature = "rustc-dep-of-std"), link(name = "iconv"))]
5255extern "C" {
5256    #[deprecated(note = "Will be removed in 1.0 to avoid the `iconv` dependency")]
5257    pub fn iconv_open(tocode: *const c_char, fromcode: *const c_char) -> iconv_t;
5258    #[deprecated(note = "Will be removed in 1.0 to avoid the `iconv` dependency")]
5259    pub fn iconv(
5260        cd: iconv_t,
5261        inbuf: *mut *mut c_char,
5262        inbytesleft: *mut size_t,
5263        outbuf: *mut *mut c_char,
5264        outbytesleft: *mut size_t,
5265    ) -> size_t;
5266    #[deprecated(note = "Will be removed in 1.0 to avoid the `iconv` dependency")]
5267    pub fn iconv_close(cd: iconv_t) -> c_int;
5268}
5269
5270cfg_if! {
5271    if #[cfg(target_pointer_width = "32")] {
5272        mod b32;
5273        pub use self::b32::*;
5274    } else if #[cfg(target_pointer_width = "64")] {
5275        mod b64;
5276        pub use self::b64::*;
5277    } else {
5278        // Unknown target_arch
5279    }
5280}