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