libc_interface/unix/notbsd/linux/
mod.rs

1//! Linux-specific definitions for linux-like values
2
3use dox::mem;
4
5pub type useconds_t = u32;
6pub type dev_t = u64;
7pub type socklen_t = u32;
8pub type pthread_t = c_ulong;
9pub type mode_t = u32;
10pub type ino64_t = u64;
11pub type off64_t = i64;
12pub type blkcnt64_t = i64;
13pub type rlim64_t = u64;
14pub type mqd_t = ::c_int;
15pub type nfds_t = ::c_ulong;
16pub type nl_item = ::c_int;
17pub type idtype_t = ::c_uint;
18pub type loff_t = ::c_longlong;
19
20pub type __u8 = ::c_uchar;
21pub type __u16 = ::c_ushort;
22pub type __s16 = ::c_short;
23pub type __u32 = ::c_uint;
24pub type __s32 = ::c_int;
25
26pub type Elf32_Half = u16;
27pub type Elf32_Word = u32;
28pub type Elf32_Off = u32;
29pub type Elf32_Addr = u32;
30
31pub type Elf64_Half = u16;
32pub type Elf64_Word = u32;
33pub type Elf64_Off = u64;
34pub type Elf64_Addr = u64;
35pub type Elf64_Xword = u64;
36
37pub enum fpos64_t {} // TODO: fill this out with a struct
38
39s! {
40    pub struct dirent {
41        pub d_ino: ::ino_t,
42        pub d_off: ::off_t,
43        pub d_reclen: ::c_ushort,
44        pub d_type: ::c_uchar,
45        pub d_name: [::c_char; 256],
46    }
47
48    pub struct dirent64 {
49        pub d_ino: ::ino64_t,
50        pub d_off: ::off64_t,
51        pub d_reclen: ::c_ushort,
52        pub d_type: ::c_uchar,
53        pub d_name: [::c_char; 256],
54    }
55
56    pub struct rlimit64 {
57        pub rlim_cur: rlim64_t,
58        pub rlim_max: rlim64_t,
59    }
60
61    pub struct glob_t {
62        pub gl_pathc: ::size_t,
63        pub gl_pathv: *mut *mut c_char,
64        pub gl_offs: ::size_t,
65        pub gl_flags: ::c_int,
66
67        __unused1: *mut ::c_void,
68        __unused2: *mut ::c_void,
69        __unused3: *mut ::c_void,
70        __unused4: *mut ::c_void,
71        __unused5: *mut ::c_void,
72    }
73
74    #[cfg_attr(all(feature = "align",
75                   target_pointer_width = "32",
76                   any(target_arch = "mips",
77                       target_arch = "arm",
78                       target_arch = "powerpc",
79                       target_arch = "x86_64",
80                       target_arch = "x86")),
81               repr(align(4)))]
82    #[cfg_attr(all(feature = "align",
83                   any(target_pointer_width = "64",
84                       not(any(target_arch = "mips",
85                               target_arch = "arm",
86                               target_arch = "powerpc",
87                               target_arch = "x86_64",
88                               target_arch = "x86")))),
89               repr(align(8)))]
90    pub struct pthread_mutex_t {
91        #[cfg(all(not(feature = "align"),
92                  any(target_arch = "mips",
93                      target_arch = "arm",
94                      target_arch = "powerpc",
95                      all(target_arch = "x86_64",
96                          target_pointer_width = "32"))))]
97        __align: [::c_long; 0],
98        #[cfg(not(any(feature = "align",
99                      target_arch = "mips",
100                      target_arch = "arm",
101                      target_arch = "powerpc",
102                      all(target_arch = "x86_64",
103                          target_pointer_width = "32"))))]
104        __align: [::c_longlong; 0],
105        size: [u8; __SIZEOF_PTHREAD_MUTEX_T],
106    }
107
108    #[cfg_attr(all(feature = "align",
109                   target_pointer_width = "32",
110                   any(target_arch = "mips",
111                       target_arch = "arm",
112                       target_arch = "powerpc",
113                       target_arch = "x86_64",
114                       target_arch = "x86")),
115               repr(align(4)))]
116    #[cfg_attr(all(feature = "align",
117                   any(target_pointer_width = "64",
118                       not(any(target_arch = "mips",
119                               target_arch = "arm",
120                               target_arch = "powerpc",
121                               target_arch = "x86_64",
122                               target_arch = "x86")))),
123               repr(align(8)))]
124    pub struct pthread_rwlock_t {
125        #[cfg(all(not(feature = "align"),
126                  any(target_arch = "mips",
127                      target_arch = "arm",
128                      target_arch = "powerpc",
129                      all(target_arch = "x86_64",
130                          target_pointer_width = "32"))))]
131        __align: [::c_long; 0],
132        #[cfg(not(any(feature = "align",
133                      target_arch = "mips",
134                      target_arch = "arm",
135                      target_arch = "powerpc",
136                      all(target_arch = "x86_64",
137                          target_pointer_width = "32"))))]
138        __align: [::c_longlong; 0],
139        size: [u8; __SIZEOF_PTHREAD_RWLOCK_T],
140    }
141
142    #[cfg_attr(all(feature = "align",
143                   any(target_pointer_width = "32",
144                       target_arch = "x86_64", target_arch = "powerpc64",
145                       target_arch = "mips64", target_arch = "s390x",
146                       target_arch = "sparc64",
147                       all(target_arch = "aarch64", target_env = "musl"))),
148               repr(align(4)))]
149    #[cfg_attr(all(feature = "align",
150                   not(any(target_pointer_width = "32",
151                           target_arch = "x86_64", target_arch = "powerpc64",
152                           target_arch = "mips64", target_arch = "s390x",
153                           target_arch = "sparc64",
154                           all(target_arch = "aarch64", target_env = "musl")))),
155               repr(align(8)))]
156    pub struct pthread_mutexattr_t {
157        #[cfg(all(not(features = "align"),
158                  any(target_arch = "x86_64", target_arch = "powerpc64",
159                      target_arch = "mips64", target_arch = "s390x",
160                      target_arch = "sparc64",
161                      all(target_arch = "aarch64", target_env = "musl"))))]
162        __align: [::c_int; 0],
163        #[cfg(all(not(features = "align"),
164                  not(any(target_arch = "x86_64", target_arch = "powerpc64",
165                          target_arch = "mips64", target_arch = "s390x",
166                          target_arch = "sparc64",
167                          all(target_arch = "aarch64", target_env = "musl")))))]
168        __align: [::c_long; 0],
169        size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T],
170    }
171
172    #[cfg_attr(all(feature = "align",
173                   any(target_env = "musl", target_pointer_width = "32")),
174               repr(align(4)))]
175    #[cfg_attr(all(feature = "align",
176                   not(target_env = "musl"),
177                   target_pointer_width = "64"),
178               repr(align(8)))]
179    pub struct pthread_rwlockattr_t {
180        #[cfg(all(not(feature = "align"), target_env = "musl"))]
181        __align: [::c_int; 0],
182        #[cfg(all(not(feature = "align"), not(target_env = "musl")))]
183        __align: [::c_long; 0],
184        size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T],
185    }
186
187    #[cfg_attr(all(feature = "align",
188                   target_env = "musl",
189                   target_pointer_width = "32"),
190               repr(align(4)))]
191    #[cfg_attr(all(feature = "align",
192                   target_env = "musl",
193                   target_pointer_width = "64"),
194               repr(align(8)))]
195    #[cfg_attr(all(feature = "align",
196                   not(target_env = "musl"),
197                   target_arch = "x86"),
198               repr(align(4)))]
199    #[cfg_attr(all(feature = "align",
200                   not(target_env = "musl"),
201                   not(target_arch = "x86")),
202               repr(align(8)))]
203    pub struct pthread_cond_t {
204        #[cfg(all(not(feature = "align"), target_env = "musl"))]
205        __align: [*const ::c_void; 0],
206        #[cfg(not(any(feature = "align", target_env = "musl")))]
207        __align: [::c_longlong; 0],
208        size: [u8; __SIZEOF_PTHREAD_COND_T],
209    }
210
211    #[cfg_attr(feature = "align", repr(align(4)))]
212    pub struct pthread_condattr_t {
213        #[cfg(not(feature = "align"))]
214        __align: [::c_int; 0],
215        size: [u8; __SIZEOF_PTHREAD_CONDATTR_T],
216    }
217
218    pub struct passwd {
219        pub pw_name: *mut ::c_char,
220        pub pw_passwd: *mut ::c_char,
221        pub pw_uid: ::uid_t,
222        pub pw_gid: ::gid_t,
223        pub pw_gecos: *mut ::c_char,
224        pub pw_dir: *mut ::c_char,
225        pub pw_shell: *mut ::c_char,
226    }
227
228    pub struct spwd {
229        pub sp_namp: *mut ::c_char,
230        pub sp_pwdp: *mut ::c_char,
231        pub sp_lstchg: ::c_long,
232        pub sp_min: ::c_long,
233        pub sp_max: ::c_long,
234        pub sp_warn: ::c_long,
235        pub sp_inact: ::c_long,
236        pub sp_expire: ::c_long,
237        pub sp_flag: ::c_ulong,
238    }
239
240    pub struct dqblk {
241        pub dqb_bhardlimit: ::uint64_t,
242        pub dqb_bsoftlimit: ::uint64_t,
243        pub dqb_curspace: ::uint64_t,
244        pub dqb_ihardlimit: ::uint64_t,
245        pub dqb_isoftlimit: ::uint64_t,
246        pub dqb_curinodes: ::uint64_t,
247        pub dqb_btime: ::uint64_t,
248        pub dqb_itime: ::uint64_t,
249        pub dqb_valid: ::uint32_t,
250    }
251
252    pub struct signalfd_siginfo {
253        pub ssi_signo: ::uint32_t,
254        pub ssi_errno: ::int32_t,
255        pub ssi_code: ::int32_t,
256        pub ssi_pid: ::uint32_t,
257        pub ssi_uid: ::uint32_t,
258        pub ssi_fd: ::int32_t,
259        pub ssi_tid: ::uint32_t,
260        pub ssi_band: ::uint32_t,
261        pub ssi_overrun: ::uint32_t,
262        pub ssi_trapno: ::uint32_t,
263        pub ssi_status: ::int32_t,
264        pub ssi_int: ::int32_t,
265        pub ssi_ptr: ::uint64_t,
266        pub ssi_utime: ::uint64_t,
267        pub ssi_stime: ::uint64_t,
268        pub ssi_addr: ::uint64_t,
269        _pad: [::uint8_t; 48],
270    }
271
272    pub struct itimerspec {
273        pub it_interval: ::timespec,
274        pub it_value: ::timespec,
275    }
276
277    pub struct fsid_t {
278        __val: [::c_int; 2],
279    }
280
281    // x32 compatibility
282    // See https://sourceware.org/bugzilla/show_bug.cgi?id=21279
283    pub struct mq_attr {
284        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
285        pub mq_flags: i64,
286        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
287        pub mq_maxmsg: i64,
288        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
289        pub mq_msgsize: i64,
290        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
291        pub mq_curmsgs: i64,
292        #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
293        pad: [i64; 4],
294
295        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
296        pub mq_flags: ::c_long,
297        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
298        pub mq_maxmsg: ::c_long,
299        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
300        pub mq_msgsize: ::c_long,
301        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
302        pub mq_curmsgs: ::c_long,
303        #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
304        pad: [::c_long; 4],
305    }
306
307    pub struct packet_mreq {
308        pub mr_ifindex: ::c_int,
309        pub mr_type: ::c_ushort,
310        pub mr_alen: ::c_ushort,
311        pub mr_address: [::c_uchar; 8],
312    }
313
314    pub struct cpu_set_t {
315        #[cfg(all(target_pointer_width = "32",
316                  not(target_arch = "x86_64")))]
317        bits: [u32; 32],
318        #[cfg(not(all(target_pointer_width = "32",
319                      not(target_arch = "x86_64"))))]
320        bits: [u64; 16],
321    }
322
323    pub struct if_nameindex {
324        pub if_index: ::c_uint,
325        pub if_name: *mut ::c_char,
326    }
327
328    // System V IPC
329    pub struct msginfo {
330        pub msgpool: ::c_int,
331        pub msgmap: ::c_int,
332        pub msgmax: ::c_int,
333        pub msgmnb: ::c_int,
334        pub msgmni: ::c_int,
335        pub msgssz: ::c_int,
336        pub msgtql: ::c_int,
337        pub msgseg: ::c_ushort,
338    }
339
340    pub struct mmsghdr {
341        pub msg_hdr: ::msghdr,
342        pub msg_len: ::c_uint,
343    }
344
345    pub struct sembuf {
346        pub sem_num: ::c_ushort,
347        pub sem_op: ::c_short,
348        pub sem_flg: ::c_short,
349    }
350
351    pub struct input_event {
352        pub time: ::timeval,
353        pub type_: ::__u16,
354        pub code: ::__u16,
355        pub value: ::__s32,
356    }
357
358    pub struct input_id {
359        pub bustype: ::__u16,
360        pub vendor: ::__u16,
361        pub product: ::__u16,
362        pub version: ::__u16,
363    }
364
365    pub struct input_absinfo {
366        pub value: ::__s32,
367        pub minimum: ::__s32,
368        pub maximum: ::__s32,
369        pub fuzz: ::__s32,
370        pub flat: ::__s32,
371        pub resolution: ::__s32,
372    }
373
374    pub struct input_keymap_entry {
375        pub flags: ::__u8,
376        pub len: ::__u8,
377        pub index: ::__u16,
378        pub keycode: ::__u32,
379        pub scancode: [::__u8; 32],
380    }
381
382    pub struct input_mask {
383        pub type_: ::__u32,
384        pub codes_size: ::__u32,
385        pub codes_ptr: ::__u64,
386    }
387
388    pub struct ff_replay {
389        pub length: ::__u16,
390        pub delay: ::__u16,
391    }
392
393    pub struct ff_trigger {
394        pub button: ::__u16,
395        pub interval: ::__u16,
396    }
397
398    pub struct ff_envelope {
399        pub attack_length: ::__u16,
400        pub attack_level: ::__u16,
401        pub fade_length: ::__u16,
402        pub fade_level: ::__u16,
403    }
404
405    pub struct ff_constant_effect {
406        pub level: ::__s16,
407        pub envelope: ff_envelope,
408    }
409
410    pub struct ff_ramp_effect {
411        pub start_level: ::__s16,
412        pub end_level: ::__s16,
413        pub envelope: ff_envelope,
414    }
415
416    pub struct ff_condition_effect {
417        pub right_saturation: ::__u16,
418        pub left_saturation: ::__u16,
419
420        pub right_coeff: ::__s16,
421        pub left_coeff: ::__s16,
422
423        pub deadband: ::__u16,
424        pub center: ::__s16,
425    }
426
427    pub struct ff_periodic_effect {
428        pub waveform: ::__u16,
429        pub period: ::__u16,
430        pub magnitude: ::__s16,
431        pub offset: ::__s16,
432        pub phase: ::__u16,
433
434        pub envelope: ff_envelope,
435
436        pub custom_len: ::__u32,
437        pub custom_data: *mut ::__s16,
438    }
439
440    pub struct ff_rumble_effect {
441        pub strong_magnitude: ::__u16,
442        pub weak_magnitude: ::__u16,
443    }
444
445    pub struct ff_effect {
446        pub type_: ::__u16,
447        pub id: ::__s16,
448        pub direction: ::__u16,
449        pub trigger: ff_trigger,
450        pub replay: ff_replay,
451        // FIXME this is actually a union
452        #[cfg(target_pointer_width = "64")]
453        pub u: [u64; 4],
454        #[cfg(target_pointer_width = "32")]
455        pub u: [u32; 7],
456    }
457
458    pub struct dl_phdr_info {
459        #[cfg(target_pointer_width = "64")]
460        pub dlpi_addr: Elf64_Addr,
461        #[cfg(target_pointer_width = "32")]
462        pub dlpi_addr: Elf32_Addr,
463
464        pub dlpi_name: *const ::c_char,
465
466        #[cfg(target_pointer_width = "64")]
467        pub dlpi_phdr: *const Elf64_Phdr,
468        #[cfg(target_pointer_width = "32")]
469        pub dlpi_phdr: *const Elf32_Phdr,
470
471        #[cfg(target_pointer_width = "64")]
472        pub dlpi_phnum: Elf64_Half,
473        #[cfg(target_pointer_width = "32")]
474        pub dlpi_phnum: Elf32_Half,
475
476        pub dlpi_adds: ::c_ulonglong,
477        pub dlpi_subs: ::c_ulonglong,
478        pub dlpi_tls_modid: ::size_t,
479        pub dlpi_tls_data: *mut ::c_void,
480    }
481
482    pub struct Elf32_Phdr {
483        pub p_type: Elf32_Word,
484        pub p_offset: Elf32_Off,
485        pub p_vaddr: Elf32_Addr,
486        pub p_paddr: Elf32_Addr,
487        pub p_filesz: Elf32_Word,
488        pub p_memsz: Elf32_Word,
489        pub p_flags: Elf32_Word,
490        pub p_align: Elf32_Word,
491    }
492
493    pub struct Elf64_Phdr {
494        pub p_type: Elf64_Word,
495        pub p_flags: Elf64_Word,
496        pub p_offset: Elf64_Off,
497        pub p_vaddr: Elf64_Addr,
498        pub p_paddr: Elf64_Addr,
499        pub p_filesz: Elf64_Xword,
500        pub p_memsz: Elf64_Xword,
501        pub p_align: Elf64_Xword,
502    }
503
504    pub struct ucred {
505        pub pid: ::pid_t,
506        pub uid: ::uid_t,
507        pub gid: ::gid_t,
508    }
509
510    pub struct mntent {
511        pub mnt_fsname: *mut ::c_char,
512        pub mnt_dir: *mut ::c_char,
513        pub mnt_type: *mut ::c_char,
514        pub mnt_opts: *mut ::c_char,
515        pub mnt_freq: ::c_int,
516        pub mnt_passno: ::c_int,
517    }
518
519    pub struct posix_spawn_file_actions_t {
520        __allocated: ::c_int,
521        __used: ::c_int,
522        __actions: *mut ::c_int,
523        __pad: [::c_int; 16],
524    }
525
526    pub struct posix_spawnattr_t {
527        __flags: ::c_short,
528        __pgrp: ::pid_t,
529        __sd: ::sigset_t,
530        __ss: ::sigset_t,
531        #[cfg(target_env = "musl")]
532        __prio: ::c_int,
533        #[cfg(not(target_env = "musl"))]
534        __sp: ::sched_param,
535        __policy: ::c_int,
536        __pad: [::c_int; 16],
537    }
538
539    pub struct genlmsghdr {
540        pub cmd: u8,
541        pub version: u8,
542        pub reserved: u16,
543    }
544
545    pub struct in6_pktinfo {
546        pub ipi6_addr: ::in6_addr,
547        pub ipi6_ifindex: ::c_uint,
548    }
549
550    pub struct arpd_request {
551        pub req: ::c_ushort,
552        pub ip: u32,
553        pub dev: ::c_ulong,
554        pub stamp: ::c_ulong,
555        pub updated: ::c_ulong,
556        pub ha: [::c_uchar; ::MAX_ADDR_LEN],
557    }
558}
559
560pub const ABDAY_1: ::nl_item = 0x20000;
561pub const ABDAY_2: ::nl_item = 0x20001;
562pub const ABDAY_3: ::nl_item = 0x20002;
563pub const ABDAY_4: ::nl_item = 0x20003;
564pub const ABDAY_5: ::nl_item = 0x20004;
565pub const ABDAY_6: ::nl_item = 0x20005;
566pub const ABDAY_7: ::nl_item = 0x20006;
567
568pub const DAY_1: ::nl_item = 0x20007;
569pub const DAY_2: ::nl_item = 0x20008;
570pub const DAY_3: ::nl_item = 0x20009;
571pub const DAY_4: ::nl_item = 0x2000A;
572pub const DAY_5: ::nl_item = 0x2000B;
573pub const DAY_6: ::nl_item = 0x2000C;
574pub const DAY_7: ::nl_item = 0x2000D;
575
576pub const ABMON_1: ::nl_item = 0x2000E;
577pub const ABMON_2: ::nl_item = 0x2000F;
578pub const ABMON_3: ::nl_item = 0x20010;
579pub const ABMON_4: ::nl_item = 0x20011;
580pub const ABMON_5: ::nl_item = 0x20012;
581pub const ABMON_6: ::nl_item = 0x20013;
582pub const ABMON_7: ::nl_item = 0x20014;
583pub const ABMON_8: ::nl_item = 0x20015;
584pub const ABMON_9: ::nl_item = 0x20016;
585pub const ABMON_10: ::nl_item = 0x20017;
586pub const ABMON_11: ::nl_item = 0x20018;
587pub const ABMON_12: ::nl_item = 0x20019;
588
589pub const MON_1: ::nl_item = 0x2001A;
590pub const MON_2: ::nl_item = 0x2001B;
591pub const MON_3: ::nl_item = 0x2001C;
592pub const MON_4: ::nl_item = 0x2001D;
593pub const MON_5: ::nl_item = 0x2001E;
594pub const MON_6: ::nl_item = 0x2001F;
595pub const MON_7: ::nl_item = 0x20020;
596pub const MON_8: ::nl_item = 0x20021;
597pub const MON_9: ::nl_item = 0x20022;
598pub const MON_10: ::nl_item = 0x20023;
599pub const MON_11: ::nl_item = 0x20024;
600pub const MON_12: ::nl_item = 0x20025;
601
602pub const AM_STR: ::nl_item = 0x20026;
603pub const PM_STR: ::nl_item = 0x20027;
604
605pub const D_T_FMT: ::nl_item = 0x20028;
606pub const D_FMT: ::nl_item = 0x20029;
607pub const T_FMT: ::nl_item = 0x2002A;
608pub const T_FMT_AMPM: ::nl_item = 0x2002B;
609
610pub const ERA: ::nl_item = 0x2002C;
611pub const ERA_D_FMT: ::nl_item = 0x2002E;
612pub const ALT_DIGITS: ::nl_item = 0x2002F;
613pub const ERA_D_T_FMT: ::nl_item = 0x20030;
614pub const ERA_T_FMT: ::nl_item = 0x20031;
615
616pub const CODESET: ::nl_item = 14;
617
618pub const CRNCYSTR: ::nl_item = 0x4000F;
619
620pub const RUSAGE_THREAD: ::c_int = 1;
621pub const RUSAGE_CHILDREN: ::c_int = -1;
622
623pub const RADIXCHAR: ::nl_item = 0x10000;
624pub const THOUSEP: ::nl_item = 0x10001;
625
626pub const YESEXPR: ::nl_item = 0x50000;
627pub const NOEXPR: ::nl_item = 0x50001;
628pub const YESSTR: ::nl_item = 0x50002;
629pub const NOSTR: ::nl_item = 0x50003;
630
631pub const FILENAME_MAX: ::c_uint = 4096;
632pub const L_tmpnam: ::c_uint = 20;
633pub const _PC_LINK_MAX: ::c_int = 0;
634pub const _PC_MAX_CANON: ::c_int = 1;
635pub const _PC_MAX_INPUT: ::c_int = 2;
636pub const _PC_NAME_MAX: ::c_int = 3;
637pub const _PC_PATH_MAX: ::c_int = 4;
638pub const _PC_PIPE_BUF: ::c_int = 5;
639pub const _PC_CHOWN_RESTRICTED: ::c_int = 6;
640pub const _PC_NO_TRUNC: ::c_int = 7;
641pub const _PC_VDISABLE: ::c_int = 8;
642pub const _PC_SYNC_IO: ::c_int = 9;
643pub const _PC_ASYNC_IO: ::c_int = 10;
644pub const _PC_PRIO_IO: ::c_int = 11;
645pub const _PC_SOCK_MAXBUF: ::c_int = 12;
646pub const _PC_FILESIZEBITS: ::c_int = 13;
647pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 14;
648pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 15;
649pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 16;
650pub const _PC_REC_XFER_ALIGN: ::c_int = 17;
651pub const _PC_ALLOC_SIZE_MIN: ::c_int = 18;
652pub const _PC_SYMLINK_MAX: ::c_int = 19;
653pub const _PC_2_SYMLINKS: ::c_int = 20;
654
655pub const _SC_ARG_MAX: ::c_int = 0;
656pub const _SC_CHILD_MAX: ::c_int = 1;
657pub const _SC_CLK_TCK: ::c_int = 2;
658pub const _SC_NGROUPS_MAX: ::c_int = 3;
659pub const _SC_OPEN_MAX: ::c_int = 4;
660pub const _SC_STREAM_MAX: ::c_int = 5;
661pub const _SC_TZNAME_MAX: ::c_int = 6;
662pub const _SC_JOB_CONTROL: ::c_int = 7;
663pub const _SC_SAVED_IDS: ::c_int = 8;
664pub const _SC_REALTIME_SIGNALS: ::c_int = 9;
665pub const _SC_PRIORITY_SCHEDULING: ::c_int = 10;
666pub const _SC_TIMERS: ::c_int = 11;
667pub const _SC_ASYNCHRONOUS_IO: ::c_int = 12;
668pub const _SC_PRIORITIZED_IO: ::c_int = 13;
669pub const _SC_SYNCHRONIZED_IO: ::c_int = 14;
670pub const _SC_FSYNC: ::c_int = 15;
671pub const _SC_MAPPED_FILES: ::c_int = 16;
672pub const _SC_MEMLOCK: ::c_int = 17;
673pub const _SC_MEMLOCK_RANGE: ::c_int = 18;
674pub const _SC_MEMORY_PROTECTION: ::c_int = 19;
675pub const _SC_MESSAGE_PASSING: ::c_int = 20;
676pub const _SC_SEMAPHORES: ::c_int = 21;
677pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 22;
678pub const _SC_AIO_LISTIO_MAX: ::c_int = 23;
679pub const _SC_AIO_MAX: ::c_int = 24;
680pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 25;
681pub const _SC_DELAYTIMER_MAX: ::c_int = 26;
682pub const _SC_MQ_OPEN_MAX: ::c_int = 27;
683pub const _SC_MQ_PRIO_MAX: ::c_int = 28;
684pub const _SC_VERSION: ::c_int = 29;
685pub const _SC_PAGESIZE: ::c_int = 30;
686pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
687pub const _SC_RTSIG_MAX: ::c_int = 31;
688pub const _SC_SEM_NSEMS_MAX: ::c_int = 32;
689pub const _SC_SEM_VALUE_MAX: ::c_int = 33;
690pub const _SC_SIGQUEUE_MAX: ::c_int = 34;
691pub const _SC_TIMER_MAX: ::c_int = 35;
692pub const _SC_BC_BASE_MAX: ::c_int = 36;
693pub const _SC_BC_DIM_MAX: ::c_int = 37;
694pub const _SC_BC_SCALE_MAX: ::c_int = 38;
695pub const _SC_BC_STRING_MAX: ::c_int = 39;
696pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 40;
697pub const _SC_EXPR_NEST_MAX: ::c_int = 42;
698pub const _SC_LINE_MAX: ::c_int = 43;
699pub const _SC_RE_DUP_MAX: ::c_int = 44;
700pub const _SC_2_VERSION: ::c_int = 46;
701pub const _SC_2_C_BIND: ::c_int = 47;
702pub const _SC_2_C_DEV: ::c_int = 48;
703pub const _SC_2_FORT_DEV: ::c_int = 49;
704pub const _SC_2_FORT_RUN: ::c_int = 50;
705pub const _SC_2_SW_DEV: ::c_int = 51;
706pub const _SC_2_LOCALEDEF: ::c_int = 52;
707pub const _SC_UIO_MAXIOV: ::c_int = 60;
708pub const _SC_IOV_MAX: ::c_int = 60;
709pub const _SC_THREADS: ::c_int = 67;
710pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 68;
711pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 69;
712pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 70;
713pub const _SC_LOGIN_NAME_MAX: ::c_int = 71;
714pub const _SC_TTY_NAME_MAX: ::c_int = 72;
715pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 73;
716pub const _SC_THREAD_KEYS_MAX: ::c_int = 74;
717pub const _SC_THREAD_STACK_MIN: ::c_int = 75;
718pub const _SC_THREAD_THREADS_MAX: ::c_int = 76;
719pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 77;
720pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 78;
721pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 79;
722pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 80;
723pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 81;
724pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 82;
725pub const _SC_NPROCESSORS_CONF: ::c_int = 83;
726pub const _SC_NPROCESSORS_ONLN: ::c_int = 84;
727pub const _SC_PHYS_PAGES: ::c_int = 85;
728pub const _SC_AVPHYS_PAGES: ::c_int = 86;
729pub const _SC_ATEXIT_MAX: ::c_int = 87;
730pub const _SC_PASS_MAX: ::c_int = 88;
731pub const _SC_XOPEN_VERSION: ::c_int = 89;
732pub const _SC_XOPEN_XCU_VERSION: ::c_int = 90;
733pub const _SC_XOPEN_UNIX: ::c_int = 91;
734pub const _SC_XOPEN_CRYPT: ::c_int = 92;
735pub const _SC_XOPEN_ENH_I18N: ::c_int = 93;
736pub const _SC_XOPEN_SHM: ::c_int = 94;
737pub const _SC_2_CHAR_TERM: ::c_int = 95;
738pub const _SC_2_UPE: ::c_int = 97;
739pub const _SC_XOPEN_XPG2: ::c_int = 98;
740pub const _SC_XOPEN_XPG3: ::c_int = 99;
741pub const _SC_XOPEN_XPG4: ::c_int = 100;
742pub const _SC_NZERO: ::c_int = 109;
743pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125;
744pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126;
745pub const _SC_XBS5_LP64_OFF64: ::c_int = 127;
746pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 128;
747pub const _SC_XOPEN_LEGACY: ::c_int = 129;
748pub const _SC_XOPEN_REALTIME: ::c_int = 130;
749pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131;
750pub const _SC_ADVISORY_INFO: ::c_int = 132;
751pub const _SC_BARRIERS: ::c_int = 133;
752pub const _SC_CLOCK_SELECTION: ::c_int = 137;
753pub const _SC_CPUTIME: ::c_int = 138;
754pub const _SC_THREAD_CPUTIME: ::c_int = 139;
755pub const _SC_MONOTONIC_CLOCK: ::c_int = 149;
756pub const _SC_READER_WRITER_LOCKS: ::c_int = 153;
757pub const _SC_SPIN_LOCKS: ::c_int = 154;
758pub const _SC_REGEXP: ::c_int = 155;
759pub const _SC_SHELL: ::c_int = 157;
760pub const _SC_SPAWN: ::c_int = 159;
761pub const _SC_SPORADIC_SERVER: ::c_int = 160;
762pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 161;
763pub const _SC_TIMEOUTS: ::c_int = 164;
764pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 165;
765pub const _SC_2_PBS: ::c_int = 168;
766pub const _SC_2_PBS_ACCOUNTING: ::c_int = 169;
767pub const _SC_2_PBS_LOCATE: ::c_int = 170;
768pub const _SC_2_PBS_MESSAGE: ::c_int = 171;
769pub const _SC_2_PBS_TRACK: ::c_int = 172;
770pub const _SC_SYMLOOP_MAX: ::c_int = 173;
771pub const _SC_STREAMS: ::c_int = 174;
772pub const _SC_2_PBS_CHECKPOINT: ::c_int = 175;
773pub const _SC_V6_ILP32_OFF32: ::c_int = 176;
774pub const _SC_V6_ILP32_OFFBIG: ::c_int = 177;
775pub const _SC_V6_LP64_OFF64: ::c_int = 178;
776pub const _SC_V6_LPBIG_OFFBIG: ::c_int = 179;
777pub const _SC_HOST_NAME_MAX: ::c_int = 180;
778pub const _SC_TRACE: ::c_int = 181;
779pub const _SC_TRACE_EVENT_FILTER: ::c_int = 182;
780pub const _SC_TRACE_INHERIT: ::c_int = 183;
781pub const _SC_TRACE_LOG: ::c_int = 184;
782pub const _SC_IPV6: ::c_int = 235;
783pub const _SC_RAW_SOCKETS: ::c_int = 236;
784pub const _SC_V7_ILP32_OFF32: ::c_int = 237;
785pub const _SC_V7_ILP32_OFFBIG: ::c_int = 238;
786pub const _SC_V7_LP64_OFF64: ::c_int = 239;
787pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 240;
788pub const _SC_SS_REPL_MAX: ::c_int = 241;
789pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 242;
790pub const _SC_TRACE_NAME_MAX: ::c_int = 243;
791pub const _SC_TRACE_SYS_MAX: ::c_int = 244;
792pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 245;
793pub const _SC_XOPEN_STREAMS: ::c_int = 246;
794pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 247;
795pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 248;
796
797pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY;
798pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY;
799
800pub const GLOB_ERR: ::c_int = 1 << 0;
801pub const GLOB_MARK: ::c_int = 1 << 1;
802pub const GLOB_NOSORT: ::c_int = 1 << 2;
803pub const GLOB_DOOFFS: ::c_int = 1 << 3;
804pub const GLOB_NOCHECK: ::c_int = 1 << 4;
805pub const GLOB_APPEND: ::c_int = 1 << 5;
806pub const GLOB_NOESCAPE: ::c_int = 1 << 6;
807
808pub const GLOB_NOSPACE: ::c_int = 1;
809pub const GLOB_ABORTED: ::c_int = 2;
810pub const GLOB_NOMATCH: ::c_int = 3;
811
812pub const POSIX_MADV_NORMAL: ::c_int = 0;
813pub const POSIX_MADV_RANDOM: ::c_int = 1;
814pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2;
815pub const POSIX_MADV_WILLNEED: ::c_int = 3;
816
817pub const S_IEXEC: mode_t = 64;
818pub const S_IWRITE: mode_t = 128;
819pub const S_IREAD: mode_t = 256;
820
821pub const F_LOCK: ::c_int = 1;
822pub const F_TEST: ::c_int = 3;
823pub const F_TLOCK: ::c_int = 2;
824pub const F_ULOCK: ::c_int = 0;
825
826pub const IFF_LOWER_UP: ::c_int = 0x10000;
827pub const IFF_DORMANT: ::c_int = 0x20000;
828pub const IFF_ECHO: ::c_int = 0x40000;
829
830// linux/if_tun.h
831pub const IFF_TUN: ::c_short = 0x0001;
832pub const IFF_TAP: ::c_short = 0x0002;
833pub const IFF_NO_PI: ::c_short = 0x1000;
834// Read queue size
835pub const TUN_READQ_SIZE: ::c_short = 500;
836// TUN device type flags: deprecated. Use IFF_TUN/IFF_TAP instead.
837pub const TUN_TUN_DEV: ::c_short   = ::IFF_TUN;
838pub const TUN_TAP_DEV: ::c_short   = ::IFF_TAP;
839pub const TUN_TYPE_MASK: ::c_short = 0x000f;
840// This flag has no real effect
841pub const IFF_ONE_QUEUE: ::c_short    = 0x2000;
842pub const IFF_VNET_HDR: ::c_short     = 0x4000;
843pub const IFF_TUN_EXCL: ::c_short     = 0x8000;
844pub const IFF_MULTI_QUEUE: ::c_short  = 0x0100;
845pub const IFF_ATTACH_QUEUE: ::c_short = 0x0200;
846pub const IFF_DETACH_QUEUE: ::c_short = 0x0400;
847// read-only flag
848pub const IFF_PERSIST: ::c_short  = 0x0800;
849pub const IFF_NOFILTER: ::c_short = 0x1000;
850
851pub const ST_RDONLY: ::c_ulong = 1;
852pub const ST_NOSUID: ::c_ulong = 2;
853pub const ST_NODEV: ::c_ulong = 4;
854pub const ST_NOEXEC: ::c_ulong = 8;
855pub const ST_SYNCHRONOUS: ::c_ulong = 16;
856pub const ST_MANDLOCK: ::c_ulong = 64;
857pub const ST_WRITE: ::c_ulong = 128;
858pub const ST_APPEND: ::c_ulong = 256;
859pub const ST_IMMUTABLE: ::c_ulong = 512;
860pub const ST_NOATIME: ::c_ulong = 1024;
861pub const ST_NODIRATIME: ::c_ulong = 2048;
862
863pub const RTLD_NEXT: *mut ::c_void = -1i64 as *mut ::c_void;
864pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
865pub const RTLD_NODELETE: ::c_int = 0x1000;
866pub const RTLD_NOW: ::c_int = 0x2;
867
868pub const TCP_MD5SIG: ::c_int = 14;
869
870align_const! {
871    pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
872        size: [0; __SIZEOF_PTHREAD_MUTEX_T],
873    };
874    pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
875        size: [0; __SIZEOF_PTHREAD_COND_T],
876    };
877    pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
878        size: [0; __SIZEOF_PTHREAD_RWLOCK_T],
879    };
880}
881pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
882pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
883pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
884pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
885pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 0;
886pub const PTHREAD_PROCESS_SHARED: ::c_int = 1;
887pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
888
889pub const RENAME_NOREPLACE: ::c_int = 1;
890pub const RENAME_EXCHANGE: ::c_int = 2;
891pub const RENAME_WHITEOUT: ::c_int = 4;
892
893pub const SCHED_OTHER: ::c_int = 0;
894pub const SCHED_FIFO: ::c_int = 1;
895pub const SCHED_RR: ::c_int = 2;
896pub const SCHED_BATCH: ::c_int = 3;
897pub const SCHED_IDLE: ::c_int = 5;
898
899// netinet/in.h
900// NOTE: These are in addition to the constants defined in src/unix/mod.rs
901
902// IPPROTO_IP defined in src/unix/mod.rs
903/// Hop-by-hop option header
904pub const IPPROTO_HOPOPTS: ::c_int = 0;
905// IPPROTO_ICMP defined in src/unix/mod.rs
906/// group mgmt protocol
907pub const IPPROTO_IGMP: ::c_int = 2;
908/// for compatibility
909pub const IPPROTO_IPIP: ::c_int = 4;
910// IPPROTO_TCP defined in src/unix/mod.rs
911/// exterior gateway protocol
912pub const IPPROTO_EGP: ::c_int = 8;
913/// pup
914pub const IPPROTO_PUP: ::c_int = 12;
915// IPPROTO_UDP defined in src/unix/mod.rs
916/// xns idp
917pub const IPPROTO_IDP: ::c_int = 22;
918/// tp-4 w/ class negotiation
919pub const IPPROTO_TP: ::c_int = 29;
920/// DCCP
921pub const IPPROTO_DCCP: ::c_int = 33;
922// IPPROTO_IPV6 defined in src/unix/mod.rs
923/// IP6 routing header
924pub const IPPROTO_ROUTING: ::c_int = 43;
925/// IP6 fragmentation header
926pub const IPPROTO_FRAGMENT: ::c_int = 44;
927/// resource reservation
928pub const IPPROTO_RSVP: ::c_int = 46;
929/// General Routing Encap.
930pub const IPPROTO_GRE: ::c_int = 47;
931/// IP6 Encap Sec. Payload
932pub const IPPROTO_ESP: ::c_int = 50;
933/// IP6 Auth Header
934pub const IPPROTO_AH: ::c_int = 51;
935// IPPROTO_ICMPV6 defined in src/unix/mod.rs
936/// IP6 no next header
937pub const IPPROTO_NONE: ::c_int = 59;
938/// IP6 destination option
939pub const IPPROTO_DSTOPTS: ::c_int = 60;
940pub const IPPROTO_MTP: ::c_int = 92;
941pub const IPPROTO_BEETPH: ::c_int = 94;
942/// encapsulation header
943pub const IPPROTO_ENCAP: ::c_int = 98;
944/// Protocol indep. multicast
945pub const IPPROTO_PIM: ::c_int = 103;
946/// IP Payload Comp. Protocol
947pub const IPPROTO_COMP: ::c_int = 108;
948/// SCTP
949pub const IPPROTO_SCTP: ::c_int = 132;
950pub const IPPROTO_MH: ::c_int = 135;
951pub const IPPROTO_UDPLITE: ::c_int = 136;
952pub const IPPROTO_MPLS: ::c_int = 137;
953/// raw IP packet
954pub const IPPROTO_RAW: ::c_int = 255;
955pub const IPPROTO_MAX: ::c_int = 256;
956
957pub const AF_IB: ::c_int = 27;
958pub const AF_MPLS: ::c_int = 28;
959pub const AF_NFC: ::c_int = 39;
960pub const AF_VSOCK: ::c_int = 40;
961pub const PF_IB: ::c_int = AF_IB;
962pub const PF_MPLS: ::c_int = AF_MPLS;
963pub const PF_NFC: ::c_int = AF_NFC;
964pub const PF_VSOCK: ::c_int = AF_VSOCK;
965
966// System V IPC
967pub const IPC_PRIVATE: ::key_t = 0;
968
969pub const IPC_CREAT: ::c_int = 0o1000;
970pub const IPC_EXCL: ::c_int = 0o2000;
971pub const IPC_NOWAIT: ::c_int = 0o4000;
972
973pub const IPC_RMID: ::c_int = 0;
974pub const IPC_SET: ::c_int = 1;
975pub const IPC_STAT: ::c_int = 2;
976pub const IPC_INFO: ::c_int = 3;
977pub const MSG_STAT: ::c_int = 11;
978pub const MSG_INFO: ::c_int = 12;
979
980pub const MSG_NOERROR: ::c_int = 0o10000;
981pub const MSG_EXCEPT: ::c_int = 0o20000;
982pub const MSG_COPY: ::c_int = 0o40000;
983
984pub const SHM_R: ::c_int = 0o400;
985pub const SHM_W: ::c_int = 0o200;
986
987pub const SHM_RDONLY: ::c_int = 0o10000;
988pub const SHM_RND: ::c_int = 0o20000;
989pub const SHM_REMAP: ::c_int = 0o40000;
990pub const SHM_EXEC: ::c_int = 0o100000;
991
992pub const SHM_LOCK: ::c_int = 11;
993pub const SHM_UNLOCK: ::c_int = 12;
994
995pub const SHM_HUGETLB: ::c_int = 0o4000;
996pub const SHM_NORESERVE: ::c_int = 0o10000;
997
998pub const EPOLLRDHUP: ::c_int = 0x2000;
999pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000;
1000pub const EPOLLONESHOT: ::c_int = 0x40000000;
1001
1002pub const QFMT_VFS_OLD: ::c_int = 1;
1003pub const QFMT_VFS_V0: ::c_int = 2;
1004pub const QFMT_VFS_V1: ::c_int = 4;
1005
1006pub const EFD_SEMAPHORE: ::c_int = 0x1;
1007
1008pub const LOG_NFACILITIES: ::c_int = 24;
1009
1010pub const SEM_FAILED: *mut ::sem_t = 0 as *mut sem_t;
1011
1012pub const RB_AUTOBOOT: ::c_int = 0x01234567u32 as i32;
1013pub const RB_HALT_SYSTEM: ::c_int = 0xcdef0123u32 as i32;
1014pub const RB_ENABLE_CAD: ::c_int = 0x89abcdefu32 as i32;
1015pub const RB_DISABLE_CAD: ::c_int = 0x00000000u32 as i32;
1016pub const RB_POWER_OFF: ::c_int = 0x4321fedcu32 as i32;
1017pub const RB_SW_SUSPEND: ::c_int = 0xd000fce2u32 as i32;
1018pub const RB_KEXEC: ::c_int = 0x45584543u32 as i32;
1019
1020pub const AI_PASSIVE: ::c_int = 0x0001;
1021pub const AI_CANONNAME: ::c_int = 0x0002;
1022pub const AI_NUMERICHOST: ::c_int = 0x0004;
1023pub const AI_V4MAPPED: ::c_int = 0x0008;
1024pub const AI_ALL: ::c_int = 0x0010;
1025pub const AI_ADDRCONFIG: ::c_int = 0x0020;
1026
1027pub const AI_NUMERICSERV: ::c_int = 0x0400;
1028
1029pub const EAI_BADFLAGS: ::c_int = -1;
1030pub const EAI_NONAME: ::c_int = -2;
1031pub const EAI_AGAIN: ::c_int = -3;
1032pub const EAI_FAIL: ::c_int = -4;
1033pub const EAI_NODATA: ::c_int = -5;
1034pub const EAI_FAMILY: ::c_int = -6;
1035pub const EAI_SOCKTYPE: ::c_int = -7;
1036pub const EAI_SERVICE: ::c_int = -8;
1037pub const EAI_MEMORY: ::c_int = -10;
1038pub const EAI_SYSTEM: ::c_int = -11;
1039pub const EAI_OVERFLOW: ::c_int = -12;
1040
1041pub const NI_NUMERICHOST: ::c_int = 1;
1042pub const NI_NUMERICSERV: ::c_int = 2;
1043pub const NI_NOFQDN: ::c_int = 4;
1044pub const NI_NAMEREQD: ::c_int = 8;
1045pub const NI_DGRAM: ::c_int = 16;
1046
1047pub const SYNC_FILE_RANGE_WAIT_BEFORE: ::c_uint = 1;
1048pub const SYNC_FILE_RANGE_WRITE: ::c_uint = 2;
1049pub const SYNC_FILE_RANGE_WAIT_AFTER: ::c_uint = 4;
1050
1051pub const AIO_CANCELED: ::c_int = 0;
1052pub const AIO_NOTCANCELED: ::c_int = 1;
1053pub const AIO_ALLDONE: ::c_int = 2;
1054pub const LIO_READ: ::c_int = 0;
1055pub const LIO_WRITE: ::c_int = 1;
1056pub const LIO_NOP: ::c_int = 2;
1057pub const LIO_WAIT: ::c_int = 0;
1058pub const LIO_NOWAIT: ::c_int = 1;
1059
1060pub const MREMAP_MAYMOVE: ::c_int = 1;
1061pub const MREMAP_FIXED: ::c_int = 2;
1062
1063pub const PR_SET_PDEATHSIG: ::c_int = 1;
1064pub const PR_GET_PDEATHSIG: ::c_int = 2;
1065
1066pub const PR_GET_DUMPABLE: ::c_int = 3;
1067pub const PR_SET_DUMPABLE: ::c_int = 4;
1068
1069pub const PR_GET_UNALIGN: ::c_int = 5;
1070pub const PR_SET_UNALIGN: ::c_int = 6;
1071pub const PR_UNALIGN_NOPRINT: ::c_int = 1;
1072pub const PR_UNALIGN_SIGBUS: ::c_int = 2;
1073
1074pub const PR_GET_KEEPCAPS: ::c_int = 7;
1075pub const PR_SET_KEEPCAPS: ::c_int = 8;
1076
1077pub const PR_GET_FPEMU: ::c_int = 9;
1078pub const PR_SET_FPEMU: ::c_int = 10;
1079pub const PR_FPEMU_NOPRINT: ::c_int = 1;
1080pub const PR_FPEMU_SIGFPE: ::c_int = 2;
1081
1082pub const PR_GET_FPEXC: ::c_int = 11;
1083pub const PR_SET_FPEXC: ::c_int = 12;
1084pub const PR_FP_EXC_SW_ENABLE: ::c_int = 0x80;
1085pub const PR_FP_EXC_DIV: ::c_int = 0x010000;
1086pub const PR_FP_EXC_OVF: ::c_int = 0x020000;
1087pub const PR_FP_EXC_UND: ::c_int = 0x040000;
1088pub const PR_FP_EXC_RES: ::c_int = 0x080000;
1089pub const PR_FP_EXC_INV: ::c_int = 0x100000;
1090pub const PR_FP_EXC_DISABLED: ::c_int = 0;
1091pub const PR_FP_EXC_NONRECOV: ::c_int = 1;
1092pub const PR_FP_EXC_ASYNC: ::c_int = 2;
1093pub const PR_FP_EXC_PRECISE: ::c_int = 3;
1094
1095pub const PR_GET_TIMING: ::c_int = 13;
1096pub const PR_SET_TIMING: ::c_int = 14;
1097pub const PR_TIMING_STATISTICAL: ::c_int = 0;
1098pub const PR_TIMING_TIMESTAMP: ::c_int = 1;
1099
1100pub const PR_SET_NAME: ::c_int = 15;
1101pub const PR_GET_NAME: ::c_int = 16;
1102
1103pub const PR_GET_ENDIAN: ::c_int = 19;
1104pub const PR_SET_ENDIAN: ::c_int = 20;
1105pub const PR_ENDIAN_BIG: ::c_int = 0;
1106pub const PR_ENDIAN_LITTLE: ::c_int = 1;
1107pub const PR_ENDIAN_PPC_LITTLE: ::c_int = 2;
1108
1109pub const PR_GET_SECCOMP: ::c_int = 21;
1110pub const PR_SET_SECCOMP: ::c_int = 22;
1111
1112pub const PR_CAPBSET_READ: ::c_int = 23;
1113pub const PR_CAPBSET_DROP: ::c_int = 24;
1114
1115pub const PR_GET_TSC: ::c_int = 25;
1116pub const PR_SET_TSC: ::c_int = 26;
1117pub const PR_TSC_ENABLE: ::c_int = 1;
1118pub const PR_TSC_SIGSEGV: ::c_int = 2;
1119
1120pub const PR_GET_SECUREBITS: ::c_int = 27;
1121pub const PR_SET_SECUREBITS: ::c_int = 28;
1122
1123pub const PR_SET_TIMERSLACK: ::c_int = 29;
1124pub const PR_GET_TIMERSLACK: ::c_int = 30;
1125
1126pub const PR_TASK_PERF_EVENTS_DISABLE: ::c_int = 31;
1127pub const PR_TASK_PERF_EVENTS_ENABLE: ::c_int = 32;
1128
1129pub const PR_MCE_KILL: ::c_int = 33;
1130pub const PR_MCE_KILL_CLEAR: ::c_int = 0;
1131pub const PR_MCE_KILL_SET: ::c_int = 1;
1132
1133pub const PR_MCE_KILL_LATE: ::c_int = 0;
1134pub const PR_MCE_KILL_EARLY: ::c_int = 1;
1135pub const PR_MCE_KILL_DEFAULT: ::c_int = 2;
1136
1137pub const PR_MCE_KILL_GET: ::c_int = 34;
1138
1139pub const PR_SET_MM: ::c_int = 35;
1140pub const PR_SET_MM_START_CODE: ::c_int = 1;
1141pub const PR_SET_MM_END_CODE: ::c_int = 2;
1142pub const PR_SET_MM_START_DATA: ::c_int = 3;
1143pub const PR_SET_MM_END_DATA: ::c_int = 4;
1144pub const PR_SET_MM_START_STACK: ::c_int = 5;
1145pub const PR_SET_MM_START_BRK: ::c_int = 6;
1146pub const PR_SET_MM_BRK: ::c_int = 7;
1147pub const PR_SET_MM_ARG_START: ::c_int = 8;
1148pub const PR_SET_MM_ARG_END: ::c_int = 9;
1149pub const PR_SET_MM_ENV_START: ::c_int = 10;
1150pub const PR_SET_MM_ENV_END: ::c_int = 11;
1151pub const PR_SET_MM_AUXV: ::c_int = 12;
1152pub const PR_SET_MM_EXE_FILE: ::c_int = 13;
1153pub const PR_SET_MM_MAP: ::c_int = 14;
1154pub const PR_SET_MM_MAP_SIZE: ::c_int = 15;
1155
1156pub const PR_SET_PTRACER: ::c_int = 0x59616d61;
1157
1158pub const PR_SET_CHILD_SUBREAPER: ::c_int = 36;
1159pub const PR_GET_CHILD_SUBREAPER: ::c_int = 37;
1160
1161pub const PR_SET_NO_NEW_PRIVS: ::c_int = 38;
1162pub const PR_GET_NO_NEW_PRIVS: ::c_int = 39;
1163
1164pub const PR_GET_TID_ADDRESS: ::c_int = 40;
1165
1166pub const PR_SET_THP_DISABLE: ::c_int = 41;
1167pub const PR_GET_THP_DISABLE: ::c_int = 42;
1168
1169pub const PR_MPX_ENABLE_MANAGEMENT: ::c_int = 43;
1170pub const PR_MPX_DISABLE_MANAGEMENT: ::c_int = 44;
1171
1172pub const PR_SET_FP_MODE: ::c_int = 45;
1173pub const PR_GET_FP_MODE: ::c_int = 46;
1174pub const PR_FP_MODE_FR: ::c_int = 1 << 0;
1175pub const PR_FP_MODE_FRE: ::c_int = 1 << 1;
1176
1177pub const PR_CAP_AMBIENT: ::c_int = 47;
1178pub const PR_CAP_AMBIENT_IS_SET: ::c_int = 1;
1179pub const PR_CAP_AMBIENT_RAISE: ::c_int = 2;
1180pub const PR_CAP_AMBIENT_LOWER: ::c_int = 3;
1181pub const PR_CAP_AMBIENT_CLEAR_ALL: ::c_int = 4;
1182
1183pub const GRND_NONBLOCK: ::c_uint = 0x0001;
1184pub const GRND_RANDOM: ::c_uint = 0x0002;
1185
1186pub const SECCOMP_MODE_DISABLED: ::c_uint = 0;
1187pub const SECCOMP_MODE_STRICT: ::c_uint = 1;
1188pub const SECCOMP_MODE_FILTER: ::c_uint = 2;
1189
1190pub const ITIMER_REAL: ::c_int = 0;
1191pub const ITIMER_VIRTUAL: ::c_int = 1;
1192pub const ITIMER_PROF: ::c_int = 2;
1193
1194pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC;
1195pub const TFD_NONBLOCK: ::c_int = O_NONBLOCK;
1196pub const TFD_TIMER_ABSTIME: ::c_int = 1;
1197
1198pub const XATTR_CREATE: ::c_int = 0x1;
1199pub const XATTR_REPLACE: ::c_int = 0x2;
1200
1201pub const _POSIX_VDISABLE: ::cc_t = 0;
1202
1203pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01;
1204pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02;
1205pub const FALLOC_FL_COLLAPSE_RANGE: ::c_int = 0x08;
1206pub const FALLOC_FL_ZERO_RANGE: ::c_int = 0x10;
1207pub const FALLOC_FL_INSERT_RANGE: ::c_int = 0x20;
1208pub const FALLOC_FL_UNSHARE_RANGE: ::c_int = 0x40;
1209
1210// On Linux, libc doesn't define this constant, libattr does instead.
1211// We still define it for Linux as it's defined by libc on other platforms,
1212// and it's mentioned in the man pages for getxattr and setxattr.
1213pub const ENOATTR: ::c_int = ::ENODATA;
1214
1215pub const SO_ORIGINAL_DST: ::c_int = 80;
1216pub const IUTF8: ::tcflag_t = 0x00004000;
1217pub const CMSPAR: ::tcflag_t = 0o10000000000;
1218
1219pub const MFD_CLOEXEC: ::c_uint = 0x0001;
1220pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002;
1221
1222// these are used in the p_type field of Elf32_Phdr and Elf64_Phdr, which has
1223// the type Elf32Word and Elf64Word respectively. Luckily, both of those are u32
1224// so we can use that type here to avoid having to cast.
1225pub const PT_NULL: u32 = 0;
1226pub const PT_LOAD: u32 = 1;
1227pub const PT_DYNAMIC: u32 = 2;
1228pub const PT_INTERP: u32 = 3;
1229pub const PT_NOTE: u32 = 4;
1230pub const PT_SHLIB: u32 = 5;
1231pub const PT_PHDR: u32 = 6;
1232pub const PT_TLS: u32 = 7;
1233pub const PT_NUM: u32 = 8;
1234pub const PT_LOOS: u32 = 0x60000000;
1235pub const PT_GNU_EH_FRAME: u32 = 0x6474e550;
1236pub const PT_GNU_STACK: u32 = 0x6474e551;
1237pub const PT_GNU_RELRO: u32 = 0x6474e552;
1238
1239// linux/if_ether.h
1240pub const ETH_ALEN: ::c_int = 6;
1241pub const ETH_HLEN: ::c_int = 14;
1242pub const ETH_ZLEN: ::c_int = 60;
1243pub const ETH_DATA_LEN: ::c_int = 1500;
1244pub const ETH_FRAME_LEN: ::c_int = 1514;
1245pub const ETH_FCS_LEN: ::c_int = 4;
1246
1247// These are the defined Ethernet Protocol ID's.
1248pub const ETH_P_LOOP: ::c_int = 0x0060;
1249pub const ETH_P_PUP: ::c_int = 0x0200;
1250pub const ETH_P_PUPAT: ::c_int = 0x0201;
1251pub const ETH_P_IP: ::c_int = 0x0800;
1252pub const ETH_P_X25: ::c_int = 0x0805;
1253pub const ETH_P_ARP: ::c_int = 0x0806;
1254pub const ETH_P_BPQ: ::c_int = 0x08FF;
1255pub const ETH_P_IEEEPUP: ::c_int = 0x0a00;
1256pub const ETH_P_IEEEPUPAT: ::c_int = 0x0a01;
1257pub const ETH_P_BATMAN: ::c_int = 0x4305;
1258pub const ETH_P_DEC: ::c_int = 0x6000;
1259pub const ETH_P_DNA_DL: ::c_int = 0x6001;
1260pub const ETH_P_DNA_RC: ::c_int = 0x6002;
1261pub const ETH_P_DNA_RT: ::c_int = 0x6003;
1262pub const ETH_P_LAT: ::c_int = 0x6004;
1263pub const ETH_P_DIAG: ::c_int = 0x6005;
1264pub const ETH_P_CUST: ::c_int = 0x6006;
1265pub const ETH_P_SCA: ::c_int = 0x6007;
1266pub const ETH_P_TEB: ::c_int = 0x6558;
1267pub const ETH_P_RARP: ::c_int = 0x8035;
1268pub const ETH_P_ATALK: ::c_int = 0x809B;
1269pub const ETH_P_AARP: ::c_int = 0x80F3;
1270pub const ETH_P_8021Q: ::c_int = 0x8100;
1271pub const ETH_P_IPX: ::c_int = 0x8137;
1272pub const ETH_P_IPV6: ::c_int = 0x86DD;
1273pub const ETH_P_PAUSE: ::c_int = 0x8808;
1274pub const ETH_P_SLOW: ::c_int = 0x8809;
1275pub const ETH_P_WCCP: ::c_int = 0x883E;
1276pub const ETH_P_MPLS_UC: ::c_int = 0x8847;
1277pub const ETH_P_MPLS_MC: ::c_int = 0x8848;
1278pub const ETH_P_ATMMPOA: ::c_int = 0x884c;
1279pub const ETH_P_PPP_DISC: ::c_int = 0x8863;
1280pub const ETH_P_PPP_SES: ::c_int = 0x8864;
1281pub const ETH_P_LINK_CTL: ::c_int = 0x886c;
1282pub const ETH_P_ATMFATE: ::c_int = 0x8884;
1283pub const ETH_P_PAE: ::c_int = 0x888E;
1284pub const ETH_P_AOE: ::c_int = 0x88A2;
1285pub const ETH_P_8021AD: ::c_int = 0x88A8;
1286pub const ETH_P_802_EX1: ::c_int = 0x88B5;
1287pub const ETH_P_TIPC: ::c_int = 0x88CA;
1288pub const ETH_P_MACSEC: ::c_int = 0x88E5;
1289pub const ETH_P_8021AH: ::c_int = 0x88E7;
1290pub const ETH_P_MVRP: ::c_int = 0x88F5;
1291pub const ETH_P_1588: ::c_int = 0x88F7;
1292pub const ETH_P_PRP: ::c_int = 0x88FB;
1293pub const ETH_P_FCOE: ::c_int = 0x8906;
1294pub const ETH_P_TDLS: ::c_int = 0x890D;
1295pub const ETH_P_FIP: ::c_int = 0x8914;
1296pub const ETH_P_80221: ::c_int = 0x8917;
1297pub const ETH_P_LOOPBACK: ::c_int = 0x9000;
1298pub const ETH_P_QINQ1: ::c_int = 0x9100;
1299pub const ETH_P_QINQ2: ::c_int = 0x9200;
1300pub const ETH_P_QINQ3: ::c_int = 0x9300;
1301pub const ETH_P_EDSA: ::c_int = 0xDADA;
1302pub const ETH_P_AF_IUCV: ::c_int = 0xFBFB;
1303
1304pub const ETH_P_802_3_MIN: ::c_int = 0x0600;
1305
1306// Non DIX types. Won't clash for 1500 types.
1307pub const ETH_P_802_3: ::c_int = 0x0001;
1308pub const ETH_P_AX25: ::c_int = 0x0002;
1309pub const ETH_P_ALL: ::c_int = 0x0003;
1310pub const ETH_P_802_2: ::c_int = 0x0004;
1311pub const ETH_P_SNAP: ::c_int = 0x0005;
1312pub const ETH_P_DDCMP: ::c_int = 0x0006;
1313pub const ETH_P_WAN_PPP: ::c_int = 0x0007;
1314pub const ETH_P_PPP_MP: ::c_int = 0x0008;
1315pub const ETH_P_LOCALTALK: ::c_int = 0x0009;
1316pub const ETH_P_CANFD: ::c_int = 0x000D;
1317pub const ETH_P_PPPTALK: ::c_int = 0x0010;
1318pub const ETH_P_TR_802_2: ::c_int = 0x0011;
1319pub const ETH_P_MOBITEX: ::c_int = 0x0015;
1320pub const ETH_P_CONTROL: ::c_int = 0x0016;
1321pub const ETH_P_IRDA: ::c_int = 0x0017;
1322pub const ETH_P_ECONET: ::c_int = 0x0018;
1323pub const ETH_P_HDLC: ::c_int = 0x0019;
1324pub const ETH_P_ARCNET: ::c_int = 0x001A;
1325pub const ETH_P_DSA: ::c_int = 0x001B;
1326pub const ETH_P_TRAILER: ::c_int = 0x001C;
1327pub const ETH_P_PHONET: ::c_int = 0x00F5;
1328pub const ETH_P_IEEE802154: ::c_int = 0x00F6;
1329pub const ETH_P_CAIF: ::c_int = 0x00F7;
1330
1331pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01;
1332pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02;
1333pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x04;
1334pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x08;
1335pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_int = 0x10;
1336pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x20;
1337
1338pub const NLMSG_NOOP: ::c_int = 0x1;
1339pub const NLMSG_ERROR: ::c_int = 0x2;
1340pub const NLMSG_DONE: ::c_int = 0x3;
1341pub const NLMSG_OVERRUN: ::c_int = 0x4;
1342pub const NLMSG_MIN_TYPE: ::c_int = 0x10;
1343
1344pub const GENL_NAMSIZ: ::c_int = 16;
1345
1346pub const GENL_MIN_ID: ::c_int = NLMSG_MIN_TYPE;
1347pub const GENL_MAX_ID: ::c_int = 1023;
1348
1349pub const GENL_ADMIN_PERM: ::c_int = 0x01;
1350pub const GENL_CMD_CAP_DO: ::c_int = 0x02;
1351pub const GENL_CMD_CAP_DUMP: ::c_int = 0x04;
1352pub const GENL_CMD_CAP_HASPOL: ::c_int = 0x08;
1353
1354pub const GENL_ID_CTRL: ::c_int = NLMSG_MIN_TYPE;
1355
1356pub const CTRL_CMD_UNSPEC: ::c_int = 0;
1357pub const CTRL_CMD_NEWFAMILY: ::c_int = 1;
1358pub const CTRL_CMD_DELFAMILY: ::c_int = 2;
1359pub const CTRL_CMD_GETFAMILY: ::c_int = 3;
1360pub const CTRL_CMD_NEWOPS: ::c_int = 4;
1361pub const CTRL_CMD_DELOPS: ::c_int = 5;
1362pub const CTRL_CMD_GETOPS: ::c_int = 6;
1363pub const CTRL_CMD_NEWMCAST_GRP: ::c_int = 7;
1364pub const CTRL_CMD_DELMCAST_GRP: ::c_int = 8;
1365pub const CTRL_CMD_GETMCAST_GRP: ::c_int = 9;
1366
1367pub const CTRL_ATTR_UNSPEC: ::c_int = 0;
1368pub const CTRL_ATTR_FAMILY_ID: ::c_int = 1;
1369pub const CTRL_ATTR_FAMILY_NAME: ::c_int = 2;
1370pub const CTRL_ATTR_VERSION: ::c_int = 3;
1371pub const CTRL_ATTR_HDRSIZE: ::c_int = 4;
1372pub const CTRL_ATTR_MAXATTR: ::c_int = 5;
1373pub const CTRL_ATTR_OPS: ::c_int = 6;
1374pub const CTRL_ATTR_MCAST_GROUPS: ::c_int = 7;
1375
1376pub const CTRL_ATTR_OP_UNSPEC: ::c_int = 0;
1377pub const CTRL_ATTR_OP_ID: ::c_int = 1;
1378pub const CTRL_ATTR_OP_FLAGS: ::c_int = 2;
1379
1380pub const CTRL_ATTR_MCAST_GRP_UNSPEC: ::c_int = 0;
1381pub const CTRL_ATTR_MCAST_GRP_NAME: ::c_int = 1;
1382pub const CTRL_ATTR_MCAST_GRP_ID: ::c_int = 2;
1383
1384// linux/if_packet.h
1385pub const PACKET_ADD_MEMBERSHIP: ::c_int = 1;
1386pub const PACKET_DROP_MEMBERSHIP: ::c_int = 2;
1387
1388pub const PACKET_MR_MULTICAST: ::c_int = 0;
1389pub const PACKET_MR_PROMISC: ::c_int = 1;
1390pub const PACKET_MR_ALLMULTI: ::c_int = 2;
1391pub const PACKET_MR_UNICAST: ::c_int = 3;
1392
1393// linux/netfilter.h
1394pub const NF_DROP: ::c_int = 0;
1395pub const NF_ACCEPT: ::c_int =  1;
1396pub const NF_STOLEN: ::c_int =  2;
1397pub const NF_QUEUE: ::c_int =  3;
1398pub const NF_REPEAT: ::c_int =  4;
1399pub const NF_STOP: ::c_int =  5;
1400pub const NF_MAX_VERDICT: ::c_int = NF_STOP;
1401
1402pub const NF_VERDICT_MASK: ::c_int = 0x000000ff;
1403pub const NF_VERDICT_FLAG_QUEUE_BYPASS: ::c_int = 0x00008000;
1404
1405pub const NF_VERDICT_QMASK: ::c_int = 0xffff0000;
1406pub const NF_VERDICT_QBITS: ::c_int = 16;
1407
1408pub const NF_VERDICT_BITS: ::c_int = 16;
1409
1410pub const NF_INET_PRE_ROUTING: ::c_int = 0;
1411pub const NF_INET_LOCAL_IN: ::c_int = 1;
1412pub const NF_INET_FORWARD: ::c_int = 2;
1413pub const NF_INET_LOCAL_OUT: ::c_int = 3;
1414pub const NF_INET_POST_ROUTING: ::c_int = 4;
1415pub const NF_INET_NUMHOOKS: ::c_int = 5;
1416
1417// Some NFPROTO are not compatible with musl and are defined in submodules.
1418pub const NFPROTO_UNSPEC: ::c_int = 0;
1419pub const NFPROTO_IPV4: ::c_int = 2;
1420pub const NFPROTO_ARP: ::c_int = 3;
1421pub const NFPROTO_BRIDGE: ::c_int = 7;
1422pub const NFPROTO_IPV6: ::c_int = 10;
1423pub const NFPROTO_DECNET: ::c_int = 12;
1424pub const NFPROTO_NUMPROTO: ::c_int = 13;
1425
1426// linux/netfilter_ipv4.h
1427pub const NF_IP_PRE_ROUTING: ::c_int = 0;
1428pub const NF_IP_LOCAL_IN: ::c_int = 1;
1429pub const NF_IP_FORWARD: ::c_int = 2;
1430pub const NF_IP_LOCAL_OUT: ::c_int = 3;
1431pub const NF_IP_POST_ROUTING: ::c_int = 4;
1432pub const NF_IP_NUMHOOKS: ::c_int = 5;
1433
1434pub const NF_IP_PRI_FIRST: ::c_int = ::INT_MIN;
1435pub const NF_IP_PRI_CONNTRACK_DEFRAG: ::c_int = -400;
1436pub const NF_IP_PRI_RAW: ::c_int = -300;
1437pub const NF_IP_PRI_SELINUX_FIRST: ::c_int = -225;
1438pub const NF_IP_PRI_CONNTRACK: ::c_int = -200;
1439pub const NF_IP_PRI_MANGLE: ::c_int = -150;
1440pub const NF_IP_PRI_NAT_DST: ::c_int = -100;
1441pub const NF_IP_PRI_FILTER: ::c_int = 0;
1442pub const NF_IP_PRI_SECURITY: ::c_int = 50;
1443pub const NF_IP_PRI_NAT_SRC: ::c_int = 100;
1444pub const NF_IP_PRI_SELINUX_LAST: ::c_int = 225;
1445pub const NF_IP_PRI_CONNTRACK_HELPER: ::c_int = 300;
1446pub const NF_IP_PRI_CONNTRACK_CONFIRM: ::c_int = ::INT_MAX;
1447pub const NF_IP_PRI_LAST: ::c_int = ::INT_MAX;
1448
1449// linux/netfilter_ipv6.h
1450pub const NF_IP6_PRE_ROUTING: ::c_int = 0;
1451pub const NF_IP6_LOCAL_IN: ::c_int = 1;
1452pub const NF_IP6_FORWARD: ::c_int = 2;
1453pub const NF_IP6_LOCAL_OUT: ::c_int = 3;
1454pub const NF_IP6_POST_ROUTING: ::c_int = 4;
1455pub const NF_IP6_NUMHOOKS: ::c_int = 5;
1456
1457pub const NF_IP6_PRI_FIRST: ::c_int = ::INT_MIN;
1458pub const NF_IP6_PRI_CONNTRACK_DEFRAG: ::c_int = -400;
1459pub const NF_IP6_PRI_RAW: ::c_int = -300;
1460pub const NF_IP6_PRI_SELINUX_FIRST: ::c_int = -225;
1461pub const NF_IP6_PRI_CONNTRACK: ::c_int = -200;
1462pub const NF_IP6_PRI_MANGLE: ::c_int = -150;
1463pub const NF_IP6_PRI_NAT_DST: ::c_int = -100;
1464pub const NF_IP6_PRI_FILTER: ::c_int = 0;
1465pub const NF_IP6_PRI_SECURITY: ::c_int = 50;
1466pub const NF_IP6_PRI_NAT_SRC: ::c_int = 100;
1467pub const NF_IP6_PRI_SELINUX_LAST: ::c_int = 225;
1468pub const NF_IP6_PRI_CONNTRACK_HELPER: ::c_int = 300;
1469pub const NF_IP6_PRI_LAST: ::c_int = ::INT_MAX;
1470
1471pub const SIOCADDRT: ::c_ulong = 0x0000890B;
1472pub const SIOCDELRT: ::c_ulong = 0x0000890C;
1473pub const SIOCGIFNAME: ::c_ulong = 0x00008910;
1474pub const SIOCSIFLINK: ::c_ulong = 0x00008911;
1475pub const SIOCGIFCONF: ::c_ulong = 0x00008912;
1476pub const SIOCGIFFLAGS: ::c_ulong = 0x00008913;
1477pub const SIOCSIFFLAGS: ::c_ulong = 0x00008914;
1478pub const SIOCGIFADDR: ::c_ulong = 0x00008915;
1479pub const SIOCSIFADDR: ::c_ulong = 0x00008916;
1480pub const SIOCGIFDSTADDR: ::c_ulong = 0x00008917;
1481pub const SIOCSIFDSTADDR: ::c_ulong = 0x00008918;
1482pub const SIOCGIFBRDADDR: ::c_ulong = 0x00008919;
1483pub const SIOCSIFBRDADDR: ::c_ulong = 0x0000891A;
1484pub const SIOCGIFNETMASK: ::c_ulong = 0x0000891B;
1485pub const SIOCSIFNETMASK: ::c_ulong = 0x0000891C;
1486pub const SIOCGIFMETRIC: ::c_ulong = 0x0000891D;
1487pub const SIOCSIFMETRIC: ::c_ulong = 0x0000891E;
1488pub const SIOCGIFMEM: ::c_ulong = 0x0000891F;
1489pub const SIOCSIFMEM: ::c_ulong = 0x00008920;
1490pub const SIOCGIFMTU: ::c_ulong = 0x00008921;
1491pub const SIOCSIFMTU: ::c_ulong = 0x00008922;
1492pub const SIOCSIFHWADDR: ::c_ulong = 0x00008924;
1493pub const SIOCGIFENCAP: ::c_ulong = 0x00008925;
1494pub const SIOCSIFENCAP: ::c_ulong = 0x00008926;
1495pub const SIOCGIFHWADDR: ::c_ulong = 0x00008927;
1496pub const SIOCGIFSLAVE: ::c_ulong = 0x00008929;
1497pub const SIOCSIFSLAVE: ::c_ulong = 0x00008930;
1498pub const SIOCADDMULTI: ::c_ulong = 0x00008931;
1499pub const SIOCDELMULTI: ::c_ulong = 0x00008932;
1500pub const SIOCDARP: ::c_ulong = 0x00008953;
1501pub const SIOCGARP: ::c_ulong = 0x00008954;
1502pub const SIOCSARP: ::c_ulong = 0x00008955;
1503pub const SIOCDRARP: ::c_ulong = 0x00008960;
1504pub const SIOCGRARP: ::c_ulong = 0x00008961;
1505pub const SIOCSRARP: ::c_ulong = 0x00008962;
1506pub const SIOCGIFMAP: ::c_ulong = 0x00008970;
1507pub const SIOCSIFMAP: ::c_ulong = 0x00008971;
1508
1509pub const IPTOS_TOS_MASK: u8 = 0x1E;
1510pub const IPTOS_PREC_MASK: u8 = 0xE0;
1511
1512pub const RTF_UP: ::c_ushort = 0x0001;
1513pub const RTF_GATEWAY: ::c_ushort = 0x0002;
1514
1515pub const RTF_HOST: ::c_ushort = 0x0004;
1516pub const RTF_REINSTATE: ::c_ushort = 0x0008;
1517pub const RTF_DYNAMIC: ::c_ushort = 0x0010;
1518pub const RTF_MODIFIED: ::c_ushort = 0x0020;
1519pub const RTF_MTU: ::c_ushort = 0x0040;
1520pub const RTF_MSS: ::c_ushort = RTF_MTU;
1521pub const RTF_WINDOW: ::c_ushort = 0x0080;
1522pub const RTF_IRTT: ::c_ushort = 0x0100;
1523pub const RTF_REJECT: ::c_ushort = 0x0200;
1524pub const RTF_STATIC: ::c_ushort = 0x0400;
1525pub const RTF_XRESOLVE: ::c_ushort = 0x0800;
1526pub const RTF_NOFORWARD: ::c_ushort = 0x1000;
1527pub const RTF_THROW: ::c_ushort = 0x2000;
1528pub const RTF_NOPMTUDISC: ::c_ushort = 0x4000;
1529
1530pub const RTF_DEFAULT: u32 = 0x00010000;
1531pub const RTF_ALLONLINK: u32 = 0x00020000;
1532pub const RTF_ADDRCONF: u32 = 0x00040000;
1533pub const RTF_LINKRT: u32 = 0x00100000;
1534pub const RTF_NONEXTHOP: u32 = 0x00200000;
1535pub const RTF_CACHE: u32 = 0x01000000;
1536pub const RTF_FLOW: u32 = 0x02000000;
1537pub const RTF_POLICY: u32 = 0x04000000;
1538
1539pub const RTCF_VALVE: u32 = 0x00200000;
1540pub const RTCF_MASQ: u32 = 0x00400000;
1541pub const RTCF_NAT: u32 = 0x00800000;
1542pub const RTCF_DOREDIRECT: u32 = 0x01000000;
1543pub const RTCF_LOG: u32 = 0x02000000;
1544pub const RTCF_DIRECTSRC: u32 = 0x04000000;
1545
1546pub const RTF_LOCAL: u32 = 0x80000000;
1547pub const RTF_INTERFACE: u32 = 0x40000000;
1548pub const RTF_MULTICAST: u32 = 0x20000000;
1549pub const RTF_BROADCAST: u32 = 0x10000000;
1550pub const RTF_NAT: u32 = 0x08000000;
1551pub const RTF_ADDRCLASSMASK: u32 = 0xF8000000;
1552
1553pub const RT_CLASS_UNSPEC: u8 = 0;
1554pub const RT_CLASS_DEFAULT: u8 = 253;
1555pub const RT_CLASS_MAIN: u8 = 254;
1556pub const RT_CLASS_LOCAL: u8 = 255;
1557pub const RT_CLASS_MAX: u8 = 255;
1558
1559pub const RTMSG_OVERRUN: u32 = ::NLMSG_OVERRUN as u32;
1560pub const RTMSG_NEWDEVICE: u32 = 0x11;
1561pub const RTMSG_DELDEVICE: u32 = 0x12;
1562pub const RTMSG_NEWROUTE: u32 = 0x21;
1563pub const RTMSG_DELROUTE: u32 = 0x22;
1564pub const RTMSG_NEWRULE: u32 = 0x31;
1565pub const RTMSG_DELRULE: u32 = 0x32;
1566pub const RTMSG_CONTROL: u32 = 0x40;
1567pub const RTMSG_AR_FAILED: u32 = 0x51;
1568
1569pub const MAX_ADDR_LEN: usize = 7;
1570pub const ARPD_UPDATE: ::c_ushort = 0x01;
1571pub const ARPD_LOOKUP: ::c_ushort = 0x02;
1572pub const ARPD_FLUSH: ::c_ushort = 0x03;
1573pub const ATF_MAGIC: ::c_int = 0x80;
1574
1575// linux/module.h
1576pub const MODULE_INIT_IGNORE_MODVERSIONS: ::c_uint = 0x0001;
1577pub const MODULE_INIT_IGNORE_VERMAGIC: ::c_uint = 0x0002;
1578
1579f! {
1580    pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
1581        for slot in cpuset.bits.iter_mut() {
1582            *slot = 0;
1583        }
1584    }
1585
1586    pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
1587        let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
1588        let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
1589        cpuset.bits[idx] |= 1 << offset;
1590        ()
1591    }
1592
1593    pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
1594        let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc
1595        let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
1596        cpuset.bits[idx] &= !(1 << offset);
1597        ()
1598    }
1599
1600    pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
1601        let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]);
1602        let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
1603        0 != (cpuset.bits[idx] & (1 << offset))
1604    }
1605
1606    pub fn major(dev: ::dev_t) -> ::c_uint {
1607        let mut major = 0;
1608        major |= (dev & 0x00000000000fff00) >> 8;
1609        major |= (dev & 0xfffff00000000000) >> 32;
1610        major as ::c_uint
1611    }
1612
1613    pub fn minor(dev: ::dev_t) -> ::c_uint {
1614        let mut minor = 0;
1615        minor |= (dev & 0x00000000000000ff) >> 0;
1616        minor |= (dev & 0x00000ffffff00000) >> 12;
1617        minor as ::c_uint
1618    }
1619
1620    pub fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t {
1621        let major = major as ::dev_t;
1622        let minor = minor as ::dev_t;
1623        let mut dev = 0;
1624        dev |= (major & 0x00000fff) << 8;
1625        dev |= (major & 0xfffff000) << 32;
1626        dev |= (minor & 0x000000ff) << 0;
1627        dev |= (minor & 0xffffff00) << 12;
1628        dev
1629    }
1630
1631    pub fn IPTOS_TOS(tos: u8) -> u8 {
1632        tos & IPTOS_TOS_MASK
1633    }
1634
1635    pub fn IPTOS_PREC(tos: u8) -> u8 {
1636        tos & IPTOS_PREC_MASK
1637    }
1638
1639    pub fn RT_TOS(tos: u8) -> u8 {
1640        tos & ::IPTOS_TOS_MASK
1641    }
1642
1643    pub fn RT_ADDRCLASS(flags: u32) -> u32 {
1644        flags >> 23
1645    }
1646
1647    pub fn RT_LOCALADDR(flags: u32) -> bool {
1648        (flags & RTF_ADDRCLASSMASK) == (RTF_LOCAL | RTF_INTERFACE)
1649    }
1650}
1651
1652cfg_if! {
1653    if #[cfg(any(target_env = "musl", target_os = "fuchsia"))] {
1654        mod musl;
1655        pub use self::musl::*;
1656    } else if #[cfg(any(target_arch = "mips",
1657                        target_arch = "mips64"))] {
1658        mod mips;
1659        pub use self::mips::*;
1660    } else if #[cfg(any(target_arch = "s390x"))] {
1661        mod s390x;
1662        pub use self::s390x::*;
1663    } else {
1664        mod other;
1665        pub use self::other::*;
1666    }
1667}