libc/unix/linux_like/linux/
mod.rs

1//! Linux-specific definitions for linux-like values
2
3use core::mem::size_of;
4
5use crate::prelude::*;
6
7pub type useconds_t = u32;
8pub type dev_t = u64;
9pub type socklen_t = u32;
10pub type mode_t = u32;
11pub type ino64_t = u64;
12pub type off64_t = i64;
13pub type blkcnt64_t = i64;
14pub type rlim64_t = u64;
15pub type mqd_t = c_int;
16pub type nfds_t = c_ulong;
17pub type nl_item = c_int;
18pub type idtype_t = c_uint;
19pub type loff_t = c_longlong;
20pub type pthread_key_t = c_uint;
21pub type pthread_once_t = c_int;
22pub type pthread_spinlock_t = c_int;
23pub type __kernel_fsid_t = __c_anonymous__kernel_fsid_t;
24pub type __kernel_clockid_t = c_int;
25
26pub type __u8 = c_uchar;
27pub type __u16 = c_ushort;
28pub type __s16 = c_short;
29pub type __u32 = c_uint;
30pub type __s32 = c_int;
31
32pub type Elf32_Half = u16;
33pub type Elf32_Word = u32;
34pub type Elf32_Off = u32;
35pub type Elf32_Addr = u32;
36pub type Elf32_Xword = u64;
37pub type Elf32_Sword = i32;
38
39pub type Elf64_Half = u16;
40pub type Elf64_Word = u32;
41pub type Elf64_Off = u64;
42pub type Elf64_Addr = u64;
43pub type Elf64_Xword = u64;
44pub type Elf64_Sxword = i64;
45pub type Elf64_Sword = i32;
46
47pub type Elf32_Section = u16;
48pub type Elf64_Section = u16;
49
50pub type Elf32_Relr = Elf32_Word;
51pub type Elf64_Relr = Elf32_Xword;
52pub type Elf32_Rel = __c_anonymous_elf32_rel;
53pub type Elf64_Rel = __c_anonymous_elf64_rel;
54
55cfg_if! {
56    if #[cfg(not(target_arch = "sparc64"))] {
57        pub type Elf32_Rela = __c_anonymous_elf32_rela;
58        pub type Elf64_Rela = __c_anonymous_elf64_rela;
59    }
60}
61
62// linux/can.h
63pub type canid_t = u32;
64
65// linux/can/j1939.h
66pub type can_err_mask_t = u32;
67pub type pgn_t = u32;
68pub type priority_t = u8;
69pub type name_t = u64;
70
71pub type iconv_t = *mut c_void;
72
73// linux/sctp.h
74pub type sctp_assoc_t = __s32;
75
76pub type eventfd_t = u64;
77missing! {
78    #[cfg_attr(feature = "extra_traits", derive(Debug))]
79    pub enum fpos64_t {} // FIXME(linux): fill this out with a struct
80}
81
82e! {
83    #[repr(u32)]
84    pub enum tpacket_versions {
85        TPACKET_V1,
86        TPACKET_V2,
87        TPACKET_V3,
88    }
89}
90
91s! {
92    pub struct glob_t {
93        pub gl_pathc: size_t,
94        pub gl_pathv: *mut *mut c_char,
95        pub gl_offs: size_t,
96        pub gl_flags: c_int,
97
98        __unused1: *mut c_void,
99        __unused2: *mut c_void,
100        __unused3: *mut c_void,
101        __unused4: *mut c_void,
102        __unused5: *mut c_void,
103    }
104
105    pub struct passwd {
106        pub pw_name: *mut c_char,
107        pub pw_passwd: *mut c_char,
108        pub pw_uid: crate::uid_t,
109        pub pw_gid: crate::gid_t,
110        pub pw_gecos: *mut c_char,
111        pub pw_dir: *mut c_char,
112        pub pw_shell: *mut c_char,
113    }
114
115    pub struct spwd {
116        pub sp_namp: *mut c_char,
117        pub sp_pwdp: *mut c_char,
118        pub sp_lstchg: c_long,
119        pub sp_min: c_long,
120        pub sp_max: c_long,
121        pub sp_warn: c_long,
122        pub sp_inact: c_long,
123        pub sp_expire: c_long,
124        pub sp_flag: c_ulong,
125    }
126
127    pub struct dqblk {
128        pub dqb_bhardlimit: u64,
129        pub dqb_bsoftlimit: u64,
130        pub dqb_curspace: u64,
131        pub dqb_ihardlimit: u64,
132        pub dqb_isoftlimit: u64,
133        pub dqb_curinodes: u64,
134        pub dqb_btime: u64,
135        pub dqb_itime: u64,
136        pub dqb_valid: u32,
137    }
138
139    pub struct signalfd_siginfo {
140        pub ssi_signo: u32,
141        pub ssi_errno: i32,
142        pub ssi_code: i32,
143        pub ssi_pid: u32,
144        pub ssi_uid: u32,
145        pub ssi_fd: i32,
146        pub ssi_tid: u32,
147        pub ssi_band: u32,
148        pub ssi_overrun: u32,
149        pub ssi_trapno: u32,
150        pub ssi_status: i32,
151        pub ssi_int: i32,
152        pub ssi_ptr: u64,
153        pub ssi_utime: u64,
154        pub ssi_stime: u64,
155        pub ssi_addr: u64,
156        pub ssi_addr_lsb: u16,
157        _pad2: u16,
158        pub ssi_syscall: i32,
159        pub ssi_call_addr: u64,
160        pub ssi_arch: u32,
161        _pad: [u8; 28],
162    }
163
164    pub struct itimerspec {
165        pub it_interval: crate::timespec,
166        pub it_value: crate::timespec,
167    }
168
169    pub struct fsid_t {
170        __val: [c_int; 2],
171    }
172
173    pub struct fanout_args {
174        #[cfg(target_endian = "little")]
175        pub id: __u16,
176        pub type_flags: __u16,
177        #[cfg(target_endian = "big")]
178        pub id: __u16,
179        pub max_num_members: __u32,
180    }
181
182    pub struct packet_mreq {
183        pub mr_ifindex: c_int,
184        pub mr_type: c_ushort,
185        pub mr_alen: c_ushort,
186        pub mr_address: [c_uchar; 8],
187    }
188
189    #[deprecated(since = "0.2.70", note = "sockaddr_ll type must be used instead")]
190    pub struct sockaddr_pkt {
191        pub spkt_family: c_ushort,
192        pub spkt_device: [c_uchar; 14],
193        pub spkt_protocol: c_ushort,
194    }
195
196    pub struct tpacket_auxdata {
197        pub tp_status: __u32,
198        pub tp_len: __u32,
199        pub tp_snaplen: __u32,
200        pub tp_mac: __u16,
201        pub tp_net: __u16,
202        pub tp_vlan_tci: __u16,
203        pub tp_vlan_tpid: __u16,
204    }
205
206    pub struct tpacket_hdr {
207        pub tp_status: c_ulong,
208        pub tp_len: c_uint,
209        pub tp_snaplen: c_uint,
210        pub tp_mac: c_ushort,
211        pub tp_net: c_ushort,
212        pub tp_sec: c_uint,
213        pub tp_usec: c_uint,
214    }
215
216    pub struct tpacket_hdr_variant1 {
217        pub tp_rxhash: __u32,
218        pub tp_vlan_tci: __u32,
219        pub tp_vlan_tpid: __u16,
220        pub tp_padding: __u16,
221    }
222
223    pub struct tpacket2_hdr {
224        pub tp_status: __u32,
225        pub tp_len: __u32,
226        pub tp_snaplen: __u32,
227        pub tp_mac: __u16,
228        pub tp_net: __u16,
229        pub tp_sec: __u32,
230        pub tp_nsec: __u32,
231        pub tp_vlan_tci: __u16,
232        pub tp_vlan_tpid: __u16,
233        pub tp_padding: [__u8; 4],
234    }
235
236    pub struct tpacket_req {
237        pub tp_block_size: c_uint,
238        pub tp_block_nr: c_uint,
239        pub tp_frame_size: c_uint,
240        pub tp_frame_nr: c_uint,
241    }
242
243    pub struct tpacket_req3 {
244        pub tp_block_size: c_uint,
245        pub tp_block_nr: c_uint,
246        pub tp_frame_size: c_uint,
247        pub tp_frame_nr: c_uint,
248        pub tp_retire_blk_tov: c_uint,
249        pub tp_sizeof_priv: c_uint,
250        pub tp_feature_req_word: c_uint,
251    }
252
253    #[repr(align(8))]
254    pub struct tpacket_rollover_stats {
255        pub tp_all: crate::__u64,
256        pub tp_huge: crate::__u64,
257        pub tp_failed: crate::__u64,
258    }
259
260    pub struct tpacket_stats {
261        pub tp_packets: c_uint,
262        pub tp_drops: c_uint,
263    }
264
265    pub struct tpacket_stats_v3 {
266        pub tp_packets: c_uint,
267        pub tp_drops: c_uint,
268        pub tp_freeze_q_cnt: c_uint,
269    }
270
271    pub struct tpacket3_hdr {
272        pub tp_next_offset: __u32,
273        pub tp_sec: __u32,
274        pub tp_nsec: __u32,
275        pub tp_snaplen: __u32,
276        pub tp_len: __u32,
277        pub tp_status: __u32,
278        pub tp_mac: __u16,
279        pub tp_net: __u16,
280        pub hv1: crate::tpacket_hdr_variant1,
281        pub tp_padding: [__u8; 8],
282    }
283
284    pub struct tpacket_bd_ts {
285        pub ts_sec: c_uint,
286        pub ts_usec: c_uint,
287    }
288
289    #[repr(align(8))]
290    pub struct tpacket_hdr_v1 {
291        pub block_status: __u32,
292        pub num_pkts: __u32,
293        pub offset_to_first_pkt: __u32,
294        pub blk_len: __u32,
295        pub seq_num: crate::__u64,
296        pub ts_first_pkt: crate::tpacket_bd_ts,
297        pub ts_last_pkt: crate::tpacket_bd_ts,
298    }
299
300    pub struct cpu_set_t {
301        #[cfg(all(target_pointer_width = "32", not(target_arch = "x86_64")))]
302        bits: [u32; 32],
303        #[cfg(not(all(target_pointer_width = "32", not(target_arch = "x86_64"))))]
304        bits: [u64; 16],
305    }
306
307    pub struct if_nameindex {
308        pub if_index: c_uint,
309        pub if_name: *mut c_char,
310    }
311
312    // System V IPC
313    pub struct msginfo {
314        pub msgpool: c_int,
315        pub msgmap: c_int,
316        pub msgmax: c_int,
317        pub msgmnb: c_int,
318        pub msgmni: c_int,
319        pub msgssz: c_int,
320        pub msgtql: c_int,
321        pub msgseg: c_ushort,
322    }
323
324    pub struct sembuf {
325        pub sem_num: c_ushort,
326        pub sem_op: c_short,
327        pub sem_flg: c_short,
328    }
329
330    pub struct input_event {
331        // FIXME(1.0): Change to the commented variant, see https://github.com/rust-lang/libc/pull/4148#discussion_r1857511742
332        #[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))]
333        pub time: crate::timeval,
334        // #[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))]
335        // pub input_event_sec: time_t,
336        // #[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))]
337        // pub input_event_usec: suseconds_t,
338        // #[cfg(target_arch = "sparc64")]
339        // _pad1: c_int,
340        #[cfg(all(target_pointer_width = "32", linux_time_bits64))]
341        pub input_event_sec: c_ulong,
342
343        #[cfg(all(target_pointer_width = "32", linux_time_bits64))]
344        pub input_event_usec: c_ulong,
345
346        pub type_: __u16,
347        pub code: __u16,
348        pub value: __s32,
349    }
350
351    pub struct input_id {
352        pub bustype: __u16,
353        pub vendor: __u16,
354        pub product: __u16,
355        pub version: __u16,
356    }
357
358    pub struct input_absinfo {
359        pub value: __s32,
360        pub minimum: __s32,
361        pub maximum: __s32,
362        pub fuzz: __s32,
363        pub flat: __s32,
364        pub resolution: __s32,
365    }
366
367    pub struct input_keymap_entry {
368        pub flags: __u8,
369        pub len: __u8,
370        pub index: __u16,
371        pub keycode: __u32,
372        pub scancode: [__u8; 32],
373    }
374
375    pub struct input_mask {
376        pub type_: __u32,
377        pub codes_size: __u32,
378        pub codes_ptr: crate::__u64,
379    }
380
381    pub struct ff_replay {
382        pub length: __u16,
383        pub delay: __u16,
384    }
385
386    pub struct ff_trigger {
387        pub button: __u16,
388        pub interval: __u16,
389    }
390
391    pub struct ff_envelope {
392        pub attack_length: __u16,
393        pub attack_level: __u16,
394        pub fade_length: __u16,
395        pub fade_level: __u16,
396    }
397
398    pub struct ff_constant_effect {
399        pub level: __s16,
400        pub envelope: ff_envelope,
401    }
402
403    pub struct ff_ramp_effect {
404        pub start_level: __s16,
405        pub end_level: __s16,
406        pub envelope: ff_envelope,
407    }
408
409    pub struct ff_condition_effect {
410        pub right_saturation: __u16,
411        pub left_saturation: __u16,
412
413        pub right_coeff: __s16,
414        pub left_coeff: __s16,
415
416        pub deadband: __u16,
417        pub center: __s16,
418    }
419
420    pub struct ff_periodic_effect {
421        pub waveform: __u16,
422        pub period: __u16,
423        pub magnitude: __s16,
424        pub offset: __s16,
425        pub phase: __u16,
426
427        pub envelope: ff_envelope,
428
429        pub custom_len: __u32,
430        pub custom_data: *mut __s16,
431    }
432
433    pub struct ff_rumble_effect {
434        pub strong_magnitude: __u16,
435        pub weak_magnitude: __u16,
436    }
437
438    pub struct ff_effect {
439        pub type_: __u16,
440        pub id: __s16,
441        pub direction: __u16,
442        pub trigger: ff_trigger,
443        pub replay: ff_replay,
444        // FIXME(1.0): this is actually a union
445        #[cfg(target_pointer_width = "64")]
446        pub u: [u64; 4],
447        #[cfg(target_pointer_width = "32")]
448        pub u: [u32; 7],
449    }
450
451    pub struct uinput_ff_upload {
452        pub request_id: __u32,
453        pub retval: __s32,
454        pub effect: ff_effect,
455        pub old: ff_effect,
456    }
457
458    pub struct uinput_ff_erase {
459        pub request_id: __u32,
460        pub retval: __s32,
461        pub effect_id: __u32,
462    }
463
464    pub struct uinput_abs_setup {
465        pub code: __u16,
466        pub absinfo: input_absinfo,
467    }
468
469    pub struct dl_phdr_info {
470        #[cfg(target_pointer_width = "64")]
471        pub dlpi_addr: Elf64_Addr,
472        #[cfg(target_pointer_width = "32")]
473        pub dlpi_addr: Elf32_Addr,
474
475        pub dlpi_name: *const c_char,
476
477        #[cfg(target_pointer_width = "64")]
478        pub dlpi_phdr: *const Elf64_Phdr,
479        #[cfg(target_pointer_width = "32")]
480        pub dlpi_phdr: *const Elf32_Phdr,
481
482        #[cfg(target_pointer_width = "64")]
483        pub dlpi_phnum: Elf64_Half,
484        #[cfg(target_pointer_width = "32")]
485        pub dlpi_phnum: Elf32_Half,
486
487        // As of uClibc 1.0.36, the following fields are
488        // gated behind a "#if 0" block which always evaluates
489        // to false. So I'm just removing these, and if uClibc changes
490        // the #if block in the future to include the following fields, these
491        // will probably need including here. tsidea, skrap
492        // QNX (NTO) platform does not define these fields
493        #[cfg(not(any(target_env = "uclibc", target_os = "nto")))]
494        pub dlpi_adds: c_ulonglong,
495        #[cfg(not(any(target_env = "uclibc", target_os = "nto")))]
496        pub dlpi_subs: c_ulonglong,
497        #[cfg(not(any(target_env = "uclibc", target_os = "nto")))]
498        pub dlpi_tls_modid: size_t,
499        #[cfg(not(any(target_env = "uclibc", target_os = "nto")))]
500        pub dlpi_tls_data: *mut c_void,
501    }
502
503    pub struct Elf32_Ehdr {
504        pub e_ident: [c_uchar; 16],
505        pub e_type: Elf32_Half,
506        pub e_machine: Elf32_Half,
507        pub e_version: Elf32_Word,
508        pub e_entry: Elf32_Addr,
509        pub e_phoff: Elf32_Off,
510        pub e_shoff: Elf32_Off,
511        pub e_flags: Elf32_Word,
512        pub e_ehsize: Elf32_Half,
513        pub e_phentsize: Elf32_Half,
514        pub e_phnum: Elf32_Half,
515        pub e_shentsize: Elf32_Half,
516        pub e_shnum: Elf32_Half,
517        pub e_shstrndx: Elf32_Half,
518    }
519
520    pub struct Elf64_Ehdr {
521        pub e_ident: [c_uchar; 16],
522        pub e_type: Elf64_Half,
523        pub e_machine: Elf64_Half,
524        pub e_version: Elf64_Word,
525        pub e_entry: Elf64_Addr,
526        pub e_phoff: Elf64_Off,
527        pub e_shoff: Elf64_Off,
528        pub e_flags: Elf64_Word,
529        pub e_ehsize: Elf64_Half,
530        pub e_phentsize: Elf64_Half,
531        pub e_phnum: Elf64_Half,
532        pub e_shentsize: Elf64_Half,
533        pub e_shnum: Elf64_Half,
534        pub e_shstrndx: Elf64_Half,
535    }
536
537    pub struct Elf32_Sym {
538        pub st_name: Elf32_Word,
539        pub st_value: Elf32_Addr,
540        pub st_size: Elf32_Word,
541        pub st_info: c_uchar,
542        pub st_other: c_uchar,
543        pub st_shndx: Elf32_Section,
544    }
545
546    pub struct Elf64_Sym {
547        pub st_name: Elf64_Word,
548        pub st_info: c_uchar,
549        pub st_other: c_uchar,
550        pub st_shndx: Elf64_Section,
551        pub st_value: Elf64_Addr,
552        pub st_size: Elf64_Xword,
553    }
554
555    pub struct Elf32_Phdr {
556        pub p_type: Elf32_Word,
557        pub p_offset: Elf32_Off,
558        pub p_vaddr: Elf32_Addr,
559        pub p_paddr: Elf32_Addr,
560        pub p_filesz: Elf32_Word,
561        pub p_memsz: Elf32_Word,
562        pub p_flags: Elf32_Word,
563        pub p_align: Elf32_Word,
564    }
565
566    pub struct Elf64_Phdr {
567        pub p_type: Elf64_Word,
568        pub p_flags: Elf64_Word,
569        pub p_offset: Elf64_Off,
570        pub p_vaddr: Elf64_Addr,
571        pub p_paddr: Elf64_Addr,
572        pub p_filesz: Elf64_Xword,
573        pub p_memsz: Elf64_Xword,
574        pub p_align: Elf64_Xword,
575    }
576
577    pub struct Elf32_Shdr {
578        pub sh_name: Elf32_Word,
579        pub sh_type: Elf32_Word,
580        pub sh_flags: Elf32_Word,
581        pub sh_addr: Elf32_Addr,
582        pub sh_offset: Elf32_Off,
583        pub sh_size: Elf32_Word,
584        pub sh_link: Elf32_Word,
585        pub sh_info: Elf32_Word,
586        pub sh_addralign: Elf32_Word,
587        pub sh_entsize: Elf32_Word,
588    }
589
590    pub struct Elf64_Shdr {
591        pub sh_name: Elf64_Word,
592        pub sh_type: Elf64_Word,
593        pub sh_flags: Elf64_Xword,
594        pub sh_addr: Elf64_Addr,
595        pub sh_offset: Elf64_Off,
596        pub sh_size: Elf64_Xword,
597        pub sh_link: Elf64_Word,
598        pub sh_info: Elf64_Word,
599        pub sh_addralign: Elf64_Xword,
600        pub sh_entsize: Elf64_Xword,
601    }
602
603    pub struct __c_anonymous_elf32_rel {
604        pub r_offset: Elf32_Addr,
605        pub r_info: Elf32_Word,
606    }
607
608    pub struct __c_anonymous_elf64_rel {
609        pub r_offset: Elf64_Addr,
610        pub r_info: Elf64_Xword,
611    }
612
613    pub struct __c_anonymous__kernel_fsid_t {
614        pub val: [c_int; 2],
615    }
616
617    pub struct ucred {
618        pub pid: crate::pid_t,
619        pub uid: crate::uid_t,
620        pub gid: crate::gid_t,
621    }
622
623    pub struct mntent {
624        pub mnt_fsname: *mut c_char,
625        pub mnt_dir: *mut c_char,
626        pub mnt_type: *mut c_char,
627        pub mnt_opts: *mut c_char,
628        pub mnt_freq: c_int,
629        pub mnt_passno: c_int,
630    }
631
632    pub struct posix_spawn_file_actions_t {
633        __allocated: c_int,
634        __used: c_int,
635        __actions: *mut c_int,
636        __pad: [c_int; 16],
637    }
638
639    pub struct posix_spawnattr_t {
640        __flags: c_short,
641        __pgrp: crate::pid_t,
642        __sd: crate::sigset_t,
643        __ss: crate::sigset_t,
644        #[cfg(any(target_env = "musl", target_env = "ohos"))]
645        __prio: c_int,
646        #[cfg(not(any(target_env = "musl", target_env = "ohos")))]
647        __sp: crate::sched_param,
648        __policy: c_int,
649        __pad: [c_int; 16],
650    }
651
652    pub struct genlmsghdr {
653        pub cmd: u8,
654        pub version: u8,
655        pub reserved: u16,
656    }
657
658    pub struct in6_pktinfo {
659        pub ipi6_addr: crate::in6_addr,
660        pub ipi6_ifindex: c_uint,
661    }
662
663    pub struct arpd_request {
664        pub req: c_ushort,
665        pub ip: u32,
666        pub dev: c_ulong,
667        pub stamp: c_ulong,
668        pub updated: c_ulong,
669        pub ha: [c_uchar; crate::MAX_ADDR_LEN],
670    }
671
672    pub struct inotify_event {
673        pub wd: c_int,
674        pub mask: u32,
675        pub cookie: u32,
676        pub len: u32,
677    }
678
679    pub struct fanotify_response {
680        pub fd: c_int,
681        pub response: __u32,
682    }
683
684    pub struct fanotify_event_info_header {
685        pub info_type: __u8,
686        pub pad: __u8,
687        pub len: __u16,
688    }
689
690    pub struct fanotify_event_info_fid {
691        pub hdr: fanotify_event_info_header,
692        pub fsid: crate::__kernel_fsid_t,
693        pub handle: [c_uchar; 0],
694    }
695
696    pub struct sockaddr_vm {
697        pub svm_family: crate::sa_family_t,
698        pub svm_reserved1: c_ushort,
699        pub svm_port: c_uint,
700        pub svm_cid: c_uint,
701        pub svm_zero: [u8; 4],
702    }
703
704    pub struct regmatch_t {
705        pub rm_so: regoff_t,
706        pub rm_eo: regoff_t,
707    }
708
709    pub struct sock_extended_err {
710        pub ee_errno: u32,
711        pub ee_origin: u8,
712        pub ee_type: u8,
713        pub ee_code: u8,
714        pub ee_pad: u8,
715        pub ee_info: u32,
716        pub ee_data: u32,
717    }
718
719    // linux/can.h
720    pub struct __c_anonymous_sockaddr_can_tp {
721        pub rx_id: canid_t,
722        pub tx_id: canid_t,
723    }
724
725    pub struct __c_anonymous_sockaddr_can_j1939 {
726        pub name: u64,
727        pub pgn: u32,
728        pub addr: u8,
729    }
730
731    pub struct can_filter {
732        pub can_id: canid_t,
733        pub can_mask: canid_t,
734    }
735
736    // linux/can/j1939.h
737    pub struct j1939_filter {
738        pub name: name_t,
739        pub name_mask: name_t,
740        pub pgn: pgn_t,
741        pub pgn_mask: pgn_t,
742        pub addr: u8,
743        pub addr_mask: u8,
744    }
745
746    // linux/filter.h
747    pub struct sock_filter {
748        pub code: __u16,
749        pub jt: __u8,
750        pub jf: __u8,
751        pub k: __u32,
752    }
753
754    pub struct sock_fprog {
755        pub len: c_ushort,
756        pub filter: *mut sock_filter,
757    }
758
759    // linux/seccomp.h
760    pub struct seccomp_data {
761        pub nr: c_int,
762        pub arch: __u32,
763        pub instruction_pointer: crate::__u64,
764        pub args: [crate::__u64; 6],
765    }
766
767    pub struct seccomp_notif_sizes {
768        pub seccomp_notif: __u16,
769        pub seccomp_notif_resp: __u16,
770        pub seccomp_data: __u16,
771    }
772
773    pub struct seccomp_notif {
774        pub id: crate::__u64,
775        pub pid: __u32,
776        pub flags: __u32,
777        pub data: seccomp_data,
778    }
779
780    pub struct seccomp_notif_resp {
781        pub id: crate::__u64,
782        pub val: crate::__s64,
783        pub error: __s32,
784        pub flags: __u32,
785    }
786
787    pub struct seccomp_notif_addfd {
788        pub id: crate::__u64,
789        pub flags: __u32,
790        pub srcfd: __u32,
791        pub newfd: __u32,
792        pub newfd_flags: __u32,
793    }
794
795    pub struct nlmsghdr {
796        pub nlmsg_len: u32,
797        pub nlmsg_type: u16,
798        pub nlmsg_flags: u16,
799        pub nlmsg_seq: u32,
800        pub nlmsg_pid: u32,
801    }
802
803    pub struct nlmsgerr {
804        pub error: c_int,
805        pub msg: nlmsghdr,
806    }
807
808    pub struct nlattr {
809        pub nla_len: u16,
810        pub nla_type: u16,
811    }
812
813    pub struct file_clone_range {
814        pub src_fd: crate::__s64,
815        pub src_offset: crate::__u64,
816        pub src_length: crate::__u64,
817        pub dest_offset: crate::__u64,
818    }
819
820    pub struct __c_anonymous_ifru_map {
821        pub mem_start: c_ulong,
822        pub mem_end: c_ulong,
823        pub base_addr: c_ushort,
824        pub irq: c_uchar,
825        pub dma: c_uchar,
826        pub port: c_uchar,
827    }
828
829    pub struct in6_ifreq {
830        pub ifr6_addr: crate::in6_addr,
831        pub ifr6_prefixlen: u32,
832        pub ifr6_ifindex: c_int,
833    }
834
835    pub struct option {
836        pub name: *const c_char,
837        pub has_arg: c_int,
838        pub flag: *mut c_int,
839        pub val: c_int,
840    }
841
842    // linux/openat2.h
843    #[non_exhaustive]
844    pub struct open_how {
845        pub flags: crate::__u64,
846        pub mode: crate::__u64,
847        pub resolve: crate::__u64,
848    }
849
850    // linux/ptp_clock.h
851    pub struct ptp_clock_time {
852        pub sec: crate::__s64,
853        pub nsec: __u32,
854        pub reserved: __u32,
855    }
856
857    pub struct ptp_extts_request {
858        pub index: c_uint,
859        pub flags: c_uint,
860        pub rsv: [c_uint; 2],
861    }
862
863    pub struct ptp_sys_offset_extended {
864        pub n_samples: c_uint,
865        pub clockid: __kernel_clockid_t,
866        pub rsv: [c_uint; 2],
867        pub ts: [[ptp_clock_time; 3]; PTP_MAX_SAMPLES as usize],
868    }
869
870    pub struct ptp_sys_offset_precise {
871        pub device: ptp_clock_time,
872        pub sys_realtime: ptp_clock_time,
873        pub sys_monoraw: ptp_clock_time,
874        pub rsv: [c_uint; 4],
875    }
876
877    pub struct ptp_extts_event {
878        pub t: ptp_clock_time,
879        index: c_uint,
880        flags: c_uint,
881        rsv: [c_uint; 2],
882    }
883
884    // linux/sctp.h
885
886    pub struct sctp_initmsg {
887        pub sinit_num_ostreams: __u16,
888        pub sinit_max_instreams: __u16,
889        pub sinit_max_attempts: __u16,
890        pub sinit_max_init_timeo: __u16,
891    }
892
893    pub struct sctp_sndrcvinfo {
894        pub sinfo_stream: __u16,
895        pub sinfo_ssn: __u16,
896        pub sinfo_flags: __u16,
897        pub sinfo_ppid: __u32,
898        pub sinfo_context: __u32,
899        pub sinfo_timetolive: __u32,
900        pub sinfo_tsn: __u32,
901        pub sinfo_cumtsn: __u32,
902        pub sinfo_assoc_id: crate::sctp_assoc_t,
903    }
904
905    pub struct sctp_sndinfo {
906        pub snd_sid: __u16,
907        pub snd_flags: __u16,
908        pub snd_ppid: __u32,
909        pub snd_context: __u32,
910        pub snd_assoc_id: crate::sctp_assoc_t,
911    }
912
913    pub struct sctp_rcvinfo {
914        pub rcv_sid: __u16,
915        pub rcv_ssn: __u16,
916        pub rcv_flags: __u16,
917        pub rcv_ppid: __u32,
918        pub rcv_tsn: __u32,
919        pub rcv_cumtsn: __u32,
920        pub rcv_context: __u32,
921        pub rcv_assoc_id: crate::sctp_assoc_t,
922    }
923
924    pub struct sctp_nxtinfo {
925        pub nxt_sid: __u16,
926        pub nxt_flags: __u16,
927        pub nxt_ppid: __u32,
928        pub nxt_length: __u32,
929        pub nxt_assoc_id: crate::sctp_assoc_t,
930    }
931
932    pub struct sctp_prinfo {
933        pub pr_policy: __u16,
934        pub pr_value: __u32,
935    }
936
937    pub struct sctp_authinfo {
938        pub auth_keynumber: __u16,
939    }
940
941    pub struct rlimit64 {
942        pub rlim_cur: rlim64_t,
943        pub rlim_max: rlim64_t,
944    }
945
946    // linux/tls.h
947
948    pub struct tls_crypto_info {
949        pub version: __u16,
950        pub cipher_type: __u16,
951    }
952
953    pub struct tls12_crypto_info_aes_gcm_128 {
954        pub info: tls_crypto_info,
955        pub iv: [c_uchar; TLS_CIPHER_AES_GCM_128_IV_SIZE],
956        pub key: [c_uchar; TLS_CIPHER_AES_GCM_128_KEY_SIZE],
957        pub salt: [c_uchar; TLS_CIPHER_AES_GCM_128_SALT_SIZE],
958        pub rec_seq: [c_uchar; TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE],
959    }
960
961    pub struct tls12_crypto_info_aes_gcm_256 {
962        pub info: tls_crypto_info,
963        pub iv: [c_uchar; TLS_CIPHER_AES_GCM_256_IV_SIZE],
964        pub key: [c_uchar; TLS_CIPHER_AES_GCM_256_KEY_SIZE],
965        pub salt: [c_uchar; TLS_CIPHER_AES_GCM_256_SALT_SIZE],
966        pub rec_seq: [c_uchar; TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE],
967    }
968
969    pub struct tls12_crypto_info_chacha20_poly1305 {
970        pub info: tls_crypto_info,
971        pub iv: [c_uchar; TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE],
972        pub key: [c_uchar; TLS_CIPHER_CHACHA20_POLY1305_KEY_SIZE],
973        pub salt: [c_uchar; TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE],
974        pub rec_seq: [c_uchar; TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE],
975    }
976
977    // linux/wireless.h
978
979    pub struct iw_param {
980        pub value: __s32,
981        pub fixed: __u8,
982        pub disabled: __u8,
983        pub flags: __u16,
984    }
985
986    pub struct iw_point {
987        pub pointer: *mut c_void,
988        pub length: __u16,
989        pub flags: __u16,
990    }
991
992    pub struct iw_freq {
993        pub m: __s32,
994        pub e: __s16,
995        pub i: __u8,
996        pub flags: __u8,
997    }
998
999    pub struct iw_quality {
1000        pub qual: __u8,
1001        pub level: __u8,
1002        pub noise: __u8,
1003        pub updated: __u8,
1004    }
1005
1006    pub struct iw_discarded {
1007        pub nwid: __u32,
1008        pub code: __u32,
1009        pub fragment: __u32,
1010        pub retries: __u32,
1011        pubmisc: __u32,
1012    }
1013
1014    pub struct iw_missed {
1015        pub beacon: __u32,
1016    }
1017
1018    pub struct iw_scan_req {
1019        pub scan_type: __u8,
1020        pub essid_len: __u8,
1021        pub num_channels: __u8,
1022        pub flags: __u8,
1023        pub bssid: crate::sockaddr,
1024        pub essid: [__u8; IW_ESSID_MAX_SIZE],
1025        pub min_channel_time: __u32,
1026        pub max_channel_time: __u32,
1027        pub channel_list: [iw_freq; IW_MAX_FREQUENCIES],
1028    }
1029
1030    pub struct iw_encode_ext {
1031        pub ext_flags: __u32,
1032        pub tx_seq: [__u8; IW_ENCODE_SEQ_MAX_SIZE],
1033        pub rx_seq: [__u8; IW_ENCODE_SEQ_MAX_SIZE],
1034        pub addr: crate::sockaddr,
1035        pub alg: __u16,
1036        pub key_len: __u16,
1037        pub key: [__u8; 0],
1038    }
1039
1040    pub struct iw_pmksa {
1041        pub cmd: __u32,
1042        pub bssid: crate::sockaddr,
1043        pub pmkid: [__u8; IW_PMKID_LEN],
1044    }
1045
1046    pub struct iw_pmkid_cand {
1047        pub flags: __u32,
1048        pub index: __u32,
1049        pub bssid: crate::sockaddr,
1050    }
1051
1052    pub struct iw_statistics {
1053        pub status: __u16,
1054        pub qual: iw_quality,
1055        pub discard: iw_discarded,
1056        pub miss: iw_missed,
1057    }
1058
1059    pub struct iw_range {
1060        pub throughput: __u32,
1061        pub min_nwid: __u32,
1062        pub max_nwid: __u32,
1063        pub old_num_channels: __u16,
1064        pub old_num_frequency: __u8,
1065        pub scan_capa: __u8,
1066        pub event_capa: [__u32; 6],
1067        pub sensitivity: __s32,
1068        pub max_qual: iw_quality,
1069        pub avg_qual: iw_quality,
1070        pub num_bitrates: __u8,
1071        pub bitrate: [__s32; IW_MAX_BITRATES],
1072        pub min_rts: __s32,
1073        pub max_rts: __s32,
1074        pub min_frag: __s32,
1075        pub max_frag: __s32,
1076        pub min_pmp: __s32,
1077        pub max_pmp: __s32,
1078        pub min_pmt: __s32,
1079        pub max_pmt: __s32,
1080        pub pmp_flags: __u16,
1081        pub pmt_flags: __u16,
1082        pub pm_capa: __u16,
1083        pub encoding_size: [__u16; IW_MAX_ENCODING_SIZES],
1084        pub num_encoding_sizes: __u8,
1085        pub max_encoding_tokens: __u8,
1086        pub encoding_login_index: __u8,
1087        pub txpower_capa: __u16,
1088        pub num_txpower: __u8,
1089        pub txpower: [__s32; IW_MAX_TXPOWER],
1090        pub we_version_compiled: __u8,
1091        pub we_version_source: __u8,
1092        pub retry_capa: __u16,
1093        pub retry_flags: __u16,
1094        pub r_time_flags: __u16,
1095        pub min_retry: __s32,
1096        pub max_retry: __s32,
1097        pub min_r_time: __s32,
1098        pub max_r_time: __s32,
1099        pub num_channels: __u16,
1100        pub num_frequency: __u8,
1101        pub freq: [iw_freq; IW_MAX_FREQUENCIES],
1102        pub enc_capa: __u32,
1103    }
1104
1105    pub struct iw_priv_args {
1106        pub cmd: __u32,
1107        pub set_args: __u16,
1108        pub get_args: __u16,
1109        pub name: [c_char; crate::IFNAMSIZ],
1110    }
1111
1112    // #include <linux/eventpoll.h>
1113
1114    pub struct epoll_params {
1115        pub busy_poll_usecs: u32,
1116        pub busy_poll_budget: u16,
1117        pub prefer_busy_poll: u8,
1118        pub __pad: u8, // Must be zero
1119    }
1120
1121    #[cfg_attr(
1122        any(
1123            target_pointer_width = "32",
1124            target_arch = "x86_64",
1125            target_arch = "powerpc64",
1126            target_arch = "mips64",
1127            target_arch = "mips64r6",
1128            target_arch = "s390x",
1129            target_arch = "sparc64",
1130            target_arch = "aarch64",
1131            target_arch = "riscv64",
1132            target_arch = "riscv32",
1133            target_arch = "loongarch64"
1134        ),
1135        repr(align(4))
1136    )]
1137    #[cfg_attr(
1138        not(any(
1139            target_pointer_width = "32",
1140            target_arch = "x86_64",
1141            target_arch = "powerpc64",
1142            target_arch = "mips64",
1143            target_arch = "mips64r6",
1144            target_arch = "s390x",
1145            target_arch = "sparc64",
1146            target_arch = "aarch64",
1147            target_arch = "riscv64",
1148            target_arch = "riscv32",
1149            target_arch = "loongarch64"
1150        )),
1151        repr(align(8))
1152    )]
1153    pub struct pthread_mutexattr_t {
1154        #[doc(hidden)]
1155        size: [u8; crate::__SIZEOF_PTHREAD_MUTEXATTR_T],
1156    }
1157
1158    #[cfg_attr(
1159        any(target_env = "musl", target_env = "ohos", target_pointer_width = "32"),
1160        repr(align(4))
1161    )]
1162    #[cfg_attr(
1163        all(
1164            not(target_env = "musl"),
1165            not(target_env = "ohos"),
1166            target_pointer_width = "64"
1167        ),
1168        repr(align(8))
1169    )]
1170    pub struct pthread_rwlockattr_t {
1171        #[doc(hidden)]
1172        size: [u8; crate::__SIZEOF_PTHREAD_RWLOCKATTR_T],
1173    }
1174
1175    #[repr(align(4))]
1176    pub struct pthread_condattr_t {
1177        #[doc(hidden)]
1178        size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T],
1179    }
1180
1181    #[repr(align(4))]
1182    pub struct pthread_barrierattr_t {
1183        #[doc(hidden)]
1184        size: [u8; crate::__SIZEOF_PTHREAD_BARRIERATTR_T],
1185    }
1186
1187    #[repr(align(8))]
1188    pub struct fanotify_event_metadata {
1189        pub event_len: __u32,
1190        pub vers: __u8,
1191        pub reserved: __u8,
1192        pub metadata_len: __u16,
1193        pub mask: __u64,
1194        pub fd: c_int,
1195        pub pid: c_int,
1196    }
1197
1198    // linux/ptp_clock.h
1199
1200    pub struct ptp_sys_offset {
1201        pub n_samples: c_uint,
1202        pub rsv: [c_uint; 3],
1203        // FIXME(garando): replace length with `2 * PTP_MAX_SAMPLES + 1` when supported
1204        pub ts: [ptp_clock_time; 51],
1205    }
1206
1207    pub struct ptp_pin_desc {
1208        pub name: [c_char; 64],
1209        pub index: c_uint,
1210        pub func: c_uint,
1211        pub chan: c_uint,
1212        pub rsv: [c_uint; 5],
1213    }
1214
1215    pub struct ptp_clock_caps {
1216        pub max_adj: c_int,
1217        pub n_alarm: c_int,
1218        pub n_ext_ts: c_int,
1219        pub n_per_out: c_int,
1220        pub pps: c_int,
1221        pub n_pins: c_int,
1222        pub cross_timestamping: c_int,
1223        pub adjust_phase: c_int,
1224        pub max_phase_adj: c_int,
1225        pub rsv: [c_int; 11],
1226    }
1227
1228    // linux/if_xdp.h
1229
1230    pub struct sockaddr_xdp {
1231        pub sxdp_family: crate::__u16,
1232        pub sxdp_flags: crate::__u16,
1233        pub sxdp_ifindex: crate::__u32,
1234        pub sxdp_queue_id: crate::__u32,
1235        pub sxdp_shared_umem_fd: crate::__u32,
1236    }
1237
1238    pub struct xdp_ring_offset {
1239        pub producer: crate::__u64,
1240        pub consumer: crate::__u64,
1241        pub desc: crate::__u64,
1242        pub flags: crate::__u64,
1243    }
1244
1245    pub struct xdp_mmap_offsets {
1246        pub rx: xdp_ring_offset,
1247        pub tx: xdp_ring_offset,
1248        pub fr: xdp_ring_offset,
1249        pub cr: xdp_ring_offset,
1250    }
1251
1252    pub struct xdp_ring_offset_v1 {
1253        pub producer: crate::__u64,
1254        pub consumer: crate::__u64,
1255        pub desc: crate::__u64,
1256    }
1257
1258    pub struct xdp_mmap_offsets_v1 {
1259        pub rx: xdp_ring_offset_v1,
1260        pub tx: xdp_ring_offset_v1,
1261        pub fr: xdp_ring_offset_v1,
1262        pub cr: xdp_ring_offset_v1,
1263    }
1264
1265    pub struct xdp_umem_reg {
1266        pub addr: crate::__u64,
1267        pub len: crate::__u64,
1268        pub chunk_size: crate::__u32,
1269        pub headroom: crate::__u32,
1270        pub flags: crate::__u32,
1271        pub tx_metadata_len: crate::__u32,
1272    }
1273
1274    pub struct xdp_umem_reg_v1 {
1275        pub addr: crate::__u64,
1276        pub len: crate::__u64,
1277        pub chunk_size: crate::__u32,
1278        pub headroom: crate::__u32,
1279    }
1280
1281    pub struct xdp_statistics {
1282        pub rx_dropped: crate::__u64,
1283        pub rx_invalid_descs: crate::__u64,
1284        pub tx_invalid_descs: crate::__u64,
1285        pub rx_ring_full: crate::__u64,
1286        pub rx_fill_ring_empty_descs: crate::__u64,
1287        pub tx_ring_empty_descs: crate::__u64,
1288    }
1289
1290    pub struct xdp_statistics_v1 {
1291        pub rx_dropped: crate::__u64,
1292        pub rx_invalid_descs: crate::__u64,
1293        pub tx_invalid_descs: crate::__u64,
1294    }
1295
1296    pub struct xdp_options {
1297        pub flags: crate::__u32,
1298    }
1299
1300    pub struct xdp_desc {
1301        pub addr: crate::__u64,
1302        pub len: crate::__u32,
1303        pub options: crate::__u32,
1304    }
1305
1306    pub struct xsk_tx_metadata_completion {
1307        pub tx_timestamp: crate::__u64,
1308    }
1309
1310    pub struct xsk_tx_metadata_request {
1311        pub csum_start: __u16,
1312        pub csum_offset: __u16,
1313    }
1314
1315    // linux/mount.h
1316
1317    pub struct mount_attr {
1318        pub attr_set: crate::__u64,
1319        pub attr_clr: crate::__u64,
1320        pub propagation: crate::__u64,
1321        pub userns_fd: crate::__u64,
1322    }
1323
1324    // linux/uio.h
1325
1326    pub struct dmabuf_cmsg {
1327        pub frag_offset: crate::__u64,
1328        pub frag_size: crate::__u32,
1329        pub frag_token: crate::__u32,
1330        pub dmabuf_id: crate::__u32,
1331        pub flags: crate::__u32,
1332    }
1333
1334    pub struct dmabuf_token {
1335        pub token_start: crate::__u32,
1336        pub token_count: crate::__u32,
1337    }
1338}
1339
1340cfg_if! {
1341    if #[cfg(not(target_arch = "sparc64"))] {
1342        s! {
1343            pub struct iw_thrspy {
1344                pub addr: crate::sockaddr,
1345                pub qual: iw_quality,
1346                pub low: iw_quality,
1347                pub high: iw_quality,
1348            }
1349
1350            pub struct iw_mlme {
1351                pub cmd: __u16,
1352                pub reason_code: __u16,
1353                pub addr: crate::sockaddr,
1354            }
1355
1356            pub struct iw_michaelmicfailure {
1357                pub flags: __u32,
1358                pub src_addr: crate::sockaddr,
1359                pub tsc: [__u8; IW_ENCODE_SEQ_MAX_SIZE],
1360            }
1361
1362            pub struct __c_anonymous_elf32_rela {
1363                pub r_offset: Elf32_Addr,
1364                pub r_info: Elf32_Word,
1365                pub r_addend: Elf32_Sword,
1366            }
1367
1368            pub struct __c_anonymous_elf64_rela {
1369                pub r_offset: Elf64_Addr,
1370                pub r_info: Elf64_Xword,
1371                pub r_addend: Elf64_Sxword,
1372            }
1373        }
1374    }
1375}
1376
1377s_no_extra_traits! {
1378    pub struct sockaddr_nl {
1379        pub nl_family: crate::sa_family_t,
1380        nl_pad: c_ushort,
1381        pub nl_pid: u32,
1382        pub nl_groups: u32,
1383    }
1384
1385    pub struct dirent {
1386        pub d_ino: crate::ino_t,
1387        pub d_off: off_t,
1388        pub d_reclen: c_ushort,
1389        pub d_type: c_uchar,
1390        pub d_name: [c_char; 256],
1391    }
1392
1393    pub struct sockaddr_alg {
1394        pub salg_family: crate::sa_family_t,
1395        pub salg_type: [c_uchar; 14],
1396        pub salg_feat: u32,
1397        pub salg_mask: u32,
1398        pub salg_name: [c_uchar; 64],
1399    }
1400
1401    pub struct uinput_setup {
1402        pub id: input_id,
1403        pub name: [c_char; UINPUT_MAX_NAME_SIZE],
1404        pub ff_effects_max: __u32,
1405    }
1406
1407    pub struct uinput_user_dev {
1408        pub name: [c_char; UINPUT_MAX_NAME_SIZE],
1409        pub id: input_id,
1410        pub ff_effects_max: __u32,
1411        pub absmax: [__s32; ABS_CNT],
1412        pub absmin: [__s32; ABS_CNT],
1413        pub absfuzz: [__s32; ABS_CNT],
1414        pub absflat: [__s32; ABS_CNT],
1415    }
1416
1417    /// WARNING: The `PartialEq`, `Eq` and `Hash` implementations of this
1418    /// type are unsound and will be removed in the future.
1419    #[deprecated(
1420        note = "this struct has unsafe trait implementations that will be \
1421                removed in the future",
1422        since = "0.2.80"
1423    )]
1424    pub struct af_alg_iv {
1425        pub ivlen: u32,
1426        pub iv: [c_uchar; 0],
1427    }
1428
1429    // x32 compatibility
1430    // See https://sourceware.org/bugzilla/show_bug.cgi?id=21279
1431    pub struct mq_attr {
1432        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
1433        pub mq_flags: i64,
1434        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
1435        pub mq_maxmsg: i64,
1436        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
1437        pub mq_msgsize: i64,
1438        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
1439        pub mq_curmsgs: i64,
1440        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
1441        pad: [i64; 4],
1442
1443        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
1444        pub mq_flags: c_long,
1445        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
1446        pub mq_maxmsg: c_long,
1447        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
1448        pub mq_msgsize: c_long,
1449        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
1450        pub mq_curmsgs: c_long,
1451        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
1452        pad: [c_long; 4],
1453    }
1454
1455    pub union __c_anonymous_ifr_ifru {
1456        pub ifru_addr: crate::sockaddr,
1457        pub ifru_dstaddr: crate::sockaddr,
1458        pub ifru_broadaddr: crate::sockaddr,
1459        pub ifru_netmask: crate::sockaddr,
1460        pub ifru_hwaddr: crate::sockaddr,
1461        pub ifru_flags: c_short,
1462        pub ifru_ifindex: c_int,
1463        pub ifru_metric: c_int,
1464        pub ifru_mtu: c_int,
1465        pub ifru_map: __c_anonymous_ifru_map,
1466        pub ifru_slave: [c_char; crate::IFNAMSIZ],
1467        pub ifru_newname: [c_char; crate::IFNAMSIZ],
1468        pub ifru_data: *mut c_char,
1469    }
1470
1471    pub struct ifreq {
1472        /// interface name, e.g. "en0"
1473        pub ifr_name: [c_char; crate::IFNAMSIZ],
1474        pub ifr_ifru: __c_anonymous_ifr_ifru,
1475    }
1476
1477    pub union __c_anonymous_ifc_ifcu {
1478        pub ifcu_buf: *mut c_char,
1479        pub ifcu_req: *mut crate::ifreq,
1480    }
1481
1482    /// Structure used in SIOCGIFCONF request.  Used to retrieve interface configuration for
1483    /// machine (useful for programs which must know all networks accessible).
1484    pub struct ifconf {
1485        /// Size of buffer
1486        pub ifc_len: c_int,
1487        pub ifc_ifcu: __c_anonymous_ifc_ifcu,
1488    }
1489
1490    pub struct hwtstamp_config {
1491        pub flags: c_int,
1492        pub tx_type: c_int,
1493        pub rx_filter: c_int,
1494    }
1495
1496    pub struct dirent64 {
1497        pub d_ino: crate::ino64_t,
1498        pub d_off: off64_t,
1499        pub d_reclen: c_ushort,
1500        pub d_type: c_uchar,
1501        pub d_name: [c_char; 256],
1502    }
1503
1504    pub struct sched_attr {
1505        pub size: __u32,
1506        pub sched_policy: __u32,
1507        pub sched_flags: crate::__u64,
1508        pub sched_nice: __s32,
1509        pub sched_priority: __u32,
1510        pub sched_runtime: crate::__u64,
1511        pub sched_deadline: crate::__u64,
1512        pub sched_period: crate::__u64,
1513    }
1514
1515    #[allow(missing_debug_implementations)]
1516    pub union tpacket_req_u {
1517        pub req: crate::tpacket_req,
1518        pub req3: crate::tpacket_req3,
1519    }
1520
1521    #[allow(missing_debug_implementations)]
1522    pub union tpacket_bd_header_u {
1523        pub bh1: crate::tpacket_hdr_v1,
1524    }
1525
1526    #[allow(missing_debug_implementations)]
1527    pub struct tpacket_block_desc {
1528        pub version: __u32,
1529        pub offset_to_priv: __u32,
1530        pub hdr: crate::tpacket_bd_header_u,
1531    }
1532
1533    #[cfg_attr(
1534        all(
1535            any(target_env = "musl", target_env = "ohos"),
1536            target_pointer_width = "32"
1537        ),
1538        repr(align(4))
1539    )]
1540    #[cfg_attr(
1541        all(
1542            any(target_env = "musl", target_env = "ohos"),
1543            target_pointer_width = "64"
1544        ),
1545        repr(align(8))
1546    )]
1547    #[cfg_attr(
1548        all(
1549            not(any(target_env = "musl", target_env = "ohos")),
1550            target_arch = "x86"
1551        ),
1552        repr(align(4))
1553    )]
1554    #[cfg_attr(
1555        all(
1556            not(any(target_env = "musl", target_env = "ohos")),
1557            not(target_arch = "x86")
1558        ),
1559        repr(align(8))
1560    )]
1561    pub struct pthread_cond_t {
1562        #[doc(hidden)]
1563        size: [u8; crate::__SIZEOF_PTHREAD_COND_T],
1564    }
1565
1566    #[cfg_attr(
1567        all(
1568            target_pointer_width = "32",
1569            any(
1570                target_arch = "mips",
1571                target_arch = "mips32r6",
1572                target_arch = "arm",
1573                target_arch = "hexagon",
1574                target_arch = "m68k",
1575                target_arch = "csky",
1576                target_arch = "powerpc",
1577                target_arch = "sparc",
1578                target_arch = "x86_64",
1579                target_arch = "x86"
1580            )
1581        ),
1582        repr(align(4))
1583    )]
1584    #[cfg_attr(
1585        any(
1586            target_pointer_width = "64",
1587            not(any(
1588                target_arch = "mips",
1589                target_arch = "mips32r6",
1590                target_arch = "arm",
1591                target_arch = "hexagon",
1592                target_arch = "m68k",
1593                target_arch = "csky",
1594                target_arch = "powerpc",
1595                target_arch = "sparc",
1596                target_arch = "x86_64",
1597                target_arch = "x86"
1598            ))
1599        ),
1600        repr(align(8))
1601    )]
1602    pub struct pthread_mutex_t {
1603        #[doc(hidden)]
1604        size: [u8; crate::__SIZEOF_PTHREAD_MUTEX_T],
1605    }
1606
1607    #[cfg_attr(
1608        all(
1609            target_pointer_width = "32",
1610            any(
1611                target_arch = "mips",
1612                target_arch = "mips32r6",
1613                target_arch = "arm",
1614                target_arch = "hexagon",
1615                target_arch = "m68k",
1616                target_arch = "csky",
1617                target_arch = "powerpc",
1618                target_arch = "sparc",
1619                target_arch = "x86_64",
1620                target_arch = "x86"
1621            )
1622        ),
1623        repr(align(4))
1624    )]
1625    #[cfg_attr(
1626        any(
1627            target_pointer_width = "64",
1628            not(any(
1629                target_arch = "mips",
1630                target_arch = "mips32r6",
1631                target_arch = "arm",
1632                target_arch = "hexagon",
1633                target_arch = "m68k",
1634                target_arch = "powerpc",
1635                target_arch = "sparc",
1636                target_arch = "x86_64",
1637                target_arch = "x86"
1638            ))
1639        ),
1640        repr(align(8))
1641    )]
1642    pub struct pthread_rwlock_t {
1643        size: [u8; crate::__SIZEOF_PTHREAD_RWLOCK_T],
1644    }
1645
1646    #[cfg_attr(
1647        all(
1648            target_pointer_width = "32",
1649            any(
1650                target_arch = "mips",
1651                target_arch = "mips32r6",
1652                target_arch = "arm",
1653                target_arch = "hexagon",
1654                target_arch = "m68k",
1655                target_arch = "csky",
1656                target_arch = "powerpc",
1657                target_arch = "sparc",
1658                target_arch = "x86_64",
1659                target_arch = "x86"
1660            )
1661        ),
1662        repr(align(4))
1663    )]
1664    #[cfg_attr(
1665        any(
1666            target_pointer_width = "64",
1667            not(any(
1668                target_arch = "mips",
1669                target_arch = "mips32r6",
1670                target_arch = "arm",
1671                target_arch = "hexagon",
1672                target_arch = "m68k",
1673                target_arch = "csky",
1674                target_arch = "powerpc",
1675                target_arch = "sparc",
1676                target_arch = "x86_64",
1677                target_arch = "x86"
1678            ))
1679        ),
1680        repr(align(8))
1681    )]
1682    pub struct pthread_barrier_t {
1683        size: [u8; crate::__SIZEOF_PTHREAD_BARRIER_T],
1684    }
1685
1686    // linux/net_tstamp.h
1687    #[allow(missing_debug_implementations)]
1688    pub struct sock_txtime {
1689        pub clockid: crate::clockid_t,
1690        pub flags: __u32,
1691    }
1692
1693    // linux/can.h
1694    #[repr(align(8))]
1695    #[allow(missing_debug_implementations)]
1696    pub struct can_frame {
1697        pub can_id: canid_t,
1698        // FIXME(1.0): this field was renamed to `len` in Linux 5.11
1699        pub can_dlc: u8,
1700        __pad: u8,
1701        __res0: u8,
1702        pub len8_dlc: u8,
1703        pub data: [u8; CAN_MAX_DLEN],
1704    }
1705
1706    #[repr(align(8))]
1707    #[allow(missing_debug_implementations)]
1708    pub struct canfd_frame {
1709        pub can_id: canid_t,
1710        pub len: u8,
1711        pub flags: u8,
1712        __res0: u8,
1713        __res1: u8,
1714        pub data: [u8; CANFD_MAX_DLEN],
1715    }
1716
1717    #[repr(align(8))]
1718    #[allow(missing_debug_implementations)]
1719    pub struct canxl_frame {
1720        pub prio: canid_t,
1721        pub flags: u8,
1722        pub sdt: u8,
1723        pub len: u16,
1724        pub af: u32,
1725        pub data: [u8; CANXL_MAX_DLEN],
1726    }
1727
1728    #[allow(missing_debug_implementations)]
1729    pub union __c_anonymous_sockaddr_can_can_addr {
1730        pub tp: __c_anonymous_sockaddr_can_tp,
1731        pub j1939: __c_anonymous_sockaddr_can_j1939,
1732    }
1733
1734    #[allow(missing_debug_implementations)]
1735    pub struct sockaddr_can {
1736        pub can_family: crate::sa_family_t,
1737        pub can_ifindex: c_int,
1738        pub can_addr: __c_anonymous_sockaddr_can_can_addr,
1739    }
1740
1741    // linux/wireless.h
1742    pub union iwreq_data {
1743        pub name: [c_char; crate::IFNAMSIZ],
1744        pub essid: iw_point,
1745        pub nwid: iw_param,
1746        pub freq: iw_freq,
1747        pub sens: iw_param,
1748        pub bitrate: iw_param,
1749        pub txpower: iw_param,
1750        pub rts: iw_param,
1751        pub frag: iw_param,
1752        pub mode: __u32,
1753        pub retry: iw_param,
1754        pub encoding: iw_point,
1755        pub power: iw_param,
1756        pub qual: iw_quality,
1757        pub ap_addr: crate::sockaddr,
1758        pub addr: crate::sockaddr,
1759        pub param: iw_param,
1760        pub data: iw_point,
1761    }
1762
1763    pub struct iw_event {
1764        pub len: __u16,
1765        pub cmd: __u16,
1766        pub u: iwreq_data,
1767    }
1768
1769    pub union __c_anonymous_iwreq {
1770        pub ifrn_name: [c_char; crate::IFNAMSIZ],
1771    }
1772
1773    pub struct iwreq {
1774        pub ifr_ifrn: __c_anonymous_iwreq,
1775        pub u: iwreq_data,
1776    }
1777
1778    // linux/ptp_clock.h
1779    pub union __c_anonymous_ptp_perout_request_1 {
1780        pub start: ptp_clock_time,
1781        pub phase: ptp_clock_time,
1782    }
1783
1784    pub union __c_anonymous_ptp_perout_request_2 {
1785        pub on: ptp_clock_time,
1786        pub rsv: [c_uint; 4],
1787    }
1788
1789    #[allow(missing_debug_implementations)]
1790    pub struct ptp_perout_request {
1791        pub anonymous_1: __c_anonymous_ptp_perout_request_1,
1792        pub period: ptp_clock_time,
1793        pub index: c_uint,
1794        pub flags: c_uint,
1795        pub anonymous_2: __c_anonymous_ptp_perout_request_2,
1796    }
1797
1798    // linux/if_xdp.h
1799    #[allow(missing_debug_implementations)]
1800    pub struct xsk_tx_metadata {
1801        pub flags: crate::__u64,
1802        pub xsk_tx_metadata_union: __c_anonymous_xsk_tx_metadata_union,
1803    }
1804
1805    pub union __c_anonymous_xsk_tx_metadata_union {
1806        pub request: xsk_tx_metadata_request,
1807        pub completion: xsk_tx_metadata_completion,
1808    }
1809}
1810
1811cfg_if! {
1812    if #[cfg(feature = "extra_traits")] {
1813        impl PartialEq for sockaddr_nl {
1814            fn eq(&self, other: &sockaddr_nl) -> bool {
1815                self.nl_family == other.nl_family
1816                    && self.nl_pid == other.nl_pid
1817                    && self.nl_groups == other.nl_groups
1818            }
1819        }
1820        impl Eq for sockaddr_nl {}
1821        impl fmt::Debug for sockaddr_nl {
1822            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1823                f.debug_struct("sockaddr_nl")
1824                    .field("nl_family", &self.nl_family)
1825                    .field("nl_pid", &self.nl_pid)
1826                    .field("nl_groups", &self.nl_groups)
1827                    .finish()
1828            }
1829        }
1830        impl hash::Hash for sockaddr_nl {
1831            fn hash<H: hash::Hasher>(&self, state: &mut H) {
1832                self.nl_family.hash(state);
1833                self.nl_pid.hash(state);
1834                self.nl_groups.hash(state);
1835            }
1836        }
1837
1838        impl PartialEq for dirent {
1839            fn eq(&self, other: &dirent) -> bool {
1840                self.d_ino == other.d_ino
1841                    && self.d_off == other.d_off
1842                    && self.d_reclen == other.d_reclen
1843                    && self.d_type == other.d_type
1844                    && self
1845                        .d_name
1846                        .iter()
1847                        .zip(other.d_name.iter())
1848                        .all(|(a, b)| a == b)
1849            }
1850        }
1851
1852        impl Eq for dirent {}
1853
1854        impl fmt::Debug for dirent {
1855            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1856                f.debug_struct("dirent")
1857                    .field("d_ino", &self.d_ino)
1858                    .field("d_off", &self.d_off)
1859                    .field("d_reclen", &self.d_reclen)
1860                    .field("d_type", &self.d_type)
1861                    // FIXME(debug): .field("d_name", &self.d_name)
1862                    .finish()
1863            }
1864        }
1865
1866        impl hash::Hash for dirent {
1867            fn hash<H: hash::Hasher>(&self, state: &mut H) {
1868                self.d_ino.hash(state);
1869                self.d_off.hash(state);
1870                self.d_reclen.hash(state);
1871                self.d_type.hash(state);
1872                self.d_name.hash(state);
1873            }
1874        }
1875
1876        impl PartialEq for dirent64 {
1877            fn eq(&self, other: &dirent64) -> bool {
1878                self.d_ino == other.d_ino
1879                    && self.d_off == other.d_off
1880                    && self.d_reclen == other.d_reclen
1881                    && self.d_type == other.d_type
1882                    && self
1883                        .d_name
1884                        .iter()
1885                        .zip(other.d_name.iter())
1886                        .all(|(a, b)| a == b)
1887            }
1888        }
1889
1890        impl Eq for dirent64 {}
1891
1892        impl fmt::Debug for dirent64 {
1893            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1894                f.debug_struct("dirent64")
1895                    .field("d_ino", &self.d_ino)
1896                    .field("d_off", &self.d_off)
1897                    .field("d_reclen", &self.d_reclen)
1898                    .field("d_type", &self.d_type)
1899                    // FIXME(debug): .field("d_name", &self.d_name)
1900                    .finish()
1901            }
1902        }
1903
1904        impl hash::Hash for dirent64 {
1905            fn hash<H: hash::Hasher>(&self, state: &mut H) {
1906                self.d_ino.hash(state);
1907                self.d_off.hash(state);
1908                self.d_reclen.hash(state);
1909                self.d_type.hash(state);
1910                self.d_name.hash(state);
1911            }
1912        }
1913
1914        impl PartialEq for pthread_cond_t {
1915            fn eq(&self, other: &pthread_cond_t) -> bool {
1916                self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b)
1917            }
1918        }
1919
1920        impl Eq for pthread_cond_t {}
1921
1922        impl fmt::Debug for pthread_cond_t {
1923            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1924                f.debug_struct("pthread_cond_t")
1925                    // FIXME(debug): .field("size", &self.size)
1926                    .finish()
1927            }
1928        }
1929
1930        impl hash::Hash for pthread_cond_t {
1931            fn hash<H: hash::Hasher>(&self, state: &mut H) {
1932                self.size.hash(state);
1933            }
1934        }
1935
1936        impl PartialEq for pthread_mutex_t {
1937            fn eq(&self, other: &pthread_mutex_t) -> bool {
1938                self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b)
1939            }
1940        }
1941
1942        impl Eq for pthread_mutex_t {}
1943
1944        impl fmt::Debug for pthread_mutex_t {
1945            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1946                f.debug_struct("pthread_mutex_t")
1947                    // FIXME(debug): .field("size", &self.size)
1948                    .finish()
1949            }
1950        }
1951
1952        impl hash::Hash for pthread_mutex_t {
1953            fn hash<H: hash::Hasher>(&self, state: &mut H) {
1954                self.size.hash(state);
1955            }
1956        }
1957
1958        impl PartialEq for pthread_rwlock_t {
1959            fn eq(&self, other: &pthread_rwlock_t) -> bool {
1960                self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b)
1961            }
1962        }
1963
1964        impl Eq for pthread_rwlock_t {}
1965
1966        impl fmt::Debug for pthread_rwlock_t {
1967            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1968                f.debug_struct("pthread_rwlock_t")
1969                    // FIXME(debug): .field("size", &self.size)
1970                    .finish()
1971            }
1972        }
1973
1974        impl hash::Hash for pthread_rwlock_t {
1975            fn hash<H: hash::Hasher>(&self, state: &mut H) {
1976                self.size.hash(state);
1977            }
1978        }
1979
1980        impl PartialEq for pthread_barrier_t {
1981            fn eq(&self, other: &pthread_barrier_t) -> bool {
1982                self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b)
1983            }
1984        }
1985
1986        impl Eq for pthread_barrier_t {}
1987
1988        impl fmt::Debug for pthread_barrier_t {
1989            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1990                f.debug_struct("pthread_barrier_t")
1991                    .field("size", &self.size)
1992                    .finish()
1993            }
1994        }
1995
1996        impl hash::Hash for pthread_barrier_t {
1997            fn hash<H: hash::Hasher>(&self, state: &mut H) {
1998                self.size.hash(state);
1999            }
2000        }
2001
2002        impl PartialEq for sockaddr_alg {
2003            fn eq(&self, other: &sockaddr_alg) -> bool {
2004                self.salg_family == other.salg_family
2005                    && self
2006                        .salg_type
2007                        .iter()
2008                        .zip(other.salg_type.iter())
2009                        .all(|(a, b)| a == b)
2010                    && self.salg_feat == other.salg_feat
2011                    && self.salg_mask == other.salg_mask
2012                    && self
2013                        .salg_name
2014                        .iter()
2015                        .zip(other.salg_name.iter())
2016                        .all(|(a, b)| a == b)
2017            }
2018        }
2019
2020        impl Eq for sockaddr_alg {}
2021
2022        impl fmt::Debug for sockaddr_alg {
2023            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2024                f.debug_struct("sockaddr_alg")
2025                    .field("salg_family", &self.salg_family)
2026                    .field("salg_type", &self.salg_type)
2027                    .field("salg_feat", &self.salg_feat)
2028                    .field("salg_mask", &self.salg_mask)
2029                    .field("salg_name", &&self.salg_name[..])
2030                    .finish()
2031            }
2032        }
2033
2034        impl hash::Hash for sockaddr_alg {
2035            fn hash<H: hash::Hasher>(&self, state: &mut H) {
2036                self.salg_family.hash(state);
2037                self.salg_type.hash(state);
2038                self.salg_feat.hash(state);
2039                self.salg_mask.hash(state);
2040                self.salg_name.hash(state);
2041            }
2042        }
2043
2044        impl PartialEq for uinput_setup {
2045            fn eq(&self, other: &uinput_setup) -> bool {
2046                self.id == other.id
2047                    && self.name[..] == other.name[..]
2048                    && self.ff_effects_max == other.ff_effects_max
2049            }
2050        }
2051        impl Eq for uinput_setup {}
2052
2053        impl fmt::Debug for uinput_setup {
2054            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2055                f.debug_struct("uinput_setup")
2056                    .field("id", &self.id)
2057                    .field("name", &&self.name[..])
2058                    .field("ff_effects_max", &self.ff_effects_max)
2059                    .finish()
2060            }
2061        }
2062
2063        impl hash::Hash for uinput_setup {
2064            fn hash<H: hash::Hasher>(&self, state: &mut H) {
2065                self.id.hash(state);
2066                self.name.hash(state);
2067                self.ff_effects_max.hash(state);
2068            }
2069        }
2070
2071        impl PartialEq for uinput_user_dev {
2072            fn eq(&self, other: &uinput_user_dev) -> bool {
2073                self.name[..] == other.name[..]
2074                    && self.id == other.id
2075                    && self.ff_effects_max == other.ff_effects_max
2076                    && self.absmax[..] == other.absmax[..]
2077                    && self.absmin[..] == other.absmin[..]
2078                    && self.absfuzz[..] == other.absfuzz[..]
2079                    && self.absflat[..] == other.absflat[..]
2080            }
2081        }
2082        impl Eq for uinput_user_dev {}
2083
2084        impl fmt::Debug for uinput_user_dev {
2085            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2086                f.debug_struct("uinput_setup")
2087                    .field("name", &&self.name[..])
2088                    .field("id", &self.id)
2089                    .field("ff_effects_max", &self.ff_effects_max)
2090                    .field("absmax", &&self.absmax[..])
2091                    .field("absmin", &&self.absmin[..])
2092                    .field("absfuzz", &&self.absfuzz[..])
2093                    .field("absflat", &&self.absflat[..])
2094                    .finish()
2095            }
2096        }
2097
2098        impl hash::Hash for uinput_user_dev {
2099            fn hash<H: hash::Hasher>(&self, state: &mut H) {
2100                self.name.hash(state);
2101                self.id.hash(state);
2102                self.ff_effects_max.hash(state);
2103                self.absmax.hash(state);
2104                self.absmin.hash(state);
2105                self.absfuzz.hash(state);
2106                self.absflat.hash(state);
2107            }
2108        }
2109
2110        #[allow(deprecated)]
2111        impl af_alg_iv {
2112            fn as_slice(&self) -> &[u8] {
2113                unsafe { ::core::slice::from_raw_parts(self.iv.as_ptr(), self.ivlen as usize) }
2114            }
2115        }
2116
2117        #[allow(deprecated)]
2118        impl PartialEq for af_alg_iv {
2119            fn eq(&self, other: &af_alg_iv) -> bool {
2120                *self.as_slice() == *other.as_slice()
2121            }
2122        }
2123
2124        #[allow(deprecated)]
2125        impl Eq for af_alg_iv {}
2126
2127        #[allow(deprecated)]
2128        impl fmt::Debug for af_alg_iv {
2129            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2130                f.debug_struct("af_alg_iv")
2131                    .field("ivlen", &self.ivlen)
2132                    .finish()
2133            }
2134        }
2135
2136        #[allow(deprecated)]
2137        impl hash::Hash for af_alg_iv {
2138            fn hash<H: hash::Hasher>(&self, state: &mut H) {
2139                self.as_slice().hash(state);
2140            }
2141        }
2142
2143        impl PartialEq for mq_attr {
2144            fn eq(&self, other: &mq_attr) -> bool {
2145                self.mq_flags == other.mq_flags
2146                    && self.mq_maxmsg == other.mq_maxmsg
2147                    && self.mq_msgsize == other.mq_msgsize
2148                    && self.mq_curmsgs == other.mq_curmsgs
2149            }
2150        }
2151        impl Eq for mq_attr {}
2152        impl fmt::Debug for mq_attr {
2153            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2154                f.debug_struct("mq_attr")
2155                    .field("mq_flags", &self.mq_flags)
2156                    .field("mq_maxmsg", &self.mq_maxmsg)
2157                    .field("mq_msgsize", &self.mq_msgsize)
2158                    .field("mq_curmsgs", &self.mq_curmsgs)
2159                    .finish()
2160            }
2161        }
2162        impl hash::Hash for mq_attr {
2163            fn hash<H: hash::Hasher>(&self, state: &mut H) {
2164                self.mq_flags.hash(state);
2165                self.mq_maxmsg.hash(state);
2166                self.mq_msgsize.hash(state);
2167                self.mq_curmsgs.hash(state);
2168            }
2169        }
2170        impl fmt::Debug for ifreq {
2171            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2172                f.debug_struct("ifreq")
2173                    .field("ifr_name", &self.ifr_name)
2174                    .field("ifr_ifru", &self.ifr_ifru)
2175                    .finish()
2176            }
2177        }
2178        impl fmt::Debug for ifconf {
2179            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2180                f.debug_struct("ifconf")
2181                    .field("ifc_len", &self.ifc_len)
2182                    .field("ifc_ifcu", &self.ifc_ifcu)
2183                    .finish()
2184            }
2185        }
2186        impl fmt::Debug for hwtstamp_config {
2187            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2188                f.debug_struct("hwtstamp_config")
2189                    .field("flags", &self.flags)
2190                    .field("tx_type", &self.tx_type)
2191                    .field("rx_filter", &self.rx_filter)
2192                    .finish()
2193            }
2194        }
2195        impl PartialEq for hwtstamp_config {
2196            fn eq(&self, other: &hwtstamp_config) -> bool {
2197                self.flags == other.flags
2198                    && self.tx_type == other.tx_type
2199                    && self.rx_filter == other.rx_filter
2200            }
2201        }
2202        impl Eq for hwtstamp_config {}
2203        impl hash::Hash for hwtstamp_config {
2204            fn hash<H: hash::Hasher>(&self, state: &mut H) {
2205                self.flags.hash(state);
2206                self.tx_type.hash(state);
2207                self.rx_filter.hash(state);
2208            }
2209        }
2210
2211        impl fmt::Debug for sched_attr {
2212            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2213                f.debug_struct("sched_attr")
2214                    .field("size", &self.size)
2215                    .field("sched_policy", &self.sched_policy)
2216                    .field("sched_flags", &self.sched_flags)
2217                    .field("sched_nice", &self.sched_nice)
2218                    .field("sched_priority", &self.sched_priority)
2219                    .field("sched_runtime", &self.sched_runtime)
2220                    .field("sched_deadline", &self.sched_deadline)
2221                    .field("sched_period", &self.sched_period)
2222                    .finish()
2223            }
2224        }
2225        impl PartialEq for sched_attr {
2226            fn eq(&self, other: &sched_attr) -> bool {
2227                self.size == other.size
2228                    && self.sched_policy == other.sched_policy
2229                    && self.sched_flags == other.sched_flags
2230                    && self.sched_nice == other.sched_nice
2231                    && self.sched_priority == other.sched_priority
2232                    && self.sched_runtime == other.sched_runtime
2233                    && self.sched_deadline == other.sched_deadline
2234                    && self.sched_period == other.sched_period
2235            }
2236        }
2237        impl Eq for sched_attr {}
2238        impl hash::Hash for sched_attr {
2239            fn hash<H: hash::Hasher>(&self, state: &mut H) {
2240                self.size.hash(state);
2241                self.sched_policy.hash(state);
2242                self.sched_flags.hash(state);
2243                self.sched_nice.hash(state);
2244                self.sched_priority.hash(state);
2245                self.sched_runtime.hash(state);
2246                self.sched_deadline.hash(state);
2247                self.sched_period.hash(state);
2248            }
2249        }
2250
2251        impl fmt::Debug for iw_event {
2252            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2253                f.debug_struct("iw_event")
2254                    .field("len", &self.len)
2255                    .field("cmd", &self.cmd)
2256                    .field("u", &self.u)
2257                    .finish()
2258            }
2259        }
2260
2261        impl fmt::Debug for iwreq {
2262            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2263                f.debug_struct("iwreq")
2264                    .field("ifr_ifrn", &self.ifr_ifrn)
2265                    .field("u", &self.u)
2266                    .finish()
2267            }
2268        }
2269    }
2270}
2271
2272cfg_if! {
2273    if #[cfg(any(
2274        target_env = "gnu",
2275        target_env = "musl",
2276        target_env = "ohos"
2277    ))] {
2278        pub const ABDAY_1: crate::nl_item = 0x20000;
2279        pub const ABDAY_2: crate::nl_item = 0x20001;
2280        pub const ABDAY_3: crate::nl_item = 0x20002;
2281        pub const ABDAY_4: crate::nl_item = 0x20003;
2282        pub const ABDAY_5: crate::nl_item = 0x20004;
2283        pub const ABDAY_6: crate::nl_item = 0x20005;
2284        pub const ABDAY_7: crate::nl_item = 0x20006;
2285
2286        pub const DAY_1: crate::nl_item = 0x20007;
2287        pub const DAY_2: crate::nl_item = 0x20008;
2288        pub const DAY_3: crate::nl_item = 0x20009;
2289        pub const DAY_4: crate::nl_item = 0x2000A;
2290        pub const DAY_5: crate::nl_item = 0x2000B;
2291        pub const DAY_6: crate::nl_item = 0x2000C;
2292        pub const DAY_7: crate::nl_item = 0x2000D;
2293
2294        pub const ABMON_1: crate::nl_item = 0x2000E;
2295        pub const ABMON_2: crate::nl_item = 0x2000F;
2296        pub const ABMON_3: crate::nl_item = 0x20010;
2297        pub const ABMON_4: crate::nl_item = 0x20011;
2298        pub const ABMON_5: crate::nl_item = 0x20012;
2299        pub const ABMON_6: crate::nl_item = 0x20013;
2300        pub const ABMON_7: crate::nl_item = 0x20014;
2301        pub const ABMON_8: crate::nl_item = 0x20015;
2302        pub const ABMON_9: crate::nl_item = 0x20016;
2303        pub const ABMON_10: crate::nl_item = 0x20017;
2304        pub const ABMON_11: crate::nl_item = 0x20018;
2305        pub const ABMON_12: crate::nl_item = 0x20019;
2306
2307        pub const MON_1: crate::nl_item = 0x2001A;
2308        pub const MON_2: crate::nl_item = 0x2001B;
2309        pub const MON_3: crate::nl_item = 0x2001C;
2310        pub const MON_4: crate::nl_item = 0x2001D;
2311        pub const MON_5: crate::nl_item = 0x2001E;
2312        pub const MON_6: crate::nl_item = 0x2001F;
2313        pub const MON_7: crate::nl_item = 0x20020;
2314        pub const MON_8: crate::nl_item = 0x20021;
2315        pub const MON_9: crate::nl_item = 0x20022;
2316        pub const MON_10: crate::nl_item = 0x20023;
2317        pub const MON_11: crate::nl_item = 0x20024;
2318        pub const MON_12: crate::nl_item = 0x20025;
2319
2320        pub const AM_STR: crate::nl_item = 0x20026;
2321        pub const PM_STR: crate::nl_item = 0x20027;
2322
2323        pub const D_T_FMT: crate::nl_item = 0x20028;
2324        pub const D_FMT: crate::nl_item = 0x20029;
2325        pub const T_FMT: crate::nl_item = 0x2002A;
2326        pub const T_FMT_AMPM: crate::nl_item = 0x2002B;
2327
2328        pub const ERA: crate::nl_item = 0x2002C;
2329        pub const ERA_D_FMT: crate::nl_item = 0x2002E;
2330        pub const ALT_DIGITS: crate::nl_item = 0x2002F;
2331        pub const ERA_D_T_FMT: crate::nl_item = 0x20030;
2332        pub const ERA_T_FMT: crate::nl_item = 0x20031;
2333
2334        pub const CODESET: crate::nl_item = 14;
2335        pub const CRNCYSTR: crate::nl_item = 0x4000F;
2336        pub const RADIXCHAR: crate::nl_item = 0x10000;
2337        pub const THOUSEP: crate::nl_item = 0x10001;
2338        pub const YESEXPR: crate::nl_item = 0x50000;
2339        pub const NOEXPR: crate::nl_item = 0x50001;
2340        pub const YESSTR: crate::nl_item = 0x50002;
2341        pub const NOSTR: crate::nl_item = 0x50003;
2342    }
2343}
2344
2345pub const RUSAGE_CHILDREN: c_int = -1;
2346pub const L_tmpnam: c_uint = 20;
2347pub const _PC_LINK_MAX: c_int = 0;
2348pub const _PC_MAX_CANON: c_int = 1;
2349pub const _PC_MAX_INPUT: c_int = 2;
2350pub const _PC_NAME_MAX: c_int = 3;
2351pub const _PC_PATH_MAX: c_int = 4;
2352pub const _PC_PIPE_BUF: c_int = 5;
2353pub const _PC_CHOWN_RESTRICTED: c_int = 6;
2354pub const _PC_NO_TRUNC: c_int = 7;
2355pub const _PC_VDISABLE: c_int = 8;
2356pub const _PC_SYNC_IO: c_int = 9;
2357pub const _PC_ASYNC_IO: c_int = 10;
2358pub const _PC_PRIO_IO: c_int = 11;
2359pub const _PC_SOCK_MAXBUF: c_int = 12;
2360pub const _PC_FILESIZEBITS: c_int = 13;
2361pub const _PC_REC_INCR_XFER_SIZE: c_int = 14;
2362pub const _PC_REC_MAX_XFER_SIZE: c_int = 15;
2363pub const _PC_REC_MIN_XFER_SIZE: c_int = 16;
2364pub const _PC_REC_XFER_ALIGN: c_int = 17;
2365pub const _PC_ALLOC_SIZE_MIN: c_int = 18;
2366pub const _PC_SYMLINK_MAX: c_int = 19;
2367pub const _PC_2_SYMLINKS: c_int = 20;
2368
2369pub const MS_NOUSER: c_ulong = 0xffffffff80000000;
2370
2371pub const _SC_ARG_MAX: c_int = 0;
2372pub const _SC_CHILD_MAX: c_int = 1;
2373pub const _SC_CLK_TCK: c_int = 2;
2374pub const _SC_NGROUPS_MAX: c_int = 3;
2375pub const _SC_OPEN_MAX: c_int = 4;
2376pub const _SC_STREAM_MAX: c_int = 5;
2377pub const _SC_TZNAME_MAX: c_int = 6;
2378pub const _SC_JOB_CONTROL: c_int = 7;
2379pub const _SC_SAVED_IDS: c_int = 8;
2380pub const _SC_REALTIME_SIGNALS: c_int = 9;
2381pub const _SC_PRIORITY_SCHEDULING: c_int = 10;
2382pub const _SC_TIMERS: c_int = 11;
2383pub const _SC_ASYNCHRONOUS_IO: c_int = 12;
2384pub const _SC_PRIORITIZED_IO: c_int = 13;
2385pub const _SC_SYNCHRONIZED_IO: c_int = 14;
2386pub const _SC_FSYNC: c_int = 15;
2387pub const _SC_MAPPED_FILES: c_int = 16;
2388pub const _SC_MEMLOCK: c_int = 17;
2389pub const _SC_MEMLOCK_RANGE: c_int = 18;
2390pub const _SC_MEMORY_PROTECTION: c_int = 19;
2391pub const _SC_MESSAGE_PASSING: c_int = 20;
2392pub const _SC_SEMAPHORES: c_int = 21;
2393pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22;
2394pub const _SC_AIO_LISTIO_MAX: c_int = 23;
2395pub const _SC_AIO_MAX: c_int = 24;
2396pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 25;
2397pub const _SC_DELAYTIMER_MAX: c_int = 26;
2398pub const _SC_MQ_OPEN_MAX: c_int = 27;
2399pub const _SC_MQ_PRIO_MAX: c_int = 28;
2400pub const _SC_VERSION: c_int = 29;
2401pub const _SC_PAGESIZE: c_int = 30;
2402pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE;
2403pub const _SC_RTSIG_MAX: c_int = 31;
2404pub const _SC_SEM_NSEMS_MAX: c_int = 32;
2405pub const _SC_SEM_VALUE_MAX: c_int = 33;
2406pub const _SC_SIGQUEUE_MAX: c_int = 34;
2407pub const _SC_TIMER_MAX: c_int = 35;
2408pub const _SC_BC_BASE_MAX: c_int = 36;
2409pub const _SC_BC_DIM_MAX: c_int = 37;
2410pub const _SC_BC_SCALE_MAX: c_int = 38;
2411pub const _SC_BC_STRING_MAX: c_int = 39;
2412pub const _SC_COLL_WEIGHTS_MAX: c_int = 40;
2413pub const _SC_EXPR_NEST_MAX: c_int = 42;
2414pub const _SC_LINE_MAX: c_int = 43;
2415pub const _SC_RE_DUP_MAX: c_int = 44;
2416pub const _SC_2_VERSION: c_int = 46;
2417pub const _SC_2_C_BIND: c_int = 47;
2418pub const _SC_2_C_DEV: c_int = 48;
2419pub const _SC_2_FORT_DEV: c_int = 49;
2420pub const _SC_2_FORT_RUN: c_int = 50;
2421pub const _SC_2_SW_DEV: c_int = 51;
2422pub const _SC_2_LOCALEDEF: c_int = 52;
2423pub const _SC_UIO_MAXIOV: c_int = 60;
2424pub const _SC_IOV_MAX: c_int = 60;
2425pub const _SC_THREADS: c_int = 67;
2426pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68;
2427pub const _SC_GETGR_R_SIZE_MAX: c_int = 69;
2428pub const _SC_GETPW_R_SIZE_MAX: c_int = 70;
2429pub const _SC_LOGIN_NAME_MAX: c_int = 71;
2430pub const _SC_TTY_NAME_MAX: c_int = 72;
2431pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73;
2432pub const _SC_THREAD_KEYS_MAX: c_int = 74;
2433pub const _SC_THREAD_STACK_MIN: c_int = 75;
2434pub const _SC_THREAD_THREADS_MAX: c_int = 76;
2435pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77;
2436pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78;
2437pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79;
2438pub const _SC_THREAD_PRIO_INHERIT: c_int = 80;
2439pub const _SC_THREAD_PRIO_PROTECT: c_int = 81;
2440pub const _SC_THREAD_PROCESS_SHARED: c_int = 82;
2441pub const _SC_NPROCESSORS_CONF: c_int = 83;
2442pub const _SC_NPROCESSORS_ONLN: c_int = 84;
2443pub const _SC_PHYS_PAGES: c_int = 85;
2444pub const _SC_AVPHYS_PAGES: c_int = 86;
2445pub const _SC_ATEXIT_MAX: c_int = 87;
2446pub const _SC_PASS_MAX: c_int = 88;
2447pub const _SC_XOPEN_VERSION: c_int = 89;
2448pub const _SC_XOPEN_XCU_VERSION: c_int = 90;
2449pub const _SC_XOPEN_UNIX: c_int = 91;
2450pub const _SC_XOPEN_CRYPT: c_int = 92;
2451pub const _SC_XOPEN_ENH_I18N: c_int = 93;
2452pub const _SC_XOPEN_SHM: c_int = 94;
2453pub const _SC_2_CHAR_TERM: c_int = 95;
2454pub const _SC_2_UPE: c_int = 97;
2455pub const _SC_XOPEN_XPG2: c_int = 98;
2456pub const _SC_XOPEN_XPG3: c_int = 99;
2457pub const _SC_XOPEN_XPG4: c_int = 100;
2458pub const _SC_NZERO: c_int = 109;
2459pub const _SC_XBS5_ILP32_OFF32: c_int = 125;
2460pub const _SC_XBS5_ILP32_OFFBIG: c_int = 126;
2461pub const _SC_XBS5_LP64_OFF64: c_int = 127;
2462pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 128;
2463pub const _SC_XOPEN_LEGACY: c_int = 129;
2464pub const _SC_XOPEN_REALTIME: c_int = 130;
2465pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131;
2466pub const _SC_ADVISORY_INFO: c_int = 132;
2467pub const _SC_BARRIERS: c_int = 133;
2468pub const _SC_CLOCK_SELECTION: c_int = 137;
2469pub const _SC_CPUTIME: c_int = 138;
2470pub const _SC_THREAD_CPUTIME: c_int = 139;
2471pub const _SC_MONOTONIC_CLOCK: c_int = 149;
2472pub const _SC_READER_WRITER_LOCKS: c_int = 153;
2473pub const _SC_SPIN_LOCKS: c_int = 154;
2474pub const _SC_REGEXP: c_int = 155;
2475pub const _SC_SHELL: c_int = 157;
2476pub const _SC_SPAWN: c_int = 159;
2477pub const _SC_SPORADIC_SERVER: c_int = 160;
2478pub const _SC_THREAD_SPORADIC_SERVER: c_int = 161;
2479pub const _SC_TIMEOUTS: c_int = 164;
2480pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 165;
2481pub const _SC_2_PBS: c_int = 168;
2482pub const _SC_2_PBS_ACCOUNTING: c_int = 169;
2483pub const _SC_2_PBS_LOCATE: c_int = 170;
2484pub const _SC_2_PBS_MESSAGE: c_int = 171;
2485pub const _SC_2_PBS_TRACK: c_int = 172;
2486pub const _SC_SYMLOOP_MAX: c_int = 173;
2487pub const _SC_STREAMS: c_int = 174;
2488pub const _SC_2_PBS_CHECKPOINT: c_int = 175;
2489pub const _SC_V6_ILP32_OFF32: c_int = 176;
2490pub const _SC_V6_ILP32_OFFBIG: c_int = 177;
2491pub const _SC_V6_LP64_OFF64: c_int = 178;
2492pub const _SC_V6_LPBIG_OFFBIG: c_int = 179;
2493pub const _SC_HOST_NAME_MAX: c_int = 180;
2494pub const _SC_TRACE: c_int = 181;
2495pub const _SC_TRACE_EVENT_FILTER: c_int = 182;
2496pub const _SC_TRACE_INHERIT: c_int = 183;
2497pub const _SC_TRACE_LOG: c_int = 184;
2498pub const _SC_IPV6: c_int = 235;
2499pub const _SC_RAW_SOCKETS: c_int = 236;
2500pub const _SC_V7_ILP32_OFF32: c_int = 237;
2501pub const _SC_V7_ILP32_OFFBIG: c_int = 238;
2502pub const _SC_V7_LP64_OFF64: c_int = 239;
2503pub const _SC_V7_LPBIG_OFFBIG: c_int = 240;
2504pub const _SC_SS_REPL_MAX: c_int = 241;
2505pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 242;
2506pub const _SC_TRACE_NAME_MAX: c_int = 243;
2507pub const _SC_TRACE_SYS_MAX: c_int = 244;
2508pub const _SC_TRACE_USER_EVENT_MAX: c_int = 245;
2509pub const _SC_XOPEN_STREAMS: c_int = 246;
2510pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 247;
2511pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 248;
2512
2513pub const _CS_PATH: c_int = 0;
2514pub const _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS: c_int = 1;
2515pub const _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS: c_int = 4;
2516pub const _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS: c_int = 5;
2517pub const _CS_POSIX_V6_ILP32_OFF32_CFLAGS: c_int = 1116;
2518pub const _CS_POSIX_V6_ILP32_OFF32_LDFLAGS: c_int = 1117;
2519pub const _CS_POSIX_V6_ILP32_OFF32_LIBS: c_int = 1118;
2520pub const _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS: c_int = 1119;
2521pub const _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS: c_int = 1120;
2522pub const _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS: c_int = 1121;
2523pub const _CS_POSIX_V6_ILP32_OFFBIG_LIBS: c_int = 1122;
2524pub const _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS: c_int = 1123;
2525pub const _CS_POSIX_V6_LP64_OFF64_CFLAGS: c_int = 1124;
2526pub const _CS_POSIX_V6_LP64_OFF64_LDFLAGS: c_int = 1125;
2527pub const _CS_POSIX_V6_LP64_OFF64_LIBS: c_int = 1126;
2528pub const _CS_POSIX_V6_LP64_OFF64_LINTFLAGS: c_int = 1127;
2529pub const _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS: c_int = 1128;
2530pub const _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS: c_int = 1129;
2531pub const _CS_POSIX_V6_LPBIG_OFFBIG_LIBS: c_int = 1130;
2532pub const _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS: c_int = 1131;
2533pub const _CS_POSIX_V7_ILP32_OFF32_CFLAGS: c_int = 1132;
2534pub const _CS_POSIX_V7_ILP32_OFF32_LDFLAGS: c_int = 1133;
2535pub const _CS_POSIX_V7_ILP32_OFF32_LIBS: c_int = 1134;
2536pub const _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS: c_int = 1135;
2537pub const _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS: c_int = 1136;
2538pub const _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS: c_int = 1137;
2539pub const _CS_POSIX_V7_ILP32_OFFBIG_LIBS: c_int = 1138;
2540pub const _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS: c_int = 1139;
2541pub const _CS_POSIX_V7_LP64_OFF64_CFLAGS: c_int = 1140;
2542pub const _CS_POSIX_V7_LP64_OFF64_LDFLAGS: c_int = 1141;
2543pub const _CS_POSIX_V7_LP64_OFF64_LIBS: c_int = 1142;
2544pub const _CS_POSIX_V7_LP64_OFF64_LINTFLAGS: c_int = 1143;
2545pub const _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS: c_int = 1144;
2546pub const _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS: c_int = 1145;
2547pub const _CS_POSIX_V7_LPBIG_OFFBIG_LIBS: c_int = 1146;
2548pub const _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS: c_int = 1147;
2549
2550pub const RLIM_SAVED_MAX: crate::rlim_t = RLIM_INFINITY;
2551pub const RLIM_SAVED_CUR: crate::rlim_t = RLIM_INFINITY;
2552
2553// elf.h - Fields in the e_ident array.
2554pub const EI_NIDENT: usize = 16;
2555
2556pub const EI_MAG0: usize = 0;
2557pub const ELFMAG0: u8 = 0x7f;
2558pub const EI_MAG1: usize = 1;
2559pub const ELFMAG1: u8 = b'E';
2560pub const EI_MAG2: usize = 2;
2561pub const ELFMAG2: u8 = b'L';
2562pub const EI_MAG3: usize = 3;
2563pub const ELFMAG3: u8 = b'F';
2564pub const SELFMAG: usize = 4;
2565
2566pub const EI_CLASS: usize = 4;
2567pub const ELFCLASSNONE: u8 = 0;
2568pub const ELFCLASS32: u8 = 1;
2569pub const ELFCLASS64: u8 = 2;
2570pub const ELFCLASSNUM: usize = 3;
2571
2572pub const EI_DATA: usize = 5;
2573pub const ELFDATANONE: u8 = 0;
2574pub const ELFDATA2LSB: u8 = 1;
2575pub const ELFDATA2MSB: u8 = 2;
2576pub const ELFDATANUM: usize = 3;
2577
2578pub const EI_VERSION: usize = 6;
2579
2580pub const EI_OSABI: usize = 7;
2581pub const ELFOSABI_NONE: u8 = 0;
2582pub const ELFOSABI_SYSV: u8 = 0;
2583pub const ELFOSABI_HPUX: u8 = 1;
2584pub const ELFOSABI_NETBSD: u8 = 2;
2585pub const ELFOSABI_GNU: u8 = 3;
2586pub const ELFOSABI_LINUX: u8 = ELFOSABI_GNU;
2587pub const ELFOSABI_SOLARIS: u8 = 6;
2588pub const ELFOSABI_AIX: u8 = 7;
2589pub const ELFOSABI_IRIX: u8 = 8;
2590pub const ELFOSABI_FREEBSD: u8 = 9;
2591pub const ELFOSABI_TRU64: u8 = 10;
2592pub const ELFOSABI_MODESTO: u8 = 11;
2593pub const ELFOSABI_OPENBSD: u8 = 12;
2594pub const ELFOSABI_ARM: u8 = 97;
2595pub const ELFOSABI_STANDALONE: u8 = 255;
2596
2597pub const EI_ABIVERSION: usize = 8;
2598
2599pub const EI_PAD: usize = 9;
2600
2601// elf.h - Legal values for e_type (object file type).
2602pub const ET_NONE: u16 = 0;
2603pub const ET_REL: u16 = 1;
2604pub const ET_EXEC: u16 = 2;
2605pub const ET_DYN: u16 = 3;
2606pub const ET_CORE: u16 = 4;
2607pub const ET_NUM: u16 = 5;
2608pub const ET_LOOS: u16 = 0xfe00;
2609pub const ET_HIOS: u16 = 0xfeff;
2610pub const ET_LOPROC: u16 = 0xff00;
2611pub const ET_HIPROC: u16 = 0xffff;
2612
2613// elf.h - Legal values for e_machine (architecture).
2614pub const EM_NONE: u16 = 0;
2615pub const EM_M32: u16 = 1;
2616pub const EM_SPARC: u16 = 2;
2617pub const EM_386: u16 = 3;
2618pub const EM_68K: u16 = 4;
2619pub const EM_88K: u16 = 5;
2620pub const EM_860: u16 = 7;
2621pub const EM_MIPS: u16 = 8;
2622pub const EM_S370: u16 = 9;
2623pub const EM_MIPS_RS3_LE: u16 = 10;
2624pub const EM_PARISC: u16 = 15;
2625pub const EM_VPP500: u16 = 17;
2626pub const EM_SPARC32PLUS: u16 = 18;
2627pub const EM_960: u16 = 19;
2628pub const EM_PPC: u16 = 20;
2629pub const EM_PPC64: u16 = 21;
2630pub const EM_S390: u16 = 22;
2631pub const EM_V800: u16 = 36;
2632pub const EM_FR20: u16 = 37;
2633pub const EM_RH32: u16 = 38;
2634pub const EM_RCE: u16 = 39;
2635pub const EM_ARM: u16 = 40;
2636pub const EM_FAKE_ALPHA: u16 = 41;
2637pub const EM_SH: u16 = 42;
2638pub const EM_SPARCV9: u16 = 43;
2639pub const EM_TRICORE: u16 = 44;
2640pub const EM_ARC: u16 = 45;
2641pub const EM_H8_300: u16 = 46;
2642pub const EM_H8_300H: u16 = 47;
2643pub const EM_H8S: u16 = 48;
2644pub const EM_H8_500: u16 = 49;
2645pub const EM_IA_64: u16 = 50;
2646pub const EM_MIPS_X: u16 = 51;
2647pub const EM_COLDFIRE: u16 = 52;
2648pub const EM_68HC12: u16 = 53;
2649pub const EM_MMA: u16 = 54;
2650pub const EM_PCP: u16 = 55;
2651pub const EM_NCPU: u16 = 56;
2652pub const EM_NDR1: u16 = 57;
2653pub const EM_STARCORE: u16 = 58;
2654pub const EM_ME16: u16 = 59;
2655pub const EM_ST100: u16 = 60;
2656pub const EM_TINYJ: u16 = 61;
2657pub const EM_X86_64: u16 = 62;
2658pub const EM_PDSP: u16 = 63;
2659pub const EM_FX66: u16 = 66;
2660pub const EM_ST9PLUS: u16 = 67;
2661pub const EM_ST7: u16 = 68;
2662pub const EM_68HC16: u16 = 69;
2663pub const EM_68HC11: u16 = 70;
2664pub const EM_68HC08: u16 = 71;
2665pub const EM_68HC05: u16 = 72;
2666pub const EM_SVX: u16 = 73;
2667pub const EM_ST19: u16 = 74;
2668pub const EM_VAX: u16 = 75;
2669pub const EM_CRIS: u16 = 76;
2670pub const EM_JAVELIN: u16 = 77;
2671pub const EM_FIREPATH: u16 = 78;
2672pub const EM_ZSP: u16 = 79;
2673pub const EM_MMIX: u16 = 80;
2674pub const EM_HUANY: u16 = 81;
2675pub const EM_PRISM: u16 = 82;
2676pub const EM_AVR: u16 = 83;
2677pub const EM_FR30: u16 = 84;
2678pub const EM_D10V: u16 = 85;
2679pub const EM_D30V: u16 = 86;
2680pub const EM_V850: u16 = 87;
2681pub const EM_M32R: u16 = 88;
2682pub const EM_MN10300: u16 = 89;
2683pub const EM_MN10200: u16 = 90;
2684pub const EM_PJ: u16 = 91;
2685pub const EM_OPENRISC: u16 = 92;
2686pub const EM_ARC_A5: u16 = 93;
2687pub const EM_XTENSA: u16 = 94;
2688pub const EM_AARCH64: u16 = 183;
2689pub const EM_TILEPRO: u16 = 188;
2690pub const EM_TILEGX: u16 = 191;
2691pub const EM_ALPHA: u16 = 0x9026;
2692
2693// elf.h - Legal values for e_version (version).
2694pub const EV_NONE: u32 = 0;
2695pub const EV_CURRENT: u32 = 1;
2696pub const EV_NUM: u32 = 2;
2697
2698// elf.h - Legal values for p_type (segment type).
2699pub const PT_NULL: u32 = 0;
2700pub const PT_LOAD: u32 = 1;
2701pub const PT_DYNAMIC: u32 = 2;
2702pub const PT_INTERP: u32 = 3;
2703pub const PT_NOTE: u32 = 4;
2704pub const PT_SHLIB: u32 = 5;
2705pub const PT_PHDR: u32 = 6;
2706pub const PT_TLS: u32 = 7;
2707pub const PT_NUM: u32 = 8;
2708pub const PT_LOOS: u32 = 0x60000000;
2709pub const PT_GNU_EH_FRAME: u32 = 0x6474e550;
2710pub const PT_GNU_STACK: u32 = 0x6474e551;
2711pub const PT_GNU_RELRO: u32 = 0x6474e552;
2712pub const PT_LOSUNW: u32 = 0x6ffffffa;
2713pub const PT_SUNWBSS: u32 = 0x6ffffffa;
2714pub const PT_SUNWSTACK: u32 = 0x6ffffffb;
2715pub const PT_HISUNW: u32 = 0x6fffffff;
2716pub const PT_HIOS: u32 = 0x6fffffff;
2717pub const PT_LOPROC: u32 = 0x70000000;
2718pub const PT_HIPROC: u32 = 0x7fffffff;
2719
2720// Legal values for p_flags (segment flags).
2721pub const PF_X: u32 = 1 << 0;
2722pub const PF_W: u32 = 1 << 1;
2723pub const PF_R: u32 = 1 << 2;
2724pub const PF_MASKOS: u32 = 0x0ff00000;
2725pub const PF_MASKPROC: u32 = 0xf0000000;
2726
2727// elf.h - Legal values for a_type (entry type).
2728pub const AT_NULL: c_ulong = 0;
2729pub const AT_IGNORE: c_ulong = 1;
2730pub const AT_EXECFD: c_ulong = 2;
2731pub const AT_PHDR: c_ulong = 3;
2732pub const AT_PHENT: c_ulong = 4;
2733pub const AT_PHNUM: c_ulong = 5;
2734pub const AT_PAGESZ: c_ulong = 6;
2735pub const AT_BASE: c_ulong = 7;
2736pub const AT_FLAGS: c_ulong = 8;
2737pub const AT_ENTRY: c_ulong = 9;
2738pub const AT_NOTELF: c_ulong = 10;
2739pub const AT_UID: c_ulong = 11;
2740pub const AT_EUID: c_ulong = 12;
2741pub const AT_GID: c_ulong = 13;
2742pub const AT_EGID: c_ulong = 14;
2743pub const AT_PLATFORM: c_ulong = 15;
2744pub const AT_HWCAP: c_ulong = 16;
2745pub const AT_CLKTCK: c_ulong = 17;
2746
2747pub const AT_SECURE: c_ulong = 23;
2748pub const AT_BASE_PLATFORM: c_ulong = 24;
2749pub const AT_RANDOM: c_ulong = 25;
2750pub const AT_HWCAP2: c_ulong = 26;
2751
2752pub const AT_EXECFN: c_ulong = 31;
2753
2754// defined in arch/<arch>/include/uapi/asm/auxvec.h but has the same value
2755// wherever it is defined.
2756pub const AT_SYSINFO_EHDR: c_ulong = 33;
2757pub const AT_MINSIGSTKSZ: c_ulong = 51;
2758
2759pub const GLOB_ERR: c_int = 1 << 0;
2760pub const GLOB_MARK: c_int = 1 << 1;
2761pub const GLOB_NOSORT: c_int = 1 << 2;
2762pub const GLOB_DOOFFS: c_int = 1 << 3;
2763pub const GLOB_NOCHECK: c_int = 1 << 4;
2764pub const GLOB_APPEND: c_int = 1 << 5;
2765pub const GLOB_NOESCAPE: c_int = 1 << 6;
2766
2767pub const GLOB_NOSPACE: c_int = 1;
2768pub const GLOB_ABORTED: c_int = 2;
2769pub const GLOB_NOMATCH: c_int = 3;
2770
2771pub const POSIX_MADV_NORMAL: c_int = 0;
2772pub const POSIX_MADV_RANDOM: c_int = 1;
2773pub const POSIX_MADV_SEQUENTIAL: c_int = 2;
2774pub const POSIX_MADV_WILLNEED: c_int = 3;
2775pub const POSIX_SPAWN_USEVFORK: c_int = 64;
2776pub const POSIX_SPAWN_SETSID: c_int = 128;
2777
2778pub const S_IEXEC: mode_t = 0o0100;
2779pub const S_IWRITE: mode_t = 0o0200;
2780pub const S_IREAD: mode_t = 0o0400;
2781
2782pub const F_LOCK: c_int = 1;
2783pub const F_TEST: c_int = 3;
2784pub const F_TLOCK: c_int = 2;
2785pub const F_ULOCK: c_int = 0;
2786
2787pub const F_SEAL_FUTURE_WRITE: c_int = 0x0010;
2788pub const F_SEAL_EXEC: c_int = 0x0020;
2789
2790pub const IFF_LOWER_UP: c_int = 0x10000;
2791pub const IFF_DORMANT: c_int = 0x20000;
2792pub const IFF_ECHO: c_int = 0x40000;
2793
2794// linux/if_addr.h
2795pub const IFA_UNSPEC: c_ushort = 0;
2796pub const IFA_ADDRESS: c_ushort = 1;
2797pub const IFA_LOCAL: c_ushort = 2;
2798pub const IFA_LABEL: c_ushort = 3;
2799pub const IFA_BROADCAST: c_ushort = 4;
2800pub const IFA_ANYCAST: c_ushort = 5;
2801pub const IFA_CACHEINFO: c_ushort = 6;
2802pub const IFA_MULTICAST: c_ushort = 7;
2803pub const IFA_FLAGS: c_ushort = 8;
2804
2805pub const IFA_F_SECONDARY: u32 = 0x01;
2806pub const IFA_F_TEMPORARY: u32 = 0x01;
2807pub const IFA_F_NODAD: u32 = 0x02;
2808pub const IFA_F_OPTIMISTIC: u32 = 0x04;
2809pub const IFA_F_DADFAILED: u32 = 0x08;
2810pub const IFA_F_HOMEADDRESS: u32 = 0x10;
2811pub const IFA_F_DEPRECATED: u32 = 0x20;
2812pub const IFA_F_TENTATIVE: u32 = 0x40;
2813pub const IFA_F_PERMANENT: u32 = 0x80;
2814pub const IFA_F_MANAGETEMPADDR: u32 = 0x100;
2815pub const IFA_F_NOPREFIXROUTE: u32 = 0x200;
2816pub const IFA_F_MCAUTOJOIN: u32 = 0x400;
2817pub const IFA_F_STABLE_PRIVACY: u32 = 0x800;
2818
2819// linux/if_link.h
2820pub const IFLA_UNSPEC: c_ushort = 0;
2821pub const IFLA_ADDRESS: c_ushort = 1;
2822pub const IFLA_BROADCAST: c_ushort = 2;
2823pub const IFLA_IFNAME: c_ushort = 3;
2824pub const IFLA_MTU: c_ushort = 4;
2825pub const IFLA_LINK: c_ushort = 5;
2826pub const IFLA_QDISC: c_ushort = 6;
2827pub const IFLA_STATS: c_ushort = 7;
2828pub const IFLA_COST: c_ushort = 8;
2829pub const IFLA_PRIORITY: c_ushort = 9;
2830pub const IFLA_MASTER: c_ushort = 10;
2831pub const IFLA_WIRELESS: c_ushort = 11;
2832pub const IFLA_PROTINFO: c_ushort = 12;
2833pub const IFLA_TXQLEN: c_ushort = 13;
2834pub const IFLA_MAP: c_ushort = 14;
2835pub const IFLA_WEIGHT: c_ushort = 15;
2836pub const IFLA_OPERSTATE: c_ushort = 16;
2837pub const IFLA_LINKMODE: c_ushort = 17;
2838pub const IFLA_LINKINFO: c_ushort = 18;
2839pub const IFLA_NET_NS_PID: c_ushort = 19;
2840pub const IFLA_IFALIAS: c_ushort = 20;
2841pub const IFLA_NUM_VF: c_ushort = 21;
2842pub const IFLA_VFINFO_LIST: c_ushort = 22;
2843pub const IFLA_STATS64: c_ushort = 23;
2844pub const IFLA_VF_PORTS: c_ushort = 24;
2845pub const IFLA_PORT_SELF: c_ushort = 25;
2846pub const IFLA_AF_SPEC: c_ushort = 26;
2847pub const IFLA_GROUP: c_ushort = 27;
2848pub const IFLA_NET_NS_FD: c_ushort = 28;
2849pub const IFLA_EXT_MASK: c_ushort = 29;
2850pub const IFLA_PROMISCUITY: c_ushort = 30;
2851pub const IFLA_NUM_TX_QUEUES: c_ushort = 31;
2852pub const IFLA_NUM_RX_QUEUES: c_ushort = 32;
2853pub const IFLA_CARRIER: c_ushort = 33;
2854pub const IFLA_PHYS_PORT_ID: c_ushort = 34;
2855pub const IFLA_CARRIER_CHANGES: c_ushort = 35;
2856pub const IFLA_PHYS_SWITCH_ID: c_ushort = 36;
2857pub const IFLA_LINK_NETNSID: c_ushort = 37;
2858pub const IFLA_PHYS_PORT_NAME: c_ushort = 38;
2859pub const IFLA_PROTO_DOWN: c_ushort = 39;
2860pub const IFLA_GSO_MAX_SEGS: c_ushort = 40;
2861pub const IFLA_GSO_MAX_SIZE: c_ushort = 41;
2862pub const IFLA_PAD: c_ushort = 42;
2863pub const IFLA_XDP: c_ushort = 43;
2864pub const IFLA_EVENT: c_ushort = 44;
2865pub const IFLA_NEW_NETNSID: c_ushort = 45;
2866pub const IFLA_IF_NETNSID: c_ushort = 46;
2867pub const IFLA_TARGET_NETNSID: c_ushort = IFLA_IF_NETNSID;
2868pub const IFLA_CARRIER_UP_COUNT: c_ushort = 47;
2869pub const IFLA_CARRIER_DOWN_COUNT: c_ushort = 48;
2870pub const IFLA_NEW_IFINDEX: c_ushort = 49;
2871pub const IFLA_MIN_MTU: c_ushort = 50;
2872pub const IFLA_MAX_MTU: c_ushort = 51;
2873pub const IFLA_PROP_LIST: c_ushort = 52;
2874pub const IFLA_ALT_IFNAME: c_ushort = 53;
2875pub const IFLA_PERM_ADDRESS: c_ushort = 54;
2876pub const IFLA_PROTO_DOWN_REASON: c_ushort = 55;
2877pub const IFLA_PARENT_DEV_NAME: c_ushort = 56;
2878pub const IFLA_PARENT_DEV_BUS_NAME: c_ushort = 57;
2879pub const IFLA_GRO_MAX_SIZE: c_ushort = 58;
2880pub const IFLA_TSO_MAX_SIZE: c_ushort = 59;
2881pub const IFLA_TSO_MAX_SEGS: c_ushort = 60;
2882pub const IFLA_ALLMULTI: c_ushort = 61;
2883
2884pub const IFLA_INFO_UNSPEC: c_ushort = 0;
2885pub const IFLA_INFO_KIND: c_ushort = 1;
2886pub const IFLA_INFO_DATA: c_ushort = 2;
2887pub const IFLA_INFO_XSTATS: c_ushort = 3;
2888pub const IFLA_INFO_SLAVE_KIND: c_ushort = 4;
2889pub const IFLA_INFO_SLAVE_DATA: c_ushort = 5;
2890
2891// linux/if_tun.h
2892/* TUNSETIFF ifr flags */
2893pub const IFF_TUN: c_int = 0x0001;
2894pub const IFF_TAP: c_int = 0x0002;
2895pub const IFF_NAPI: c_int = 0x0010;
2896pub const IFF_NAPI_FRAGS: c_int = 0x0020;
2897// Used in TUNSETIFF to bring up tun/tap without carrier
2898pub const IFF_NO_CARRIER: c_int = 0x0040;
2899pub const IFF_NO_PI: c_int = 0x1000;
2900// Read queue size
2901pub const TUN_READQ_SIZE: c_short = 500;
2902// TUN device type flags: deprecated. Use IFF_TUN/IFF_TAP instead.
2903pub const TUN_TUN_DEV: c_short = crate::IFF_TUN as c_short;
2904pub const TUN_TAP_DEV: c_short = crate::IFF_TAP as c_short;
2905pub const TUN_TYPE_MASK: c_short = 0x000f;
2906// This flag has no real effect
2907pub const IFF_ONE_QUEUE: c_int = 0x2000;
2908pub const IFF_VNET_HDR: c_int = 0x4000;
2909pub const IFF_TUN_EXCL: c_int = 0x8000;
2910pub const IFF_MULTI_QUEUE: c_int = 0x0100;
2911pub const IFF_ATTACH_QUEUE: c_int = 0x0200;
2912pub const IFF_DETACH_QUEUE: c_int = 0x0400;
2913// read-only flag
2914pub const IFF_PERSIST: c_int = 0x0800;
2915pub const IFF_NOFILTER: c_int = 0x1000;
2916// Socket options
2917pub const TUN_TX_TIMESTAMP: c_int = 1;
2918// Features for GSO (TUNSETOFFLOAD)
2919pub const TUN_F_CSUM: c_uint = 0x01;
2920pub const TUN_F_TSO4: c_uint = 0x02;
2921pub const TUN_F_TSO6: c_uint = 0x04;
2922pub const TUN_F_TSO_ECN: c_uint = 0x08;
2923pub const TUN_F_UFO: c_uint = 0x10;
2924pub const TUN_F_USO4: c_uint = 0x20;
2925pub const TUN_F_USO6: c_uint = 0x40;
2926// Protocol info prepended to the packets (when IFF_NO_PI is not set)
2927pub const TUN_PKT_STRIP: c_int = 0x0001;
2928// Accept all multicast packets
2929pub const TUN_FLT_ALLMULTI: c_int = 0x0001;
2930
2931// Since Linux 3.1
2932pub const SEEK_DATA: c_int = 3;
2933pub const SEEK_HOLE: c_int = 4;
2934
2935pub const ST_RDONLY: c_ulong = 1;
2936pub const ST_NOSUID: c_ulong = 2;
2937pub const ST_NODEV: c_ulong = 4;
2938pub const ST_NOEXEC: c_ulong = 8;
2939pub const ST_SYNCHRONOUS: c_ulong = 16;
2940pub const ST_MANDLOCK: c_ulong = 64;
2941pub const ST_WRITE: c_ulong = 128;
2942pub const ST_APPEND: c_ulong = 256;
2943pub const ST_IMMUTABLE: c_ulong = 512;
2944pub const ST_NOATIME: c_ulong = 1024;
2945pub const ST_NODIRATIME: c_ulong = 2048;
2946
2947pub const RTLD_NEXT: *mut c_void = -1i64 as *mut c_void;
2948pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void;
2949pub const RTLD_NODELETE: c_int = 0x1000;
2950pub const RTLD_NOW: c_int = 0x2;
2951
2952pub const AT_EACCESS: c_int = 0x200;
2953
2954// linux/mempolicy.h
2955pub const MPOL_DEFAULT: c_int = 0;
2956pub const MPOL_PREFERRED: c_int = 1;
2957pub const MPOL_BIND: c_int = 2;
2958pub const MPOL_INTERLEAVE: c_int = 3;
2959pub const MPOL_LOCAL: c_int = 4;
2960pub const MPOL_F_NUMA_BALANCING: c_int = 1 << 13;
2961pub const MPOL_F_RELATIVE_NODES: c_int = 1 << 14;
2962pub const MPOL_F_STATIC_NODES: c_int = 1 << 15;
2963
2964// linux/membarrier.h
2965pub const MEMBARRIER_CMD_QUERY: c_int = 0;
2966pub const MEMBARRIER_CMD_GLOBAL: c_int = 1 << 0;
2967pub const MEMBARRIER_CMD_GLOBAL_EXPEDITED: c_int = 1 << 1;
2968pub const MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED: c_int = 1 << 2;
2969pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED: c_int = 1 << 3;
2970pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED: c_int = 1 << 4;
2971pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE: c_int = 1 << 5;
2972pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE: c_int = 1 << 6;
2973pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ: c_int = 1 << 7;
2974pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ: c_int = 1 << 8;
2975
2976pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
2977    size: [0; __SIZEOF_PTHREAD_MUTEX_T],
2978};
2979pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
2980    size: [0; __SIZEOF_PTHREAD_COND_T],
2981};
2982pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
2983    size: [0; __SIZEOF_PTHREAD_RWLOCK_T],
2984};
2985
2986pub const PTHREAD_BARRIER_SERIAL_THREAD: c_int = -1;
2987pub const PTHREAD_ONCE_INIT: pthread_once_t = 0;
2988pub const PTHREAD_MUTEX_NORMAL: c_int = 0;
2989pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1;
2990pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2;
2991pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL;
2992pub const PTHREAD_MUTEX_STALLED: c_int = 0;
2993pub const PTHREAD_MUTEX_ROBUST: c_int = 1;
2994pub const PTHREAD_PRIO_NONE: c_int = 0;
2995pub const PTHREAD_PRIO_INHERIT: c_int = 1;
2996pub const PTHREAD_PRIO_PROTECT: c_int = 2;
2997pub const PTHREAD_PROCESS_PRIVATE: c_int = 0;
2998pub const PTHREAD_PROCESS_SHARED: c_int = 1;
2999pub const PTHREAD_INHERIT_SCHED: c_int = 0;
3000pub const PTHREAD_EXPLICIT_SCHED: c_int = 1;
3001pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
3002
3003pub const RENAME_NOREPLACE: c_uint = 1;
3004pub const RENAME_EXCHANGE: c_uint = 2;
3005pub const RENAME_WHITEOUT: c_uint = 4;
3006
3007// netinet/in.h
3008// NOTE: These are in addition to the constants defined in src/unix/mod.rs
3009
3010#[deprecated(
3011    since = "0.2.80",
3012    note = "This value was increased in the newer kernel \
3013            and we'll change this following upstream in the future release. \
3014            See #1896 for more info."
3015)]
3016pub const IPPROTO_MAX: c_int = 256;
3017
3018// System V IPC
3019pub const IPC_PRIVATE: crate::key_t = 0;
3020
3021pub const IPC_CREAT: c_int = 0o1000;
3022pub const IPC_EXCL: c_int = 0o2000;
3023pub const IPC_NOWAIT: c_int = 0o4000;
3024
3025pub const IPC_RMID: c_int = 0;
3026pub const IPC_SET: c_int = 1;
3027pub const IPC_STAT: c_int = 2;
3028pub const IPC_INFO: c_int = 3;
3029pub const MSG_STAT: c_int = 11;
3030pub const MSG_INFO: c_int = 12;
3031pub const MSG_NOTIFICATION: c_int = 0x8000;
3032
3033pub const MSG_NOERROR: c_int = 0o10000;
3034pub const MSG_EXCEPT: c_int = 0o20000;
3035pub const MSG_ZEROCOPY: c_int = 0x4000000;
3036
3037pub const SEM_UNDO: c_int = 0x1000;
3038
3039pub const GETPID: c_int = 11;
3040pub const GETVAL: c_int = 12;
3041pub const GETALL: c_int = 13;
3042pub const GETNCNT: c_int = 14;
3043pub const GETZCNT: c_int = 15;
3044pub const SETVAL: c_int = 16;
3045pub const SETALL: c_int = 17;
3046pub const SEM_STAT: c_int = 18;
3047pub const SEM_INFO: c_int = 19;
3048pub const SEM_STAT_ANY: c_int = 20;
3049
3050pub const SHM_R: c_int = 0o400;
3051pub const SHM_W: c_int = 0o200;
3052
3053pub const SHM_RDONLY: c_int = 0o10000;
3054pub const SHM_RND: c_int = 0o20000;
3055pub const SHM_REMAP: c_int = 0o40000;
3056
3057pub const SHM_LOCK: c_int = 11;
3058pub const SHM_UNLOCK: c_int = 12;
3059
3060pub const SHM_HUGETLB: c_int = 0o4000;
3061#[cfg(not(all(target_env = "uclibc", target_arch = "mips")))]
3062pub const SHM_NORESERVE: c_int = 0o10000;
3063
3064pub const QFMT_VFS_OLD: c_int = 1;
3065pub const QFMT_VFS_V0: c_int = 2;
3066pub const QFMT_VFS_V1: c_int = 4;
3067
3068pub const EFD_SEMAPHORE: c_int = 0x1;
3069
3070pub const LOG_NFACILITIES: c_int = 24;
3071
3072pub const SEM_FAILED: *mut crate::sem_t = 0 as *mut sem_t;
3073
3074pub const RB_AUTOBOOT: c_int = 0x01234567u32 as i32;
3075pub const RB_HALT_SYSTEM: c_int = 0xcdef0123u32 as i32;
3076pub const RB_ENABLE_CAD: c_int = 0x89abcdefu32 as i32;
3077pub const RB_DISABLE_CAD: c_int = 0x00000000u32 as i32;
3078pub const RB_POWER_OFF: c_int = 0x4321fedcu32 as i32;
3079pub const RB_SW_SUSPEND: c_int = 0xd000fce2u32 as i32;
3080pub const RB_KEXEC: c_int = 0x45584543u32 as i32;
3081
3082pub const AI_PASSIVE: c_int = 0x0001;
3083pub const AI_CANONNAME: c_int = 0x0002;
3084pub const AI_NUMERICHOST: c_int = 0x0004;
3085pub const AI_V4MAPPED: c_int = 0x0008;
3086pub const AI_ALL: c_int = 0x0010;
3087pub const AI_ADDRCONFIG: c_int = 0x0020;
3088
3089pub const AI_NUMERICSERV: c_int = 0x0400;
3090
3091pub const EAI_BADFLAGS: c_int = -1;
3092pub const EAI_NONAME: c_int = -2;
3093pub const EAI_AGAIN: c_int = -3;
3094pub const EAI_FAIL: c_int = -4;
3095pub const EAI_NODATA: c_int = -5;
3096pub const EAI_FAMILY: c_int = -6;
3097pub const EAI_SOCKTYPE: c_int = -7;
3098pub const EAI_SERVICE: c_int = -8;
3099pub const EAI_MEMORY: c_int = -10;
3100pub const EAI_SYSTEM: c_int = -11;
3101pub const EAI_OVERFLOW: c_int = -12;
3102
3103pub const NI_NUMERICHOST: c_int = 1;
3104pub const NI_NUMERICSERV: c_int = 2;
3105pub const NI_NOFQDN: c_int = 4;
3106pub const NI_NAMEREQD: c_int = 8;
3107pub const NI_DGRAM: c_int = 16;
3108pub const NI_IDN: c_int = 32;
3109
3110pub const SYNC_FILE_RANGE_WAIT_BEFORE: c_uint = 1;
3111pub const SYNC_FILE_RANGE_WRITE: c_uint = 2;
3112pub const SYNC_FILE_RANGE_WAIT_AFTER: c_uint = 4;
3113
3114cfg_if! {
3115    if #[cfg(not(target_env = "uclibc"))] {
3116        pub const AIO_CANCELED: c_int = 0;
3117        pub const AIO_NOTCANCELED: c_int = 1;
3118        pub const AIO_ALLDONE: c_int = 2;
3119        pub const LIO_READ: c_int = 0;
3120        pub const LIO_WRITE: c_int = 1;
3121        pub const LIO_NOP: c_int = 2;
3122        pub const LIO_WAIT: c_int = 0;
3123        pub const LIO_NOWAIT: c_int = 1;
3124        pub const RUSAGE_THREAD: c_int = 1;
3125        pub const MSG_COPY: c_int = 0o40000;
3126        pub const SHM_EXEC: c_int = 0o100000;
3127        pub const IPV6_MULTICAST_ALL: c_int = 29;
3128        pub const IPV6_ROUTER_ALERT_ISOLATE: c_int = 30;
3129        pub const PACKET_MR_UNICAST: c_int = 3;
3130        pub const PTRACE_EVENT_STOP: c_int = 128;
3131        pub const UDP_SEGMENT: c_int = 103;
3132        pub const UDP_GRO: c_int = 104;
3133    }
3134}
3135
3136pub const MREMAP_MAYMOVE: c_int = 1;
3137pub const MREMAP_FIXED: c_int = 2;
3138pub const MREMAP_DONTUNMAP: c_int = 4;
3139
3140pub const PR_SET_PDEATHSIG: c_int = 1;
3141pub const PR_GET_PDEATHSIG: c_int = 2;
3142
3143pub const PR_GET_DUMPABLE: c_int = 3;
3144pub const PR_SET_DUMPABLE: c_int = 4;
3145
3146pub const PR_GET_UNALIGN: c_int = 5;
3147pub const PR_SET_UNALIGN: c_int = 6;
3148pub const PR_UNALIGN_NOPRINT: c_int = 1;
3149pub const PR_UNALIGN_SIGBUS: c_int = 2;
3150
3151pub const PR_GET_KEEPCAPS: c_int = 7;
3152pub const PR_SET_KEEPCAPS: c_int = 8;
3153
3154pub const PR_GET_FPEMU: c_int = 9;
3155pub const PR_SET_FPEMU: c_int = 10;
3156pub const PR_FPEMU_NOPRINT: c_int = 1;
3157pub const PR_FPEMU_SIGFPE: c_int = 2;
3158
3159pub const PR_GET_FPEXC: c_int = 11;
3160pub const PR_SET_FPEXC: c_int = 12;
3161pub const PR_FP_EXC_SW_ENABLE: c_int = 0x80;
3162pub const PR_FP_EXC_DIV: c_int = 0x010000;
3163pub const PR_FP_EXC_OVF: c_int = 0x020000;
3164pub const PR_FP_EXC_UND: c_int = 0x040000;
3165pub const PR_FP_EXC_RES: c_int = 0x080000;
3166pub const PR_FP_EXC_INV: c_int = 0x100000;
3167pub const PR_FP_EXC_DISABLED: c_int = 0;
3168pub const PR_FP_EXC_NONRECOV: c_int = 1;
3169pub const PR_FP_EXC_ASYNC: c_int = 2;
3170pub const PR_FP_EXC_PRECISE: c_int = 3;
3171
3172pub const PR_GET_TIMING: c_int = 13;
3173pub const PR_SET_TIMING: c_int = 14;
3174pub const PR_TIMING_STATISTICAL: c_int = 0;
3175pub const PR_TIMING_TIMESTAMP: c_int = 1;
3176
3177pub const PR_SET_NAME: c_int = 15;
3178pub const PR_GET_NAME: c_int = 16;
3179
3180pub const PR_GET_ENDIAN: c_int = 19;
3181pub const PR_SET_ENDIAN: c_int = 20;
3182pub const PR_ENDIAN_BIG: c_int = 0;
3183pub const PR_ENDIAN_LITTLE: c_int = 1;
3184pub const PR_ENDIAN_PPC_LITTLE: c_int = 2;
3185
3186pub const PR_GET_SECCOMP: c_int = 21;
3187pub const PR_SET_SECCOMP: c_int = 22;
3188
3189pub const PR_CAPBSET_READ: c_int = 23;
3190pub const PR_CAPBSET_DROP: c_int = 24;
3191
3192pub const PR_GET_TSC: c_int = 25;
3193pub const PR_SET_TSC: c_int = 26;
3194pub const PR_TSC_ENABLE: c_int = 1;
3195pub const PR_TSC_SIGSEGV: c_int = 2;
3196
3197pub const PR_GET_SECUREBITS: c_int = 27;
3198pub const PR_SET_SECUREBITS: c_int = 28;
3199
3200pub const PR_SET_TIMERSLACK: c_int = 29;
3201pub const PR_GET_TIMERSLACK: c_int = 30;
3202
3203pub const PR_TASK_PERF_EVENTS_DISABLE: c_int = 31;
3204pub const PR_TASK_PERF_EVENTS_ENABLE: c_int = 32;
3205
3206pub const PR_MCE_KILL: c_int = 33;
3207pub const PR_MCE_KILL_CLEAR: c_int = 0;
3208pub const PR_MCE_KILL_SET: c_int = 1;
3209
3210pub const PR_MCE_KILL_LATE: c_int = 0;
3211pub const PR_MCE_KILL_EARLY: c_int = 1;
3212pub const PR_MCE_KILL_DEFAULT: c_int = 2;
3213
3214pub const PR_MCE_KILL_GET: c_int = 34;
3215
3216pub const PR_SET_MM: c_int = 35;
3217pub const PR_SET_MM_START_CODE: c_int = 1;
3218pub const PR_SET_MM_END_CODE: c_int = 2;
3219pub const PR_SET_MM_START_DATA: c_int = 3;
3220pub const PR_SET_MM_END_DATA: c_int = 4;
3221pub const PR_SET_MM_START_STACK: c_int = 5;
3222pub const PR_SET_MM_START_BRK: c_int = 6;
3223pub const PR_SET_MM_BRK: c_int = 7;
3224pub const PR_SET_MM_ARG_START: c_int = 8;
3225pub const PR_SET_MM_ARG_END: c_int = 9;
3226pub const PR_SET_MM_ENV_START: c_int = 10;
3227pub const PR_SET_MM_ENV_END: c_int = 11;
3228pub const PR_SET_MM_AUXV: c_int = 12;
3229pub const PR_SET_MM_EXE_FILE: c_int = 13;
3230pub const PR_SET_MM_MAP: c_int = 14;
3231pub const PR_SET_MM_MAP_SIZE: c_int = 15;
3232
3233pub const PR_SET_PTRACER: c_int = 0x59616d61;
3234pub const PR_SET_PTRACER_ANY: c_ulong = 0xffffffffffffffff;
3235
3236pub const PR_SET_CHILD_SUBREAPER: c_int = 36;
3237pub const PR_GET_CHILD_SUBREAPER: c_int = 37;
3238
3239pub const PR_SET_NO_NEW_PRIVS: c_int = 38;
3240pub const PR_GET_NO_NEW_PRIVS: c_int = 39;
3241
3242pub const PR_GET_TID_ADDRESS: c_int = 40;
3243
3244pub const PR_SET_THP_DISABLE: c_int = 41;
3245pub const PR_GET_THP_DISABLE: c_int = 42;
3246
3247pub const PR_MPX_ENABLE_MANAGEMENT: c_int = 43;
3248pub const PR_MPX_DISABLE_MANAGEMENT: c_int = 44;
3249
3250pub const PR_SET_FP_MODE: c_int = 45;
3251pub const PR_GET_FP_MODE: c_int = 46;
3252pub const PR_FP_MODE_FR: c_int = 1 << 0;
3253pub const PR_FP_MODE_FRE: c_int = 1 << 1;
3254
3255pub const PR_CAP_AMBIENT: c_int = 47;
3256pub const PR_CAP_AMBIENT_IS_SET: c_int = 1;
3257pub const PR_CAP_AMBIENT_RAISE: c_int = 2;
3258pub const PR_CAP_AMBIENT_LOWER: c_int = 3;
3259pub const PR_CAP_AMBIENT_CLEAR_ALL: c_int = 4;
3260
3261pub const PR_SET_VMA: c_int = 0x53564d41;
3262pub const PR_SET_VMA_ANON_NAME: c_int = 0;
3263
3264pub const PR_SCHED_CORE: c_int = 62;
3265pub const PR_SCHED_CORE_GET: c_int = 0;
3266pub const PR_SCHED_CORE_CREATE: c_int = 1;
3267pub const PR_SCHED_CORE_SHARE_TO: c_int = 2;
3268pub const PR_SCHED_CORE_SHARE_FROM: c_int = 3;
3269pub const PR_SCHED_CORE_MAX: c_int = 4;
3270pub const PR_SCHED_CORE_SCOPE_THREAD: c_int = 0;
3271pub const PR_SCHED_CORE_SCOPE_THREAD_GROUP: c_int = 1;
3272pub const PR_SCHED_CORE_SCOPE_PROCESS_GROUP: c_int = 2;
3273
3274pub const GRND_NONBLOCK: c_uint = 0x0001;
3275pub const GRND_RANDOM: c_uint = 0x0002;
3276pub const GRND_INSECURE: c_uint = 0x0004;
3277
3278// <linux/seccomp.h>
3279pub const SECCOMP_MODE_DISABLED: c_uint = 0;
3280pub const SECCOMP_MODE_STRICT: c_uint = 1;
3281pub const SECCOMP_MODE_FILTER: c_uint = 2;
3282
3283pub const SECCOMP_SET_MODE_STRICT: c_uint = 0;
3284pub const SECCOMP_SET_MODE_FILTER: c_uint = 1;
3285pub const SECCOMP_GET_ACTION_AVAIL: c_uint = 2;
3286pub const SECCOMP_GET_NOTIF_SIZES: c_uint = 3;
3287
3288pub const SECCOMP_FILTER_FLAG_TSYNC: c_ulong = 1;
3289pub const SECCOMP_FILTER_FLAG_LOG: c_ulong = 2;
3290pub const SECCOMP_FILTER_FLAG_SPEC_ALLOW: c_ulong = 4;
3291pub const SECCOMP_FILTER_FLAG_NEW_LISTENER: c_ulong = 8;
3292pub const SECCOMP_FILTER_FLAG_TSYNC_ESRCH: c_ulong = 16;
3293pub const SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV: c_ulong = 32;
3294
3295pub const SECCOMP_RET_KILL_PROCESS: c_uint = 0x80000000;
3296pub const SECCOMP_RET_KILL_THREAD: c_uint = 0x00000000;
3297pub const SECCOMP_RET_KILL: c_uint = SECCOMP_RET_KILL_THREAD;
3298pub const SECCOMP_RET_TRAP: c_uint = 0x00030000;
3299pub const SECCOMP_RET_ERRNO: c_uint = 0x00050000;
3300pub const SECCOMP_RET_TRACE: c_uint = 0x7ff00000;
3301pub const SECCOMP_RET_LOG: c_uint = 0x7ffc0000;
3302pub const SECCOMP_RET_ALLOW: c_uint = 0x7fff0000;
3303
3304pub const SECCOMP_RET_ACTION_FULL: c_uint = 0xffff0000;
3305pub const SECCOMP_RET_ACTION: c_uint = 0x7fff0000;
3306pub const SECCOMP_RET_DATA: c_uint = 0x0000ffff;
3307
3308pub const SECCOMP_USER_NOTIF_FLAG_CONTINUE: c_ulong = 1;
3309
3310pub const SECCOMP_ADDFD_FLAG_SETFD: c_ulong = 1;
3311pub const SECCOMP_ADDFD_FLAG_SEND: c_ulong = 2;
3312
3313pub const ITIMER_REAL: c_int = 0;
3314pub const ITIMER_VIRTUAL: c_int = 1;
3315pub const ITIMER_PROF: c_int = 2;
3316
3317pub const TFD_CLOEXEC: c_int = O_CLOEXEC;
3318pub const TFD_NONBLOCK: c_int = O_NONBLOCK;
3319pub const TFD_TIMER_ABSTIME: c_int = 1;
3320pub const TFD_TIMER_CANCEL_ON_SET: c_int = 2;
3321
3322pub const _POSIX_VDISABLE: crate::cc_t = 0;
3323
3324pub const FALLOC_FL_KEEP_SIZE: c_int = 0x01;
3325pub const FALLOC_FL_PUNCH_HOLE: c_int = 0x02;
3326pub const FALLOC_FL_COLLAPSE_RANGE: c_int = 0x08;
3327pub const FALLOC_FL_ZERO_RANGE: c_int = 0x10;
3328pub const FALLOC_FL_INSERT_RANGE: c_int = 0x20;
3329pub const FALLOC_FL_UNSHARE_RANGE: c_int = 0x40;
3330
3331#[deprecated(
3332    since = "0.2.55",
3333    note = "ENOATTR is not available on Linux; use ENODATA instead"
3334)]
3335pub const ENOATTR: c_int = crate::ENODATA;
3336
3337pub const SO_ORIGINAL_DST: c_int = 80;
3338
3339pub const IP_RECVFRAGSIZE: c_int = 25;
3340
3341pub const IPV6_FLOWINFO: c_int = 11;
3342pub const IPV6_FLOWLABEL_MGR: c_int = 32;
3343pub const IPV6_FLOWINFO_SEND: c_int = 33;
3344pub const IPV6_RECVFRAGSIZE: c_int = 77;
3345pub const IPV6_FREEBIND: c_int = 78;
3346pub const IPV6_FLOWINFO_FLOWLABEL: c_int = 0x000fffff;
3347pub const IPV6_FLOWINFO_PRIORITY: c_int = 0x0ff00000;
3348
3349pub const IPV6_RTHDR_LOOSE: c_int = 0;
3350pub const IPV6_RTHDR_STRICT: c_int = 1;
3351
3352// SO_MEMINFO offsets
3353pub const SK_MEMINFO_RMEM_ALLOC: c_int = 0;
3354pub const SK_MEMINFO_RCVBUF: c_int = 1;
3355pub const SK_MEMINFO_WMEM_ALLOC: c_int = 2;
3356pub const SK_MEMINFO_SNDBUF: c_int = 3;
3357pub const SK_MEMINFO_FWD_ALLOC: c_int = 4;
3358pub const SK_MEMINFO_WMEM_QUEUED: c_int = 5;
3359pub const SK_MEMINFO_OPTMEM: c_int = 6;
3360pub const SK_MEMINFO_BACKLOG: c_int = 7;
3361pub const SK_MEMINFO_DROPS: c_int = 8;
3362
3363pub const IUTF8: crate::tcflag_t = 0x00004000;
3364#[cfg(not(all(target_env = "uclibc", target_arch = "mips")))]
3365pub const CMSPAR: crate::tcflag_t = 0o10000000000;
3366
3367pub const MFD_CLOEXEC: c_uint = 0x0001;
3368pub const MFD_ALLOW_SEALING: c_uint = 0x0002;
3369pub const MFD_HUGETLB: c_uint = 0x0004;
3370pub const MFD_NOEXEC_SEAL: c_uint = 0x0008;
3371pub const MFD_EXEC: c_uint = 0x0010;
3372pub const MFD_HUGE_64KB: c_uint = 0x40000000;
3373pub const MFD_HUGE_512KB: c_uint = 0x4c000000;
3374pub const MFD_HUGE_1MB: c_uint = 0x50000000;
3375pub const MFD_HUGE_2MB: c_uint = 0x54000000;
3376pub const MFD_HUGE_8MB: c_uint = 0x5c000000;
3377pub const MFD_HUGE_16MB: c_uint = 0x60000000;
3378pub const MFD_HUGE_32MB: c_uint = 0x64000000;
3379pub const MFD_HUGE_256MB: c_uint = 0x70000000;
3380pub const MFD_HUGE_512MB: c_uint = 0x74000000;
3381pub const MFD_HUGE_1GB: c_uint = 0x78000000;
3382pub const MFD_HUGE_2GB: c_uint = 0x7c000000;
3383pub const MFD_HUGE_16GB: c_uint = 0x88000000;
3384pub const MFD_HUGE_MASK: c_uint = 63;
3385pub const MFD_HUGE_SHIFT: c_uint = 26;
3386
3387// linux/close_range.h
3388pub const CLOSE_RANGE_UNSHARE: c_uint = 1 << 1;
3389pub const CLOSE_RANGE_CLOEXEC: c_uint = 1 << 2;
3390
3391// linux/filter.h
3392pub const SKF_AD_OFF: c_int = -0x1000;
3393pub const SKF_AD_PROTOCOL: c_int = 0;
3394pub const SKF_AD_PKTTYPE: c_int = 4;
3395pub const SKF_AD_IFINDEX: c_int = 8;
3396pub const SKF_AD_NLATTR: c_int = 12;
3397pub const SKF_AD_NLATTR_NEST: c_int = 16;
3398pub const SKF_AD_MARK: c_int = 20;
3399pub const SKF_AD_QUEUE: c_int = 24;
3400pub const SKF_AD_HATYPE: c_int = 28;
3401pub const SKF_AD_RXHASH: c_int = 32;
3402pub const SKF_AD_CPU: c_int = 36;
3403pub const SKF_AD_ALU_XOR_X: c_int = 40;
3404pub const SKF_AD_VLAN_TAG: c_int = 44;
3405pub const SKF_AD_VLAN_TAG_PRESENT: c_int = 48;
3406pub const SKF_AD_PAY_OFFSET: c_int = 52;
3407pub const SKF_AD_RANDOM: c_int = 56;
3408pub const SKF_AD_VLAN_TPID: c_int = 60;
3409pub const SKF_AD_MAX: c_int = 64;
3410pub const SKF_NET_OFF: c_int = -0x100000;
3411pub const SKF_LL_OFF: c_int = -0x200000;
3412pub const BPF_NET_OFF: c_int = SKF_NET_OFF;
3413pub const BPF_LL_OFF: c_int = SKF_LL_OFF;
3414pub const BPF_MEMWORDS: c_int = 16;
3415pub const BPF_MAXINSNS: c_int = 4096;
3416
3417// linux/bpf_common.h
3418pub const BPF_LD: __u32 = 0x00;
3419pub const BPF_LDX: __u32 = 0x01;
3420pub const BPF_ST: __u32 = 0x02;
3421pub const BPF_STX: __u32 = 0x03;
3422pub const BPF_ALU: __u32 = 0x04;
3423pub const BPF_JMP: __u32 = 0x05;
3424pub const BPF_RET: __u32 = 0x06;
3425pub const BPF_MISC: __u32 = 0x07;
3426pub const BPF_W: __u32 = 0x00;
3427pub const BPF_H: __u32 = 0x08;
3428pub const BPF_B: __u32 = 0x10;
3429pub const BPF_IMM: __u32 = 0x00;
3430pub const BPF_ABS: __u32 = 0x20;
3431pub const BPF_IND: __u32 = 0x40;
3432pub const BPF_MEM: __u32 = 0x60;
3433pub const BPF_LEN: __u32 = 0x80;
3434pub const BPF_MSH: __u32 = 0xa0;
3435pub const BPF_ADD: __u32 = 0x00;
3436pub const BPF_SUB: __u32 = 0x10;
3437pub const BPF_MUL: __u32 = 0x20;
3438pub const BPF_DIV: __u32 = 0x30;
3439pub const BPF_OR: __u32 = 0x40;
3440pub const BPF_AND: __u32 = 0x50;
3441pub const BPF_LSH: __u32 = 0x60;
3442pub const BPF_RSH: __u32 = 0x70;
3443pub const BPF_NEG: __u32 = 0x80;
3444pub const BPF_MOD: __u32 = 0x90;
3445pub const BPF_XOR: __u32 = 0xa0;
3446pub const BPF_JA: __u32 = 0x00;
3447pub const BPF_JEQ: __u32 = 0x10;
3448pub const BPF_JGT: __u32 = 0x20;
3449pub const BPF_JGE: __u32 = 0x30;
3450pub const BPF_JSET: __u32 = 0x40;
3451pub const BPF_K: __u32 = 0x00;
3452pub const BPF_X: __u32 = 0x08;
3453
3454// linux/openat2.h
3455pub const RESOLVE_NO_XDEV: crate::__u64 = 0x01;
3456pub const RESOLVE_NO_MAGICLINKS: crate::__u64 = 0x02;
3457pub const RESOLVE_NO_SYMLINKS: crate::__u64 = 0x04;
3458pub const RESOLVE_BENEATH: crate::__u64 = 0x08;
3459pub const RESOLVE_IN_ROOT: crate::__u64 = 0x10;
3460pub const RESOLVE_CACHED: crate::__u64 = 0x20;
3461
3462// linux/if_ether.h
3463pub const ETH_ALEN: c_int = 6;
3464pub const ETH_HLEN: c_int = 14;
3465pub const ETH_ZLEN: c_int = 60;
3466pub const ETH_DATA_LEN: c_int = 1500;
3467pub const ETH_FRAME_LEN: c_int = 1514;
3468pub const ETH_FCS_LEN: c_int = 4;
3469
3470// These are the defined Ethernet Protocol ID's.
3471pub const ETH_P_LOOP: c_int = 0x0060;
3472pub const ETH_P_PUP: c_int = 0x0200;
3473pub const ETH_P_PUPAT: c_int = 0x0201;
3474pub const ETH_P_IP: c_int = 0x0800;
3475pub const ETH_P_X25: c_int = 0x0805;
3476pub const ETH_P_ARP: c_int = 0x0806;
3477pub const ETH_P_BPQ: c_int = 0x08FF;
3478pub const ETH_P_IEEEPUP: c_int = 0x0a00;
3479pub const ETH_P_IEEEPUPAT: c_int = 0x0a01;
3480pub const ETH_P_BATMAN: c_int = 0x4305;
3481pub const ETH_P_DEC: c_int = 0x6000;
3482pub const ETH_P_DNA_DL: c_int = 0x6001;
3483pub const ETH_P_DNA_RC: c_int = 0x6002;
3484pub const ETH_P_DNA_RT: c_int = 0x6003;
3485pub const ETH_P_LAT: c_int = 0x6004;
3486pub const ETH_P_DIAG: c_int = 0x6005;
3487pub const ETH_P_CUST: c_int = 0x6006;
3488pub const ETH_P_SCA: c_int = 0x6007;
3489pub const ETH_P_TEB: c_int = 0x6558;
3490pub const ETH_P_RARP: c_int = 0x8035;
3491pub const ETH_P_ATALK: c_int = 0x809B;
3492pub const ETH_P_AARP: c_int = 0x80F3;
3493pub const ETH_P_8021Q: c_int = 0x8100;
3494pub const ETH_P_IPX: c_int = 0x8137;
3495pub const ETH_P_IPV6: c_int = 0x86DD;
3496pub const ETH_P_PAUSE: c_int = 0x8808;
3497pub const ETH_P_SLOW: c_int = 0x8809;
3498pub const ETH_P_WCCP: c_int = 0x883E;
3499pub const ETH_P_MPLS_UC: c_int = 0x8847;
3500pub const ETH_P_MPLS_MC: c_int = 0x8848;
3501pub const ETH_P_ATMMPOA: c_int = 0x884c;
3502pub const ETH_P_PPP_DISC: c_int = 0x8863;
3503pub const ETH_P_PPP_SES: c_int = 0x8864;
3504pub const ETH_P_LINK_CTL: c_int = 0x886c;
3505pub const ETH_P_ATMFATE: c_int = 0x8884;
3506pub const ETH_P_PAE: c_int = 0x888E;
3507pub const ETH_P_AOE: c_int = 0x88A2;
3508pub const ETH_P_8021AD: c_int = 0x88A8;
3509pub const ETH_P_802_EX1: c_int = 0x88B5;
3510pub const ETH_P_TIPC: c_int = 0x88CA;
3511pub const ETH_P_MACSEC: c_int = 0x88E5;
3512pub const ETH_P_8021AH: c_int = 0x88E7;
3513pub const ETH_P_MVRP: c_int = 0x88F5;
3514pub const ETH_P_1588: c_int = 0x88F7;
3515pub const ETH_P_PRP: c_int = 0x88FB;
3516pub const ETH_P_FCOE: c_int = 0x8906;
3517pub const ETH_P_TDLS: c_int = 0x890D;
3518pub const ETH_P_FIP: c_int = 0x8914;
3519pub const ETH_P_80221: c_int = 0x8917;
3520pub const ETH_P_LOOPBACK: c_int = 0x9000;
3521pub const ETH_P_QINQ1: c_int = 0x9100;
3522pub const ETH_P_QINQ2: c_int = 0x9200;
3523pub const ETH_P_QINQ3: c_int = 0x9300;
3524pub const ETH_P_EDSA: c_int = 0xDADA;
3525pub const ETH_P_AF_IUCV: c_int = 0xFBFB;
3526
3527pub const ETH_P_802_3_MIN: c_int = 0x0600;
3528
3529// Non DIX types. Won't clash for 1500 types.
3530pub const ETH_P_802_3: c_int = 0x0001;
3531pub const ETH_P_AX25: c_int = 0x0002;
3532pub const ETH_P_ALL: c_int = 0x0003;
3533pub const ETH_P_802_2: c_int = 0x0004;
3534pub const ETH_P_SNAP: c_int = 0x0005;
3535pub const ETH_P_DDCMP: c_int = 0x0006;
3536pub const ETH_P_WAN_PPP: c_int = 0x0007;
3537pub const ETH_P_PPP_MP: c_int = 0x0008;
3538pub const ETH_P_LOCALTALK: c_int = 0x0009;
3539pub const ETH_P_CANFD: c_int = 0x000D;
3540pub const ETH_P_PPPTALK: c_int = 0x0010;
3541pub const ETH_P_TR_802_2: c_int = 0x0011;
3542pub const ETH_P_MOBITEX: c_int = 0x0015;
3543pub const ETH_P_CONTROL: c_int = 0x0016;
3544pub const ETH_P_IRDA: c_int = 0x0017;
3545pub const ETH_P_ECONET: c_int = 0x0018;
3546pub const ETH_P_HDLC: c_int = 0x0019;
3547pub const ETH_P_ARCNET: c_int = 0x001A;
3548pub const ETH_P_DSA: c_int = 0x001B;
3549pub const ETH_P_TRAILER: c_int = 0x001C;
3550pub const ETH_P_PHONET: c_int = 0x00F5;
3551pub const ETH_P_IEEE802154: c_int = 0x00F6;
3552pub const ETH_P_CAIF: c_int = 0x00F7;
3553
3554// DIFF(main): changed to `c_short` in f62eb023ab
3555pub const POSIX_SPAWN_RESETIDS: c_int = 0x01;
3556pub const POSIX_SPAWN_SETPGROUP: c_int = 0x02;
3557pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x04;
3558pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x08;
3559pub const POSIX_SPAWN_SETSCHEDPARAM: c_int = 0x10;
3560pub const POSIX_SPAWN_SETSCHEDULER: c_int = 0x20;
3561
3562pub const NLMSG_NOOP: c_int = 0x1;
3563pub const NLMSG_ERROR: c_int = 0x2;
3564pub const NLMSG_DONE: c_int = 0x3;
3565pub const NLMSG_OVERRUN: c_int = 0x4;
3566pub const NLMSG_MIN_TYPE: c_int = 0x10;
3567
3568// linux/netfilter/nfnetlink.h
3569pub const NFNLGRP_NONE: c_int = 0;
3570pub const NFNLGRP_CONNTRACK_NEW: c_int = 1;
3571pub const NFNLGRP_CONNTRACK_UPDATE: c_int = 2;
3572pub const NFNLGRP_CONNTRACK_DESTROY: c_int = 3;
3573pub const NFNLGRP_CONNTRACK_EXP_NEW: c_int = 4;
3574pub const NFNLGRP_CONNTRACK_EXP_UPDATE: c_int = 5;
3575pub const NFNLGRP_CONNTRACK_EXP_DESTROY: c_int = 6;
3576pub const NFNLGRP_NFTABLES: c_int = 7;
3577pub const NFNLGRP_ACCT_QUOTA: c_int = 8;
3578pub const NFNLGRP_NFTRACE: c_int = 9;
3579
3580pub const NFNETLINK_V0: c_int = 0;
3581
3582pub const NFNL_SUBSYS_NONE: c_int = 0;
3583pub const NFNL_SUBSYS_CTNETLINK: c_int = 1;
3584pub const NFNL_SUBSYS_CTNETLINK_EXP: c_int = 2;
3585pub const NFNL_SUBSYS_QUEUE: c_int = 3;
3586pub const NFNL_SUBSYS_ULOG: c_int = 4;
3587pub const NFNL_SUBSYS_OSF: c_int = 5;
3588pub const NFNL_SUBSYS_IPSET: c_int = 6;
3589pub const NFNL_SUBSYS_ACCT: c_int = 7;
3590pub const NFNL_SUBSYS_CTNETLINK_TIMEOUT: c_int = 8;
3591pub const NFNL_SUBSYS_CTHELPER: c_int = 9;
3592pub const NFNL_SUBSYS_NFTABLES: c_int = 10;
3593pub const NFNL_SUBSYS_NFT_COMPAT: c_int = 11;
3594pub const NFNL_SUBSYS_HOOK: c_int = 12;
3595pub const NFNL_SUBSYS_COUNT: c_int = 13;
3596
3597pub const NFNL_MSG_BATCH_BEGIN: c_int = NLMSG_MIN_TYPE;
3598pub const NFNL_MSG_BATCH_END: c_int = NLMSG_MIN_TYPE + 1;
3599
3600pub const NFNL_BATCH_UNSPEC: c_int = 0;
3601pub const NFNL_BATCH_GENID: c_int = 1;
3602
3603// linux/netfilter/nfnetlink_log.h
3604pub const NFULNL_MSG_PACKET: c_int = 0;
3605pub const NFULNL_MSG_CONFIG: c_int = 1;
3606
3607pub const NFULA_VLAN_UNSPEC: c_int = 0;
3608pub const NFULA_VLAN_PROTO: c_int = 1;
3609pub const NFULA_VLAN_TCI: c_int = 2;
3610
3611pub const NFULA_UNSPEC: c_int = 0;
3612pub const NFULA_PACKET_HDR: c_int = 1;
3613pub const NFULA_MARK: c_int = 2;
3614pub const NFULA_TIMESTAMP: c_int = 3;
3615pub const NFULA_IFINDEX_INDEV: c_int = 4;
3616pub const NFULA_IFINDEX_OUTDEV: c_int = 5;
3617pub const NFULA_IFINDEX_PHYSINDEV: c_int = 6;
3618pub const NFULA_IFINDEX_PHYSOUTDEV: c_int = 7;
3619pub const NFULA_HWADDR: c_int = 8;
3620pub const NFULA_PAYLOAD: c_int = 9;
3621pub const NFULA_PREFIX: c_int = 10;
3622pub const NFULA_UID: c_int = 11;
3623pub const NFULA_SEQ: c_int = 12;
3624pub const NFULA_SEQ_GLOBAL: c_int = 13;
3625pub const NFULA_GID: c_int = 14;
3626pub const NFULA_HWTYPE: c_int = 15;
3627pub const NFULA_HWHEADER: c_int = 16;
3628pub const NFULA_HWLEN: c_int = 17;
3629pub const NFULA_CT: c_int = 18;
3630pub const NFULA_CT_INFO: c_int = 19;
3631pub const NFULA_VLAN: c_int = 20;
3632pub const NFULA_L2HDR: c_int = 21;
3633
3634pub const NFULNL_CFG_CMD_NONE: c_int = 0;
3635pub const NFULNL_CFG_CMD_BIND: c_int = 1;
3636pub const NFULNL_CFG_CMD_UNBIND: c_int = 2;
3637pub const NFULNL_CFG_CMD_PF_BIND: c_int = 3;
3638pub const NFULNL_CFG_CMD_PF_UNBIND: c_int = 4;
3639
3640pub const NFULA_CFG_UNSPEC: c_int = 0;
3641pub const NFULA_CFG_CMD: c_int = 1;
3642pub const NFULA_CFG_MODE: c_int = 2;
3643pub const NFULA_CFG_NLBUFSIZ: c_int = 3;
3644pub const NFULA_CFG_TIMEOUT: c_int = 4;
3645pub const NFULA_CFG_QTHRESH: c_int = 5;
3646pub const NFULA_CFG_FLAGS: c_int = 6;
3647
3648pub const NFULNL_COPY_NONE: c_int = 0x00;
3649pub const NFULNL_COPY_META: c_int = 0x01;
3650pub const NFULNL_COPY_PACKET: c_int = 0x02;
3651
3652pub const NFULNL_CFG_F_SEQ: c_int = 0x0001;
3653pub const NFULNL_CFG_F_SEQ_GLOBAL: c_int = 0x0002;
3654pub const NFULNL_CFG_F_CONNTRACK: c_int = 0x0004;
3655
3656// linux/netfilter/nfnetlink_queue.h
3657pub const NFQNL_MSG_PACKET: c_int = 0;
3658pub const NFQNL_MSG_VERDICT: c_int = 1;
3659pub const NFQNL_MSG_CONFIG: c_int = 2;
3660pub const NFQNL_MSG_VERDICT_BATCH: c_int = 3;
3661
3662pub const NFQA_UNSPEC: c_int = 0;
3663pub const NFQA_PACKET_HDR: c_int = 1;
3664pub const NFQA_VERDICT_HDR: c_int = 2;
3665pub const NFQA_MARK: c_int = 3;
3666pub const NFQA_TIMESTAMP: c_int = 4;
3667pub const NFQA_IFINDEX_INDEV: c_int = 5;
3668pub const NFQA_IFINDEX_OUTDEV: c_int = 6;
3669pub const NFQA_IFINDEX_PHYSINDEV: c_int = 7;
3670pub const NFQA_IFINDEX_PHYSOUTDEV: c_int = 8;
3671pub const NFQA_HWADDR: c_int = 9;
3672pub const NFQA_PAYLOAD: c_int = 10;
3673pub const NFQA_CT: c_int = 11;
3674pub const NFQA_CT_INFO: c_int = 12;
3675pub const NFQA_CAP_LEN: c_int = 13;
3676pub const NFQA_SKB_INFO: c_int = 14;
3677pub const NFQA_EXP: c_int = 15;
3678pub const NFQA_UID: c_int = 16;
3679pub const NFQA_GID: c_int = 17;
3680pub const NFQA_SECCTX: c_int = 18;
3681pub const NFQA_VLAN: c_int = 19;
3682pub const NFQA_L2HDR: c_int = 20;
3683pub const NFQA_PRIORITY: c_int = 21;
3684
3685pub const NFQA_VLAN_UNSPEC: c_int = 0;
3686pub const NFQA_VLAN_PROTO: c_int = 1;
3687pub const NFQA_VLAN_TCI: c_int = 2;
3688
3689pub const NFQNL_CFG_CMD_NONE: c_int = 0;
3690pub const NFQNL_CFG_CMD_BIND: c_int = 1;
3691pub const NFQNL_CFG_CMD_UNBIND: c_int = 2;
3692pub const NFQNL_CFG_CMD_PF_BIND: c_int = 3;
3693pub const NFQNL_CFG_CMD_PF_UNBIND: c_int = 4;
3694
3695pub const NFQNL_COPY_NONE: c_int = 0;
3696pub const NFQNL_COPY_META: c_int = 1;
3697pub const NFQNL_COPY_PACKET: c_int = 2;
3698
3699pub const NFQA_CFG_UNSPEC: c_int = 0;
3700pub const NFQA_CFG_CMD: c_int = 1;
3701pub const NFQA_CFG_PARAMS: c_int = 2;
3702pub const NFQA_CFG_QUEUE_MAXLEN: c_int = 3;
3703pub const NFQA_CFG_MASK: c_int = 4;
3704pub const NFQA_CFG_FLAGS: c_int = 5;
3705
3706pub const NFQA_CFG_F_FAIL_OPEN: c_int = 0x0001;
3707pub const NFQA_CFG_F_CONNTRACK: c_int = 0x0002;
3708pub const NFQA_CFG_F_GSO: c_int = 0x0004;
3709pub const NFQA_CFG_F_UID_GID: c_int = 0x0008;
3710pub const NFQA_CFG_F_SECCTX: c_int = 0x0010;
3711pub const NFQA_CFG_F_MAX: c_int = 0x0020;
3712
3713pub const NFQA_SKB_CSUMNOTREADY: c_int = 0x0001;
3714pub const NFQA_SKB_GSO: c_int = 0x0002;
3715pub const NFQA_SKB_CSUM_NOTVERIFIED: c_int = 0x0004;
3716
3717// linux/genetlink.h
3718
3719pub const GENL_NAMSIZ: c_int = 16;
3720
3721pub const GENL_MIN_ID: c_int = NLMSG_MIN_TYPE;
3722pub const GENL_MAX_ID: c_int = 1023;
3723
3724pub const GENL_ADMIN_PERM: c_int = 0x01;
3725pub const GENL_CMD_CAP_DO: c_int = 0x02;
3726pub const GENL_CMD_CAP_DUMP: c_int = 0x04;
3727pub const GENL_CMD_CAP_HASPOL: c_int = 0x08;
3728
3729pub const GENL_ID_CTRL: c_int = NLMSG_MIN_TYPE;
3730
3731pub const CTRL_CMD_UNSPEC: c_int = 0;
3732pub const CTRL_CMD_NEWFAMILY: c_int = 1;
3733pub const CTRL_CMD_DELFAMILY: c_int = 2;
3734pub const CTRL_CMD_GETFAMILY: c_int = 3;
3735pub const CTRL_CMD_NEWOPS: c_int = 4;
3736pub const CTRL_CMD_DELOPS: c_int = 5;
3737pub const CTRL_CMD_GETOPS: c_int = 6;
3738pub const CTRL_CMD_NEWMCAST_GRP: c_int = 7;
3739pub const CTRL_CMD_DELMCAST_GRP: c_int = 8;
3740pub const CTRL_CMD_GETMCAST_GRP: c_int = 9;
3741
3742pub const CTRL_ATTR_UNSPEC: c_int = 0;
3743pub const CTRL_ATTR_FAMILY_ID: c_int = 1;
3744pub const CTRL_ATTR_FAMILY_NAME: c_int = 2;
3745pub const CTRL_ATTR_VERSION: c_int = 3;
3746pub const CTRL_ATTR_HDRSIZE: c_int = 4;
3747pub const CTRL_ATTR_MAXATTR: c_int = 5;
3748pub const CTRL_ATTR_OPS: c_int = 6;
3749pub const CTRL_ATTR_MCAST_GROUPS: c_int = 7;
3750
3751pub const CTRL_ATTR_OP_UNSPEC: c_int = 0;
3752pub const CTRL_ATTR_OP_ID: c_int = 1;
3753pub const CTRL_ATTR_OP_FLAGS: c_int = 2;
3754
3755pub const CTRL_ATTR_MCAST_GRP_UNSPEC: c_int = 0;
3756pub const CTRL_ATTR_MCAST_GRP_NAME: c_int = 1;
3757pub const CTRL_ATTR_MCAST_GRP_ID: c_int = 2;
3758
3759// linux/if_packet.h
3760pub const PACKET_HOST: c_uchar = 0;
3761pub const PACKET_BROADCAST: c_uchar = 1;
3762pub const PACKET_MULTICAST: c_uchar = 2;
3763pub const PACKET_OTHERHOST: c_uchar = 3;
3764pub const PACKET_OUTGOING: c_uchar = 4;
3765pub const PACKET_LOOPBACK: c_uchar = 5;
3766pub const PACKET_USER: c_uchar = 6;
3767pub const PACKET_KERNEL: c_uchar = 7;
3768
3769pub const PACKET_ADD_MEMBERSHIP: c_int = 1;
3770pub const PACKET_DROP_MEMBERSHIP: c_int = 2;
3771pub const PACKET_RX_RING: c_int = 5;
3772pub const PACKET_STATISTICS: c_int = 6;
3773pub const PACKET_AUXDATA: c_int = 8;
3774pub const PACKET_VERSION: c_int = 10;
3775pub const PACKET_RESERVE: c_int = 12;
3776pub const PACKET_TX_RING: c_int = 13;
3777pub const PACKET_LOSS: c_int = 14;
3778pub const PACKET_TIMESTAMP: c_int = 17;
3779pub const PACKET_FANOUT: c_int = 18;
3780pub const PACKET_QDISC_BYPASS: c_int = 20;
3781
3782pub const PACKET_FANOUT_HASH: c_uint = 0;
3783pub const PACKET_FANOUT_LB: c_uint = 1;
3784pub const PACKET_FANOUT_CPU: c_uint = 2;
3785pub const PACKET_FANOUT_ROLLOVER: c_uint = 3;
3786pub const PACKET_FANOUT_RND: c_uint = 4;
3787pub const PACKET_FANOUT_QM: c_uint = 5;
3788pub const PACKET_FANOUT_CBPF: c_uint = 6;
3789pub const PACKET_FANOUT_EBPF: c_uint = 7;
3790pub const PACKET_FANOUT_FLAG_ROLLOVER: c_uint = 0x1000;
3791pub const PACKET_FANOUT_FLAG_UNIQUEID: c_uint = 0x2000;
3792pub const PACKET_FANOUT_FLAG_DEFRAG: c_uint = 0x8000;
3793
3794pub const PACKET_MR_MULTICAST: c_int = 0;
3795pub const PACKET_MR_PROMISC: c_int = 1;
3796pub const PACKET_MR_ALLMULTI: c_int = 2;
3797
3798pub const TP_STATUS_KERNEL: __u32 = 0;
3799pub const TP_STATUS_USER: __u32 = 1 << 0;
3800pub const TP_STATUS_COPY: __u32 = 1 << 1;
3801pub const TP_STATUS_LOSING: __u32 = 1 << 2;
3802pub const TP_STATUS_CSUMNOTREADY: __u32 = 1 << 3;
3803pub const TP_STATUS_VLAN_VALID: __u32 = 1 << 4;
3804pub const TP_STATUS_BLK_TMO: __u32 = 1 << 5;
3805pub const TP_STATUS_VLAN_TPID_VALID: __u32 = 1 << 6;
3806pub const TP_STATUS_CSUM_VALID: __u32 = 1 << 7;
3807
3808pub const TP_STATUS_AVAILABLE: __u32 = 0;
3809pub const TP_STATUS_SEND_REQUEST: __u32 = 1 << 0;
3810pub const TP_STATUS_SENDING: __u32 = 1 << 1;
3811pub const TP_STATUS_WRONG_FORMAT: __u32 = 1 << 2;
3812
3813pub const TP_STATUS_TS_SOFTWARE: __u32 = 1 << 29;
3814pub const TP_STATUS_TS_SYS_HARDWARE: __u32 = 1 << 30;
3815pub const TP_STATUS_TS_RAW_HARDWARE: __u32 = 1 << 31;
3816
3817pub const TP_FT_REQ_FILL_RXHASH: __u32 = 1;
3818
3819pub const TPACKET_ALIGNMENT: usize = 16;
3820
3821pub const TPACKET_HDRLEN: usize = ((size_of::<crate::tpacket_hdr>() + TPACKET_ALIGNMENT - 1)
3822    & !(TPACKET_ALIGNMENT - 1))
3823    + size_of::<crate::sockaddr_ll>();
3824pub const TPACKET2_HDRLEN: usize = ((size_of::<crate::tpacket2_hdr>() + TPACKET_ALIGNMENT - 1)
3825    & !(TPACKET_ALIGNMENT - 1))
3826    + size_of::<crate::sockaddr_ll>();
3827pub const TPACKET3_HDRLEN: usize = ((size_of::<crate::tpacket3_hdr>() + TPACKET_ALIGNMENT - 1)
3828    & !(TPACKET_ALIGNMENT - 1))
3829    + size_of::<crate::sockaddr_ll>();
3830
3831// linux/netfilter.h
3832pub const NF_DROP: c_int = 0;
3833pub const NF_ACCEPT: c_int = 1;
3834pub const NF_STOLEN: c_int = 2;
3835pub const NF_QUEUE: c_int = 3;
3836pub const NF_REPEAT: c_int = 4;
3837pub const NF_STOP: c_int = 5;
3838pub const NF_MAX_VERDICT: c_int = NF_STOP;
3839
3840pub const NF_VERDICT_MASK: c_int = 0x000000ff;
3841pub const NF_VERDICT_FLAG_QUEUE_BYPASS: c_int = 0x00008000;
3842
3843pub const NF_VERDICT_QMASK: c_int = 0xffff0000;
3844pub const NF_VERDICT_QBITS: c_int = 16;
3845
3846pub const NF_VERDICT_BITS: c_int = 16;
3847
3848pub const NF_INET_PRE_ROUTING: c_int = 0;
3849pub const NF_INET_LOCAL_IN: c_int = 1;
3850pub const NF_INET_FORWARD: c_int = 2;
3851pub const NF_INET_LOCAL_OUT: c_int = 3;
3852pub const NF_INET_POST_ROUTING: c_int = 4;
3853pub const NF_INET_NUMHOOKS: c_int = 5;
3854pub const NF_INET_INGRESS: c_int = NF_INET_NUMHOOKS;
3855
3856pub const NF_NETDEV_INGRESS: c_int = 0;
3857pub const NF_NETDEV_EGRESS: c_int = 1;
3858pub const NF_NETDEV_NUMHOOKS: c_int = 2;
3859
3860// Some NFPROTO are not compatible with musl and are defined in submodules.
3861pub const NFPROTO_UNSPEC: c_int = 0;
3862pub const NFPROTO_INET: c_int = 1;
3863pub const NFPROTO_IPV4: c_int = 2;
3864pub const NFPROTO_ARP: c_int = 3;
3865pub const NFPROTO_NETDEV: c_int = 5;
3866pub const NFPROTO_BRIDGE: c_int = 7;
3867pub const NFPROTO_IPV6: c_int = 10;
3868pub const NFPROTO_DECNET: c_int = 12;
3869pub const NFPROTO_NUMPROTO: c_int = 13;
3870
3871// linux/netfilter_arp.h
3872pub const NF_ARP: c_int = 0;
3873pub const NF_ARP_IN: c_int = 0;
3874pub const NF_ARP_OUT: c_int = 1;
3875pub const NF_ARP_FORWARD: c_int = 2;
3876pub const NF_ARP_NUMHOOKS: c_int = 3;
3877
3878// linux/netfilter_bridge.h
3879pub const NF_BR_PRE_ROUTING: c_int = 0;
3880pub const NF_BR_LOCAL_IN: c_int = 1;
3881pub const NF_BR_FORWARD: c_int = 2;
3882pub const NF_BR_LOCAL_OUT: c_int = 3;
3883pub const NF_BR_POST_ROUTING: c_int = 4;
3884pub const NF_BR_BROUTING: c_int = 5;
3885pub const NF_BR_NUMHOOKS: c_int = 6;
3886
3887pub const NF_BR_PRI_FIRST: c_int = crate::INT_MIN;
3888pub const NF_BR_PRI_NAT_DST_BRIDGED: c_int = -300;
3889pub const NF_BR_PRI_FILTER_BRIDGED: c_int = -200;
3890pub const NF_BR_PRI_BRNF: c_int = 0;
3891pub const NF_BR_PRI_NAT_DST_OTHER: c_int = 100;
3892pub const NF_BR_PRI_FILTER_OTHER: c_int = 200;
3893pub const NF_BR_PRI_NAT_SRC: c_int = 300;
3894pub const NF_BR_PRI_LAST: c_int = crate::INT_MAX;
3895
3896// linux/netfilter_ipv4.h
3897pub const NF_IP_PRE_ROUTING: c_int = 0;
3898pub const NF_IP_LOCAL_IN: c_int = 1;
3899pub const NF_IP_FORWARD: c_int = 2;
3900pub const NF_IP_LOCAL_OUT: c_int = 3;
3901pub const NF_IP_POST_ROUTING: c_int = 4;
3902pub const NF_IP_NUMHOOKS: c_int = 5;
3903
3904pub const NF_IP_PRI_FIRST: c_int = crate::INT_MIN;
3905pub const NF_IP_PRI_RAW_BEFORE_DEFRAG: c_int = -450;
3906pub const NF_IP_PRI_CONNTRACK_DEFRAG: c_int = -400;
3907pub const NF_IP_PRI_RAW: c_int = -300;
3908pub const NF_IP_PRI_SELINUX_FIRST: c_int = -225;
3909pub const NF_IP_PRI_CONNTRACK: c_int = -200;
3910pub const NF_IP_PRI_MANGLE: c_int = -150;
3911pub const NF_IP_PRI_NAT_DST: c_int = -100;
3912pub const NF_IP_PRI_FILTER: c_int = 0;
3913pub const NF_IP_PRI_SECURITY: c_int = 50;
3914pub const NF_IP_PRI_NAT_SRC: c_int = 100;
3915pub const NF_IP_PRI_SELINUX_LAST: c_int = 225;
3916pub const NF_IP_PRI_CONNTRACK_HELPER: c_int = 300;
3917pub const NF_IP_PRI_CONNTRACK_CONFIRM: c_int = crate::INT_MAX;
3918pub const NF_IP_PRI_LAST: c_int = crate::INT_MAX;
3919
3920// linux/netfilter_ipv6.h
3921pub const NF_IP6_PRE_ROUTING: c_int = 0;
3922pub const NF_IP6_LOCAL_IN: c_int = 1;
3923pub const NF_IP6_FORWARD: c_int = 2;
3924pub const NF_IP6_LOCAL_OUT: c_int = 3;
3925pub const NF_IP6_POST_ROUTING: c_int = 4;
3926pub const NF_IP6_NUMHOOKS: c_int = 5;
3927
3928pub const NF_IP6_PRI_FIRST: c_int = crate::INT_MIN;
3929pub const NF_IP6_PRI_RAW_BEFORE_DEFRAG: c_int = -450;
3930pub const NF_IP6_PRI_CONNTRACK_DEFRAG: c_int = -400;
3931pub const NF_IP6_PRI_RAW: c_int = -300;
3932pub const NF_IP6_PRI_SELINUX_FIRST: c_int = -225;
3933pub const NF_IP6_PRI_CONNTRACK: c_int = -200;
3934pub const NF_IP6_PRI_MANGLE: c_int = -150;
3935pub const NF_IP6_PRI_NAT_DST: c_int = -100;
3936pub const NF_IP6_PRI_FILTER: c_int = 0;
3937pub const NF_IP6_PRI_SECURITY: c_int = 50;
3938pub const NF_IP6_PRI_NAT_SRC: c_int = 100;
3939pub const NF_IP6_PRI_SELINUX_LAST: c_int = 225;
3940pub const NF_IP6_PRI_CONNTRACK_HELPER: c_int = 300;
3941pub const NF_IP6_PRI_LAST: c_int = crate::INT_MAX;
3942
3943// linux/netfilter_ipv6/ip6_tables.h
3944pub const IP6T_SO_ORIGINAL_DST: c_int = 80;
3945
3946pub const SIOCADDRT: c_ulong = 0x0000890B;
3947pub const SIOCDELRT: c_ulong = 0x0000890C;
3948pub const SIOCGIFNAME: c_ulong = 0x00008910;
3949pub const SIOCSIFLINK: c_ulong = 0x00008911;
3950pub const SIOCGIFCONF: c_ulong = 0x00008912;
3951pub const SIOCGIFFLAGS: c_ulong = 0x00008913;
3952pub const SIOCSIFFLAGS: c_ulong = 0x00008914;
3953pub const SIOCGIFADDR: c_ulong = 0x00008915;
3954pub const SIOCSIFADDR: c_ulong = 0x00008916;
3955pub const SIOCGIFDSTADDR: c_ulong = 0x00008917;
3956pub const SIOCSIFDSTADDR: c_ulong = 0x00008918;
3957pub const SIOCGIFBRDADDR: c_ulong = 0x00008919;
3958pub const SIOCSIFBRDADDR: c_ulong = 0x0000891A;
3959pub const SIOCGIFNETMASK: c_ulong = 0x0000891B;
3960pub const SIOCSIFNETMASK: c_ulong = 0x0000891C;
3961pub const SIOCGIFMETRIC: c_ulong = 0x0000891D;
3962pub const SIOCSIFMETRIC: c_ulong = 0x0000891E;
3963pub const SIOCGIFMEM: c_ulong = 0x0000891F;
3964pub const SIOCSIFMEM: c_ulong = 0x00008920;
3965pub const SIOCGIFMTU: c_ulong = 0x00008921;
3966pub const SIOCSIFMTU: c_ulong = 0x00008922;
3967pub const SIOCSIFNAME: c_ulong = 0x00008923;
3968pub const SIOCSIFHWADDR: c_ulong = 0x00008924;
3969pub const SIOCGIFENCAP: c_ulong = 0x00008925;
3970pub const SIOCSIFENCAP: c_ulong = 0x00008926;
3971pub const SIOCGIFHWADDR: c_ulong = 0x00008927;
3972pub const SIOCGIFSLAVE: c_ulong = 0x00008929;
3973pub const SIOCSIFSLAVE: c_ulong = 0x00008930;
3974pub const SIOCADDMULTI: c_ulong = 0x00008931;
3975pub const SIOCDELMULTI: c_ulong = 0x00008932;
3976pub const SIOCGIFINDEX: c_ulong = 0x00008933;
3977pub const SIOGIFINDEX: c_ulong = SIOCGIFINDEX;
3978pub const SIOCSIFPFLAGS: c_ulong = 0x00008934;
3979pub const SIOCGIFPFLAGS: c_ulong = 0x00008935;
3980pub const SIOCDIFADDR: c_ulong = 0x00008936;
3981pub const SIOCSIFHWBROADCAST: c_ulong = 0x00008937;
3982pub const SIOCGIFCOUNT: c_ulong = 0x00008938;
3983pub const SIOCGIFBR: c_ulong = 0x00008940;
3984pub const SIOCSIFBR: c_ulong = 0x00008941;
3985pub const SIOCGIFTXQLEN: c_ulong = 0x00008942;
3986pub const SIOCSIFTXQLEN: c_ulong = 0x00008943;
3987pub const SIOCETHTOOL: c_ulong = 0x00008946;
3988pub const SIOCGMIIPHY: c_ulong = 0x00008947;
3989pub const SIOCGMIIREG: c_ulong = 0x00008948;
3990pub const SIOCSMIIREG: c_ulong = 0x00008949;
3991pub const SIOCWANDEV: c_ulong = 0x0000894A;
3992pub const SIOCOUTQNSD: c_ulong = 0x0000894B;
3993pub const SIOCGSKNS: c_ulong = 0x0000894C;
3994pub const SIOCDARP: c_ulong = 0x00008953;
3995pub const SIOCGARP: c_ulong = 0x00008954;
3996pub const SIOCSARP: c_ulong = 0x00008955;
3997pub const SIOCDRARP: c_ulong = 0x00008960;
3998pub const SIOCGRARP: c_ulong = 0x00008961;
3999pub const SIOCSRARP: c_ulong = 0x00008962;
4000pub const SIOCGIFMAP: c_ulong = 0x00008970;
4001pub const SIOCSIFMAP: c_ulong = 0x00008971;
4002pub const SIOCSHWTSTAMP: c_ulong = 0x000089b0;
4003pub const SIOCGHWTSTAMP: c_ulong = 0x000089b1;
4004
4005// wireless.h
4006pub const WIRELESS_EXT: c_ulong = 0x16;
4007
4008pub const SIOCSIWCOMMIT: c_ulong = 0x8B00;
4009pub const SIOCGIWNAME: c_ulong = 0x8B01;
4010
4011pub const SIOCSIWNWID: c_ulong = 0x8B02;
4012pub const SIOCGIWNWID: c_ulong = 0x8B03;
4013pub const SIOCSIWFREQ: c_ulong = 0x8B04;
4014pub const SIOCGIWFREQ: c_ulong = 0x8B05;
4015pub const SIOCSIWMODE: c_ulong = 0x8B06;
4016pub const SIOCGIWMODE: c_ulong = 0x8B07;
4017pub const SIOCSIWSENS: c_ulong = 0x8B08;
4018pub const SIOCGIWSENS: c_ulong = 0x8B09;
4019
4020pub const SIOCSIWRANGE: c_ulong = 0x8B0A;
4021pub const SIOCGIWRANGE: c_ulong = 0x8B0B;
4022pub const SIOCSIWPRIV: c_ulong = 0x8B0C;
4023pub const SIOCGIWPRIV: c_ulong = 0x8B0D;
4024pub const SIOCSIWSTATS: c_ulong = 0x8B0E;
4025pub const SIOCGIWSTATS: c_ulong = 0x8B0F;
4026
4027pub const SIOCSIWSPY: c_ulong = 0x8B10;
4028pub const SIOCGIWSPY: c_ulong = 0x8B11;
4029pub const SIOCSIWTHRSPY: c_ulong = 0x8B12;
4030pub const SIOCGIWTHRSPY: c_ulong = 0x8B13;
4031
4032pub const SIOCSIWAP: c_ulong = 0x8B14;
4033pub const SIOCGIWAP: c_ulong = 0x8B15;
4034pub const SIOCGIWAPLIST: c_ulong = 0x8B17;
4035pub const SIOCSIWSCAN: c_ulong = 0x8B18;
4036pub const SIOCGIWSCAN: c_ulong = 0x8B19;
4037
4038pub const SIOCSIWESSID: c_ulong = 0x8B1A;
4039pub const SIOCGIWESSID: c_ulong = 0x8B1B;
4040pub const SIOCSIWNICKN: c_ulong = 0x8B1C;
4041pub const SIOCGIWNICKN: c_ulong = 0x8B1D;
4042
4043pub const SIOCSIWRATE: c_ulong = 0x8B20;
4044pub const SIOCGIWRATE: c_ulong = 0x8B21;
4045pub const SIOCSIWRTS: c_ulong = 0x8B22;
4046pub const SIOCGIWRTS: c_ulong = 0x8B23;
4047pub const SIOCSIWFRAG: c_ulong = 0x8B24;
4048pub const SIOCGIWFRAG: c_ulong = 0x8B25;
4049pub const SIOCSIWTXPOW: c_ulong = 0x8B26;
4050pub const SIOCGIWTXPOW: c_ulong = 0x8B27;
4051pub const SIOCSIWRETRY: c_ulong = 0x8B28;
4052pub const SIOCGIWRETRY: c_ulong = 0x8B29;
4053
4054pub const SIOCSIWENCODE: c_ulong = 0x8B2A;
4055pub const SIOCGIWENCODE: c_ulong = 0x8B2B;
4056
4057pub const SIOCSIWPOWER: c_ulong = 0x8B2C;
4058pub const SIOCGIWPOWER: c_ulong = 0x8B2D;
4059
4060pub const SIOCSIWGENIE: c_ulong = 0x8B30;
4061pub const SIOCGIWGENIE: c_ulong = 0x8B31;
4062
4063pub const SIOCSIWMLME: c_ulong = 0x8B16;
4064
4065pub const SIOCSIWAUTH: c_ulong = 0x8B32;
4066pub const SIOCGIWAUTH: c_ulong = 0x8B33;
4067
4068pub const SIOCSIWENCODEEXT: c_ulong = 0x8B34;
4069pub const SIOCGIWENCODEEXT: c_ulong = 0x8B35;
4070
4071pub const SIOCSIWPMKSA: c_ulong = 0x8B36;
4072
4073pub const SIOCIWFIRSTPRIV: c_ulong = 0x8BE0;
4074pub const SIOCIWLASTPRIV: c_ulong = 0x8BFF;
4075
4076pub const SIOCIWFIRST: c_ulong = 0x8B00;
4077pub const SIOCIWLAST: c_ulong = SIOCIWLASTPRIV;
4078
4079pub const IWEVTXDROP: c_ulong = 0x8C00;
4080pub const IWEVQUAL: c_ulong = 0x8C01;
4081pub const IWEVCUSTOM: c_ulong = 0x8C02;
4082pub const IWEVREGISTERED: c_ulong = 0x8C03;
4083pub const IWEVEXPIRED: c_ulong = 0x8C04;
4084pub const IWEVGENIE: c_ulong = 0x8C05;
4085pub const IWEVMICHAELMICFAILURE: c_ulong = 0x8C06;
4086pub const IWEVASSOCREQIE: c_ulong = 0x8C07;
4087pub const IWEVASSOCRESPIE: c_ulong = 0x8C08;
4088pub const IWEVPMKIDCAND: c_ulong = 0x8C09;
4089pub const IWEVFIRST: c_ulong = 0x8C00;
4090
4091pub const IW_PRIV_TYPE_MASK: c_ulong = 0x7000;
4092pub const IW_PRIV_TYPE_NONE: c_ulong = 0x0000;
4093pub const IW_PRIV_TYPE_BYTE: c_ulong = 0x1000;
4094pub const IW_PRIV_TYPE_CHAR: c_ulong = 0x2000;
4095pub const IW_PRIV_TYPE_INT: c_ulong = 0x4000;
4096pub const IW_PRIV_TYPE_FLOAT: c_ulong = 0x5000;
4097pub const IW_PRIV_TYPE_ADDR: c_ulong = 0x6000;
4098
4099pub const IW_PRIV_SIZE_FIXED: c_ulong = 0x0800;
4100
4101pub const IW_PRIV_SIZE_MASK: c_ulong = 0x07FF;
4102
4103pub const IW_MAX_FREQUENCIES: usize = 32;
4104pub const IW_MAX_BITRATES: usize = 32;
4105pub const IW_MAX_TXPOWER: usize = 8;
4106pub const IW_MAX_SPY: usize = 8;
4107pub const IW_MAX_AP: usize = 64;
4108pub const IW_ESSID_MAX_SIZE: usize = 32;
4109
4110pub const IW_MODE_AUTO: usize = 0;
4111pub const IW_MODE_ADHOC: usize = 1;
4112pub const IW_MODE_INFRA: usize = 2;
4113pub const IW_MODE_MASTER: usize = 3;
4114pub const IW_MODE_REPEAT: usize = 4;
4115pub const IW_MODE_SECOND: usize = 5;
4116pub const IW_MODE_MONITOR: usize = 6;
4117pub const IW_MODE_MESH: usize = 7;
4118
4119pub const IW_QUAL_QUAL_UPDATED: c_ulong = 0x01;
4120pub const IW_QUAL_LEVEL_UPDATED: c_ulong = 0x02;
4121pub const IW_QUAL_NOISE_UPDATED: c_ulong = 0x04;
4122pub const IW_QUAL_ALL_UPDATED: c_ulong = 0x07;
4123pub const IW_QUAL_DBM: c_ulong = 0x08;
4124pub const IW_QUAL_QUAL_INVALID: c_ulong = 0x10;
4125pub const IW_QUAL_LEVEL_INVALID: c_ulong = 0x20;
4126pub const IW_QUAL_NOISE_INVALID: c_ulong = 0x40;
4127pub const IW_QUAL_RCPI: c_ulong = 0x80;
4128pub const IW_QUAL_ALL_INVALID: c_ulong = 0x70;
4129
4130pub const IW_FREQ_AUTO: c_ulong = 0x00;
4131pub const IW_FREQ_FIXED: c_ulong = 0x01;
4132
4133pub const IW_MAX_ENCODING_SIZES: usize = 8;
4134pub const IW_ENCODING_TOKEN_MAX: usize = 64;
4135
4136pub const IW_ENCODE_INDEX: c_ulong = 0x00FF;
4137pub const IW_ENCODE_FLAGS: c_ulong = 0xFF00;
4138pub const IW_ENCODE_MODE: c_ulong = 0xF000;
4139pub const IW_ENCODE_DISABLED: c_ulong = 0x8000;
4140pub const IW_ENCODE_ENABLED: c_ulong = 0x0000;
4141pub const IW_ENCODE_RESTRICTED: c_ulong = 0x4000;
4142pub const IW_ENCODE_OPEN: c_ulong = 0x2000;
4143pub const IW_ENCODE_NOKEY: c_ulong = 0x0800;
4144pub const IW_ENCODE_TEMP: c_ulong = 0x0400;
4145
4146pub const IW_POWER_ON: c_ulong = 0x0000;
4147pub const IW_POWER_TYPE: c_ulong = 0xF000;
4148pub const IW_POWER_PERIOD: c_ulong = 0x1000;
4149pub const IW_POWER_TIMEOUT: c_ulong = 0x2000;
4150pub const IW_POWER_MODE: c_ulong = 0x0F00;
4151pub const IW_POWER_UNICAST_R: c_ulong = 0x0100;
4152pub const IW_POWER_MULTICAST_R: c_ulong = 0x0200;
4153pub const IW_POWER_ALL_R: c_ulong = 0x0300;
4154pub const IW_POWER_FORCE_S: c_ulong = 0x0400;
4155pub const IW_POWER_REPEATER: c_ulong = 0x0800;
4156pub const IW_POWER_MODIFIER: c_ulong = 0x000F;
4157pub const IW_POWER_MIN: c_ulong = 0x0001;
4158pub const IW_POWER_MAX: c_ulong = 0x0002;
4159pub const IW_POWER_RELATIVE: c_ulong = 0x0004;
4160
4161pub const IW_TXPOW_TYPE: c_ulong = 0x00FF;
4162pub const IW_TXPOW_DBM: c_ulong = 0x0000;
4163pub const IW_TXPOW_MWATT: c_ulong = 0x0001;
4164pub const IW_TXPOW_RELATIVE: c_ulong = 0x0002;
4165pub const IW_TXPOW_RANGE: c_ulong = 0x1000;
4166
4167pub const IW_RETRY_ON: c_ulong = 0x0000;
4168pub const IW_RETRY_TYPE: c_ulong = 0xF000;
4169pub const IW_RETRY_LIMIT: c_ulong = 0x1000;
4170pub const IW_RETRY_LIFETIME: c_ulong = 0x2000;
4171pub const IW_RETRY_MODIFIER: c_ulong = 0x00FF;
4172pub const IW_RETRY_MIN: c_ulong = 0x0001;
4173pub const IW_RETRY_MAX: c_ulong = 0x0002;
4174pub const IW_RETRY_RELATIVE: c_ulong = 0x0004;
4175pub const IW_RETRY_SHORT: c_ulong = 0x0010;
4176pub const IW_RETRY_LONG: c_ulong = 0x0020;
4177
4178pub const IW_SCAN_DEFAULT: c_ulong = 0x0000;
4179pub const IW_SCAN_ALL_ESSID: c_ulong = 0x0001;
4180pub const IW_SCAN_THIS_ESSID: c_ulong = 0x0002;
4181pub const IW_SCAN_ALL_FREQ: c_ulong = 0x0004;
4182pub const IW_SCAN_THIS_FREQ: c_ulong = 0x0008;
4183pub const IW_SCAN_ALL_MODE: c_ulong = 0x0010;
4184pub const IW_SCAN_THIS_MODE: c_ulong = 0x0020;
4185pub const IW_SCAN_ALL_RATE: c_ulong = 0x0040;
4186pub const IW_SCAN_THIS_RATE: c_ulong = 0x0080;
4187
4188pub const IW_SCAN_TYPE_ACTIVE: usize = 0;
4189pub const IW_SCAN_TYPE_PASSIVE: usize = 1;
4190
4191pub const IW_SCAN_MAX_DATA: usize = 4096;
4192
4193pub const IW_SCAN_CAPA_NONE: c_ulong = 0x00;
4194pub const IW_SCAN_CAPA_ESSID: c_ulong = 0x01;
4195pub const IW_SCAN_CAPA_BSSID: c_ulong = 0x02;
4196pub const IW_SCAN_CAPA_CHANNEL: c_ulong = 0x04;
4197pub const IW_SCAN_CAPA_MODE: c_ulong = 0x08;
4198pub const IW_SCAN_CAPA_RATE: c_ulong = 0x10;
4199pub const IW_SCAN_CAPA_TYPE: c_ulong = 0x20;
4200pub const IW_SCAN_CAPA_TIME: c_ulong = 0x40;
4201
4202pub const IW_CUSTOM_MAX: c_ulong = 256;
4203
4204pub const IW_GENERIC_IE_MAX: c_ulong = 1024;
4205
4206pub const IW_MLME_DEAUTH: c_ulong = 0;
4207pub const IW_MLME_DISASSOC: c_ulong = 1;
4208pub const IW_MLME_AUTH: c_ulong = 2;
4209pub const IW_MLME_ASSOC: c_ulong = 3;
4210
4211pub const IW_AUTH_INDEX: c_ulong = 0x0FFF;
4212pub const IW_AUTH_FLAGS: c_ulong = 0xF000;
4213
4214pub const IW_AUTH_WPA_VERSION: usize = 0;
4215pub const IW_AUTH_CIPHER_PAIRWISE: usize = 1;
4216pub const IW_AUTH_CIPHER_GROUP: usize = 2;
4217pub const IW_AUTH_KEY_MGMT: usize = 3;
4218pub const IW_AUTH_TKIP_COUNTERMEASURES: usize = 4;
4219pub const IW_AUTH_DROP_UNENCRYPTED: usize = 5;
4220pub const IW_AUTH_80211_AUTH_ALG: usize = 6;
4221pub const IW_AUTH_WPA_ENABLED: usize = 7;
4222pub const IW_AUTH_RX_UNENCRYPTED_EAPOL: usize = 8;
4223pub const IW_AUTH_ROAMING_CONTROL: usize = 9;
4224pub const IW_AUTH_PRIVACY_INVOKED: usize = 10;
4225pub const IW_AUTH_CIPHER_GROUP_MGMT: usize = 11;
4226pub const IW_AUTH_MFP: usize = 12;
4227
4228pub const IW_AUTH_WPA_VERSION_DISABLED: c_ulong = 0x00000001;
4229pub const IW_AUTH_WPA_VERSION_WPA: c_ulong = 0x00000002;
4230pub const IW_AUTH_WPA_VERSION_WPA2: c_ulong = 0x00000004;
4231
4232pub const IW_AUTH_CIPHER_NONE: c_ulong = 0x00000001;
4233pub const IW_AUTH_CIPHER_WEP40: c_ulong = 0x00000002;
4234pub const IW_AUTH_CIPHER_TKIP: c_ulong = 0x00000004;
4235pub const IW_AUTH_CIPHER_CCMP: c_ulong = 0x00000008;
4236pub const IW_AUTH_CIPHER_WEP104: c_ulong = 0x00000010;
4237pub const IW_AUTH_CIPHER_AES_CMAC: c_ulong = 0x00000020;
4238
4239pub const IW_AUTH_KEY_MGMT_802_1X: usize = 1;
4240pub const IW_AUTH_KEY_MGMT_PSK: usize = 2;
4241
4242pub const IW_AUTH_ALG_OPEN_SYSTEM: c_ulong = 0x00000001;
4243pub const IW_AUTH_ALG_SHARED_KEY: c_ulong = 0x00000002;
4244pub const IW_AUTH_ALG_LEAP: c_ulong = 0x00000004;
4245
4246pub const IW_AUTH_ROAMING_ENABLE: usize = 0;
4247pub const IW_AUTH_ROAMING_DISABLE: usize = 1;
4248
4249pub const IW_AUTH_MFP_DISABLED: usize = 0;
4250pub const IW_AUTH_MFP_OPTIONAL: usize = 1;
4251pub const IW_AUTH_MFP_REQUIRED: usize = 2;
4252
4253pub const IW_ENCODE_SEQ_MAX_SIZE: usize = 8;
4254
4255pub const IW_ENCODE_ALG_NONE: usize = 0;
4256pub const IW_ENCODE_ALG_WEP: usize = 1;
4257pub const IW_ENCODE_ALG_TKIP: usize = 2;
4258pub const IW_ENCODE_ALG_CCMP: usize = 3;
4259pub const IW_ENCODE_ALG_PMK: usize = 4;
4260pub const IW_ENCODE_ALG_AES_CMAC: usize = 5;
4261
4262pub const IW_ENCODE_EXT_TX_SEQ_VALID: c_ulong = 0x00000001;
4263pub const IW_ENCODE_EXT_RX_SEQ_VALID: c_ulong = 0x00000002;
4264pub const IW_ENCODE_EXT_GROUP_KEY: c_ulong = 0x00000004;
4265pub const IW_ENCODE_EXT_SET_TX_KEY: c_ulong = 0x00000008;
4266
4267pub const IW_MICFAILURE_KEY_ID: c_ulong = 0x00000003;
4268pub const IW_MICFAILURE_GROUP: c_ulong = 0x00000004;
4269pub const IW_MICFAILURE_PAIRWISE: c_ulong = 0x00000008;
4270pub const IW_MICFAILURE_STAKEY: c_ulong = 0x00000010;
4271pub const IW_MICFAILURE_COUNT: c_ulong = 0x00000060;
4272
4273pub const IW_ENC_CAPA_WPA: c_ulong = 0x00000001;
4274pub const IW_ENC_CAPA_WPA2: c_ulong = 0x00000002;
4275pub const IW_ENC_CAPA_CIPHER_TKIP: c_ulong = 0x00000004;
4276pub const IW_ENC_CAPA_CIPHER_CCMP: c_ulong = 0x00000008;
4277pub const IW_ENC_CAPA_4WAY_HANDSHAKE: c_ulong = 0x00000010;
4278
4279pub const IW_EVENT_CAPA_K_0: c_ulong = 0x4000050; //   IW_EVENT_CAPA_MASK(0x8B04) | IW_EVENT_CAPA_MASK(0x8B06) | IW_EVENT_CAPA_MASK(0x8B1A);
4280pub const IW_EVENT_CAPA_K_1: c_ulong = 0x400; //   W_EVENT_CAPA_MASK(0x8B2A);
4281
4282pub const IW_PMKSA_ADD: usize = 1;
4283pub const IW_PMKSA_REMOVE: usize = 2;
4284pub const IW_PMKSA_FLUSH: usize = 3;
4285
4286pub const IW_PMKID_LEN: usize = 16;
4287
4288pub const IW_PMKID_CAND_PREAUTH: c_ulong = 0x00000001;
4289
4290pub const IW_EV_LCP_PK_LEN: usize = 4;
4291
4292pub const IW_EV_CHAR_PK_LEN: usize = 20; // IW_EV_LCP_PK_LEN + crate::IFNAMSIZ;
4293pub const IW_EV_UINT_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + size_of::<u32>();
4294pub const IW_EV_FREQ_PK_LEN: usize = 12; // IW_EV_LCP_PK_LEN + size_of::<iw_freq>();
4295pub const IW_EV_PARAM_PK_LEN: usize = 12; // IW_EV_LCP_PK_LEN + size_of::<iw_param>();
4296pub const IW_EV_ADDR_PK_LEN: usize = 20; // IW_EV_LCP_PK_LEN + size_of::<crate::sockaddr>();
4297pub const IW_EV_QUAL_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + size_of::<iw_quality>();
4298pub const IW_EV_POINT_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + 4;
4299
4300pub const IPTOS_TOS_MASK: u8 = 0x1E;
4301pub const IPTOS_PREC_MASK: u8 = 0xE0;
4302
4303pub const IPTOS_ECN_NOT_ECT: u8 = 0x00;
4304
4305pub const RTF_UP: c_ushort = 0x0001;
4306pub const RTF_GATEWAY: c_ushort = 0x0002;
4307
4308pub const RTF_HOST: c_ushort = 0x0004;
4309pub const RTF_REINSTATE: c_ushort = 0x0008;
4310pub const RTF_DYNAMIC: c_ushort = 0x0010;
4311pub const RTF_MODIFIED: c_ushort = 0x0020;
4312pub const RTF_MTU: c_ushort = 0x0040;
4313pub const RTF_MSS: c_ushort = RTF_MTU;
4314pub const RTF_WINDOW: c_ushort = 0x0080;
4315pub const RTF_IRTT: c_ushort = 0x0100;
4316pub const RTF_REJECT: c_ushort = 0x0200;
4317pub const RTF_STATIC: c_ushort = 0x0400;
4318pub const RTF_XRESOLVE: c_ushort = 0x0800;
4319pub const RTF_NOFORWARD: c_ushort = 0x1000;
4320pub const RTF_THROW: c_ushort = 0x2000;
4321pub const RTF_NOPMTUDISC: c_ushort = 0x4000;
4322
4323pub const RTF_DEFAULT: u32 = 0x00010000;
4324pub const RTF_ALLONLINK: u32 = 0x00020000;
4325pub const RTF_ADDRCONF: u32 = 0x00040000;
4326pub const RTF_LINKRT: u32 = 0x00100000;
4327pub const RTF_NONEXTHOP: u32 = 0x00200000;
4328pub const RTF_CACHE: u32 = 0x01000000;
4329pub const RTF_FLOW: u32 = 0x02000000;
4330pub const RTF_POLICY: u32 = 0x04000000;
4331
4332pub const RTCF_VALVE: u32 = 0x00200000;
4333pub const RTCF_MASQ: u32 = 0x00400000;
4334pub const RTCF_NAT: u32 = 0x00800000;
4335pub const RTCF_DOREDIRECT: u32 = 0x01000000;
4336pub const RTCF_LOG: u32 = 0x02000000;
4337pub const RTCF_DIRECTSRC: u32 = 0x04000000;
4338
4339pub const RTF_LOCAL: u32 = 0x80000000;
4340pub const RTF_INTERFACE: u32 = 0x40000000;
4341pub const RTF_MULTICAST: u32 = 0x20000000;
4342pub const RTF_BROADCAST: u32 = 0x10000000;
4343pub const RTF_NAT: u32 = 0x08000000;
4344pub const RTF_ADDRCLASSMASK: u32 = 0xF8000000;
4345
4346pub const RT_CLASS_UNSPEC: u8 = 0;
4347pub const RT_CLASS_DEFAULT: u8 = 253;
4348pub const RT_CLASS_MAIN: u8 = 254;
4349pub const RT_CLASS_LOCAL: u8 = 255;
4350pub const RT_CLASS_MAX: u8 = 255;
4351
4352// linux/neighbor.h
4353pub const NUD_NONE: u16 = 0x00;
4354pub const NUD_INCOMPLETE: u16 = 0x01;
4355pub const NUD_REACHABLE: u16 = 0x02;
4356pub const NUD_STALE: u16 = 0x04;
4357pub const NUD_DELAY: u16 = 0x08;
4358pub const NUD_PROBE: u16 = 0x10;
4359pub const NUD_FAILED: u16 = 0x20;
4360pub const NUD_NOARP: u16 = 0x40;
4361pub const NUD_PERMANENT: u16 = 0x80;
4362
4363pub const NTF_USE: u8 = 0x01;
4364pub const NTF_SELF: u8 = 0x02;
4365pub const NTF_MASTER: u8 = 0x04;
4366pub const NTF_PROXY: u8 = 0x08;
4367pub const NTF_ROUTER: u8 = 0x80;
4368
4369pub const NDA_UNSPEC: c_ushort = 0;
4370pub const NDA_DST: c_ushort = 1;
4371pub const NDA_LLADDR: c_ushort = 2;
4372pub const NDA_CACHEINFO: c_ushort = 3;
4373pub const NDA_PROBES: c_ushort = 4;
4374pub const NDA_VLAN: c_ushort = 5;
4375pub const NDA_PORT: c_ushort = 6;
4376pub const NDA_VNI: c_ushort = 7;
4377pub const NDA_IFINDEX: c_ushort = 8;
4378
4379// linux/netlink.h
4380pub const NLA_ALIGNTO: c_int = 4;
4381
4382pub const NETLINK_ROUTE: c_int = 0;
4383pub const NETLINK_UNUSED: c_int = 1;
4384pub const NETLINK_USERSOCK: c_int = 2;
4385pub const NETLINK_FIREWALL: c_int = 3;
4386pub const NETLINK_SOCK_DIAG: c_int = 4;
4387pub const NETLINK_NFLOG: c_int = 5;
4388pub const NETLINK_XFRM: c_int = 6;
4389pub const NETLINK_SELINUX: c_int = 7;
4390pub const NETLINK_ISCSI: c_int = 8;
4391pub const NETLINK_AUDIT: c_int = 9;
4392pub const NETLINK_FIB_LOOKUP: c_int = 10;
4393pub const NETLINK_CONNECTOR: c_int = 11;
4394pub const NETLINK_NETFILTER: c_int = 12;
4395pub const NETLINK_IP6_FW: c_int = 13;
4396pub const NETLINK_DNRTMSG: c_int = 14;
4397pub const NETLINK_KOBJECT_UEVENT: c_int = 15;
4398pub const NETLINK_GENERIC: c_int = 16;
4399pub const NETLINK_SCSITRANSPORT: c_int = 18;
4400pub const NETLINK_ECRYPTFS: c_int = 19;
4401pub const NETLINK_RDMA: c_int = 20;
4402pub const NETLINK_CRYPTO: c_int = 21;
4403pub const NETLINK_INET_DIAG: c_int = NETLINK_SOCK_DIAG;
4404
4405pub const NLM_F_REQUEST: c_int = 1;
4406pub const NLM_F_MULTI: c_int = 2;
4407pub const NLM_F_ACK: c_int = 4;
4408pub const NLM_F_ECHO: c_int = 8;
4409pub const NLM_F_DUMP_INTR: c_int = 16;
4410pub const NLM_F_DUMP_FILTERED: c_int = 32;
4411
4412pub const NLM_F_ROOT: c_int = 0x100;
4413pub const NLM_F_MATCH: c_int = 0x200;
4414pub const NLM_F_ATOMIC: c_int = 0x400;
4415pub const NLM_F_DUMP: c_int = NLM_F_ROOT | NLM_F_MATCH;
4416
4417pub const NLM_F_REPLACE: c_int = 0x100;
4418pub const NLM_F_EXCL: c_int = 0x200;
4419pub const NLM_F_CREATE: c_int = 0x400;
4420pub const NLM_F_APPEND: c_int = 0x800;
4421
4422pub const NETLINK_ADD_MEMBERSHIP: c_int = 1;
4423pub const NETLINK_DROP_MEMBERSHIP: c_int = 2;
4424pub const NETLINK_PKTINFO: c_int = 3;
4425pub const NETLINK_BROADCAST_ERROR: c_int = 4;
4426pub const NETLINK_NO_ENOBUFS: c_int = 5;
4427pub const NETLINK_RX_RING: c_int = 6;
4428pub const NETLINK_TX_RING: c_int = 7;
4429pub const NETLINK_LISTEN_ALL_NSID: c_int = 8;
4430pub const NETLINK_LIST_MEMBERSHIPS: c_int = 9;
4431pub const NETLINK_CAP_ACK: c_int = 10;
4432pub const NETLINK_EXT_ACK: c_int = 11;
4433pub const NETLINK_GET_STRICT_CHK: c_int = 12;
4434
4435pub const NLA_F_NESTED: c_int = 1 << 15;
4436pub const NLA_F_NET_BYTEORDER: c_int = 1 << 14;
4437pub const NLA_TYPE_MASK: c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER);
4438
4439// linux/rtnetlink.h
4440pub const TCA_UNSPEC: c_ushort = 0;
4441pub const TCA_KIND: c_ushort = 1;
4442pub const TCA_OPTIONS: c_ushort = 2;
4443pub const TCA_STATS: c_ushort = 3;
4444pub const TCA_XSTATS: c_ushort = 4;
4445pub const TCA_RATE: c_ushort = 5;
4446pub const TCA_FCNT: c_ushort = 6;
4447pub const TCA_STATS2: c_ushort = 7;
4448pub const TCA_STAB: c_ushort = 8;
4449
4450pub const RTM_NEWLINK: u16 = 16;
4451pub const RTM_DELLINK: u16 = 17;
4452pub const RTM_GETLINK: u16 = 18;
4453pub const RTM_SETLINK: u16 = 19;
4454pub const RTM_NEWADDR: u16 = 20;
4455pub const RTM_DELADDR: u16 = 21;
4456pub const RTM_GETADDR: u16 = 22;
4457pub const RTM_NEWROUTE: u16 = 24;
4458pub const RTM_DELROUTE: u16 = 25;
4459pub const RTM_GETROUTE: u16 = 26;
4460pub const RTM_NEWNEIGH: u16 = 28;
4461pub const RTM_DELNEIGH: u16 = 29;
4462pub const RTM_GETNEIGH: u16 = 30;
4463pub const RTM_NEWRULE: u16 = 32;
4464pub const RTM_DELRULE: u16 = 33;
4465pub const RTM_GETRULE: u16 = 34;
4466pub const RTM_NEWQDISC: u16 = 36;
4467pub const RTM_DELQDISC: u16 = 37;
4468pub const RTM_GETQDISC: u16 = 38;
4469pub const RTM_NEWTCLASS: u16 = 40;
4470pub const RTM_DELTCLASS: u16 = 41;
4471pub const RTM_GETTCLASS: u16 = 42;
4472pub const RTM_NEWTFILTER: u16 = 44;
4473pub const RTM_DELTFILTER: u16 = 45;
4474pub const RTM_GETTFILTER: u16 = 46;
4475pub const RTM_NEWACTION: u16 = 48;
4476pub const RTM_DELACTION: u16 = 49;
4477pub const RTM_GETACTION: u16 = 50;
4478pub const RTM_NEWPREFIX: u16 = 52;
4479pub const RTM_GETMULTICAST: u16 = 58;
4480pub const RTM_GETANYCAST: u16 = 62;
4481pub const RTM_NEWNEIGHTBL: u16 = 64;
4482pub const RTM_GETNEIGHTBL: u16 = 66;
4483pub const RTM_SETNEIGHTBL: u16 = 67;
4484pub const RTM_NEWNDUSEROPT: u16 = 68;
4485pub const RTM_NEWADDRLABEL: u16 = 72;
4486pub const RTM_DELADDRLABEL: u16 = 73;
4487pub const RTM_GETADDRLABEL: u16 = 74;
4488pub const RTM_GETDCB: u16 = 78;
4489pub const RTM_SETDCB: u16 = 79;
4490pub const RTM_NEWNETCONF: u16 = 80;
4491pub const RTM_GETNETCONF: u16 = 82;
4492pub const RTM_NEWMDB: u16 = 84;
4493pub const RTM_DELMDB: u16 = 85;
4494pub const RTM_GETMDB: u16 = 86;
4495pub const RTM_NEWNSID: u16 = 88;
4496pub const RTM_DELNSID: u16 = 89;
4497pub const RTM_GETNSID: u16 = 90;
4498
4499pub const RTM_F_NOTIFY: c_uint = 0x100;
4500pub const RTM_F_CLONED: c_uint = 0x200;
4501pub const RTM_F_EQUALIZE: c_uint = 0x400;
4502pub const RTM_F_PREFIX: c_uint = 0x800;
4503
4504pub const RTA_UNSPEC: c_ushort = 0;
4505pub const RTA_DST: c_ushort = 1;
4506pub const RTA_SRC: c_ushort = 2;
4507pub const RTA_IIF: c_ushort = 3;
4508pub const RTA_OIF: c_ushort = 4;
4509pub const RTA_GATEWAY: c_ushort = 5;
4510pub const RTA_PRIORITY: c_ushort = 6;
4511pub const RTA_PREFSRC: c_ushort = 7;
4512pub const RTA_METRICS: c_ushort = 8;
4513pub const RTA_MULTIPATH: c_ushort = 9;
4514pub const RTA_PROTOINFO: c_ushort = 10; // No longer used
4515pub const RTA_FLOW: c_ushort = 11;
4516pub const RTA_CACHEINFO: c_ushort = 12;
4517pub const RTA_SESSION: c_ushort = 13; // No longer used
4518pub const RTA_MP_ALGO: c_ushort = 14; // No longer used
4519pub const RTA_TABLE: c_ushort = 15;
4520pub const RTA_MARK: c_ushort = 16;
4521pub const RTA_MFC_STATS: c_ushort = 17;
4522
4523pub const RTN_UNSPEC: c_uchar = 0;
4524pub const RTN_UNICAST: c_uchar = 1;
4525pub const RTN_LOCAL: c_uchar = 2;
4526pub const RTN_BROADCAST: c_uchar = 3;
4527pub const RTN_ANYCAST: c_uchar = 4;
4528pub const RTN_MULTICAST: c_uchar = 5;
4529pub const RTN_BLACKHOLE: c_uchar = 6;
4530pub const RTN_UNREACHABLE: c_uchar = 7;
4531pub const RTN_PROHIBIT: c_uchar = 8;
4532pub const RTN_THROW: c_uchar = 9;
4533pub const RTN_NAT: c_uchar = 10;
4534pub const RTN_XRESOLVE: c_uchar = 11;
4535
4536pub const RTPROT_UNSPEC: c_uchar = 0;
4537pub const RTPROT_REDIRECT: c_uchar = 1;
4538pub const RTPROT_KERNEL: c_uchar = 2;
4539pub const RTPROT_BOOT: c_uchar = 3;
4540pub const RTPROT_STATIC: c_uchar = 4;
4541
4542pub const RT_SCOPE_UNIVERSE: c_uchar = 0;
4543pub const RT_SCOPE_SITE: c_uchar = 200;
4544pub const RT_SCOPE_LINK: c_uchar = 253;
4545pub const RT_SCOPE_HOST: c_uchar = 254;
4546pub const RT_SCOPE_NOWHERE: c_uchar = 255;
4547
4548pub const RT_TABLE_UNSPEC: c_uchar = 0;
4549pub const RT_TABLE_COMPAT: c_uchar = 252;
4550pub const RT_TABLE_DEFAULT: c_uchar = 253;
4551pub const RT_TABLE_MAIN: c_uchar = 254;
4552pub const RT_TABLE_LOCAL: c_uchar = 255;
4553
4554pub const RTMSG_OVERRUN: u32 = crate::NLMSG_OVERRUN as u32;
4555pub const RTMSG_NEWDEVICE: u32 = 0x11;
4556pub const RTMSG_DELDEVICE: u32 = 0x12;
4557pub const RTMSG_NEWROUTE: u32 = 0x21;
4558pub const RTMSG_DELROUTE: u32 = 0x22;
4559pub const RTMSG_NEWRULE: u32 = 0x31;
4560pub const RTMSG_DELRULE: u32 = 0x32;
4561pub const RTMSG_CONTROL: u32 = 0x40;
4562pub const RTMSG_AR_FAILED: u32 = 0x51;
4563
4564pub const MAX_ADDR_LEN: usize = 7;
4565pub const ARPD_UPDATE: c_ushort = 0x01;
4566pub const ARPD_LOOKUP: c_ushort = 0x02;
4567pub const ARPD_FLUSH: c_ushort = 0x03;
4568pub const ATF_MAGIC: c_int = 0x80;
4569
4570pub const RTEXT_FILTER_VF: c_int = 1 << 0;
4571pub const RTEXT_FILTER_BRVLAN: c_int = 1 << 1;
4572pub const RTEXT_FILTER_BRVLAN_COMPRESSED: c_int = 1 << 2;
4573pub const RTEXT_FILTER_SKIP_STATS: c_int = 1 << 3;
4574pub const RTEXT_FILTER_MRP: c_int = 1 << 4;
4575pub const RTEXT_FILTER_CFM_CONFIG: c_int = 1 << 5;
4576pub const RTEXT_FILTER_CFM_STATUS: c_int = 1 << 6;
4577
4578// userspace compat definitions for RTNLGRP_*
4579pub const RTMGRP_LINK: c_int = 0x00001;
4580pub const RTMGRP_NOTIFY: c_int = 0x00002;
4581pub const RTMGRP_NEIGH: c_int = 0x00004;
4582pub const RTMGRP_TC: c_int = 0x00008;
4583pub const RTMGRP_IPV4_IFADDR: c_int = 0x00010;
4584pub const RTMGRP_IPV4_MROUTE: c_int = 0x00020;
4585pub const RTMGRP_IPV4_ROUTE: c_int = 0x00040;
4586pub const RTMGRP_IPV4_RULE: c_int = 0x00080;
4587pub const RTMGRP_IPV6_IFADDR: c_int = 0x00100;
4588pub const RTMGRP_IPV6_MROUTE: c_int = 0x00200;
4589pub const RTMGRP_IPV6_ROUTE: c_int = 0x00400;
4590pub const RTMGRP_IPV6_IFINFO: c_int = 0x00800;
4591pub const RTMGRP_DECnet_IFADDR: c_int = 0x01000;
4592pub const RTMGRP_DECnet_ROUTE: c_int = 0x04000;
4593pub const RTMGRP_IPV6_PREFIX: c_int = 0x20000;
4594
4595// enum rtnetlink_groups
4596pub const RTNLGRP_NONE: c_uint = 0x00;
4597pub const RTNLGRP_LINK: c_uint = 0x01;
4598pub const RTNLGRP_NOTIFY: c_uint = 0x02;
4599pub const RTNLGRP_NEIGH: c_uint = 0x03;
4600pub const RTNLGRP_TC: c_uint = 0x04;
4601pub const RTNLGRP_IPV4_IFADDR: c_uint = 0x05;
4602pub const RTNLGRP_IPV4_MROUTE: c_uint = 0x06;
4603pub const RTNLGRP_IPV4_ROUTE: c_uint = 0x07;
4604pub const RTNLGRP_IPV4_RULE: c_uint = 0x08;
4605pub const RTNLGRP_IPV6_IFADDR: c_uint = 0x09;
4606pub const RTNLGRP_IPV6_MROUTE: c_uint = 0x0a;
4607pub const RTNLGRP_IPV6_ROUTE: c_uint = 0x0b;
4608pub const RTNLGRP_IPV6_IFINFO: c_uint = 0x0c;
4609pub const RTNLGRP_DECnet_IFADDR: c_uint = 0x0d;
4610pub const RTNLGRP_NOP2: c_uint = 0x0e;
4611pub const RTNLGRP_DECnet_ROUTE: c_uint = 0x0f;
4612pub const RTNLGRP_DECnet_RULE: c_uint = 0x10;
4613pub const RTNLGRP_NOP4: c_uint = 0x11;
4614pub const RTNLGRP_IPV6_PREFIX: c_uint = 0x12;
4615pub const RTNLGRP_IPV6_RULE: c_uint = 0x13;
4616pub const RTNLGRP_ND_USEROPT: c_uint = 0x14;
4617pub const RTNLGRP_PHONET_IFADDR: c_uint = 0x15;
4618pub const RTNLGRP_PHONET_ROUTE: c_uint = 0x16;
4619pub const RTNLGRP_DCB: c_uint = 0x17;
4620pub const RTNLGRP_IPV4_NETCONF: c_uint = 0x18;
4621pub const RTNLGRP_IPV6_NETCONF: c_uint = 0x19;
4622pub const RTNLGRP_MDB: c_uint = 0x1a;
4623pub const RTNLGRP_MPLS_ROUTE: c_uint = 0x1b;
4624pub const RTNLGRP_NSID: c_uint = 0x1c;
4625pub const RTNLGRP_MPLS_NETCONF: c_uint = 0x1d;
4626pub const RTNLGRP_IPV4_MROUTE_R: c_uint = 0x1e;
4627pub const RTNLGRP_IPV6_MROUTE_R: c_uint = 0x1f;
4628pub const RTNLGRP_NEXTHOP: c_uint = 0x20;
4629pub const RTNLGRP_BRVLAN: c_uint = 0x21;
4630pub const RTNLGRP_MCTP_IFADDR: c_uint = 0x22;
4631pub const RTNLGRP_TUNNEL: c_uint = 0x23;
4632pub const RTNLGRP_STATS: c_uint = 0x24;
4633
4634// linux/module.h
4635pub const MODULE_INIT_IGNORE_MODVERSIONS: c_uint = 0x0001;
4636pub const MODULE_INIT_IGNORE_VERMAGIC: c_uint = 0x0002;
4637
4638// linux/net_tstamp.h
4639pub const SOF_TIMESTAMPING_TX_HARDWARE: c_uint = 1 << 0;
4640pub const SOF_TIMESTAMPING_TX_SOFTWARE: c_uint = 1 << 1;
4641pub const SOF_TIMESTAMPING_RX_HARDWARE: c_uint = 1 << 2;
4642pub const SOF_TIMESTAMPING_RX_SOFTWARE: c_uint = 1 << 3;
4643pub const SOF_TIMESTAMPING_SOFTWARE: c_uint = 1 << 4;
4644pub const SOF_TIMESTAMPING_SYS_HARDWARE: c_uint = 1 << 5;
4645pub const SOF_TIMESTAMPING_RAW_HARDWARE: c_uint = 1 << 6;
4646pub const SOF_TIMESTAMPING_OPT_ID: c_uint = 1 << 7;
4647pub const SOF_TIMESTAMPING_TX_SCHED: c_uint = 1 << 8;
4648pub const SOF_TIMESTAMPING_TX_ACK: c_uint = 1 << 9;
4649pub const SOF_TIMESTAMPING_OPT_CMSG: c_uint = 1 << 10;
4650pub const SOF_TIMESTAMPING_OPT_TSONLY: c_uint = 1 << 11;
4651pub const SOF_TIMESTAMPING_OPT_STATS: c_uint = 1 << 12;
4652pub const SOF_TIMESTAMPING_OPT_PKTINFO: c_uint = 1 << 13;
4653pub const SOF_TIMESTAMPING_OPT_TX_SWHW: c_uint = 1 << 14;
4654pub const SOF_TIMESTAMPING_BIND_PHC: c_uint = 1 << 15;
4655pub const SOF_TIMESTAMPING_OPT_ID_TCP: c_uint = 1 << 16;
4656pub const SOF_TIMESTAMPING_OPT_RX_FILTER: c_uint = 1 << 17;
4657pub const SOF_TXTIME_DEADLINE_MODE: u32 = 1 << 0;
4658pub const SOF_TXTIME_REPORT_ERRORS: u32 = 1 << 1;
4659
4660pub const HWTSTAMP_TX_OFF: c_uint = 0;
4661pub const HWTSTAMP_TX_ON: c_uint = 1;
4662pub const HWTSTAMP_TX_ONESTEP_SYNC: c_uint = 2;
4663pub const HWTSTAMP_TX_ONESTEP_P2P: c_uint = 3;
4664
4665pub const HWTSTAMP_FILTER_NONE: c_uint = 0;
4666pub const HWTSTAMP_FILTER_ALL: c_uint = 1;
4667pub const HWTSTAMP_FILTER_SOME: c_uint = 2;
4668pub const HWTSTAMP_FILTER_PTP_V1_L4_EVENT: c_uint = 3;
4669pub const HWTSTAMP_FILTER_PTP_V1_L4_SYNC: c_uint = 4;
4670pub const HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ: c_uint = 5;
4671pub const HWTSTAMP_FILTER_PTP_V2_L4_EVENT: c_uint = 6;
4672pub const HWTSTAMP_FILTER_PTP_V2_L4_SYNC: c_uint = 7;
4673pub const HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ: c_uint = 8;
4674pub const HWTSTAMP_FILTER_PTP_V2_L2_EVENT: c_uint = 9;
4675pub const HWTSTAMP_FILTER_PTP_V2_L2_SYNC: c_uint = 10;
4676pub const HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ: c_uint = 11;
4677pub const HWTSTAMP_FILTER_PTP_V2_EVENT: c_uint = 12;
4678pub const HWTSTAMP_FILTER_PTP_V2_SYNC: c_uint = 13;
4679pub const HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: c_uint = 14;
4680pub const HWTSTAMP_FILTER_NTP_ALL: c_uint = 15;
4681
4682// linux/ptp_clock.h
4683pub const PTP_MAX_SAMPLES: c_uint = 25; // Maximum allowed offset measurement samples.
4684
4685const PTP_CLK_MAGIC: u32 = b'=' as u32;
4686
4687pub const PTP_CLOCK_GETCAPS: c_uint = _IOR::<ptp_clock_caps>(PTP_CLK_MAGIC, 1);
4688pub const PTP_EXTTS_REQUEST: c_uint = _IOW::<ptp_extts_request>(PTP_CLK_MAGIC, 2);
4689pub const PTP_PEROUT_REQUEST: c_uint = _IOW::<ptp_perout_request>(PTP_CLK_MAGIC, 3);
4690pub const PTP_ENABLE_PPS: c_uint = _IOW::<c_int>(PTP_CLK_MAGIC, 4);
4691pub const PTP_SYS_OFFSET: c_uint = _IOW::<ptp_sys_offset>(PTP_CLK_MAGIC, 5);
4692pub const PTP_PIN_GETFUNC: c_uint = _IOWR::<ptp_pin_desc>(PTP_CLK_MAGIC, 6);
4693pub const PTP_PIN_SETFUNC: c_uint = _IOW::<ptp_pin_desc>(PTP_CLK_MAGIC, 7);
4694pub const PTP_SYS_OFFSET_PRECISE: c_uint = _IOWR::<ptp_sys_offset_precise>(PTP_CLK_MAGIC, 8);
4695pub const PTP_SYS_OFFSET_EXTENDED: c_uint = _IOWR::<ptp_sys_offset_extended>(PTP_CLK_MAGIC, 9);
4696
4697pub const PTP_CLOCK_GETCAPS2: c_uint = _IOR::<ptp_clock_caps>(PTP_CLK_MAGIC, 10);
4698pub const PTP_EXTTS_REQUEST2: c_uint = _IOW::<ptp_extts_request>(PTP_CLK_MAGIC, 11);
4699pub const PTP_PEROUT_REQUEST2: c_uint = _IOW::<ptp_perout_request>(PTP_CLK_MAGIC, 12);
4700pub const PTP_ENABLE_PPS2: c_uint = _IOW::<c_int>(PTP_CLK_MAGIC, 13);
4701pub const PTP_SYS_OFFSET2: c_uint = _IOW::<ptp_sys_offset>(PTP_CLK_MAGIC, 14);
4702pub const PTP_PIN_GETFUNC2: c_uint = _IOWR::<ptp_pin_desc>(PTP_CLK_MAGIC, 15);
4703pub const PTP_PIN_SETFUNC2: c_uint = _IOW::<ptp_pin_desc>(PTP_CLK_MAGIC, 16);
4704pub const PTP_SYS_OFFSET_PRECISE2: c_uint = _IOWR::<ptp_sys_offset_precise>(PTP_CLK_MAGIC, 17);
4705pub const PTP_SYS_OFFSET_EXTENDED2: c_uint = _IOWR::<ptp_sys_offset_extended>(PTP_CLK_MAGIC, 18);
4706
4707// enum ptp_pin_function
4708pub const PTP_PF_NONE: c_uint = 0;
4709pub const PTP_PF_EXTTS: c_uint = 1;
4710pub const PTP_PF_PEROUT: c_uint = 2;
4711pub const PTP_PF_PHYSYNC: c_uint = 3;
4712
4713// linux/tls.h
4714pub const TLS_TX: c_int = 1;
4715pub const TLS_RX: c_int = 2;
4716
4717pub const TLS_1_2_VERSION_MAJOR: __u8 = 0x3;
4718pub const TLS_1_2_VERSION_MINOR: __u8 = 0x3;
4719pub const TLS_1_2_VERSION: __u16 =
4720    ((TLS_1_2_VERSION_MAJOR as __u16) << 8) | (TLS_1_2_VERSION_MINOR as __u16);
4721
4722pub const TLS_1_3_VERSION_MAJOR: __u8 = 0x3;
4723pub const TLS_1_3_VERSION_MINOR: __u8 = 0x4;
4724pub const TLS_1_3_VERSION: __u16 =
4725    ((TLS_1_3_VERSION_MAJOR as __u16) << 8) | (TLS_1_3_VERSION_MINOR as __u16);
4726
4727pub const TLS_CIPHER_AES_GCM_128: __u16 = 51;
4728pub const TLS_CIPHER_AES_GCM_128_IV_SIZE: usize = 8;
4729pub const TLS_CIPHER_AES_GCM_128_KEY_SIZE: usize = 16;
4730pub const TLS_CIPHER_AES_GCM_128_SALT_SIZE: usize = 4;
4731pub const TLS_CIPHER_AES_GCM_128_TAG_SIZE: usize = 16;
4732pub const TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE: usize = 8;
4733
4734pub const TLS_CIPHER_AES_GCM_256: __u16 = 52;
4735pub const TLS_CIPHER_AES_GCM_256_IV_SIZE: usize = 8;
4736pub const TLS_CIPHER_AES_GCM_256_KEY_SIZE: usize = 32;
4737pub const TLS_CIPHER_AES_GCM_256_SALT_SIZE: usize = 4;
4738pub const TLS_CIPHER_AES_GCM_256_TAG_SIZE: usize = 16;
4739pub const TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE: usize = 8;
4740
4741pub const TLS_CIPHER_CHACHA20_POLY1305: __u16 = 54;
4742pub const TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE: usize = 12;
4743pub const TLS_CIPHER_CHACHA20_POLY1305_KEY_SIZE: usize = 32;
4744pub const TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE: usize = 0;
4745pub const TLS_CIPHER_CHACHA20_POLY1305_TAG_SIZE: usize = 16;
4746pub const TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE: usize = 8;
4747
4748pub const TLS_SET_RECORD_TYPE: c_int = 1;
4749pub const TLS_GET_RECORD_TYPE: c_int = 2;
4750
4751pub const SOL_TLS: c_int = 282;
4752
4753// linux/if_alg.h
4754pub const ALG_SET_KEY: c_int = 1;
4755pub const ALG_SET_IV: c_int = 2;
4756pub const ALG_SET_OP: c_int = 3;
4757pub const ALG_SET_AEAD_ASSOCLEN: c_int = 4;
4758pub const ALG_SET_AEAD_AUTHSIZE: c_int = 5;
4759pub const ALG_SET_DRBG_ENTROPY: c_int = 6;
4760pub const ALG_SET_KEY_BY_KEY_SERIAL: c_int = 7;
4761
4762pub const ALG_OP_DECRYPT: c_int = 0;
4763pub const ALG_OP_ENCRYPT: c_int = 1;
4764
4765// include/uapi/linux/if.h
4766pub const IF_OPER_UNKNOWN: c_int = 0;
4767pub const IF_OPER_NOTPRESENT: c_int = 1;
4768pub const IF_OPER_DOWN: c_int = 2;
4769pub const IF_OPER_LOWERLAYERDOWN: c_int = 3;
4770pub const IF_OPER_TESTING: c_int = 4;
4771pub const IF_OPER_DORMANT: c_int = 5;
4772pub const IF_OPER_UP: c_int = 6;
4773
4774pub const IF_LINK_MODE_DEFAULT: c_int = 0;
4775pub const IF_LINK_MODE_DORMANT: c_int = 1;
4776pub const IF_LINK_MODE_TESTING: c_int = 2;
4777
4778// include/uapi/linux/udp.h
4779pub const UDP_CORK: c_int = 1;
4780pub const UDP_ENCAP: c_int = 100;
4781pub const UDP_NO_CHECK6_TX: c_int = 101;
4782pub const UDP_NO_CHECK6_RX: c_int = 102;
4783
4784// include/uapi/linux/mman.h
4785pub const MAP_SHARED_VALIDATE: c_int = 0x3;
4786pub const MAP_DROPPABLE: c_int = 0x8;
4787
4788// include/uapi/asm-generic/mman-common.h
4789pub const MAP_FIXED_NOREPLACE: c_int = 0x100000;
4790pub const MLOCK_ONFAULT: c_uint = 0x01;
4791
4792// uapi/linux/vm_sockets.h
4793pub const VMADDR_CID_ANY: c_uint = 0xFFFFFFFF;
4794pub const VMADDR_CID_HYPERVISOR: c_uint = 0;
4795#[deprecated(
4796    since = "0.2.74",
4797    note = "VMADDR_CID_RESERVED is removed since Linux v5.6 and \
4798            replaced with VMADDR_CID_LOCAL"
4799)]
4800pub const VMADDR_CID_RESERVED: c_uint = 1;
4801pub const VMADDR_CID_LOCAL: c_uint = 1;
4802pub const VMADDR_CID_HOST: c_uint = 2;
4803pub const VMADDR_PORT_ANY: c_uint = 0xFFFFFFFF;
4804
4805// uapi/linux/inotify.h
4806pub const IN_ACCESS: u32 = 0x0000_0001;
4807pub const IN_MODIFY: u32 = 0x0000_0002;
4808pub const IN_ATTRIB: u32 = 0x0000_0004;
4809pub const IN_CLOSE_WRITE: u32 = 0x0000_0008;
4810pub const IN_CLOSE_NOWRITE: u32 = 0x0000_0010;
4811pub const IN_CLOSE: u32 = IN_CLOSE_WRITE | IN_CLOSE_NOWRITE;
4812pub const IN_OPEN: u32 = 0x0000_0020;
4813pub const IN_MOVED_FROM: u32 = 0x0000_0040;
4814pub const IN_MOVED_TO: u32 = 0x0000_0080;
4815pub const IN_MOVE: u32 = IN_MOVED_FROM | IN_MOVED_TO;
4816pub const IN_CREATE: u32 = 0x0000_0100;
4817pub const IN_DELETE: u32 = 0x0000_0200;
4818pub const IN_DELETE_SELF: u32 = 0x0000_0400;
4819pub const IN_MOVE_SELF: u32 = 0x0000_0800;
4820pub const IN_UNMOUNT: u32 = 0x0000_2000;
4821pub const IN_Q_OVERFLOW: u32 = 0x0000_4000;
4822pub const IN_IGNORED: u32 = 0x0000_8000;
4823pub const IN_ONLYDIR: u32 = 0x0100_0000;
4824pub const IN_DONT_FOLLOW: u32 = 0x0200_0000;
4825pub const IN_EXCL_UNLINK: u32 = 0x0400_0000;
4826
4827// linux/keyctl.h
4828pub const KEY_SPEC_THREAD_KEYRING: i32 = -1;
4829pub const KEY_SPEC_PROCESS_KEYRING: i32 = -2;
4830pub const KEY_SPEC_SESSION_KEYRING: i32 = -3;
4831pub const KEY_SPEC_USER_KEYRING: i32 = -4;
4832pub const KEY_SPEC_USER_SESSION_KEYRING: i32 = -5;
4833pub const KEY_SPEC_GROUP_KEYRING: i32 = -6;
4834pub const KEY_SPEC_REQKEY_AUTH_KEY: i32 = -7;
4835pub const KEY_SPEC_REQUESTOR_KEYRING: i32 = -8;
4836
4837pub const KEY_REQKEY_DEFL_NO_CHANGE: i32 = -1;
4838pub const KEY_REQKEY_DEFL_DEFAULT: i32 = 0;
4839pub const KEY_REQKEY_DEFL_THREAD_KEYRING: i32 = 1;
4840pub const KEY_REQKEY_DEFL_PROCESS_KEYRING: i32 = 2;
4841pub const KEY_REQKEY_DEFL_SESSION_KEYRING: i32 = 3;
4842pub const KEY_REQKEY_DEFL_USER_KEYRING: i32 = 4;
4843pub const KEY_REQKEY_DEFL_USER_SESSION_KEYRING: i32 = 5;
4844pub const KEY_REQKEY_DEFL_GROUP_KEYRING: i32 = 6;
4845pub const KEY_REQKEY_DEFL_REQUESTOR_KEYRING: i32 = 7;
4846
4847pub const KEYCTL_GET_KEYRING_ID: u32 = 0;
4848pub const KEYCTL_JOIN_SESSION_KEYRING: u32 = 1;
4849pub const KEYCTL_UPDATE: u32 = 2;
4850pub const KEYCTL_REVOKE: u32 = 3;
4851pub const KEYCTL_CHOWN: u32 = 4;
4852pub const KEYCTL_SETPERM: u32 = 5;
4853pub const KEYCTL_DESCRIBE: u32 = 6;
4854pub const KEYCTL_CLEAR: u32 = 7;
4855pub const KEYCTL_LINK: u32 = 8;
4856pub const KEYCTL_UNLINK: u32 = 9;
4857pub const KEYCTL_SEARCH: u32 = 10;
4858pub const KEYCTL_READ: u32 = 11;
4859pub const KEYCTL_INSTANTIATE: u32 = 12;
4860pub const KEYCTL_NEGATE: u32 = 13;
4861pub const KEYCTL_SET_REQKEY_KEYRING: u32 = 14;
4862pub const KEYCTL_SET_TIMEOUT: u32 = 15;
4863pub const KEYCTL_ASSUME_AUTHORITY: u32 = 16;
4864pub const KEYCTL_GET_SECURITY: u32 = 17;
4865pub const KEYCTL_SESSION_TO_PARENT: u32 = 18;
4866pub const KEYCTL_REJECT: u32 = 19;
4867pub const KEYCTL_INSTANTIATE_IOV: u32 = 20;
4868pub const KEYCTL_INVALIDATE: u32 = 21;
4869pub const KEYCTL_GET_PERSISTENT: u32 = 22;
4870
4871pub const IN_MASK_CREATE: u32 = 0x1000_0000;
4872pub const IN_MASK_ADD: u32 = 0x2000_0000;
4873pub const IN_ISDIR: u32 = 0x4000_0000;
4874pub const IN_ONESHOT: u32 = 0x8000_0000;
4875
4876pub const IN_ALL_EVENTS: u32 = IN_ACCESS
4877    | IN_MODIFY
4878    | IN_ATTRIB
4879    | IN_CLOSE_WRITE
4880    | IN_CLOSE_NOWRITE
4881    | IN_OPEN
4882    | IN_MOVED_FROM
4883    | IN_MOVED_TO
4884    | IN_DELETE
4885    | IN_CREATE
4886    | IN_DELETE_SELF
4887    | IN_MOVE_SELF;
4888
4889pub const IN_CLOEXEC: c_int = O_CLOEXEC;
4890pub const IN_NONBLOCK: c_int = O_NONBLOCK;
4891
4892// uapi/linux/mount.h
4893pub const OPEN_TREE_CLONE: c_uint = 0x01;
4894pub const OPEN_TREE_CLOEXEC: c_uint = O_CLOEXEC as c_uint;
4895
4896// uapi/linux/netfilter/nf_tables.h
4897pub const NFT_TABLE_MAXNAMELEN: c_int = 256;
4898pub const NFT_CHAIN_MAXNAMELEN: c_int = 256;
4899pub const NFT_SET_MAXNAMELEN: c_int = 256;
4900pub const NFT_OBJ_MAXNAMELEN: c_int = 256;
4901pub const NFT_USERDATA_MAXLEN: c_int = 256;
4902
4903pub const NFT_REG_VERDICT: c_int = 0;
4904pub const NFT_REG_1: c_int = 1;
4905pub const NFT_REG_2: c_int = 2;
4906pub const NFT_REG_3: c_int = 3;
4907pub const NFT_REG_4: c_int = 4;
4908pub const __NFT_REG_MAX: c_int = 5;
4909pub const NFT_REG32_00: c_int = 8;
4910pub const NFT_REG32_01: c_int = 9;
4911pub const NFT_REG32_02: c_int = 10;
4912pub const NFT_REG32_03: c_int = 11;
4913pub const NFT_REG32_04: c_int = 12;
4914pub const NFT_REG32_05: c_int = 13;
4915pub const NFT_REG32_06: c_int = 14;
4916pub const NFT_REG32_07: c_int = 15;
4917pub const NFT_REG32_08: c_int = 16;
4918pub const NFT_REG32_09: c_int = 17;
4919pub const NFT_REG32_10: c_int = 18;
4920pub const NFT_REG32_11: c_int = 19;
4921pub const NFT_REG32_12: c_int = 20;
4922pub const NFT_REG32_13: c_int = 21;
4923pub const NFT_REG32_14: c_int = 22;
4924pub const NFT_REG32_15: c_int = 23;
4925
4926pub const NFT_REG_SIZE: c_int = 16;
4927pub const NFT_REG32_SIZE: c_int = 4;
4928
4929pub const NFT_CONTINUE: c_int = -1;
4930pub const NFT_BREAK: c_int = -2;
4931pub const NFT_JUMP: c_int = -3;
4932pub const NFT_GOTO: c_int = -4;
4933pub const NFT_RETURN: c_int = -5;
4934
4935pub const NFT_MSG_NEWTABLE: c_int = 0;
4936pub const NFT_MSG_GETTABLE: c_int = 1;
4937pub const NFT_MSG_DELTABLE: c_int = 2;
4938pub const NFT_MSG_NEWCHAIN: c_int = 3;
4939pub const NFT_MSG_GETCHAIN: c_int = 4;
4940pub const NFT_MSG_DELCHAIN: c_int = 5;
4941pub const NFT_MSG_NEWRULE: c_int = 6;
4942pub const NFT_MSG_GETRULE: c_int = 7;
4943pub const NFT_MSG_DELRULE: c_int = 8;
4944pub const NFT_MSG_NEWSET: c_int = 9;
4945pub const NFT_MSG_GETSET: c_int = 10;
4946pub const NFT_MSG_DELSET: c_int = 11;
4947pub const NFT_MSG_NEWSETELEM: c_int = 12;
4948pub const NFT_MSG_GETSETELEM: c_int = 13;
4949pub const NFT_MSG_DELSETELEM: c_int = 14;
4950pub const NFT_MSG_NEWGEN: c_int = 15;
4951pub const NFT_MSG_GETGEN: c_int = 16;
4952pub const NFT_MSG_TRACE: c_int = 17;
4953cfg_if! {
4954    if #[cfg(not(target_arch = "sparc64"))] {
4955        pub const NFT_MSG_NEWOBJ: c_int = 18;
4956        pub const NFT_MSG_GETOBJ: c_int = 19;
4957        pub const NFT_MSG_DELOBJ: c_int = 20;
4958        pub const NFT_MSG_GETOBJ_RESET: c_int = 21;
4959    }
4960}
4961pub const NFT_MSG_MAX: c_int = 25;
4962
4963pub const NFT_SET_ANONYMOUS: c_int = 0x1;
4964pub const NFT_SET_CONSTANT: c_int = 0x2;
4965pub const NFT_SET_INTERVAL: c_int = 0x4;
4966pub const NFT_SET_MAP: c_int = 0x8;
4967pub const NFT_SET_TIMEOUT: c_int = 0x10;
4968pub const NFT_SET_EVAL: c_int = 0x20;
4969
4970pub const NFT_SET_POL_PERFORMANCE: c_int = 0;
4971pub const NFT_SET_POL_MEMORY: c_int = 1;
4972
4973pub const NFT_SET_ELEM_INTERVAL_END: c_int = 0x1;
4974
4975pub const NFT_DATA_VALUE: c_uint = 0;
4976pub const NFT_DATA_VERDICT: c_uint = 0xffffff00;
4977
4978pub const NFT_DATA_RESERVED_MASK: c_uint = 0xffffff00;
4979
4980pub const NFT_DATA_VALUE_MAXLEN: c_int = 64;
4981
4982pub const NFT_BYTEORDER_NTOH: c_int = 0;
4983pub const NFT_BYTEORDER_HTON: c_int = 1;
4984
4985pub const NFT_CMP_EQ: c_int = 0;
4986pub const NFT_CMP_NEQ: c_int = 1;
4987pub const NFT_CMP_LT: c_int = 2;
4988pub const NFT_CMP_LTE: c_int = 3;
4989pub const NFT_CMP_GT: c_int = 4;
4990pub const NFT_CMP_GTE: c_int = 5;
4991
4992pub const NFT_RANGE_EQ: c_int = 0;
4993pub const NFT_RANGE_NEQ: c_int = 1;
4994
4995pub const NFT_LOOKUP_F_INV: c_int = 1 << 0;
4996
4997pub const NFT_DYNSET_OP_ADD: c_int = 0;
4998pub const NFT_DYNSET_OP_UPDATE: c_int = 1;
4999
5000pub const NFT_DYNSET_F_INV: c_int = 1 << 0;
5001
5002pub const NFT_PAYLOAD_LL_HEADER: c_int = 0;
5003pub const NFT_PAYLOAD_NETWORK_HEADER: c_int = 1;
5004pub const NFT_PAYLOAD_TRANSPORT_HEADER: c_int = 2;
5005
5006pub const NFT_PAYLOAD_CSUM_NONE: c_int = 0;
5007pub const NFT_PAYLOAD_CSUM_INET: c_int = 1;
5008
5009pub const NFT_META_LEN: c_int = 0;
5010pub const NFT_META_PROTOCOL: c_int = 1;
5011pub const NFT_META_PRIORITY: c_int = 2;
5012pub const NFT_META_MARK: c_int = 3;
5013pub const NFT_META_IIF: c_int = 4;
5014pub const NFT_META_OIF: c_int = 5;
5015pub const NFT_META_IIFNAME: c_int = 6;
5016pub const NFT_META_OIFNAME: c_int = 7;
5017pub const NFT_META_IIFTYPE: c_int = 8;
5018pub const NFT_META_OIFTYPE: c_int = 9;
5019pub const NFT_META_SKUID: c_int = 10;
5020pub const NFT_META_SKGID: c_int = 11;
5021pub const NFT_META_NFTRACE: c_int = 12;
5022pub const NFT_META_RTCLASSID: c_int = 13;
5023pub const NFT_META_SECMARK: c_int = 14;
5024pub const NFT_META_NFPROTO: c_int = 15;
5025pub const NFT_META_L4PROTO: c_int = 16;
5026pub const NFT_META_BRI_IIFNAME: c_int = 17;
5027pub const NFT_META_BRI_OIFNAME: c_int = 18;
5028pub const NFT_META_PKTTYPE: c_int = 19;
5029pub const NFT_META_CPU: c_int = 20;
5030pub const NFT_META_IIFGROUP: c_int = 21;
5031pub const NFT_META_OIFGROUP: c_int = 22;
5032pub const NFT_META_CGROUP: c_int = 23;
5033pub const NFT_META_PRANDOM: c_int = 24;
5034
5035pub const NFT_CT_STATE: c_int = 0;
5036pub const NFT_CT_DIRECTION: c_int = 1;
5037pub const NFT_CT_STATUS: c_int = 2;
5038pub const NFT_CT_MARK: c_int = 3;
5039pub const NFT_CT_SECMARK: c_int = 4;
5040pub const NFT_CT_EXPIRATION: c_int = 5;
5041pub const NFT_CT_HELPER: c_int = 6;
5042pub const NFT_CT_L3PROTOCOL: c_int = 7;
5043pub const NFT_CT_SRC: c_int = 8;
5044pub const NFT_CT_DST: c_int = 9;
5045pub const NFT_CT_PROTOCOL: c_int = 10;
5046pub const NFT_CT_PROTO_SRC: c_int = 11;
5047pub const NFT_CT_PROTO_DST: c_int = 12;
5048pub const NFT_CT_LABELS: c_int = 13;
5049pub const NFT_CT_PKTS: c_int = 14;
5050pub const NFT_CT_BYTES: c_int = 15;
5051pub const NFT_CT_AVGPKT: c_int = 16;
5052pub const NFT_CT_ZONE: c_int = 17;
5053pub const NFT_CT_EVENTMASK: c_int = 18;
5054pub const NFT_CT_SRC_IP: c_int = 19;
5055pub const NFT_CT_DST_IP: c_int = 20;
5056pub const NFT_CT_SRC_IP6: c_int = 21;
5057pub const NFT_CT_DST_IP6: c_int = 22;
5058
5059pub const NFT_LIMIT_PKTS: c_int = 0;
5060pub const NFT_LIMIT_PKT_BYTES: c_int = 1;
5061
5062pub const NFT_LIMIT_F_INV: c_int = 1 << 0;
5063
5064pub const NFT_QUEUE_FLAG_BYPASS: c_int = 0x01;
5065pub const NFT_QUEUE_FLAG_CPU_FANOUT: c_int = 0x02;
5066pub const NFT_QUEUE_FLAG_MASK: c_int = 0x03;
5067
5068pub const NFT_QUOTA_F_INV: c_int = 1 << 0;
5069
5070pub const NFT_REJECT_ICMP_UNREACH: c_int = 0;
5071pub const NFT_REJECT_TCP_RST: c_int = 1;
5072pub const NFT_REJECT_ICMPX_UNREACH: c_int = 2;
5073
5074pub const NFT_REJECT_ICMPX_NO_ROUTE: c_int = 0;
5075pub const NFT_REJECT_ICMPX_PORT_UNREACH: c_int = 1;
5076pub const NFT_REJECT_ICMPX_HOST_UNREACH: c_int = 2;
5077pub const NFT_REJECT_ICMPX_ADMIN_PROHIBITED: c_int = 3;
5078
5079pub const NFT_NAT_SNAT: c_int = 0;
5080pub const NFT_NAT_DNAT: c_int = 1;
5081
5082pub const NFT_TRACETYPE_UNSPEC: c_int = 0;
5083pub const NFT_TRACETYPE_POLICY: c_int = 1;
5084pub const NFT_TRACETYPE_RETURN: c_int = 2;
5085pub const NFT_TRACETYPE_RULE: c_int = 3;
5086
5087pub const NFT_NG_INCREMENTAL: c_int = 0;
5088pub const NFT_NG_RANDOM: c_int = 1;
5089
5090// linux/input.h
5091pub const FF_MAX: __u16 = 0x7f;
5092pub const FF_CNT: usize = FF_MAX as usize + 1;
5093
5094// linux/input-event-codes.h
5095pub const INPUT_PROP_MAX: __u16 = 0x1f;
5096pub const INPUT_PROP_CNT: usize = INPUT_PROP_MAX as usize + 1;
5097pub const EV_MAX: __u16 = 0x1f;
5098pub const EV_CNT: usize = EV_MAX as usize + 1;
5099pub const SYN_MAX: __u16 = 0xf;
5100pub const SYN_CNT: usize = SYN_MAX as usize + 1;
5101pub const KEY_MAX: __u16 = 0x2ff;
5102pub const KEY_CNT: usize = KEY_MAX as usize + 1;
5103pub const REL_MAX: __u16 = 0x0f;
5104pub const REL_CNT: usize = REL_MAX as usize + 1;
5105pub const ABS_MAX: __u16 = 0x3f;
5106pub const ABS_CNT: usize = ABS_MAX as usize + 1;
5107pub const SW_MAX: __u16 = 0x10;
5108pub const SW_CNT: usize = SW_MAX as usize + 1;
5109pub const MSC_MAX: __u16 = 0x07;
5110pub const MSC_CNT: usize = MSC_MAX as usize + 1;
5111pub const LED_MAX: __u16 = 0x0f;
5112pub const LED_CNT: usize = LED_MAX as usize + 1;
5113pub const REP_MAX: __u16 = 0x01;
5114pub const REP_CNT: usize = REP_MAX as usize + 1;
5115pub const SND_MAX: __u16 = 0x07;
5116pub const SND_CNT: usize = SND_MAX as usize + 1;
5117
5118// linux/uinput.h
5119pub const UINPUT_VERSION: c_uint = 5;
5120pub const UINPUT_MAX_NAME_SIZE: usize = 80;
5121
5122// uapi/linux/fanotify.h
5123pub const FAN_ACCESS: u64 = 0x0000_0001;
5124pub const FAN_MODIFY: u64 = 0x0000_0002;
5125pub const FAN_ATTRIB: u64 = 0x0000_0004;
5126pub const FAN_CLOSE_WRITE: u64 = 0x0000_0008;
5127pub const FAN_CLOSE_NOWRITE: u64 = 0x0000_0010;
5128pub const FAN_OPEN: u64 = 0x0000_0020;
5129pub const FAN_MOVED_FROM: u64 = 0x0000_0040;
5130pub const FAN_MOVED_TO: u64 = 0x0000_0080;
5131pub const FAN_CREATE: u64 = 0x0000_0100;
5132pub const FAN_DELETE: u64 = 0x0000_0200;
5133pub const FAN_DELETE_SELF: u64 = 0x0000_0400;
5134pub const FAN_MOVE_SELF: u64 = 0x0000_0800;
5135pub const FAN_OPEN_EXEC: u64 = 0x0000_1000;
5136
5137pub const FAN_Q_OVERFLOW: u64 = 0x0000_4000;
5138pub const FAN_FS_ERROR: u64 = 0x0000_8000;
5139
5140pub const FAN_OPEN_PERM: u64 = 0x0001_0000;
5141pub const FAN_ACCESS_PERM: u64 = 0x0002_0000;
5142pub const FAN_OPEN_EXEC_PERM: u64 = 0x0004_0000;
5143
5144pub const FAN_EVENT_ON_CHILD: u64 = 0x0800_0000;
5145
5146pub const FAN_RENAME: u64 = 0x1000_0000;
5147
5148pub const FAN_ONDIR: u64 = 0x4000_0000;
5149
5150pub const FAN_CLOSE: u64 = FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE;
5151pub const FAN_MOVE: u64 = FAN_MOVED_FROM | FAN_MOVED_TO;
5152
5153pub const FAN_CLOEXEC: c_uint = 0x0000_0001;
5154pub const FAN_NONBLOCK: c_uint = 0x0000_0002;
5155
5156pub const FAN_CLASS_NOTIF: c_uint = 0x0000_0000;
5157pub const FAN_CLASS_CONTENT: c_uint = 0x0000_0004;
5158pub const FAN_CLASS_PRE_CONTENT: c_uint = 0x0000_0008;
5159
5160pub const FAN_UNLIMITED_QUEUE: c_uint = 0x0000_0010;
5161pub const FAN_UNLIMITED_MARKS: c_uint = 0x0000_0020;
5162pub const FAN_ENABLE_AUDIT: c_uint = 0x0000_0040;
5163
5164pub const FAN_REPORT_PIDFD: c_uint = 0x0000_0080;
5165pub const FAN_REPORT_TID: c_uint = 0x0000_0100;
5166pub const FAN_REPORT_FID: c_uint = 0x0000_0200;
5167pub const FAN_REPORT_DIR_FID: c_uint = 0x0000_0400;
5168pub const FAN_REPORT_NAME: c_uint = 0x0000_0800;
5169pub const FAN_REPORT_TARGET_FID: c_uint = 0x0000_1000;
5170
5171pub const FAN_REPORT_DFID_NAME: c_uint = FAN_REPORT_DIR_FID | FAN_REPORT_NAME;
5172pub const FAN_REPORT_DFID_NAME_TARGET: c_uint =
5173    FAN_REPORT_DFID_NAME | FAN_REPORT_FID | FAN_REPORT_TARGET_FID;
5174
5175pub const FAN_MARK_ADD: c_uint = 0x0000_0001;
5176pub const FAN_MARK_REMOVE: c_uint = 0x0000_0002;
5177pub const FAN_MARK_DONT_FOLLOW: c_uint = 0x0000_0004;
5178pub const FAN_MARK_ONLYDIR: c_uint = 0x0000_0008;
5179pub const FAN_MARK_IGNORED_MASK: c_uint = 0x0000_0020;
5180pub const FAN_MARK_IGNORED_SURV_MODIFY: c_uint = 0x0000_0040;
5181pub const FAN_MARK_FLUSH: c_uint = 0x0000_0080;
5182pub const FAN_MARK_EVICTABLE: c_uint = 0x0000_0200;
5183pub const FAN_MARK_IGNORE: c_uint = 0x0000_0400;
5184
5185pub const FAN_MARK_INODE: c_uint = 0x0000_0000;
5186pub const FAN_MARK_MOUNT: c_uint = 0x0000_0010;
5187pub const FAN_MARK_FILESYSTEM: c_uint = 0x0000_0100;
5188
5189pub const FAN_MARK_IGNORE_SURV: c_uint = FAN_MARK_IGNORE | FAN_MARK_IGNORED_SURV_MODIFY;
5190
5191pub const FANOTIFY_METADATA_VERSION: u8 = 3;
5192
5193pub const FAN_EVENT_INFO_TYPE_FID: u8 = 1;
5194pub const FAN_EVENT_INFO_TYPE_DFID_NAME: u8 = 2;
5195pub const FAN_EVENT_INFO_TYPE_DFID: u8 = 3;
5196pub const FAN_EVENT_INFO_TYPE_PIDFD: u8 = 4;
5197pub const FAN_EVENT_INFO_TYPE_ERROR: u8 = 5;
5198
5199pub const FAN_EVENT_INFO_TYPE_OLD_DFID_NAME: u8 = 10;
5200pub const FAN_EVENT_INFO_TYPE_NEW_DFID_NAME: u8 = 12;
5201
5202pub const FAN_RESPONSE_INFO_NONE: u8 = 0;
5203pub const FAN_RESPONSE_INFO_AUDIT_RULE: u8 = 1;
5204
5205pub const FAN_ALLOW: u32 = 0x01;
5206pub const FAN_DENY: u32 = 0x02;
5207pub const FAN_AUDIT: u32 = 0x10;
5208pub const FAN_INFO: u32 = 0x20;
5209
5210pub const FAN_NOFD: c_int = -1;
5211pub const FAN_NOPIDFD: c_int = FAN_NOFD;
5212pub const FAN_EPIDFD: c_int = -2;
5213
5214// linux/futex.h
5215pub const FUTEX_WAIT: c_int = 0;
5216pub const FUTEX_WAKE: c_int = 1;
5217pub const FUTEX_FD: c_int = 2;
5218pub const FUTEX_REQUEUE: c_int = 3;
5219pub const FUTEX_CMP_REQUEUE: c_int = 4;
5220pub const FUTEX_WAKE_OP: c_int = 5;
5221pub const FUTEX_LOCK_PI: c_int = 6;
5222pub const FUTEX_UNLOCK_PI: c_int = 7;
5223pub const FUTEX_TRYLOCK_PI: c_int = 8;
5224pub const FUTEX_WAIT_BITSET: c_int = 9;
5225pub const FUTEX_WAKE_BITSET: c_int = 10;
5226pub const FUTEX_WAIT_REQUEUE_PI: c_int = 11;
5227pub const FUTEX_CMP_REQUEUE_PI: c_int = 12;
5228pub const FUTEX_LOCK_PI2: c_int = 13;
5229
5230pub const FUTEX_PRIVATE_FLAG: c_int = 128;
5231pub const FUTEX_CLOCK_REALTIME: c_int = 256;
5232pub const FUTEX_CMD_MASK: c_int = !(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME);
5233
5234pub const FUTEX_WAITERS: u32 = 0x80000000;
5235pub const FUTEX_OWNER_DIED: u32 = 0x40000000;
5236pub const FUTEX_TID_MASK: u32 = 0x3fffffff;
5237
5238pub const FUTEX_BITSET_MATCH_ANY: c_int = 0xffffffff;
5239
5240pub const FUTEX_OP_SET: c_int = 0;
5241pub const FUTEX_OP_ADD: c_int = 1;
5242pub const FUTEX_OP_OR: c_int = 2;
5243pub const FUTEX_OP_ANDN: c_int = 3;
5244pub const FUTEX_OP_XOR: c_int = 4;
5245
5246pub const FUTEX_OP_OPARG_SHIFT: c_int = 8;
5247
5248pub const FUTEX_OP_CMP_EQ: c_int = 0;
5249pub const FUTEX_OP_CMP_NE: c_int = 1;
5250pub const FUTEX_OP_CMP_LT: c_int = 2;
5251pub const FUTEX_OP_CMP_LE: c_int = 3;
5252pub const FUTEX_OP_CMP_GT: c_int = 4;
5253pub const FUTEX_OP_CMP_GE: c_int = 5;
5254
5255pub fn FUTEX_OP(op: c_int, oparg: c_int, cmp: c_int, cmparg: c_int) -> c_int {
5256    ((op & 0xf) << 28) | ((cmp & 0xf) << 24) | ((oparg & 0xfff) << 12) | (cmparg & 0xfff)
5257}
5258
5259// linux/kexec.h
5260pub const KEXEC_ON_CRASH: c_int = 0x00000001;
5261pub const KEXEC_PRESERVE_CONTEXT: c_int = 0x00000002;
5262pub const KEXEC_ARCH_MASK: c_int = 0xffff0000;
5263pub const KEXEC_FILE_UNLOAD: c_int = 0x00000001;
5264pub const KEXEC_FILE_ON_CRASH: c_int = 0x00000002;
5265pub const KEXEC_FILE_NO_INITRAMFS: c_int = 0x00000004;
5266
5267// linux/reboot.h
5268pub const LINUX_REBOOT_MAGIC1: c_int = 0xfee1dead;
5269pub const LINUX_REBOOT_MAGIC2: c_int = 672274793;
5270pub const LINUX_REBOOT_MAGIC2A: c_int = 85072278;
5271pub const LINUX_REBOOT_MAGIC2B: c_int = 369367448;
5272pub const LINUX_REBOOT_MAGIC2C: c_int = 537993216;
5273
5274pub const LINUX_REBOOT_CMD_RESTART: c_int = 0x01234567;
5275pub const LINUX_REBOOT_CMD_HALT: c_int = 0xCDEF0123;
5276pub const LINUX_REBOOT_CMD_CAD_ON: c_int = 0x89ABCDEF;
5277pub const LINUX_REBOOT_CMD_CAD_OFF: c_int = 0x00000000;
5278pub const LINUX_REBOOT_CMD_POWER_OFF: c_int = 0x4321FEDC;
5279pub const LINUX_REBOOT_CMD_RESTART2: c_int = 0xA1B2C3D4;
5280pub const LINUX_REBOOT_CMD_SW_SUSPEND: c_int = 0xD000FCE2;
5281pub const LINUX_REBOOT_CMD_KEXEC: c_int = 0x45584543;
5282
5283pub const REG_EXTENDED: c_int = 1;
5284pub const REG_ICASE: c_int = 2;
5285pub const REG_NEWLINE: c_int = 4;
5286pub const REG_NOSUB: c_int = 8;
5287
5288pub const REG_NOTBOL: c_int = 1;
5289pub const REG_NOTEOL: c_int = 2;
5290
5291pub const REG_ENOSYS: c_int = -1;
5292pub const REG_NOMATCH: c_int = 1;
5293pub const REG_BADPAT: c_int = 2;
5294pub const REG_ECOLLATE: c_int = 3;
5295pub const REG_ECTYPE: c_int = 4;
5296pub const REG_EESCAPE: c_int = 5;
5297pub const REG_ESUBREG: c_int = 6;
5298pub const REG_EBRACK: c_int = 7;
5299pub const REG_EPAREN: c_int = 8;
5300pub const REG_EBRACE: c_int = 9;
5301pub const REG_BADBR: c_int = 10;
5302pub const REG_ERANGE: c_int = 11;
5303pub const REG_ESPACE: c_int = 12;
5304pub const REG_BADRPT: c_int = 13;
5305
5306// linux/errqueue.h
5307pub const SO_EE_ORIGIN_NONE: u8 = 0;
5308pub const SO_EE_ORIGIN_LOCAL: u8 = 1;
5309pub const SO_EE_ORIGIN_ICMP: u8 = 2;
5310pub const SO_EE_ORIGIN_ICMP6: u8 = 3;
5311pub const SO_EE_ORIGIN_TXSTATUS: u8 = 4;
5312pub const SO_EE_ORIGIN_TIMESTAMPING: u8 = SO_EE_ORIGIN_TXSTATUS;
5313
5314// errno.h
5315pub const EPERM: c_int = 1;
5316pub const ENOENT: c_int = 2;
5317pub const ESRCH: c_int = 3;
5318pub const EINTR: c_int = 4;
5319pub const EIO: c_int = 5;
5320pub const ENXIO: c_int = 6;
5321pub const E2BIG: c_int = 7;
5322pub const ENOEXEC: c_int = 8;
5323pub const EBADF: c_int = 9;
5324pub const ECHILD: c_int = 10;
5325pub const EAGAIN: c_int = 11;
5326pub const ENOMEM: c_int = 12;
5327pub const EACCES: c_int = 13;
5328pub const EFAULT: c_int = 14;
5329pub const ENOTBLK: c_int = 15;
5330pub const EBUSY: c_int = 16;
5331pub const EEXIST: c_int = 17;
5332pub const EXDEV: c_int = 18;
5333pub const ENODEV: c_int = 19;
5334pub const ENOTDIR: c_int = 20;
5335pub const EISDIR: c_int = 21;
5336pub const EINVAL: c_int = 22;
5337pub const ENFILE: c_int = 23;
5338pub const EMFILE: c_int = 24;
5339pub const ENOTTY: c_int = 25;
5340pub const ETXTBSY: c_int = 26;
5341pub const EFBIG: c_int = 27;
5342pub const ENOSPC: c_int = 28;
5343pub const ESPIPE: c_int = 29;
5344pub const EROFS: c_int = 30;
5345pub const EMLINK: c_int = 31;
5346pub const EPIPE: c_int = 32;
5347pub const EDOM: c_int = 33;
5348pub const ERANGE: c_int = 34;
5349pub const EWOULDBLOCK: c_int = EAGAIN;
5350
5351// linux/can.h
5352pub const CAN_EFF_FLAG: canid_t = 0x80000000;
5353pub const CAN_RTR_FLAG: canid_t = 0x40000000;
5354pub const CAN_ERR_FLAG: canid_t = 0x20000000;
5355pub const CAN_SFF_MASK: canid_t = 0x000007FF;
5356pub const CAN_EFF_MASK: canid_t = 0x1FFFFFFF;
5357pub const CAN_ERR_MASK: canid_t = 0x1FFFFFFF;
5358pub const CANXL_PRIO_MASK: crate::canid_t = CAN_SFF_MASK;
5359
5360pub const CAN_SFF_ID_BITS: c_int = 11;
5361pub const CAN_EFF_ID_BITS: c_int = 29;
5362pub const CANXL_PRIO_BITS: c_int = CAN_SFF_ID_BITS;
5363
5364pub const CAN_MAX_DLC: c_int = 8;
5365pub const CAN_MAX_DLEN: usize = 8;
5366pub const CANFD_MAX_DLC: c_int = 15;
5367pub const CANFD_MAX_DLEN: usize = 64;
5368
5369pub const CANFD_BRS: c_int = 0x01;
5370pub const CANFD_ESI: c_int = 0x02;
5371pub const CANFD_FDF: c_int = 0x04;
5372
5373pub const CANXL_MIN_DLC: c_int = 0;
5374pub const CANXL_MAX_DLC: c_int = 2047;
5375pub const CANXL_MAX_DLC_MASK: c_int = 0x07FF;
5376pub const CANXL_MIN_DLEN: usize = 1;
5377pub const CANXL_MAX_DLEN: usize = 2048;
5378
5379pub const CANXL_XLF: c_int = 0x80;
5380pub const CANXL_SEC: c_int = 0x01;
5381
5382pub const CAN_MTU: usize = size_of::<can_frame>();
5383pub const CANFD_MTU: usize = size_of::<canfd_frame>();
5384pub const CANXL_MTU: usize = size_of::<canxl_frame>();
5385// FIXME(offset_of): use `core::mem::offset_of!` once that is available
5386// https://github.com/rust-lang/rfcs/pull/3308
5387// pub const CANXL_HDR_SIZE: usize = core::mem::offset_of!(canxl_frame, data);
5388pub const CANXL_HDR_SIZE: usize = 12;
5389pub const CANXL_MIN_MTU: usize = CANXL_HDR_SIZE + 64;
5390pub const CANXL_MAX_MTU: usize = CANXL_MTU;
5391
5392pub const CAN_RAW: c_int = 1;
5393pub const CAN_BCM: c_int = 2;
5394pub const CAN_TP16: c_int = 3;
5395pub const CAN_TP20: c_int = 4;
5396pub const CAN_MCNET: c_int = 5;
5397pub const CAN_ISOTP: c_int = 6;
5398pub const CAN_J1939: c_int = 7;
5399pub const CAN_NPROTO: c_int = 8;
5400
5401pub const SOL_CAN_BASE: c_int = 100;
5402
5403pub const CAN_INV_FILTER: canid_t = 0x20000000;
5404pub const CAN_RAW_FILTER_MAX: c_int = 512;
5405
5406// linux/can/raw.h
5407pub const SOL_CAN_RAW: c_int = SOL_CAN_BASE + CAN_RAW;
5408pub const CAN_RAW_FILTER: c_int = 1;
5409pub const CAN_RAW_ERR_FILTER: c_int = 2;
5410pub const CAN_RAW_LOOPBACK: c_int = 3;
5411pub const CAN_RAW_RECV_OWN_MSGS: c_int = 4;
5412pub const CAN_RAW_FD_FRAMES: c_int = 5;
5413pub const CAN_RAW_JOIN_FILTERS: c_int = 6;
5414pub const CAN_RAW_XL_FRAMES: c_int = 7;
5415
5416// linux/can/j1939.h
5417pub const SOL_CAN_J1939: c_int = SOL_CAN_BASE + CAN_J1939;
5418
5419pub const J1939_MAX_UNICAST_ADDR: c_uchar = 0xfd;
5420pub const J1939_IDLE_ADDR: c_uchar = 0xfe;
5421pub const J1939_NO_ADDR: c_uchar = 0xff;
5422pub const J1939_NO_NAME: c_ulong = 0;
5423pub const J1939_PGN_REQUEST: c_uint = 0x0ea00;
5424pub const J1939_PGN_ADDRESS_CLAIMED: c_uint = 0x0ee00;
5425pub const J1939_PGN_ADDRESS_COMMANDED: c_uint = 0x0fed8;
5426pub const J1939_PGN_PDU1_MAX: c_uint = 0x3ff00;
5427pub const J1939_PGN_MAX: c_uint = 0x3ffff;
5428pub const J1939_NO_PGN: c_uint = 0x40000;
5429
5430pub const SO_J1939_FILTER: c_int = 1;
5431pub const SO_J1939_PROMISC: c_int = 2;
5432pub const SO_J1939_SEND_PRIO: c_int = 3;
5433pub const SO_J1939_ERRQUEUE: c_int = 4;
5434
5435pub const SCM_J1939_DEST_ADDR: c_int = 1;
5436pub const SCM_J1939_DEST_NAME: c_int = 2;
5437pub const SCM_J1939_PRIO: c_int = 3;
5438pub const SCM_J1939_ERRQUEUE: c_int = 4;
5439
5440pub const J1939_NLA_PAD: c_int = 0;
5441pub const J1939_NLA_BYTES_ACKED: c_int = 1;
5442pub const J1939_NLA_TOTAL_SIZE: c_int = 2;
5443pub const J1939_NLA_PGN: c_int = 3;
5444pub const J1939_NLA_SRC_NAME: c_int = 4;
5445pub const J1939_NLA_DEST_NAME: c_int = 5;
5446pub const J1939_NLA_SRC_ADDR: c_int = 6;
5447pub const J1939_NLA_DEST_ADDR: c_int = 7;
5448
5449pub const J1939_EE_INFO_NONE: c_int = 0;
5450pub const J1939_EE_INFO_TX_ABORT: c_int = 1;
5451pub const J1939_EE_INFO_RX_RTS: c_int = 2;
5452pub const J1939_EE_INFO_RX_DPO: c_int = 3;
5453pub const J1939_EE_INFO_RX_ABORT: c_int = 4;
5454
5455pub const J1939_FILTER_MAX: c_int = 512;
5456
5457// linux/sctp.h
5458pub const SCTP_FUTURE_ASSOC: c_int = 0;
5459pub const SCTP_CURRENT_ASSOC: c_int = 1;
5460pub const SCTP_ALL_ASSOC: c_int = 2;
5461pub const SCTP_RTOINFO: c_int = 0;
5462pub const SCTP_ASSOCINFO: c_int = 1;
5463pub const SCTP_INITMSG: c_int = 2;
5464pub const SCTP_NODELAY: c_int = 3;
5465pub const SCTP_AUTOCLOSE: c_int = 4;
5466pub const SCTP_SET_PEER_PRIMARY_ADDR: c_int = 5;
5467pub const SCTP_PRIMARY_ADDR: c_int = 6;
5468pub const SCTP_ADAPTATION_LAYER: c_int = 7;
5469pub const SCTP_DISABLE_FRAGMENTS: c_int = 8;
5470pub const SCTP_PEER_ADDR_PARAMS: c_int = 9;
5471pub const SCTP_DEFAULT_SEND_PARAM: c_int = 10;
5472pub const SCTP_EVENTS: c_int = 11;
5473pub const SCTP_I_WANT_MAPPED_V4_ADDR: c_int = 12;
5474pub const SCTP_MAXSEG: c_int = 13;
5475pub const SCTP_STATUS: c_int = 14;
5476pub const SCTP_GET_PEER_ADDR_INFO: c_int = 15;
5477pub const SCTP_DELAYED_ACK_TIME: c_int = 16;
5478pub const SCTP_DELAYED_ACK: c_int = SCTP_DELAYED_ACK_TIME;
5479pub const SCTP_DELAYED_SACK: c_int = SCTP_DELAYED_ACK_TIME;
5480pub const SCTP_CONTEXT: c_int = 17;
5481pub const SCTP_FRAGMENT_INTERLEAVE: c_int = 18;
5482pub const SCTP_PARTIAL_DELIVERY_POINT: c_int = 19;
5483pub const SCTP_MAX_BURST: c_int = 20;
5484pub const SCTP_AUTH_CHUNK: c_int = 21;
5485pub const SCTP_HMAC_IDENT: c_int = 22;
5486pub const SCTP_AUTH_KEY: c_int = 23;
5487pub const SCTP_AUTH_ACTIVE_KEY: c_int = 24;
5488pub const SCTP_AUTH_DELETE_KEY: c_int = 25;
5489pub const SCTP_PEER_AUTH_CHUNKS: c_int = 26;
5490pub const SCTP_LOCAL_AUTH_CHUNKS: c_int = 27;
5491pub const SCTP_GET_ASSOC_NUMBER: c_int = 28;
5492pub const SCTP_GET_ASSOC_ID_LIST: c_int = 29;
5493pub const SCTP_AUTO_ASCONF: c_int = 30;
5494pub const SCTP_PEER_ADDR_THLDS: c_int = 31;
5495pub const SCTP_RECVRCVINFO: c_int = 32;
5496pub const SCTP_RECVNXTINFO: c_int = 33;
5497pub const SCTP_DEFAULT_SNDINFO: c_int = 34;
5498pub const SCTP_AUTH_DEACTIVATE_KEY: c_int = 35;
5499pub const SCTP_REUSE_PORT: c_int = 36;
5500pub const SCTP_PEER_ADDR_THLDS_V2: c_int = 37;
5501pub const SCTP_PR_SCTP_NONE: c_int = 0x0000;
5502pub const SCTP_PR_SCTP_TTL: c_int = 0x0010;
5503pub const SCTP_PR_SCTP_RTX: c_int = 0x0020;
5504pub const SCTP_PR_SCTP_PRIO: c_int = 0x0030;
5505pub const SCTP_PR_SCTP_MAX: c_int = SCTP_PR_SCTP_PRIO;
5506pub const SCTP_PR_SCTP_MASK: c_int = 0x0030;
5507pub const SCTP_ENABLE_RESET_STREAM_REQ: c_int = 0x01;
5508pub const SCTP_ENABLE_RESET_ASSOC_REQ: c_int = 0x02;
5509pub const SCTP_ENABLE_CHANGE_ASSOC_REQ: c_int = 0x04;
5510pub const SCTP_ENABLE_STRRESET_MASK: c_int = 0x07;
5511pub const SCTP_STREAM_RESET_INCOMING: c_int = 0x01;
5512pub const SCTP_STREAM_RESET_OUTGOING: c_int = 0x02;
5513
5514pub const SCTP_INIT: c_int = 0;
5515pub const SCTP_SNDRCV: c_int = 1;
5516pub const SCTP_SNDINFO: c_int = 2;
5517pub const SCTP_RCVINFO: c_int = 3;
5518pub const SCTP_NXTINFO: c_int = 4;
5519pub const SCTP_PRINFO: c_int = 5;
5520pub const SCTP_AUTHINFO: c_int = 6;
5521pub const SCTP_DSTADDRV4: c_int = 7;
5522pub const SCTP_DSTADDRV6: c_int = 8;
5523
5524pub const SCTP_UNORDERED: c_int = 1 << 0;
5525pub const SCTP_ADDR_OVER: c_int = 1 << 1;
5526pub const SCTP_ABORT: c_int = 1 << 2;
5527pub const SCTP_SACK_IMMEDIATELY: c_int = 1 << 3;
5528pub const SCTP_SENDALL: c_int = 1 << 6;
5529pub const SCTP_PR_SCTP_ALL: c_int = 1 << 7;
5530pub const SCTP_NOTIFICATION: c_int = MSG_NOTIFICATION;
5531pub const SCTP_EOF: c_int = crate::MSG_FIN;
5532
5533/* DCCP socket options */
5534pub const DCCP_SOCKOPT_PACKET_SIZE: c_int = 1;
5535pub const DCCP_SOCKOPT_SERVICE: c_int = 2;
5536pub const DCCP_SOCKOPT_CHANGE_L: c_int = 3;
5537pub const DCCP_SOCKOPT_CHANGE_R: c_int = 4;
5538pub const DCCP_SOCKOPT_GET_CUR_MPS: c_int = 5;
5539pub const DCCP_SOCKOPT_SERVER_TIMEWAIT: c_int = 6;
5540pub const DCCP_SOCKOPT_SEND_CSCOV: c_int = 10;
5541pub const DCCP_SOCKOPT_RECV_CSCOV: c_int = 11;
5542pub const DCCP_SOCKOPT_AVAILABLE_CCIDS: c_int = 12;
5543pub const DCCP_SOCKOPT_CCID: c_int = 13;
5544pub const DCCP_SOCKOPT_TX_CCID: c_int = 14;
5545pub const DCCP_SOCKOPT_RX_CCID: c_int = 15;
5546pub const DCCP_SOCKOPT_QPOLICY_ID: c_int = 16;
5547pub const DCCP_SOCKOPT_QPOLICY_TXQLEN: c_int = 17;
5548pub const DCCP_SOCKOPT_CCID_RX_INFO: c_int = 128;
5549pub const DCCP_SOCKOPT_CCID_TX_INFO: c_int = 192;
5550
5551/// maximum number of services provided on the same listening port
5552pub const DCCP_SERVICE_LIST_MAX_LEN: c_int = 32;
5553
5554pub const CTL_KERN: c_int = 1;
5555pub const CTL_VM: c_int = 2;
5556pub const CTL_NET: c_int = 3;
5557pub const CTL_FS: c_int = 5;
5558pub const CTL_DEBUG: c_int = 6;
5559pub const CTL_DEV: c_int = 7;
5560pub const CTL_BUS: c_int = 8;
5561pub const CTL_ABI: c_int = 9;
5562pub const CTL_CPU: c_int = 10;
5563
5564pub const CTL_BUS_ISA: c_int = 1;
5565
5566pub const INOTIFY_MAX_USER_INSTANCES: c_int = 1;
5567pub const INOTIFY_MAX_USER_WATCHES: c_int = 2;
5568pub const INOTIFY_MAX_QUEUED_EVENTS: c_int = 3;
5569
5570pub const KERN_OSTYPE: c_int = 1;
5571pub const KERN_OSRELEASE: c_int = 2;
5572pub const KERN_OSREV: c_int = 3;
5573pub const KERN_VERSION: c_int = 4;
5574pub const KERN_SECUREMASK: c_int = 5;
5575pub const KERN_PROF: c_int = 6;
5576pub const KERN_NODENAME: c_int = 7;
5577pub const KERN_DOMAINNAME: c_int = 8;
5578pub const KERN_PANIC: c_int = 15;
5579pub const KERN_REALROOTDEV: c_int = 16;
5580pub const KERN_SPARC_REBOOT: c_int = 21;
5581pub const KERN_CTLALTDEL: c_int = 22;
5582pub const KERN_PRINTK: c_int = 23;
5583pub const KERN_NAMETRANS: c_int = 24;
5584pub const KERN_PPC_HTABRECLAIM: c_int = 25;
5585pub const KERN_PPC_ZEROPAGED: c_int = 26;
5586pub const KERN_PPC_POWERSAVE_NAP: c_int = 27;
5587pub const KERN_MODPROBE: c_int = 28;
5588pub const KERN_SG_BIG_BUFF: c_int = 29;
5589pub const KERN_ACCT: c_int = 30;
5590pub const KERN_PPC_L2CR: c_int = 31;
5591pub const KERN_RTSIGNR: c_int = 32;
5592pub const KERN_RTSIGMAX: c_int = 33;
5593pub const KERN_SHMMAX: c_int = 34;
5594pub const KERN_MSGMAX: c_int = 35;
5595pub const KERN_MSGMNB: c_int = 36;
5596pub const KERN_MSGPOOL: c_int = 37;
5597pub const KERN_SYSRQ: c_int = 38;
5598pub const KERN_MAX_THREADS: c_int = 39;
5599pub const KERN_RANDOM: c_int = 40;
5600pub const KERN_SHMALL: c_int = 41;
5601pub const KERN_MSGMNI: c_int = 42;
5602pub const KERN_SEM: c_int = 43;
5603pub const KERN_SPARC_STOP_A: c_int = 44;
5604pub const KERN_SHMMNI: c_int = 45;
5605pub const KERN_OVERFLOWUID: c_int = 46;
5606pub const KERN_OVERFLOWGID: c_int = 47;
5607pub const KERN_SHMPATH: c_int = 48;
5608pub const KERN_HOTPLUG: c_int = 49;
5609pub const KERN_IEEE_EMULATION_WARNINGS: c_int = 50;
5610pub const KERN_S390_USER_DEBUG_LOGGING: c_int = 51;
5611pub const KERN_CORE_USES_PID: c_int = 52;
5612pub const KERN_TAINTED: c_int = 53;
5613pub const KERN_CADPID: c_int = 54;
5614pub const KERN_PIDMAX: c_int = 55;
5615pub const KERN_CORE_PATTERN: c_int = 56;
5616pub const KERN_PANIC_ON_OOPS: c_int = 57;
5617pub const KERN_HPPA_PWRSW: c_int = 58;
5618pub const KERN_HPPA_UNALIGNED: c_int = 59;
5619pub const KERN_PRINTK_RATELIMIT: c_int = 60;
5620pub const KERN_PRINTK_RATELIMIT_BURST: c_int = 61;
5621pub const KERN_PTY: c_int = 62;
5622pub const KERN_NGROUPS_MAX: c_int = 63;
5623pub const KERN_SPARC_SCONS_PWROFF: c_int = 64;
5624pub const KERN_HZ_TIMER: c_int = 65;
5625pub const KERN_UNKNOWN_NMI_PANIC: c_int = 66;
5626pub const KERN_BOOTLOADER_TYPE: c_int = 67;
5627pub const KERN_RANDOMIZE: c_int = 68;
5628pub const KERN_SETUID_DUMPABLE: c_int = 69;
5629pub const KERN_SPIN_RETRY: c_int = 70;
5630pub const KERN_ACPI_VIDEO_FLAGS: c_int = 71;
5631pub const KERN_IA64_UNALIGNED: c_int = 72;
5632pub const KERN_COMPAT_LOG: c_int = 73;
5633pub const KERN_MAX_LOCK_DEPTH: c_int = 74;
5634pub const KERN_NMI_WATCHDOG: c_int = 75;
5635pub const KERN_PANIC_ON_NMI: c_int = 76;
5636
5637pub const VM_OVERCOMMIT_MEMORY: c_int = 5;
5638pub const VM_PAGE_CLUSTER: c_int = 10;
5639pub const VM_DIRTY_BACKGROUND: c_int = 11;
5640pub const VM_DIRTY_RATIO: c_int = 12;
5641pub const VM_DIRTY_WB_CS: c_int = 13;
5642pub const VM_DIRTY_EXPIRE_CS: c_int = 14;
5643pub const VM_NR_PDFLUSH_THREADS: c_int = 15;
5644pub const VM_OVERCOMMIT_RATIO: c_int = 16;
5645pub const VM_PAGEBUF: c_int = 17;
5646pub const VM_HUGETLB_PAGES: c_int = 18;
5647pub const VM_SWAPPINESS: c_int = 19;
5648pub const VM_LOWMEM_RESERVE_RATIO: c_int = 20;
5649pub const VM_MIN_FREE_KBYTES: c_int = 21;
5650pub const VM_MAX_MAP_COUNT: c_int = 22;
5651pub const VM_LAPTOP_MODE: c_int = 23;
5652pub const VM_BLOCK_DUMP: c_int = 24;
5653pub const VM_HUGETLB_GROUP: c_int = 25;
5654pub const VM_VFS_CACHE_PRESSURE: c_int = 26;
5655pub const VM_LEGACY_VA_LAYOUT: c_int = 27;
5656pub const VM_SWAP_TOKEN_TIMEOUT: c_int = 28;
5657pub const VM_DROP_PAGECACHE: c_int = 29;
5658pub const VM_PERCPU_PAGELIST_FRACTION: c_int = 30;
5659pub const VM_ZONE_RECLAIM_MODE: c_int = 31;
5660pub const VM_MIN_UNMAPPED: c_int = 32;
5661pub const VM_PANIC_ON_OOM: c_int = 33;
5662pub const VM_VDSO_ENABLED: c_int = 34;
5663pub const VM_MIN_SLAB: c_int = 35;
5664
5665pub const NET_CORE: c_int = 1;
5666pub const NET_ETHER: c_int = 2;
5667pub const NET_802: c_int = 3;
5668pub const NET_UNIX: c_int = 4;
5669pub const NET_IPV4: c_int = 5;
5670pub const NET_IPX: c_int = 6;
5671pub const NET_ATALK: c_int = 7;
5672pub const NET_NETROM: c_int = 8;
5673pub const NET_AX25: c_int = 9;
5674pub const NET_BRIDGE: c_int = 10;
5675pub const NET_ROSE: c_int = 11;
5676pub const NET_IPV6: c_int = 12;
5677pub const NET_X25: c_int = 13;
5678pub const NET_TR: c_int = 14;
5679pub const NET_DECNET: c_int = 15;
5680pub const NET_ECONET: c_int = 16;
5681pub const NET_SCTP: c_int = 17;
5682pub const NET_LLC: c_int = 18;
5683pub const NET_NETFILTER: c_int = 19;
5684pub const NET_DCCP: c_int = 20;
5685pub const NET_IRDA: c_int = 412;
5686
5687// include/linux/sched.h
5688/// I'm a virtual CPU.
5689pub const PF_VCPU: c_int = 0x00000001;
5690/// I am an IDLE thread.
5691pub const PF_IDLE: c_int = 0x00000002;
5692/// Getting shut down.
5693pub const PF_EXITING: c_int = 0x00000004;
5694/// Coredumps should ignore this task.
5695pub const PF_POSTCOREDUMP: c_int = 0x00000008;
5696/// Task is an IO worker.
5697pub const PF_IO_WORKER: c_int = 0x00000010;
5698/// I'm a workqueue worker.
5699pub const PF_WQ_WORKER: c_int = 0x00000020;
5700/// Forked but didn't exec.
5701pub const PF_FORKNOEXEC: c_int = 0x00000040;
5702/// Process policy on mce errors.
5703pub const PF_MCE_PROCESS: c_int = 0x00000080;
5704/// Used super-user privileges.
5705pub const PF_SUPERPRIV: c_int = 0x00000100;
5706/// Dumped core.
5707pub const PF_DUMPCORE: c_int = 0x00000200;
5708/// Killed by a signal.
5709pub const PF_SIGNALED: c_int = 0x00000400;
5710/// Allocating memory to free memory.
5711///
5712/// See `memalloc_noreclaim_save()`.
5713pub const PF_MEMALLOC: c_int = 0x00000800;
5714/// `set_user()` noticed that `RLIMIT_NPROC` was exceeded.
5715pub const PF_NPROC_EXCEEDED: c_int = 0x00001000;
5716/// If unset the fpu must be initialized before use.
5717pub const PF_USED_MATH: c_int = 0x00002000;
5718/// Kernel thread cloned from userspace thread.
5719pub const PF_USER_WORKER: c_int = 0x00004000;
5720/// This thread should not be frozen.
5721pub const PF_NOFREEZE: c_int = 0x00008000;
5722/// I am `kswapd`.
5723pub const PF_KSWAPD: c_int = 0x00020000;
5724/// All allocations inherit `GFP_NOFS`.
5725///
5726/// See `memalloc_nfs_save()`.
5727pub const PF_MEMALLOC_NOFS: c_int = 0x00040000;
5728/// All allocations inherit `GFP_NOIO`.
5729///
5730/// See `memalloc_noio_save()`.
5731pub const PF_MEMALLOC_NOIO: c_int = 0x00080000;
5732/// Throttle writes only against the bdi I write to, I am cleaning
5733/// dirty pages from some other bdi.
5734pub const PF_LOCAL_THROTTLE: c_int = 0x00100000;
5735/// I am a kernel thread.
5736pub const PF_KTHREAD: c_int = 0x00200000;
5737/// Randomize virtual address space.
5738pub const PF_RANDOMIZE: c_int = 0x00400000;
5739/// Userland is not allowed to meddle with `cpus_mask`.
5740pub const PF_NO_SETAFFINITY: c_int = 0x04000000;
5741/// Early kill for mce process policy.
5742pub const PF_MCE_EARLY: c_int = 0x08000000;
5743/// Allocations constrained to zones which allow long term pinning.
5744///
5745/// See `memalloc_pin_save()`.
5746pub const PF_MEMALLOC_PIN: c_int = 0x10000000;
5747/// Plug has ts that needs updating.
5748pub const PF_BLOCK_TS: c_int = 0x20000000;
5749/// This thread called `freeze_processes()` and should not be frozen.
5750pub const PF_SUSPEND_TASK: c_int = PF_SUSPEND_TASK_UINT as _;
5751// The used value is the highest possible bit fitting on 32 bits, so directly
5752// defining it as a signed integer causes the compiler to report an overflow.
5753// Use instead a private intermediary that assuringly has the correct type and
5754// cast it where necessary to the wanted final type, which preserves the
5755// desired information as-is in terms of integer representation.
5756const PF_SUSPEND_TASK_UINT: c_uint = 0x80000000;
5757
5758pub const CSIGNAL: c_int = 0x000000ff;
5759
5760pub const SCHED_NORMAL: c_int = 0;
5761pub const SCHED_OTHER: c_int = 0;
5762pub const SCHED_FIFO: c_int = 1;
5763pub const SCHED_RR: c_int = 2;
5764pub const SCHED_BATCH: c_int = 3;
5765pub const SCHED_IDLE: c_int = 5;
5766pub const SCHED_DEADLINE: c_int = 6;
5767
5768pub const SCHED_RESET_ON_FORK: c_int = 0x40000000;
5769
5770pub const CLONE_PIDFD: c_int = 0x1000;
5771
5772pub const SCHED_FLAG_RESET_ON_FORK: c_int = 0x01;
5773pub const SCHED_FLAG_RECLAIM: c_int = 0x02;
5774pub const SCHED_FLAG_DL_OVERRUN: c_int = 0x04;
5775pub const SCHED_FLAG_KEEP_POLICY: c_int = 0x08;
5776pub const SCHED_FLAG_KEEP_PARAMS: c_int = 0x10;
5777pub const SCHED_FLAG_UTIL_CLAMP_MIN: c_int = 0x20;
5778pub const SCHED_FLAG_UTIL_CLAMP_MAX: c_int = 0x40;
5779
5780// linux/if_xdp.h
5781pub const XDP_SHARED_UMEM: crate::__u16 = 1 << 0;
5782pub const XDP_COPY: crate::__u16 = 1 << 1;
5783pub const XDP_ZEROCOPY: crate::__u16 = 1 << 2;
5784pub const XDP_USE_NEED_WAKEUP: crate::__u16 = 1 << 3;
5785pub const XDP_USE_SG: crate::__u16 = 1 << 4;
5786
5787pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG: crate::__u32 = 1 << 0;
5788
5789pub const XDP_RING_NEED_WAKEUP: crate::__u32 = 1 << 0;
5790
5791pub const XDP_MMAP_OFFSETS: c_int = 1;
5792pub const XDP_RX_RING: c_int = 2;
5793pub const XDP_TX_RING: c_int = 3;
5794pub const XDP_UMEM_REG: c_int = 4;
5795pub const XDP_UMEM_FILL_RING: c_int = 5;
5796pub const XDP_UMEM_COMPLETION_RING: c_int = 6;
5797pub const XDP_STATISTICS: c_int = 7;
5798pub const XDP_OPTIONS: c_int = 8;
5799
5800pub const XDP_OPTIONS_ZEROCOPY: crate::__u32 = 1 << 0;
5801
5802pub const XDP_PGOFF_RX_RING: crate::off_t = 0;
5803pub const XDP_PGOFF_TX_RING: crate::off_t = 0x80000000;
5804pub const XDP_UMEM_PGOFF_FILL_RING: crate::c_ulonglong = 0x100000000;
5805pub const XDP_UMEM_PGOFF_COMPLETION_RING: crate::c_ulonglong = 0x180000000;
5806
5807pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: crate::c_int = 48;
5808pub const XSK_UNALIGNED_BUF_ADDR_MASK: crate::c_ulonglong =
5809    (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1;
5810
5811pub const XDP_PKT_CONTD: crate::__u32 = 1 << 0;
5812
5813pub const XDP_UMEM_TX_SW_CSUM: crate::__u32 = 1 << 1;
5814pub const XDP_UMEM_TX_METADATA_LEN: crate::__u32 = 1 << 2;
5815
5816pub const XDP_TXMD_FLAGS_TIMESTAMP: crate::__u32 = 1 << 0;
5817pub const XDP_TXMD_FLAGS_CHECKSUM: crate::__u32 = 1 << 1;
5818
5819pub const XDP_TX_METADATA: crate::__u32 = 1 << 1;
5820
5821pub const SOL_XDP: c_int = 283;
5822
5823// linux/mount.h
5824pub const MOUNT_ATTR_RDONLY: crate::__u64 = 0x00000001;
5825pub const MOUNT_ATTR_NOSUID: crate::__u64 = 0x00000002;
5826pub const MOUNT_ATTR_NODEV: crate::__u64 = 0x00000004;
5827pub const MOUNT_ATTR_NOEXEC: crate::__u64 = 0x00000008;
5828pub const MOUNT_ATTR__ATIME: crate::__u64 = 0x00000070;
5829pub const MOUNT_ATTR_RELATIME: crate::__u64 = 0x00000000;
5830pub const MOUNT_ATTR_NOATIME: crate::__u64 = 0x00000010;
5831pub const MOUNT_ATTR_STRICTATIME: crate::__u64 = 0x00000020;
5832pub const MOUNT_ATTR_NODIRATIME: crate::__u64 = 0x00000080;
5833pub const MOUNT_ATTR_IDMAP: crate::__u64 = 0x00100000;
5834pub const MOUNT_ATTR_NOSYMFOLLOW: crate::__u64 = 0x00200000;
5835
5836pub const MOUNT_ATTR_SIZE_VER0: c_int = 32;
5837
5838// elf.h
5839pub const NT_PRSTATUS: c_int = 1;
5840pub const NT_PRFPREG: c_int = 2;
5841pub const NT_FPREGSET: c_int = 2;
5842pub const NT_PRPSINFO: c_int = 3;
5843pub const NT_PRXREG: c_int = 4;
5844pub const NT_TASKSTRUCT: c_int = 4;
5845pub const NT_PLATFORM: c_int = 5;
5846pub const NT_AUXV: c_int = 6;
5847pub const NT_GWINDOWS: c_int = 7;
5848pub const NT_ASRS: c_int = 8;
5849pub const NT_PSTATUS: c_int = 10;
5850pub const NT_PSINFO: c_int = 13;
5851pub const NT_PRCRED: c_int = 14;
5852pub const NT_UTSNAME: c_int = 15;
5853pub const NT_LWPSTATUS: c_int = 16;
5854pub const NT_LWPSINFO: c_int = 17;
5855pub const NT_PRFPXREG: c_int = 20;
5856
5857pub const SCHED_FLAG_KEEP_ALL: c_int = SCHED_FLAG_KEEP_POLICY | SCHED_FLAG_KEEP_PARAMS;
5858
5859pub const SCHED_FLAG_UTIL_CLAMP: c_int = SCHED_FLAG_UTIL_CLAMP_MIN | SCHED_FLAG_UTIL_CLAMP_MAX;
5860
5861pub const SCHED_FLAG_ALL: c_int = SCHED_FLAG_RESET_ON_FORK
5862    | SCHED_FLAG_RECLAIM
5863    | SCHED_FLAG_DL_OVERRUN
5864    | SCHED_FLAG_KEEP_ALL
5865    | SCHED_FLAG_UTIL_CLAMP;
5866
5867// ioctl_eventpoll: added in Linux 6.9
5868pub const EPIOCSPARAMS: Ioctl = 0x40088a01;
5869pub const EPIOCGPARAMS: Ioctl = 0x80088a02;
5870
5871const _IOC_NRBITS: u32 = 8;
5872const _IOC_TYPEBITS: u32 = 8;
5873
5874// siginfo.h
5875pub const SI_DETHREAD: c_int = -7;
5876pub const TRAP_PERF: c_int = 6;
5877
5878// https://github.com/search?q=repo%3Atorvalds%2Flinux+%22%23define+_IOC_NONE%22&type=code
5879cfg_if! {
5880    if #[cfg(any(
5881        any(target_arch = "powerpc", target_arch = "powerpc64"),
5882        any(target_arch = "sparc", target_arch = "sparc64"),
5883        any(target_arch = "mips", target_arch = "mips64"),
5884    ))] {
5885        // https://github.com/torvalds/linux/blob/b311c1b497e51a628aa89e7cb954481e5f9dced2/arch/powerpc/include/uapi/asm/ioctl.h
5886        // https://github.com/torvalds/linux/blob/b311c1b497e51a628aa89e7cb954481e5f9dced2/arch/sparc/include/uapi/asm/ioctl.h
5887        // https://github.com/torvalds/linux/blob/b311c1b497e51a628aa89e7cb954481e5f9dced2/arch/mips/include/uapi/asm/ioctl.h
5888
5889        const _IOC_SIZEBITS: u32 = 13;
5890        const _IOC_DIRBITS: u32 = 3;
5891
5892        const _IOC_NONE: u32 = 1;
5893        const _IOC_READ: u32 = 2;
5894        const _IOC_WRITE: u32 = 4;
5895    } else {
5896        // https://github.com/torvalds/linux/blob/b311c1b497e51a628aa89e7cb954481e5f9dced2/include/uapi/asm-generic/ioctl.h
5897
5898        const _IOC_SIZEBITS: u32 = 14;
5899        const _IOC_DIRBITS: u32 = 2;
5900
5901        const _IOC_NONE: u32 = 0;
5902        const _IOC_WRITE: u32 = 1;
5903        const _IOC_READ: u32 = 2;
5904    }
5905}
5906
5907const _IOC_NRMASK: u32 = (1 << _IOC_NRBITS) - 1;
5908const _IOC_TYPEMASK: u32 = (1 << _IOC_TYPEBITS) - 1;
5909const _IOC_SIZEMASK: u32 = (1 << _IOC_SIZEBITS) - 1;
5910const _IOC_DIRMASK: u32 = (1 << _IOC_DIRBITS) - 1;
5911
5912const _IOC_NRSHIFT: u32 = 0;
5913const _IOC_TYPESHIFT: u32 = _IOC_NRSHIFT + _IOC_NRBITS;
5914const _IOC_SIZESHIFT: u32 = _IOC_TYPESHIFT + _IOC_TYPEBITS;
5915const _IOC_DIRSHIFT: u32 = _IOC_SIZESHIFT + _IOC_SIZEBITS;
5916
5917// adapted from https://github.com/torvalds/linux/blob/8a696a29c6905594e4abf78eaafcb62165ac61f1/rust/kernel/ioctl.rs
5918
5919/// Build an ioctl number, analogous to the C macro of the same name.
5920const fn _IOC(dir: u32, ty: u32, nr: u32, size: usize) -> u32 {
5921    // FIXME(ctest) the `garando_syntax` crate (used by ctest2 in the CI test suite)
5922    // cannot currently parse these `debug_assert!`s
5923    //
5924    // debug_assert!(dir <= _IOC_DIRMASK);
5925    // debug_assert!(ty <= _IOC_TYPEMASK);
5926    // debug_assert!(nr <= _IOC_NRMASK);
5927    // debug_assert!(size <= (_IOC_SIZEMASK as usize));
5928
5929    (dir << _IOC_DIRSHIFT)
5930        | (ty << _IOC_TYPESHIFT)
5931        | (nr << _IOC_NRSHIFT)
5932        | ((size as u32) << _IOC_SIZESHIFT)
5933}
5934
5935/// Build an ioctl number for an argumentless ioctl.
5936pub(crate) const fn _IO(ty: u32, nr: u32) -> u32 {
5937    _IOC(_IOC_NONE, ty, nr, 0)
5938}
5939
5940/// Build an ioctl number for an read-only ioctl.
5941pub(crate) const fn _IOR<T>(ty: u32, nr: u32) -> u32 {
5942    _IOC(_IOC_READ, ty, nr, size_of::<T>())
5943}
5944
5945/// Build an ioctl number for an write-only ioctl.
5946pub(crate) const fn _IOW<T>(ty: u32, nr: u32) -> u32 {
5947    _IOC(_IOC_WRITE, ty, nr, size_of::<T>())
5948}
5949
5950/// Build an ioctl number for a read-write ioctl.
5951pub(crate) const fn _IOWR<T>(ty: u32, nr: u32) -> u32 {
5952    _IOC(_IOC_READ | _IOC_WRITE, ty, nr, size_of::<T>())
5953}
5954
5955f! {
5956    pub fn NLA_ALIGN(len: c_int) -> c_int {
5957        return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1);
5958    }
5959
5960    pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr {
5961        if ((*cmsg).cmsg_len as usize) < size_of::<cmsghdr>() {
5962            return 0 as *mut cmsghdr;
5963        };
5964        let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr;
5965        let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize;
5966        if (next.wrapping_offset(1)) as usize > max
5967            || next as usize + super::CMSG_ALIGN((*next).cmsg_len as usize) > max
5968        {
5969            0 as *mut cmsghdr
5970        } else {
5971            next as *mut cmsghdr
5972        }
5973    }
5974
5975    pub fn CPU_ALLOC_SIZE(count: c_int) -> size_t {
5976        let _dummy: cpu_set_t = mem::zeroed();
5977        let size_in_bits = 8 * mem::size_of_val(&_dummy.bits[0]);
5978        ((count as size_t + size_in_bits - 1) / 8) as size_t
5979    }
5980
5981    pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
5982        for slot in cpuset.bits.iter_mut() {
5983            *slot = 0;
5984        }
5985    }
5986
5987    pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
5988        let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
5989        let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
5990        cpuset.bits[idx] |= 1 << offset;
5991        ()
5992    }
5993
5994    pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
5995        let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
5996        let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
5997        cpuset.bits[idx] &= !(1 << offset);
5998        ()
5999    }
6000
6001    pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
6002        let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]);
6003        let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
6004        0 != (cpuset.bits[idx] & (1 << offset))
6005    }
6006
6007    pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int {
6008        let mut s: u32 = 0;
6009        let size_of_mask = mem::size_of_val(&cpuset.bits[0]);
6010        for i in cpuset.bits[..(size / size_of_mask)].iter() {
6011            s += i.count_ones();
6012        }
6013        s as c_int
6014    }
6015
6016    pub fn CPU_COUNT(cpuset: &cpu_set_t) -> c_int {
6017        CPU_COUNT_S(size_of::<cpu_set_t>(), cpuset)
6018    }
6019
6020    pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
6021        set1.bits == set2.bits
6022    }
6023
6024    pub fn SCTP_PR_INDEX(policy: c_int) -> c_int {
6025        policy >> 4 - 1
6026    }
6027
6028    pub fn SCTP_PR_POLICY(policy: c_int) -> c_int {
6029        policy & SCTP_PR_SCTP_MASK
6030    }
6031
6032    pub fn SCTP_PR_SET_POLICY(flags: &mut c_int, policy: c_int) -> () {
6033        *flags &= !SCTP_PR_SCTP_MASK;
6034        *flags |= policy;
6035        ()
6036    }
6037
6038    pub fn IPTOS_TOS(tos: u8) -> u8 {
6039        tos & IPTOS_TOS_MASK
6040    }
6041
6042    pub fn IPTOS_PREC(tos: u8) -> u8 {
6043        tos & IPTOS_PREC_MASK
6044    }
6045
6046    pub fn RT_TOS(tos: u8) -> u8 {
6047        tos & crate::IPTOS_TOS_MASK
6048    }
6049
6050    pub fn RT_ADDRCLASS(flags: u32) -> u32 {
6051        flags >> 23
6052    }
6053
6054    pub fn RT_LOCALADDR(flags: u32) -> bool {
6055        (flags & RTF_ADDRCLASSMASK) == (RTF_LOCAL | RTF_INTERFACE)
6056    }
6057
6058    pub fn SO_EE_OFFENDER(ee: *const crate::sock_extended_err) -> *mut crate::sockaddr {
6059        ee.offset(1) as *mut crate::sockaddr
6060    }
6061
6062    pub fn TPACKET_ALIGN(x: usize) -> usize {
6063        (x + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1)
6064    }
6065
6066    pub fn BPF_RVAL(code: __u32) -> __u32 {
6067        code & 0x18
6068    }
6069
6070    pub fn BPF_MISCOP(code: __u32) -> __u32 {
6071        code & 0xf8
6072    }
6073
6074    pub fn BPF_STMT(code: __u16, k: __u32) -> sock_filter {
6075        sock_filter {
6076            code: code,
6077            jt: 0,
6078            jf: 0,
6079            k: k,
6080        }
6081    }
6082
6083    pub fn BPF_JUMP(code: __u16, k: __u32, jt: __u8, jf: __u8) -> sock_filter {
6084        sock_filter {
6085            code: code,
6086            jt: jt,
6087            jf: jf,
6088            k: k,
6089        }
6090    }
6091
6092    pub fn ELF32_R_SYM(val: Elf32_Word) -> Elf32_Word {
6093        val >> 8
6094    }
6095
6096    pub fn ELF32_R_TYPE(val: Elf32_Word) -> Elf32_Word {
6097        val & 0xff
6098    }
6099
6100    pub fn ELF32_R_INFO(sym: Elf32_Word, t: Elf32_Word) -> Elf32_Word {
6101        sym << 8 + t & 0xff
6102    }
6103
6104    pub fn ELF64_R_SYM(val: Elf64_Xword) -> Elf64_Xword {
6105        val >> 32
6106    }
6107
6108    pub fn ELF64_R_TYPE(val: Elf64_Xword) -> Elf64_Xword {
6109        val & 0xffffffff
6110    }
6111
6112    pub fn ELF64_R_INFO(sym: Elf64_Xword, t: Elf64_Xword) -> Elf64_Xword {
6113        sym << 32 + t
6114    }
6115}
6116
6117safe_f! {
6118    pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t {
6119        let major = major as crate::dev_t;
6120        let minor = minor as crate::dev_t;
6121        let mut dev = 0;
6122        dev |= (major & 0x00000fff) << 8;
6123        dev |= (major & 0xfffff000) << 32;
6124        dev |= (minor & 0x000000ff) << 0;
6125        dev |= (minor & 0xffffff00) << 12;
6126        dev
6127    }
6128
6129    pub {const} fn major(dev: crate::dev_t) -> c_uint {
6130        let mut major = 0;
6131        major |= (dev & 0x00000000000fff00) >> 8;
6132        major |= (dev & 0xfffff00000000000) >> 32;
6133        major as c_uint
6134    }
6135
6136    pub {const} fn minor(dev: crate::dev_t) -> c_uint {
6137        let mut minor = 0;
6138        minor |= (dev & 0x00000000000000ff) >> 0;
6139        minor |= (dev & 0x00000ffffff00000) >> 12;
6140        minor as c_uint
6141    }
6142
6143    pub {const} fn SCTP_PR_TTL_ENABLED(policy: c_int) -> bool {
6144        policy == SCTP_PR_SCTP_TTL
6145    }
6146
6147    pub {const} fn SCTP_PR_RTX_ENABLED(policy: c_int) -> bool {
6148        policy == SCTP_PR_SCTP_RTX
6149    }
6150
6151    pub {const} fn SCTP_PR_PRIO_ENABLED(policy: c_int) -> bool {
6152        policy == SCTP_PR_SCTP_PRIO
6153    }
6154}
6155
6156cfg_if! {
6157    if #[cfg(all(
6158        any(target_env = "gnu", target_env = "musl", target_env = "ohos"),
6159        any(target_arch = "x86_64", target_arch = "x86")
6160    ))] {
6161        extern "C" {
6162            pub fn iopl(level: c_int) -> c_int;
6163            pub fn ioperm(from: c_ulong, num: c_ulong, turn_on: c_int) -> c_int;
6164        }
6165    }
6166}
6167
6168cfg_if! {
6169    if #[cfg(all(not(target_env = "uclibc"), not(target_env = "ohos")))] {
6170        extern "C" {
6171            pub fn aio_read(aiocbp: *mut aiocb) -> c_int;
6172            pub fn aio_write(aiocbp: *mut aiocb) -> c_int;
6173            pub fn aio_fsync(op: c_int, aiocbp: *mut aiocb) -> c_int;
6174            pub fn aio_error(aiocbp: *const aiocb) -> c_int;
6175            pub fn aio_return(aiocbp: *mut aiocb) -> ssize_t;
6176            pub fn aio_suspend(
6177                aiocb_list: *const *const aiocb,
6178                nitems: c_int,
6179                timeout: *const crate::timespec,
6180            ) -> c_int;
6181            pub fn aio_cancel(fd: c_int, aiocbp: *mut aiocb) -> c_int;
6182            pub fn lio_listio(
6183                mode: c_int,
6184                aiocb_list: *const *mut aiocb,
6185                nitems: c_int,
6186                sevp: *mut crate::sigevent,
6187            ) -> c_int;
6188        }
6189    }
6190}
6191
6192cfg_if! {
6193    if #[cfg(not(target_env = "uclibc"))] {
6194        extern "C" {
6195            pub fn pwritev(
6196                fd: c_int,
6197                iov: *const crate::iovec,
6198                iovcnt: c_int,
6199                offset: off_t,
6200            ) -> ssize_t;
6201            pub fn preadv(
6202                fd: c_int,
6203                iov: *const crate::iovec,
6204                iovcnt: c_int,
6205                offset: off_t,
6206            ) -> ssize_t;
6207            pub fn getnameinfo(
6208                sa: *const crate::sockaddr,
6209                salen: crate::socklen_t,
6210                host: *mut c_char,
6211                hostlen: crate::socklen_t,
6212                serv: *mut c_char,
6213                servlen: crate::socklen_t,
6214                flags: c_int,
6215            ) -> c_int;
6216            pub fn getloadavg(loadavg: *mut c_double, nelem: c_int) -> c_int;
6217            pub fn process_vm_readv(
6218                pid: crate::pid_t,
6219                local_iov: *const crate::iovec,
6220                liovcnt: c_ulong,
6221                remote_iov: *const crate::iovec,
6222                riovcnt: c_ulong,
6223                flags: c_ulong,
6224            ) -> isize;
6225            pub fn process_vm_writev(
6226                pid: crate::pid_t,
6227                local_iov: *const crate::iovec,
6228                liovcnt: c_ulong,
6229                remote_iov: *const crate::iovec,
6230                riovcnt: c_ulong,
6231                flags: c_ulong,
6232            ) -> isize;
6233            pub fn futimes(fd: c_int, times: *const crate::timeval) -> c_int;
6234        }
6235    }
6236}
6237
6238// These functions are not available on OpenHarmony
6239cfg_if! {
6240    if #[cfg(not(target_env = "ohos"))] {
6241        extern "C" {
6242            // Only `getspnam_r` is implemented for musl, out of all of the reenterant
6243            // functions from `shadow.h`.
6244            // https://git.musl-libc.org/cgit/musl/tree/include/shadow.h
6245            pub fn getspnam_r(
6246                name: *const c_char,
6247                spbuf: *mut spwd,
6248                buf: *mut c_char,
6249                buflen: size_t,
6250                spbufp: *mut *mut spwd,
6251            ) -> c_int;
6252
6253            pub fn mq_open(name: *const c_char, oflag: c_int, ...) -> crate::mqd_t;
6254            pub fn mq_close(mqd: crate::mqd_t) -> c_int;
6255            pub fn mq_unlink(name: *const c_char) -> c_int;
6256            pub fn mq_receive(
6257                mqd: crate::mqd_t,
6258                msg_ptr: *mut c_char,
6259                msg_len: size_t,
6260                msg_prio: *mut c_uint,
6261            ) -> ssize_t;
6262            pub fn mq_timedreceive(
6263                mqd: crate::mqd_t,
6264                msg_ptr: *mut c_char,
6265                msg_len: size_t,
6266                msg_prio: *mut c_uint,
6267                abs_timeout: *const crate::timespec,
6268            ) -> ssize_t;
6269            pub fn mq_send(
6270                mqd: crate::mqd_t,
6271                msg_ptr: *const c_char,
6272                msg_len: size_t,
6273                msg_prio: c_uint,
6274            ) -> c_int;
6275            pub fn mq_timedsend(
6276                mqd: crate::mqd_t,
6277                msg_ptr: *const c_char,
6278                msg_len: size_t,
6279                msg_prio: c_uint,
6280                abs_timeout: *const crate::timespec,
6281            ) -> c_int;
6282            pub fn mq_getattr(mqd: crate::mqd_t, attr: *mut crate::mq_attr) -> c_int;
6283            pub fn mq_setattr(
6284                mqd: crate::mqd_t,
6285                newattr: *const crate::mq_attr,
6286                oldattr: *mut crate::mq_attr,
6287            ) -> c_int;
6288
6289            pub fn pthread_mutex_consistent(mutex: *mut pthread_mutex_t) -> c_int;
6290            pub fn pthread_cancel(thread: crate::pthread_t) -> c_int;
6291            pub fn pthread_mutexattr_getrobust(
6292                attr: *const pthread_mutexattr_t,
6293                robustness: *mut c_int,
6294            ) -> c_int;
6295            pub fn pthread_mutexattr_setrobust(
6296                attr: *mut pthread_mutexattr_t,
6297                robustness: c_int,
6298            ) -> c_int;
6299        }
6300    }
6301}
6302
6303extern "C" {
6304    #[cfg_attr(
6305        not(any(target_env = "musl", target_env = "ohos")),
6306        link_name = "__xpg_strerror_r"
6307    )]
6308    pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int;
6309
6310    pub fn abs(i: c_int) -> c_int;
6311    pub fn labs(i: c_long) -> c_long;
6312    pub fn rand() -> c_int;
6313    pub fn srand(seed: c_uint);
6314
6315    pub fn drand48() -> c_double;
6316    pub fn erand48(xseed: *mut c_ushort) -> c_double;
6317    pub fn lrand48() -> c_long;
6318    pub fn nrand48(xseed: *mut c_ushort) -> c_long;
6319    pub fn mrand48() -> c_long;
6320    pub fn jrand48(xseed: *mut c_ushort) -> c_long;
6321    pub fn srand48(seed: c_long);
6322    pub fn seed48(xseed: *mut c_ushort) -> *mut c_ushort;
6323    pub fn lcong48(p: *mut c_ushort);
6324
6325    pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int;
6326
6327    pub fn setpwent();
6328    pub fn endpwent();
6329    pub fn getpwent() -> *mut passwd;
6330    pub fn setgrent();
6331    pub fn endgrent();
6332    pub fn getgrent() -> *mut crate::group;
6333    pub fn setspent();
6334    pub fn endspent();
6335    pub fn getspent() -> *mut spwd;
6336
6337    pub fn getspnam(name: *const c_char) -> *mut spwd;
6338
6339    pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int;
6340    pub fn shm_unlink(name: *const c_char) -> c_int;
6341
6342    // System V IPC
6343    pub fn shmget(key: crate::key_t, size: size_t, shmflg: c_int) -> c_int;
6344    pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void;
6345    pub fn shmdt(shmaddr: *const c_void) -> c_int;
6346    pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int;
6347    pub fn ftok(pathname: *const c_char, proj_id: c_int) -> crate::key_t;
6348    pub fn semget(key: crate::key_t, nsems: c_int, semflag: c_int) -> c_int;
6349    pub fn semop(semid: c_int, sops: *mut crate::sembuf, nsops: size_t) -> c_int;
6350    pub fn semctl(semid: c_int, semnum: c_int, cmd: c_int, ...) -> c_int;
6351    pub fn msgctl(msqid: c_int, cmd: c_int, buf: *mut msqid_ds) -> c_int;
6352    pub fn msgget(key: crate::key_t, msgflg: c_int) -> c_int;
6353    pub fn msgrcv(
6354        msqid: c_int,
6355        msgp: *mut c_void,
6356        msgsz: size_t,
6357        msgtyp: c_long,
6358        msgflg: c_int,
6359    ) -> ssize_t;
6360    pub fn msgsnd(msqid: c_int, msgp: *const c_void, msgsz: size_t, msgflg: c_int) -> c_int;
6361
6362    pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int;
6363    pub fn __errno_location() -> *mut c_int;
6364
6365    pub fn fallocate(fd: c_int, mode: c_int, offset: off_t, len: off_t) -> c_int;
6366    pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int;
6367    pub fn readahead(fd: c_int, offset: off64_t, count: size_t) -> ssize_t;
6368    pub fn getxattr(
6369        path: *const c_char,
6370        name: *const c_char,
6371        value: *mut c_void,
6372        size: size_t,
6373    ) -> ssize_t;
6374    pub fn lgetxattr(
6375        path: *const c_char,
6376        name: *const c_char,
6377        value: *mut c_void,
6378        size: size_t,
6379    ) -> ssize_t;
6380    pub fn fgetxattr(
6381        filedes: c_int,
6382        name: *const c_char,
6383        value: *mut c_void,
6384        size: size_t,
6385    ) -> ssize_t;
6386    pub fn setxattr(
6387        path: *const c_char,
6388        name: *const c_char,
6389        value: *const c_void,
6390        size: size_t,
6391        flags: c_int,
6392    ) -> c_int;
6393    pub fn lsetxattr(
6394        path: *const c_char,
6395        name: *const c_char,
6396        value: *const c_void,
6397        size: size_t,
6398        flags: c_int,
6399    ) -> c_int;
6400    pub fn fsetxattr(
6401        filedes: c_int,
6402        name: *const c_char,
6403        value: *const c_void,
6404        size: size_t,
6405        flags: c_int,
6406    ) -> c_int;
6407    pub fn listxattr(path: *const c_char, list: *mut c_char, size: size_t) -> ssize_t;
6408    pub fn llistxattr(path: *const c_char, list: *mut c_char, size: size_t) -> ssize_t;
6409    pub fn flistxattr(filedes: c_int, list: *mut c_char, size: size_t) -> ssize_t;
6410    pub fn removexattr(path: *const c_char, name: *const c_char) -> c_int;
6411    pub fn lremovexattr(path: *const c_char, name: *const c_char) -> c_int;
6412    pub fn fremovexattr(filedes: c_int, name: *const c_char) -> c_int;
6413    pub fn signalfd(fd: c_int, mask: *const crate::sigset_t, flags: c_int) -> c_int;
6414    pub fn timerfd_create(clockid: crate::clockid_t, flags: c_int) -> c_int;
6415    pub fn timerfd_gettime(fd: c_int, curr_value: *mut itimerspec) -> c_int;
6416    pub fn timerfd_settime(
6417        fd: c_int,
6418        flags: c_int,
6419        new_value: *const itimerspec,
6420        old_value: *mut itimerspec,
6421    ) -> c_int;
6422    pub fn quotactl(cmd: c_int, special: *const c_char, id: c_int, data: *mut c_char) -> c_int;
6423    pub fn epoll_pwait(
6424        epfd: c_int,
6425        events: *mut crate::epoll_event,
6426        maxevents: c_int,
6427        timeout: c_int,
6428        sigmask: *const crate::sigset_t,
6429    ) -> c_int;
6430    pub fn dup3(oldfd: c_int, newfd: c_int, flags: c_int) -> c_int;
6431    pub fn sigtimedwait(
6432        set: *const sigset_t,
6433        info: *mut siginfo_t,
6434        timeout: *const crate::timespec,
6435    ) -> c_int;
6436    pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int;
6437    pub fn nl_langinfo_l(item: crate::nl_item, locale: crate::locale_t) -> *mut c_char;
6438    pub fn accept4(
6439        fd: c_int,
6440        addr: *mut crate::sockaddr,
6441        len: *mut crate::socklen_t,
6442        flg: c_int,
6443    ) -> c_int;
6444    pub fn pthread_getaffinity_np(
6445        thread: crate::pthread_t,
6446        cpusetsize: size_t,
6447        cpuset: *mut crate::cpu_set_t,
6448    ) -> c_int;
6449    pub fn pthread_setaffinity_np(
6450        thread: crate::pthread_t,
6451        cpusetsize: size_t,
6452        cpuset: *const crate::cpu_set_t,
6453    ) -> c_int;
6454    pub fn pthread_setschedprio(native: crate::pthread_t, priority: c_int) -> c_int;
6455    pub fn reboot(how_to: c_int) -> c_int;
6456    pub fn setfsgid(gid: crate::gid_t) -> c_int;
6457    pub fn setfsuid(uid: crate::uid_t) -> c_int;
6458
6459    // Not available now on Android
6460    pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int;
6461    pub fn if_nameindex() -> *mut if_nameindex;
6462    pub fn if_freenameindex(ptr: *mut if_nameindex);
6463    pub fn sync_file_range(fd: c_int, offset: off64_t, nbytes: off64_t, flags: c_uint) -> c_int;
6464    pub fn mremap(
6465        addr: *mut c_void,
6466        len: size_t,
6467        new_len: size_t,
6468        flags: c_int,
6469        ...
6470    ) -> *mut c_void;
6471
6472    pub fn glob(
6473        pattern: *const c_char,
6474        flags: c_int,
6475        errfunc: Option<extern "C" fn(epath: *const c_char, errno: c_int) -> c_int>,
6476        pglob: *mut crate::glob_t,
6477    ) -> c_int;
6478    pub fn globfree(pglob: *mut crate::glob_t);
6479
6480    pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int;
6481
6482    pub fn seekdir(dirp: *mut crate::DIR, loc: c_long);
6483
6484    pub fn telldir(dirp: *mut crate::DIR) -> c_long;
6485    pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int;
6486
6487    pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int;
6488    pub fn remap_file_pages(
6489        addr: *mut c_void,
6490        size: size_t,
6491        prot: c_int,
6492        pgoff: size_t,
6493        flags: c_int,
6494    ) -> c_int;
6495    pub fn recvfrom(
6496        socket: c_int,
6497        buf: *mut c_void,
6498        len: size_t,
6499        flags: c_int,
6500        addr: *mut crate::sockaddr,
6501        addrlen: *mut crate::socklen_t,
6502    ) -> ssize_t;
6503    pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int;
6504
6505    pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char;
6506
6507    pub fn vhangup() -> c_int;
6508    pub fn sync();
6509    pub fn syncfs(fd: c_int) -> c_int;
6510    pub fn syscall(num: c_long, ...) -> c_long;
6511    pub fn sched_getaffinity(
6512        pid: crate::pid_t,
6513        cpusetsize: size_t,
6514        cpuset: *mut cpu_set_t,
6515    ) -> c_int;
6516    pub fn sched_setaffinity(
6517        pid: crate::pid_t,
6518        cpusetsize: size_t,
6519        cpuset: *const cpu_set_t,
6520    ) -> c_int;
6521    pub fn epoll_create(size: c_int) -> c_int;
6522    pub fn epoll_create1(flags: c_int) -> c_int;
6523    pub fn epoll_wait(
6524        epfd: c_int,
6525        events: *mut crate::epoll_event,
6526        maxevents: c_int,
6527        timeout: c_int,
6528    ) -> c_int;
6529    pub fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut crate::epoll_event) -> c_int;
6530    pub fn pthread_getschedparam(
6531        native: crate::pthread_t,
6532        policy: *mut c_int,
6533        param: *mut crate::sched_param,
6534    ) -> c_int;
6535    pub fn unshare(flags: c_int) -> c_int;
6536    pub fn umount(target: *const c_char) -> c_int;
6537    pub fn sched_get_priority_max(policy: c_int) -> c_int;
6538    pub fn tee(fd_in: c_int, fd_out: c_int, len: size_t, flags: c_uint) -> ssize_t;
6539    pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int;
6540    pub fn splice(
6541        fd_in: c_int,
6542        off_in: *mut crate::loff_t,
6543        fd_out: c_int,
6544        off_out: *mut crate::loff_t,
6545        len: size_t,
6546        flags: c_uint,
6547    ) -> ssize_t;
6548    pub fn eventfd(init: c_uint, flags: c_int) -> c_int;
6549    pub fn eventfd_read(fd: c_int, value: *mut eventfd_t) -> c_int;
6550    pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int;
6551
6552    pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int;
6553    pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int;
6554    pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int;
6555    pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int;
6556    pub fn setns(fd: c_int, nstype: c_int) -> c_int;
6557    pub fn swapoff(path: *const c_char) -> c_int;
6558    pub fn vmsplice(fd: c_int, iov: *const crate::iovec, nr_segs: size_t, flags: c_uint)
6559        -> ssize_t;
6560    pub fn mount(
6561        src: *const c_char,
6562        target: *const c_char,
6563        fstype: *const c_char,
6564        flags: c_ulong,
6565        data: *const c_void,
6566    ) -> c_int;
6567    pub fn personality(persona: c_ulong) -> c_int;
6568    pub fn prctl(option: c_int, ...) -> c_int;
6569    pub fn sched_getparam(pid: crate::pid_t, param: *mut crate::sched_param) -> c_int;
6570    pub fn ppoll(
6571        fds: *mut crate::pollfd,
6572        nfds: nfds_t,
6573        timeout: *const crate::timespec,
6574        sigmask: *const sigset_t,
6575    ) -> c_int;
6576    pub fn pthread_mutexattr_getprotocol(
6577        attr: *const pthread_mutexattr_t,
6578        protocol: *mut c_int,
6579    ) -> c_int;
6580    pub fn pthread_mutexattr_setprotocol(attr: *mut pthread_mutexattr_t, protocol: c_int) -> c_int;
6581
6582    pub fn pthread_mutex_timedlock(
6583        lock: *mut pthread_mutex_t,
6584        abstime: *const crate::timespec,
6585    ) -> c_int;
6586    pub fn pthread_barrierattr_init(attr: *mut crate::pthread_barrierattr_t) -> c_int;
6587    pub fn pthread_barrierattr_destroy(attr: *mut crate::pthread_barrierattr_t) -> c_int;
6588    pub fn pthread_barrierattr_getpshared(
6589        attr: *const crate::pthread_barrierattr_t,
6590        shared: *mut c_int,
6591    ) -> c_int;
6592    pub fn pthread_barrierattr_setpshared(
6593        attr: *mut crate::pthread_barrierattr_t,
6594        shared: c_int,
6595    ) -> c_int;
6596    pub fn pthread_barrier_init(
6597        barrier: *mut pthread_barrier_t,
6598        attr: *const crate::pthread_barrierattr_t,
6599        count: c_uint,
6600    ) -> c_int;
6601    pub fn pthread_barrier_destroy(barrier: *mut pthread_barrier_t) -> c_int;
6602    pub fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> c_int;
6603    pub fn pthread_spin_init(lock: *mut crate::pthread_spinlock_t, pshared: c_int) -> c_int;
6604    pub fn pthread_spin_destroy(lock: *mut crate::pthread_spinlock_t) -> c_int;
6605    pub fn pthread_spin_lock(lock: *mut crate::pthread_spinlock_t) -> c_int;
6606    pub fn pthread_spin_trylock(lock: *mut crate::pthread_spinlock_t) -> c_int;
6607    pub fn pthread_spin_unlock(lock: *mut crate::pthread_spinlock_t) -> c_int;
6608    pub fn clone(
6609        cb: extern "C" fn(*mut c_void) -> c_int,
6610        child_stack: *mut c_void,
6611        flags: c_int,
6612        arg: *mut c_void,
6613        ...
6614    ) -> c_int;
6615    pub fn sched_getscheduler(pid: crate::pid_t) -> c_int;
6616    pub fn clock_nanosleep(
6617        clk_id: crate::clockid_t,
6618        flags: c_int,
6619        rqtp: *const crate::timespec,
6620        rmtp: *mut crate::timespec,
6621    ) -> c_int;
6622    pub fn pthread_attr_getguardsize(
6623        attr: *const crate::pthread_attr_t,
6624        guardsize: *mut size_t,
6625    ) -> c_int;
6626    pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int;
6627    pub fn pthread_attr_getinheritsched(
6628        attr: *const crate::pthread_attr_t,
6629        inheritsched: *mut c_int,
6630    ) -> c_int;
6631    pub fn pthread_attr_setinheritsched(
6632        attr: *mut crate::pthread_attr_t,
6633        inheritsched: c_int,
6634    ) -> c_int;
6635    pub fn pthread_attr_getschedpolicy(
6636        attr: *const crate::pthread_attr_t,
6637        policy: *mut c_int,
6638    ) -> c_int;
6639    pub fn pthread_attr_setschedpolicy(attr: *mut crate::pthread_attr_t, policy: c_int) -> c_int;
6640    pub fn pthread_attr_getschedparam(
6641        attr: *const crate::pthread_attr_t,
6642        param: *mut crate::sched_param,
6643    ) -> c_int;
6644    pub fn pthread_attr_setschedparam(
6645        attr: *mut crate::pthread_attr_t,
6646        param: *const crate::sched_param,
6647    ) -> c_int;
6648    pub fn sethostname(name: *const c_char, len: size_t) -> c_int;
6649    pub fn sched_get_priority_min(policy: c_int) -> c_int;
6650    pub fn pthread_condattr_getpshared(
6651        attr: *const pthread_condattr_t,
6652        pshared: *mut c_int,
6653    ) -> c_int;
6654    pub fn sysinfo(info: *mut crate::sysinfo) -> c_int;
6655    pub fn umount2(target: *const c_char, flags: c_int) -> c_int;
6656    pub fn pthread_setschedparam(
6657        native: crate::pthread_t,
6658        policy: c_int,
6659        param: *const crate::sched_param,
6660    ) -> c_int;
6661    pub fn swapon(path: *const c_char, swapflags: c_int) -> c_int;
6662    pub fn sched_setscheduler(
6663        pid: crate::pid_t,
6664        policy: c_int,
6665        param: *const crate::sched_param,
6666    ) -> c_int;
6667    pub fn sendfile(out_fd: c_int, in_fd: c_int, offset: *mut off_t, count: size_t) -> ssize_t;
6668    pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int;
6669    pub fn getgrgid_r(
6670        gid: crate::gid_t,
6671        grp: *mut crate::group,
6672        buf: *mut c_char,
6673        buflen: size_t,
6674        result: *mut *mut crate::group,
6675    ) -> c_int;
6676    pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int;
6677    pub fn sem_close(sem: *mut sem_t) -> c_int;
6678    pub fn getdtablesize() -> c_int;
6679    pub fn getgrnam_r(
6680        name: *const c_char,
6681        grp: *mut crate::group,
6682        buf: *mut c_char,
6683        buflen: size_t,
6684        result: *mut *mut crate::group,
6685    ) -> c_int;
6686    pub fn initgroups(user: *const c_char, group: crate::gid_t) -> c_int;
6687    pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int;
6688    pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut sem_t;
6689    pub fn getgrnam(name: *const c_char) -> *mut crate::group;
6690    pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int;
6691    pub fn sem_unlink(name: *const c_char) -> c_int;
6692    pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int;
6693    pub fn getpwnam_r(
6694        name: *const c_char,
6695        pwd: *mut passwd,
6696        buf: *mut c_char,
6697        buflen: size_t,
6698        result: *mut *mut passwd,
6699    ) -> c_int;
6700    pub fn getpwuid_r(
6701        uid: crate::uid_t,
6702        pwd: *mut passwd,
6703        buf: *mut c_char,
6704        buflen: size_t,
6705        result: *mut *mut passwd,
6706    ) -> c_int;
6707    pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int;
6708    pub fn pthread_atfork(
6709        prepare: Option<unsafe extern "C" fn()>,
6710        parent: Option<unsafe extern "C" fn()>,
6711        child: Option<unsafe extern "C" fn()>,
6712    ) -> c_int;
6713    pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group;
6714    pub fn getgrouplist(
6715        user: *const c_char,
6716        group: crate::gid_t,
6717        groups: *mut crate::gid_t,
6718        ngroups: *mut c_int,
6719    ) -> c_int;
6720    pub fn pthread_mutexattr_getpshared(
6721        attr: *const pthread_mutexattr_t,
6722        pshared: *mut c_int,
6723    ) -> c_int;
6724    pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE;
6725    pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int;
6726    pub fn pthread_create(
6727        native: *mut crate::pthread_t,
6728        attr: *const crate::pthread_attr_t,
6729        f: extern "C" fn(*mut c_void) -> *mut c_void,
6730        value: *mut c_void,
6731    ) -> c_int;
6732    pub fn dl_iterate_phdr(
6733        callback: Option<
6734            unsafe extern "C" fn(
6735                info: *mut crate::dl_phdr_info,
6736                size: size_t,
6737                data: *mut c_void,
6738            ) -> c_int,
6739        >,
6740        data: *mut c_void,
6741    ) -> c_int;
6742
6743    pub fn setmntent(filename: *const c_char, ty: *const c_char) -> *mut crate::FILE;
6744    pub fn getmntent(stream: *mut crate::FILE) -> *mut crate::mntent;
6745    pub fn addmntent(stream: *mut crate::FILE, mnt: *const crate::mntent) -> c_int;
6746    pub fn endmntent(streamp: *mut crate::FILE) -> c_int;
6747    pub fn hasmntopt(mnt: *const crate::mntent, opt: *const c_char) -> *mut c_char;
6748
6749    pub fn posix_spawn(
6750        pid: *mut crate::pid_t,
6751        path: *const c_char,
6752        file_actions: *const crate::posix_spawn_file_actions_t,
6753        attrp: *const crate::posix_spawnattr_t,
6754        argv: *const *mut c_char,
6755        envp: *const *mut c_char,
6756    ) -> c_int;
6757    pub fn posix_spawnp(
6758        pid: *mut crate::pid_t,
6759        file: *const c_char,
6760        file_actions: *const crate::posix_spawn_file_actions_t,
6761        attrp: *const crate::posix_spawnattr_t,
6762        argv: *const *mut c_char,
6763        envp: *const *mut c_char,
6764    ) -> c_int;
6765    pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int;
6766    pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int;
6767    pub fn posix_spawnattr_getsigdefault(
6768        attr: *const posix_spawnattr_t,
6769        default: *mut crate::sigset_t,
6770    ) -> c_int;
6771    pub fn posix_spawnattr_setsigdefault(
6772        attr: *mut posix_spawnattr_t,
6773        default: *const crate::sigset_t,
6774    ) -> c_int;
6775    pub fn posix_spawnattr_getsigmask(
6776        attr: *const posix_spawnattr_t,
6777        default: *mut crate::sigset_t,
6778    ) -> c_int;
6779    pub fn posix_spawnattr_setsigmask(
6780        attr: *mut posix_spawnattr_t,
6781        default: *const crate::sigset_t,
6782    ) -> c_int;
6783    pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int;
6784    pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int;
6785    pub fn posix_spawnattr_getpgroup(
6786        attr: *const posix_spawnattr_t,
6787        flags: *mut crate::pid_t,
6788    ) -> c_int;
6789    pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: crate::pid_t) -> c_int;
6790    pub fn posix_spawnattr_getschedpolicy(
6791        attr: *const posix_spawnattr_t,
6792        flags: *mut c_int,
6793    ) -> c_int;
6794    pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: c_int) -> c_int;
6795    pub fn posix_spawnattr_getschedparam(
6796        attr: *const posix_spawnattr_t,
6797        param: *mut crate::sched_param,
6798    ) -> c_int;
6799    pub fn posix_spawnattr_setschedparam(
6800        attr: *mut posix_spawnattr_t,
6801        param: *const crate::sched_param,
6802    ) -> c_int;
6803
6804    pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int;
6805    pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int;
6806    pub fn posix_spawn_file_actions_addopen(
6807        actions: *mut posix_spawn_file_actions_t,
6808        fd: c_int,
6809        path: *const c_char,
6810        oflag: c_int,
6811        mode: crate::mode_t,
6812    ) -> c_int;
6813    pub fn posix_spawn_file_actions_addclose(
6814        actions: *mut posix_spawn_file_actions_t,
6815        fd: c_int,
6816    ) -> c_int;
6817    pub fn posix_spawn_file_actions_adddup2(
6818        actions: *mut posix_spawn_file_actions_t,
6819        fd: c_int,
6820        newfd: c_int,
6821    ) -> c_int;
6822    pub fn fread_unlocked(
6823        buf: *mut c_void,
6824        size: size_t,
6825        nobj: size_t,
6826        stream: *mut crate::FILE,
6827    ) -> size_t;
6828    pub fn inotify_rm_watch(fd: c_int, wd: c_int) -> c_int;
6829    pub fn inotify_init() -> c_int;
6830    pub fn inotify_init1(flags: c_int) -> c_int;
6831    pub fn inotify_add_watch(fd: c_int, path: *const c_char, mask: u32) -> c_int;
6832    pub fn fanotify_init(flags: c_uint, event_f_flags: c_uint) -> c_int;
6833
6834    pub fn regcomp(preg: *mut crate::regex_t, pattern: *const c_char, cflags: c_int) -> c_int;
6835
6836    pub fn regexec(
6837        preg: *const crate::regex_t,
6838        input: *const c_char,
6839        nmatch: size_t,
6840        pmatch: *mut regmatch_t,
6841        eflags: c_int,
6842    ) -> c_int;
6843
6844    pub fn regerror(
6845        errcode: c_int,
6846        preg: *const crate::regex_t,
6847        errbuf: *mut c_char,
6848        errbuf_size: size_t,
6849    ) -> size_t;
6850
6851    pub fn regfree(preg: *mut crate::regex_t);
6852
6853    pub fn iconv_open(tocode: *const c_char, fromcode: *const c_char) -> iconv_t;
6854    pub fn iconv(
6855        cd: iconv_t,
6856        inbuf: *mut *mut c_char,
6857        inbytesleft: *mut size_t,
6858        outbuf: *mut *mut c_char,
6859        outbytesleft: *mut size_t,
6860    ) -> size_t;
6861    pub fn iconv_close(cd: iconv_t) -> c_int;
6862
6863    pub fn gettid() -> crate::pid_t;
6864
6865    pub fn timer_create(
6866        clockid: crate::clockid_t,
6867        sevp: *mut crate::sigevent,
6868        timerid: *mut crate::timer_t,
6869    ) -> c_int;
6870    pub fn timer_delete(timerid: crate::timer_t) -> c_int;
6871    pub fn timer_getoverrun(timerid: crate::timer_t) -> c_int;
6872    pub fn timer_gettime(timerid: crate::timer_t, curr_value: *mut crate::itimerspec) -> c_int;
6873    pub fn timer_settime(
6874        timerid: crate::timer_t,
6875        flags: c_int,
6876        new_value: *const crate::itimerspec,
6877        old_value: *mut crate::itimerspec,
6878    ) -> c_int;
6879
6880    pub fn gethostid() -> c_long;
6881
6882    pub fn pthread_getcpuclockid(thread: crate::pthread_t, clk_id: *mut crate::clockid_t) -> c_int;
6883    pub fn memmem(
6884        haystack: *const c_void,
6885        haystacklen: size_t,
6886        needle: *const c_void,
6887        needlelen: size_t,
6888    ) -> *mut c_void;
6889    pub fn sched_getcpu() -> c_int;
6890
6891    pub fn pthread_getname_np(thread: crate::pthread_t, name: *mut c_char, len: size_t) -> c_int;
6892    pub fn pthread_setname_np(thread: crate::pthread_t, name: *const c_char) -> c_int;
6893    pub fn getopt_long(
6894        argc: c_int,
6895        argv: *const *mut c_char,
6896        optstring: *const c_char,
6897        longopts: *const option,
6898        longindex: *mut c_int,
6899    ) -> c_int;
6900
6901    pub fn pthread_once(control: *mut pthread_once_t, routine: extern "C" fn()) -> c_int;
6902
6903    pub fn copy_file_range(
6904        fd_in: c_int,
6905        off_in: *mut off64_t,
6906        fd_out: c_int,
6907        off_out: *mut off64_t,
6908        len: size_t,
6909        flags: c_uint,
6910    ) -> ssize_t;
6911
6912    pub fn klogctl(syslog_type: c_int, bufp: *mut c_char, len: c_int) -> c_int;
6913
6914    pub fn ioctl(fd: c_int, request: Ioctl, ...) -> c_int;
6915}
6916
6917// LFS64 extensions
6918//
6919// * musl has 64-bit versions only so aliases the LFS64 symbols to the standard ones
6920cfg_if! {
6921    if #[cfg(not(target_env = "musl"))] {
6922        extern "C" {
6923            pub fn fallocate64(fd: c_int, mode: c_int, offset: off64_t, len: off64_t) -> c_int;
6924            pub fn fgetpos64(stream: *mut crate::FILE, ptr: *mut fpos64_t) -> c_int;
6925            pub fn fopen64(filename: *const c_char, mode: *const c_char) -> *mut crate::FILE;
6926            pub fn freopen64(
6927                filename: *const c_char,
6928                mode: *const c_char,
6929                file: *mut crate::FILE,
6930            ) -> *mut crate::FILE;
6931            pub fn fseeko64(stream: *mut crate::FILE, offset: off64_t, whence: c_int) -> c_int;
6932            pub fn fsetpos64(stream: *mut crate::FILE, ptr: *const fpos64_t) -> c_int;
6933            pub fn ftello64(stream: *mut crate::FILE) -> off64_t;
6934            pub fn posix_fallocate64(fd: c_int, offset: off64_t, len: off64_t) -> c_int;
6935            pub fn sendfile64(
6936                out_fd: c_int,
6937                in_fd: c_int,
6938                offset: *mut off64_t,
6939                count: size_t,
6940            ) -> ssize_t;
6941            pub fn tmpfile64() -> *mut crate::FILE;
6942        }
6943    }
6944}
6945
6946cfg_if! {
6947    if #[cfg(target_env = "uclibc")] {
6948        mod uclibc;
6949        pub use self::uclibc::*;
6950    } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] {
6951        mod musl;
6952        pub use self::musl::*;
6953    } else if #[cfg(target_env = "gnu")] {
6954        mod gnu;
6955        pub use self::gnu::*;
6956    }
6957}
6958
6959mod arch;
6960pub use self::arch::*;