]> git.proxmox.com Git - rustc.git/blame - vendor/libc/src/unix/linux_like/linux/gnu/mod.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / vendor / libc / src / unix / linux_like / linux / gnu / mod.rs
CommitLineData
416331ca 1pub type pthread_t = c_ulong;
476ff2be 2pub type __priority_which_t = ::c_uint;
416331ca 3pub type __rlimit_resource_t = ::c_uint;
ba9703b0
XL
4pub type Lmid_t = ::c_long;
5pub type regoff_t = ::c_int;
476ff2be 6
a2a8927a
XL
7cfg_if! {
8 if #[cfg(doc)] {
9 // Used in `linux::arch` to define ioctl constants.
10 pub(crate) type Ioctl = ::c_ulong;
11 } else {
12 #[doc(hidden)]
13 pub type Ioctl = ::c_ulong;
14 }
15}
16
476ff2be 17s! {
416331ca
XL
18 pub struct statx {
19 pub stx_mask: u32,
20 pub stx_blksize: u32,
21 pub stx_attributes: u64,
22 pub stx_nlink: u32,
23 pub stx_uid: u32,
24 pub stx_gid: u32,
25 pub stx_mode: u16,
6a06907d 26 __statx_pad1: [u16; 1],
416331ca
XL
27 pub stx_ino: u64,
28 pub stx_size: u64,
29 pub stx_blocks: u64,
30 pub stx_attributes_mask: u64,
31 pub stx_atime: ::statx_timestamp,
32 pub stx_btime: ::statx_timestamp,
33 pub stx_ctime: ::statx_timestamp,
34 pub stx_mtime: ::statx_timestamp,
35 pub stx_rdev_major: u32,
36 pub stx_rdev_minor: u32,
37 pub stx_dev_major: u32,
38 pub stx_dev_minor: u32,
6a06907d
XL
39 pub stx_mnt_id: u64,
40 __statx_pad2: u64,
41 __statx_pad3: [u64; 12],
416331ca
XL
42 }
43
44 pub struct statx_timestamp {
45 pub tv_sec: i64,
46 pub tv_nsec: u32,
47 pub __statx_timestamp_pad1: [i32; 1],
48 }
49
8bb4bdeb
XL
50 pub struct aiocb {
51 pub aio_fildes: ::c_int,
52 pub aio_lio_opcode: ::c_int,
53 pub aio_reqprio: ::c_int,
54 pub aio_buf: *mut ::c_void,
55 pub aio_nbytes: ::size_t,
56 pub aio_sigevent: ::sigevent,
57 __next_prio: *mut aiocb,
58 __abs_prio: ::c_int,
59 __policy: ::c_int,
60 __error_code: ::c_int,
61 __return_value: ::ssize_t,
62 pub aio_offset: off_t,
abe05a73 63 #[cfg(all(not(target_arch = "x86_64"), target_pointer_width = "32"))]
8bb4bdeb
XL
64 __unused1: [::c_char; 4],
65 __glibc_reserved: [::c_char; 32]
66 }
67
476ff2be
SL
68 pub struct __exit_status {
69 pub e_termination: ::c_short,
70 pub e_exit: ::c_short,
71 }
72
73 pub struct __timeval {
416331ca
XL
74 pub tv_sec: i32,
75 pub tv_usec: i32,
476ff2be
SL
76 }
77
78 pub struct glob64_t {
79 pub gl_pathc: ::size_t,
80 pub gl_pathv: *mut *mut ::c_char,
81 pub gl_offs: ::size_t,
82 pub gl_flags: ::c_int,
83
84 __unused1: *mut ::c_void,
85 __unused2: *mut ::c_void,
86 __unused3: *mut ::c_void,
87 __unused4: *mut ::c_void,
88 __unused5: *mut ::c_void,
89 }
90
476ff2be
SL
91 pub struct msghdr {
92 pub msg_name: *mut ::c_void,
93 pub msg_namelen: ::socklen_t,
94 pub msg_iov: *mut ::iovec,
95 pub msg_iovlen: ::size_t,
96 pub msg_control: *mut ::c_void,
97 pub msg_controllen: ::size_t,
98 pub msg_flags: ::c_int,
99 }
100
8bb4bdeb
XL
101 pub struct cmsghdr {
102 pub cmsg_len: ::size_t,
103 pub cmsg_level: ::c_int,
104 pub cmsg_type: ::c_int,
105 }
106
476ff2be
SL
107 pub struct termios {
108 pub c_iflag: ::tcflag_t,
109 pub c_oflag: ::tcflag_t,
110 pub c_cflag: ::tcflag_t,
111 pub c_lflag: ::tcflag_t,
112 pub c_line: ::cc_t,
113 pub c_cc: [::cc_t; ::NCCS],
416331ca 114 #[cfg(not(any(
dfeec247 115 target_arch = "sparc",
416331ca
XL
116 target_arch = "sparc64",
117 target_arch = "mips",
118 target_arch = "mips64")))]
476ff2be 119 pub c_ispeed: ::speed_t,
416331ca 120 #[cfg(not(any(
dfeec247 121 target_arch = "sparc",
416331ca
XL
122 target_arch = "sparc64",
123 target_arch = "mips",
124 target_arch = "mips64")))]
476ff2be
SL
125 pub c_ospeed: ::speed_t,
126 }
127
2c00a5a8
XL
128 pub struct mallinfo {
129 pub arena: ::c_int,
130 pub ordblks: ::c_int,
131 pub smblks: ::c_int,
132 pub hblks: ::c_int,
133 pub hblkhd: ::c_int,
134 pub usmblks: ::c_int,
135 pub fsmblks: ::c_int,
136 pub uordblks: ::c_int,
137 pub fordblks: ::c_int,
138 pub keepcost: ::c_int,
139 }
140
136023e0
XL
141 pub struct mallinfo2 {
142 pub arena: ::size_t,
143 pub ordblks: ::size_t,
144 pub smblks: ::size_t,
145 pub hblks: ::size_t,
146 pub hblkhd: ::size_t,
147 pub usmblks: ::size_t,
148 pub fsmblks: ::size_t,
149 pub uordblks: ::size_t,
150 pub fordblks: ::size_t,
151 pub keepcost: ::size_t,
152 }
153
2c00a5a8 154 pub struct nl_pktinfo {
8faf50e0 155 pub group: u32,
2c00a5a8
XL
156 }
157
158 pub struct nl_mmap_req {
8faf50e0
XL
159 pub nm_block_size: ::c_uint,
160 pub nm_block_nr: ::c_uint,
161 pub nm_frame_size: ::c_uint,
162 pub nm_frame_nr: ::c_uint,
2c00a5a8
XL
163 }
164
165 pub struct nl_mmap_hdr {
8faf50e0
XL
166 pub nm_status: ::c_uint,
167 pub nm_len: ::c_uint,
168 pub nm_group: u32,
169 pub nm_pid: u32,
170 pub nm_uid: u32,
171 pub nm_gid: u32,
2c00a5a8
XL
172 }
173
8faf50e0
XL
174 pub struct rtentry {
175 pub rt_pad1: ::c_ulong,
176 pub rt_dst: ::sockaddr,
177 pub rt_gateway: ::sockaddr,
178 pub rt_genmask: ::sockaddr,
179 pub rt_flags: ::c_ushort,
180 pub rt_pad2: ::c_short,
181 pub rt_pad3: ::c_ulong,
182 pub rt_tos: ::c_uchar,
183 pub rt_class: ::c_uchar,
184 #[cfg(target_pointer_width = "64")]
185 pub rt_pad4: [::c_short; 3usize],
186 #[cfg(not(target_pointer_width = "64"))]
187 pub rt_pad4: ::c_short,
188 pub rt_metric: ::c_short,
189 pub rt_dev: *mut ::c_char,
190 pub rt_mtu: ::c_ulong,
191 pub rt_window: ::c_ulong,
192 pub rt_irtt: ::c_ushort,
2c00a5a8 193 }
ba9703b0
XL
194
195 pub struct timex {
196 pub modes: ::c_uint,
197 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
198 pub offset: i64,
199 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
200 pub offset: ::c_long,
201 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
202 pub freq: i64,
203 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
204 pub freq: ::c_long,
205 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
206 pub maxerror: i64,
207 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
208 pub maxerror: ::c_long,
209 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
210 pub esterror: i64,
211 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
212 pub esterror: ::c_long,
213 pub status: ::c_int,
214 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
215 pub constant: i64,
216 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
217 pub constant: ::c_long,
218 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
219 pub precision: i64,
220 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
221 pub precision: ::c_long,
222 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
223 pub tolerance: i64,
224 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
225 pub tolerance: ::c_long,
226 pub time: ::timeval,
227 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
228 pub tick: i64,
229 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
230 pub tick: ::c_long,
231 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
232 pub ppsfreq: i64,
233 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
234 pub ppsfreq: ::c_long,
235 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
236 pub jitter: i64,
237 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
238 pub jitter: ::c_long,
239 pub shift: ::c_int,
240 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
241 pub stabil: i64,
242 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
243 pub stabil: ::c_long,
244 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
245 pub jitcnt: i64,
246 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
247 pub jitcnt: ::c_long,
248 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
249 pub calcnt: i64,
250 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
251 pub calcnt: ::c_long,
252 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
253 pub errcnt: i64,
254 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
255 pub errcnt: ::c_long,
256 #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
257 pub stbcnt: i64,
258 #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
259 pub stbcnt: ::c_long,
260 pub tai: ::c_int,
261 pub __unused1: i32,
262 pub __unused2: i32,
263 pub __unused3: i32,
264 pub __unused4: i32,
265 pub __unused5: i32,
266 pub __unused6: i32,
267 pub __unused7: i32,
268 pub __unused8: i32,
269 pub __unused9: i32,
270 pub __unused10: i32,
271 pub __unused11: i32,
272 }
273
274 pub struct ntptimeval {
275 pub time: ::timeval,
276 pub maxerror: ::c_long,
277 pub esterror: ::c_long,
278 pub tai: ::c_long,
279 pub __glibc_reserved1: ::c_long,
280 pub __glibc_reserved2: ::c_long,
281 pub __glibc_reserved3: ::c_long,
282 pub __glibc_reserved4: ::c_long,
283 }
284
285 pub struct regex_t {
286 __buffer: *mut ::c_void,
287 __allocated: ::size_t,
288 __used: ::size_t,
289 __syntax: ::c_ulong,
290 __fastmap: *mut ::c_char,
291 __translate: *mut ::c_char,
292 __re_nsub: ::size_t,
293 __bitfield: u8,
294 }
6a06907d
XL
295
296 pub struct Elf64_Chdr {
297 pub ch_type: ::Elf64_Word,
298 pub ch_reserved: ::Elf64_Word,
299 pub ch_size: ::Elf64_Xword,
300 pub ch_addralign: ::Elf64_Xword,
301 }
302
303 pub struct Elf32_Chdr {
304 pub ch_type: ::Elf32_Word,
305 pub ch_size: ::Elf32_Word,
306 pub ch_addralign: ::Elf32_Word,
307 }
136023e0
XL
308
309 pub struct seminfo {
310 pub semmap: ::c_int,
311 pub semmni: ::c_int,
312 pub semmns: ::c_int,
313 pub semmnu: ::c_int,
314 pub semmsl: ::c_int,
315 pub semopm: ::c_int,
316 pub semume: ::c_int,
317 pub semusz: ::c_int,
318 pub semvmx: ::c_int,
319 pub semaem: ::c_int,
320 }
5099ac24
FG
321
322 pub struct ptrace_peeksiginfo_args {
323 pub off: ::__u64,
324 pub flags: ::__u32,
325 pub nr: ::__s32,
326 }
327
328 pub struct __c_anonymous_ptrace_syscall_info_entry {
329 pub nr: ::__u64,
330 pub args: [::__u64; 6],
331 }
332
333 pub struct __c_anonymous_ptrace_syscall_info_exit {
334 pub sval: ::__s64,
335 pub is_error: ::__u8,
336 }
337
338 pub struct __c_anonymous_ptrace_syscall_info_seccomp {
339 pub nr: ::__u64,
340 pub args: [::__u64; 6],
341 pub ret_data: ::__u32,
342 }
343
344 pub struct ptrace_syscall_info {
345 pub op: ::__u8,
346 pub pad: [::__u8; 3],
347 pub arch: ::__u32,
348 pub instruction_pointer: ::__u64,
349 pub stack_pointer: ::__u64,
350 #[cfg(libc_union)]
351 pub u: __c_anonymous_ptrace_syscall_info_data,
352 }
476ff2be
SL
353}
354
48663c56
XL
355impl siginfo_t {
356 pub unsafe fn si_addr(&self) -> *mut ::c_void {
357 #[repr(C)]
358 struct siginfo_sigfault {
359 _si_signo: ::c_int,
360 _si_errno: ::c_int,
361 _si_code: ::c_int,
e74abb32 362 si_addr: *mut ::c_void,
48663c56
XL
363 }
364 (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr
365 }
416331ca
XL
366
367 pub unsafe fn si_value(&self) -> ::sigval {
368 #[repr(C)]
369 struct siginfo_timer {
370 _si_signo: ::c_int,
371 _si_errno: ::c_int,
372 _si_code: ::c_int,
373 _si_tid: ::c_int,
374 _si_overrun: ::c_int,
375 si_sigval: ::sigval,
376 }
377 (*(self as *const siginfo_t as *const siginfo_timer)).si_sigval
378 }
48663c56
XL
379}
380
3dfed10e
XL
381cfg_if! {
382 if #[cfg(libc_union)] {
383 // Internal, for casts to access union fields
384 #[repr(C)]
385 struct sifields_sigchld {
386 si_pid: ::pid_t,
387 si_uid: ::uid_t,
388 si_status: ::c_int,
389 si_utime: ::c_long,
390 si_stime: ::c_long,
391 }
392 impl ::Copy for sifields_sigchld {}
393 impl ::Clone for sifields_sigchld {
394 fn clone(&self) -> sifields_sigchld {
395 *self
396 }
397 }
398
399 // Internal, for casts to access union fields
400 #[repr(C)]
401 union sifields {
402 _align_pointer: *mut ::c_void,
403 sigchld: sifields_sigchld,
404 }
405
406 // Internal, for casts to access union fields. Note that some variants
407 // of sifields start with a pointer, which makes the alignment of
408 // sifields vary on 32-bit and 64-bit architectures.
409 #[repr(C)]
410 struct siginfo_f {
411 _siginfo_base: [::c_int; 3],
412 sifields: sifields,
413 }
414
415 impl siginfo_t {
416 unsafe fn sifields(&self) -> &sifields {
417 &(*(self as *const siginfo_t as *const siginfo_f)).sifields
418 }
419
420 pub unsafe fn si_pid(&self) -> ::pid_t {
421 self.sifields().sigchld.si_pid
422 }
423
424 pub unsafe fn si_uid(&self) -> ::uid_t {
425 self.sifields().sigchld.si_uid
426 }
427
428 pub unsafe fn si_status(&self) -> ::c_int {
429 self.sifields().sigchld.si_status
430 }
431
432 pub unsafe fn si_utime(&self) -> ::c_long {
433 self.sifields().sigchld.si_utime
434 }
435
436 pub unsafe fn si_stime(&self) -> ::c_long {
437 self.sifields().sigchld.si_stime
438 }
439 }
5099ac24
FG
440
441 pub union __c_anonymous_ptrace_syscall_info_data {
442 pub entry: __c_anonymous_ptrace_syscall_info_entry,
443 pub exit: __c_anonymous_ptrace_syscall_info_exit,
444 pub seccomp: __c_anonymous_ptrace_syscall_info_seccomp,
445 }
446 impl ::Copy for __c_anonymous_ptrace_syscall_info_data {}
447 impl ::Clone for __c_anonymous_ptrace_syscall_info_data {
448 fn clone(&self) -> __c_anonymous_ptrace_syscall_info_data {
449 *self
450 }
451 }
3dfed10e
XL
452 }
453}
454
532ac7d7
XL
455s_no_extra_traits! {
456 pub struct utmpx {
457 pub ut_type: ::c_short,
458 pub ut_pid: ::pid_t,
459 pub ut_line: [::c_char; __UT_LINESIZE],
460 pub ut_id: [::c_char; 4],
461
462 pub ut_user: [::c_char; __UT_NAMESIZE],
463 pub ut_host: [::c_char; __UT_HOSTSIZE],
464 pub ut_exit: __exit_status,
465
466 #[cfg(any(target_arch = "aarch64",
416331ca 467 target_arch = "s390x",
04454e1e 468 target_arch = "loongarch64",
532ac7d7
XL
469 all(target_pointer_width = "32",
470 not(target_arch = "x86_64"))))]
471 pub ut_session: ::c_long,
472 #[cfg(any(target_arch = "aarch64",
416331ca 473 target_arch = "s390x",
04454e1e 474 target_arch = "loongarch64",
532ac7d7
XL
475 all(target_pointer_width = "32",
476 not(target_arch = "x86_64"))))]
477 pub ut_tv: ::timeval,
478
479 #[cfg(not(any(target_arch = "aarch64",
416331ca 480 target_arch = "s390x",
04454e1e 481 target_arch = "loongarch64",
532ac7d7
XL
482 all(target_pointer_width = "32",
483 not(target_arch = "x86_64")))))]
416331ca 484 pub ut_session: i32,
532ac7d7 485 #[cfg(not(any(target_arch = "aarch64",
416331ca 486 target_arch = "s390x",
04454e1e 487 target_arch = "loongarch64",
532ac7d7
XL
488 all(target_pointer_width = "32",
489 not(target_arch = "x86_64")))))]
490 pub ut_tv: __timeval,
491
416331ca 492 pub ut_addr_v6: [i32; 4],
532ac7d7
XL
493 __glibc_reserved: [::c_char; 20],
494 }
495}
496
497cfg_if! {
498 if #[cfg(feature = "extra_traits")] {
499 impl PartialEq for utmpx {
500 fn eq(&self, other: &utmpx) -> bool {
501 self.ut_type == other.ut_type
502 && self.ut_pid == other.ut_pid
503 && self.ut_line == other.ut_line
504 && self.ut_id == other.ut_id
505 && self.ut_user == other.ut_user
506 && self
507 .ut_host
508 .iter()
509 .zip(other.ut_host.iter())
510 .all(|(a,b)| a == b)
511 && self.ut_exit == other.ut_exit
512 && self.ut_session == other.ut_session
513 && self.ut_tv == other.ut_tv
514 && self.ut_addr_v6 == other.ut_addr_v6
515 && self.__glibc_reserved == other.__glibc_reserved
516 }
517 }
518
519 impl Eq for utmpx {}
520
521 impl ::fmt::Debug for utmpx {
522 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
523 f.debug_struct("utmpx")
524 .field("ut_type", &self.ut_type)
525 .field("ut_pid", &self.ut_pid)
526 .field("ut_line", &self.ut_line)
527 .field("ut_id", &self.ut_id)
528 .field("ut_user", &self.ut_user)
529 // FIXME: .field("ut_host", &self.ut_host)
530 .field("ut_exit", &self.ut_exit)
531 .field("ut_session", &self.ut_session)
532 .field("ut_tv", &self.ut_tv)
533 .field("ut_addr_v6", &self.ut_addr_v6)
534 .field("__glibc_reserved", &self.__glibc_reserved)
535 .finish()
536 }
537 }
538
539 impl ::hash::Hash for utmpx {
540 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
541 self.ut_type.hash(state);
542 self.ut_pid.hash(state);
543 self.ut_line.hash(state);
544 self.ut_id.hash(state);
545 self.ut_user.hash(state);
546 self.ut_host.hash(state);
547 self.ut_exit.hash(state);
548 self.ut_session.hash(state);
549 self.ut_tv.hash(state);
550 self.ut_addr_v6.hash(state);
551 self.__glibc_reserved.hash(state);
552 }
553 }
5099ac24
FG
554
555 #[cfg(libc_union)]
556 impl PartialEq for __c_anonymous_ptrace_syscall_info_data {
557 fn eq(&self, other: &__c_anonymous_ptrace_syscall_info_data) -> bool {
558 unsafe {
559 self.entry == other.entry ||
560 self.exit == other.exit ||
561 self.seccomp == other.seccomp
562 }
563 }
564 }
565
566 #[cfg(libc_union)]
567 impl Eq for __c_anonymous_ptrace_syscall_info_data {}
568
569 #[cfg(libc_union)]
570 impl ::fmt::Debug for __c_anonymous_ptrace_syscall_info_data {
571 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
572 unsafe {
573 f.debug_struct("__c_anonymous_ptrace_syscall_info_data")
574 .field("entry", &self.entry)
575 .field("exit", &self.exit)
576 .field("seccomp", &self.seccomp)
577 .finish()
578 }
579 }
580 }
581
582 #[cfg(libc_union)]
583 impl ::hash::Hash for __c_anonymous_ptrace_syscall_info_data {
584 fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
585 unsafe {
586 self.entry.hash(state);
587 self.exit.hash(state);
588 self.seccomp.hash(state);
589 }
590 }
591 }
532ac7d7
XL
592 }
593}
594
ba9703b0
XL
595// include/uapi/asm-generic/hugetlb_encode.h
596pub const HUGETLB_FLAG_ENCODE_SHIFT: ::c_int = 26;
5869c6ff 597pub const HUGETLB_FLAG_ENCODE_MASK: ::c_int = 0x3f;
ba9703b0 598
5869c6ff 599pub const HUGETLB_FLAG_ENCODE_64KB: ::c_int = 16 << HUGETLB_FLAG_ENCODE_SHIFT;
ba9703b0 600pub const HUGETLB_FLAG_ENCODE_512KB: ::c_int = 19 << HUGETLB_FLAG_ENCODE_SHIFT;
5869c6ff
XL
601pub const HUGETLB_FLAG_ENCODE_1MB: ::c_int = 20 << HUGETLB_FLAG_ENCODE_SHIFT;
602pub const HUGETLB_FLAG_ENCODE_2MB: ::c_int = 21 << HUGETLB_FLAG_ENCODE_SHIFT;
603pub const HUGETLB_FLAG_ENCODE_8MB: ::c_int = 23 << HUGETLB_FLAG_ENCODE_SHIFT;
604pub const HUGETLB_FLAG_ENCODE_16MB: ::c_int = 24 << HUGETLB_FLAG_ENCODE_SHIFT;
605pub const HUGETLB_FLAG_ENCODE_32MB: ::c_int = 25 << HUGETLB_FLAG_ENCODE_SHIFT;
ba9703b0
XL
606pub const HUGETLB_FLAG_ENCODE_256MB: ::c_int = 28 << HUGETLB_FLAG_ENCODE_SHIFT;
607pub const HUGETLB_FLAG_ENCODE_512MB: ::c_int = 29 << HUGETLB_FLAG_ENCODE_SHIFT;
5869c6ff
XL
608pub const HUGETLB_FLAG_ENCODE_1GB: ::c_int = 30 << HUGETLB_FLAG_ENCODE_SHIFT;
609pub const HUGETLB_FLAG_ENCODE_2GB: ::c_int = 31 << HUGETLB_FLAG_ENCODE_SHIFT;
610pub const HUGETLB_FLAG_ENCODE_16GB: ::c_int = 34 << HUGETLB_FLAG_ENCODE_SHIFT;
ba9703b0
XL
611
612// include/uapi/linux/mman.h
613/*
614 * Huge page size encoding when MAP_HUGETLB is specified, and a huge page
615 * size other than the default is desired. See hugetlb_encode.h.
616 * All known huge page size encodings are provided here. It is the
617 * responsibility of the application to know which sizes are supported on
618 * the running system. See mmap(2) man page for details.
619 */
620pub const MAP_HUGE_SHIFT: ::c_int = HUGETLB_FLAG_ENCODE_SHIFT;
5869c6ff 621pub const MAP_HUGE_MASK: ::c_int = HUGETLB_FLAG_ENCODE_MASK;
ba9703b0 622
5869c6ff 623pub const MAP_HUGE_64KB: ::c_int = HUGETLB_FLAG_ENCODE_64KB;
ba9703b0 624pub const MAP_HUGE_512KB: ::c_int = HUGETLB_FLAG_ENCODE_512KB;
5869c6ff
XL
625pub const MAP_HUGE_1MB: ::c_int = HUGETLB_FLAG_ENCODE_1MB;
626pub const MAP_HUGE_2MB: ::c_int = HUGETLB_FLAG_ENCODE_2MB;
627pub const MAP_HUGE_8MB: ::c_int = HUGETLB_FLAG_ENCODE_8MB;
628pub const MAP_HUGE_16MB: ::c_int = HUGETLB_FLAG_ENCODE_16MB;
629pub const MAP_HUGE_32MB: ::c_int = HUGETLB_FLAG_ENCODE_32MB;
ba9703b0
XL
630pub const MAP_HUGE_256MB: ::c_int = HUGETLB_FLAG_ENCODE_256MB;
631pub const MAP_HUGE_512MB: ::c_int = HUGETLB_FLAG_ENCODE_512MB;
5869c6ff
XL
632pub const MAP_HUGE_1GB: ::c_int = HUGETLB_FLAG_ENCODE_1GB;
633pub const MAP_HUGE_2GB: ::c_int = HUGETLB_FLAG_ENCODE_2GB;
634pub const MAP_HUGE_16GB: ::c_int = HUGETLB_FLAG_ENCODE_16GB;
ba9703b0 635
f035d41b
XL
636pub const PRIO_PROCESS: ::__priority_which_t = 0;
637pub const PRIO_PGRP: ::__priority_which_t = 1;
638pub const PRIO_USER: ::__priority_which_t = 2;
639
416331ca
XL
640pub const MS_RMT_MASK: ::c_ulong = 0x02800051;
641
476ff2be
SL
642pub const __UT_LINESIZE: usize = 32;
643pub const __UT_NAMESIZE: usize = 32;
644pub const __UT_HOSTSIZE: usize = 256;
645pub const EMPTY: ::c_short = 0;
646pub const RUN_LVL: ::c_short = 1;
647pub const BOOT_TIME: ::c_short = 2;
648pub const NEW_TIME: ::c_short = 3;
649pub const OLD_TIME: ::c_short = 4;
650pub const INIT_PROCESS: ::c_short = 5;
651pub const LOGIN_PROCESS: ::c_short = 6;
652pub const USER_PROCESS: ::c_short = 7;
653pub const DEAD_PROCESS: ::c_short = 8;
654pub const ACCOUNTING: ::c_short = 9;
655
ba9703b0
XL
656// dlfcn.h
657pub const LM_ID_BASE: ::c_long = 0;
658pub const LM_ID_NEWLM: ::c_long = -1;
659
660pub const RTLD_DI_LMID: ::c_int = 1;
661pub const RTLD_DI_LINKMAP: ::c_int = 2;
662pub const RTLD_DI_CONFIGADDR: ::c_int = 3;
663pub const RTLD_DI_SERINFO: ::c_int = 4;
664pub const RTLD_DI_SERINFOSIZE: ::c_int = 5;
665pub const RTLD_DI_ORIGIN: ::c_int = 6;
666pub const RTLD_DI_PROFILENAME: ::c_int = 7;
667pub const RTLD_DI_PROFILEOUT: ::c_int = 8;
668pub const RTLD_DI_TLS_MODID: ::c_int = 9;
669pub const RTLD_DI_TLS_DATA: ::c_int = 10;
670
476ff2be 671pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK;
a2a8927a 672pub const PIDFD_NONBLOCK: ::c_uint = O_NONBLOCK as ::c_uint;
476ff2be 673
8bb4bdeb
XL
674pub const SOL_RXRPC: ::c_int = 272;
675pub const SOL_PPPOL2TP: ::c_int = 273;
8bb4bdeb
XL
676pub const SOL_PNPIPE: ::c_int = 275;
677pub const SOL_RDS: ::c_int = 276;
678pub const SOL_IUCV: ::c_int = 277;
679pub const SOL_CAIF: ::c_int = 278;
8bb4bdeb 680pub const SOL_NFC: ::c_int = 280;
69743fb6 681pub const SOL_XDP: ::c_int = 283;
8bb4bdeb
XL
682
683pub const MSG_TRYHARD: ::c_int = 4;
684
476ff2be
SL
685pub const LC_PAPER: ::c_int = 7;
686pub const LC_NAME: ::c_int = 8;
687pub const LC_ADDRESS: ::c_int = 9;
688pub const LC_TELEPHONE: ::c_int = 10;
689pub const LC_MEASUREMENT: ::c_int = 11;
690pub const LC_IDENTIFICATION: ::c_int = 12;
ba9703b0
XL
691pub const LC_PAPER_MASK: ::c_int = 1 << LC_PAPER;
692pub const LC_NAME_MASK: ::c_int = 1 << LC_NAME;
693pub const LC_ADDRESS_MASK: ::c_int = 1 << LC_ADDRESS;
694pub const LC_TELEPHONE_MASK: ::c_int = 1 << LC_TELEPHONE;
695pub const LC_MEASUREMENT_MASK: ::c_int = 1 << LC_MEASUREMENT;
696pub const LC_IDENTIFICATION_MASK: ::c_int = 1 << LC_IDENTIFICATION;
476ff2be 697pub const LC_ALL_MASK: ::c_int = ::LC_CTYPE_MASK
e74abb32
XL
698 | ::LC_NUMERIC_MASK
699 | ::LC_TIME_MASK
700 | ::LC_COLLATE_MASK
701 | ::LC_MONETARY_MASK
702 | ::LC_MESSAGES_MASK
703 | LC_PAPER_MASK
704 | LC_NAME_MASK
705 | LC_ADDRESS_MASK
706 | LC_TELEPHONE_MASK
707 | LC_MEASUREMENT_MASK
708 | LC_IDENTIFICATION_MASK;
476ff2be 709
8bb4bdeb 710pub const ENOTSUP: ::c_int = EOPNOTSUPP;
416331ca 711
476ff2be 712pub const SOCK_SEQPACKET: ::c_int = 5;
abe05a73
XL
713pub const SOCK_DCCP: ::c_int = 6;
714pub const SOCK_PACKET: ::c_int = 10;
476ff2be 715
6a06907d
XL
716pub const FAN_MARK_INODE: ::c_uint = 0x0000_0000;
717pub const FAN_MARK_MOUNT: ::c_uint = 0x0000_0010;
718// NOTE: FAN_MARK_FILESYSTEM requires Linux Kernel >= 4.20.0
719pub const FAN_MARK_FILESYSTEM: ::c_uint = 0x0000_0100;
720
721pub const AF_IB: ::c_int = 27;
722pub const AF_MPLS: ::c_int = 28;
723pub const AF_NFC: ::c_int = 39;
724pub const AF_VSOCK: ::c_int = 40;
725pub const AF_XDP: ::c_int = 44;
726pub const PF_IB: ::c_int = AF_IB;
727pub const PF_MPLS: ::c_int = AF_MPLS;
728pub const PF_NFC: ::c_int = AF_NFC;
729pub const PF_VSOCK: ::c_int = AF_VSOCK;
730pub const PF_XDP: ::c_int = AF_XDP;
731
abe05a73
XL
732/* DCCP socket options */
733pub const DCCP_SOCKOPT_PACKET_SIZE: ::c_int = 1;
734pub const DCCP_SOCKOPT_SERVICE: ::c_int = 2;
735pub const DCCP_SOCKOPT_CHANGE_L: ::c_int = 3;
736pub const DCCP_SOCKOPT_CHANGE_R: ::c_int = 4;
737pub const DCCP_SOCKOPT_GET_CUR_MPS: ::c_int = 5;
738pub const DCCP_SOCKOPT_SERVER_TIMEWAIT: ::c_int = 6;
739pub const DCCP_SOCKOPT_SEND_CSCOV: ::c_int = 10;
740pub const DCCP_SOCKOPT_RECV_CSCOV: ::c_int = 11;
741pub const DCCP_SOCKOPT_AVAILABLE_CCIDS: ::c_int = 12;
742pub const DCCP_SOCKOPT_CCID: ::c_int = 13;
743pub const DCCP_SOCKOPT_TX_CCID: ::c_int = 14;
744pub const DCCP_SOCKOPT_RX_CCID: ::c_int = 15;
745pub const DCCP_SOCKOPT_QPOLICY_ID: ::c_int = 16;
746pub const DCCP_SOCKOPT_QPOLICY_TXQLEN: ::c_int = 17;
747pub const DCCP_SOCKOPT_CCID_RX_INFO: ::c_int = 128;
748pub const DCCP_SOCKOPT_CCID_TX_INFO: ::c_int = 192;
749
750/// maximum number of services provided on the same listening port
751pub const DCCP_SERVICE_LIST_MAX_LEN: ::c_int = 32;
752
8bb4bdeb 753pub const SIGEV_THREAD_ID: ::c_int = 4;
476ff2be 754
476ff2be
SL
755pub const BUFSIZ: ::c_uint = 8192;
756pub const TMP_MAX: ::c_uint = 238328;
757pub const FOPEN_MAX: ::c_uint = 16;
6a06907d 758pub const FILENAME_MAX: ::c_uint = 4096;
476ff2be 759pub const POSIX_MADV_DONTNEED: ::c_int = 4;
041b39d2
XL
760pub const _SC_EQUIV_CLASS_MAX: ::c_int = 41;
761pub const _SC_CHARCLASS_NAME_MAX: ::c_int = 45;
762pub const _SC_PII: ::c_int = 53;
763pub const _SC_PII_XTI: ::c_int = 54;
764pub const _SC_PII_SOCKET: ::c_int = 55;
765pub const _SC_PII_INTERNET: ::c_int = 56;
766pub const _SC_PII_OSI: ::c_int = 57;
767pub const _SC_POLL: ::c_int = 58;
768pub const _SC_SELECT: ::c_int = 59;
769pub const _SC_PII_INTERNET_STREAM: ::c_int = 61;
770pub const _SC_PII_INTERNET_DGRAM: ::c_int = 62;
771pub const _SC_PII_OSI_COTS: ::c_int = 63;
772pub const _SC_PII_OSI_CLTS: ::c_int = 64;
773pub const _SC_PII_OSI_M: ::c_int = 65;
774pub const _SC_T_IOV_MAX: ::c_int = 66;
476ff2be 775pub const _SC_2_C_VERSION: ::c_int = 96;
041b39d2
XL
776pub const _SC_CHAR_BIT: ::c_int = 101;
777pub const _SC_CHAR_MAX: ::c_int = 102;
778pub const _SC_CHAR_MIN: ::c_int = 103;
779pub const _SC_INT_MAX: ::c_int = 104;
780pub const _SC_INT_MIN: ::c_int = 105;
781pub const _SC_LONG_BIT: ::c_int = 106;
782pub const _SC_WORD_BIT: ::c_int = 107;
783pub const _SC_MB_LEN_MAX: ::c_int = 108;
784pub const _SC_SSIZE_MAX: ::c_int = 110;
785pub const _SC_SCHAR_MAX: ::c_int = 111;
786pub const _SC_SCHAR_MIN: ::c_int = 112;
787pub const _SC_SHRT_MAX: ::c_int = 113;
788pub const _SC_SHRT_MIN: ::c_int = 114;
789pub const _SC_UCHAR_MAX: ::c_int = 115;
790pub const _SC_UINT_MAX: ::c_int = 116;
791pub const _SC_ULONG_MAX: ::c_int = 117;
792pub const _SC_USHRT_MAX: ::c_int = 118;
793pub const _SC_NL_ARGMAX: ::c_int = 119;
794pub const _SC_NL_LANGMAX: ::c_int = 120;
795pub const _SC_NL_MSGMAX: ::c_int = 121;
796pub const _SC_NL_NMAX: ::c_int = 122;
797pub const _SC_NL_SETMAX: ::c_int = 123;
798pub const _SC_NL_TEXTMAX: ::c_int = 124;
799pub const _SC_BASE: ::c_int = 134;
800pub const _SC_C_LANG_SUPPORT: ::c_int = 135;
801pub const _SC_C_LANG_SUPPORT_R: ::c_int = 136;
802pub const _SC_DEVICE_IO: ::c_int = 140;
803pub const _SC_DEVICE_SPECIFIC: ::c_int = 141;
804pub const _SC_DEVICE_SPECIFIC_R: ::c_int = 142;
805pub const _SC_FD_MGMT: ::c_int = 143;
806pub const _SC_FIFO: ::c_int = 144;
807pub const _SC_PIPE: ::c_int = 145;
808pub const _SC_FILE_ATTRIBUTES: ::c_int = 146;
809pub const _SC_FILE_LOCKING: ::c_int = 147;
810pub const _SC_FILE_SYSTEM: ::c_int = 148;
811pub const _SC_MULTI_PROCESS: ::c_int = 150;
812pub const _SC_SINGLE_PROCESS: ::c_int = 151;
813pub const _SC_NETWORKING: ::c_int = 152;
814pub const _SC_REGEX_VERSION: ::c_int = 156;
815pub const _SC_SIGNALS: ::c_int = 158;
816pub const _SC_SYSTEM_DATABASE: ::c_int = 162;
817pub const _SC_SYSTEM_DATABASE_R: ::c_int = 163;
818pub const _SC_USER_GROUPS: ::c_int = 166;
819pub const _SC_USER_GROUPS_R: ::c_int = 167;
820pub const _SC_LEVEL1_ICACHE_SIZE: ::c_int = 185;
821pub const _SC_LEVEL1_ICACHE_ASSOC: ::c_int = 186;
822pub const _SC_LEVEL1_ICACHE_LINESIZE: ::c_int = 187;
823pub const _SC_LEVEL1_DCACHE_SIZE: ::c_int = 188;
824pub const _SC_LEVEL1_DCACHE_ASSOC: ::c_int = 189;
825pub const _SC_LEVEL1_DCACHE_LINESIZE: ::c_int = 190;
826pub const _SC_LEVEL2_CACHE_SIZE: ::c_int = 191;
827pub const _SC_LEVEL2_CACHE_ASSOC: ::c_int = 192;
828pub const _SC_LEVEL2_CACHE_LINESIZE: ::c_int = 193;
829pub const _SC_LEVEL3_CACHE_SIZE: ::c_int = 194;
830pub const _SC_LEVEL3_CACHE_ASSOC: ::c_int = 195;
831pub const _SC_LEVEL3_CACHE_LINESIZE: ::c_int = 196;
832pub const _SC_LEVEL4_CACHE_SIZE: ::c_int = 197;
833pub const _SC_LEVEL4_CACHE_ASSOC: ::c_int = 198;
834pub const _SC_LEVEL4_CACHE_LINESIZE: ::c_int = 199;
476ff2be 835pub const O_ACCMODE: ::c_int = 3;
476ff2be
SL
836pub const ST_RELATIME: ::c_ulong = 4096;
837pub const NI_MAXHOST: ::socklen_t = 1025;
838
5099ac24
FG
839// Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the
840// following are only available on newer Linux versions than the versions
841// currently used in CI in some configurations, so we define them here.
5869c6ff
XL
842cfg_if! {
843 if #[cfg(not(target_arch = "s390x"))] {
5869c6ff 844 pub const BINDERFS_SUPER_MAGIC: ::c_long = 0x6c6f6f70;
5869c6ff
XL
845 pub const XFS_SUPER_MAGIC: ::c_long = 0x58465342;
846 } else if #[cfg(target_arch = "s390x")] {
5869c6ff 847 pub const BINDERFS_SUPER_MAGIC: ::c_uint = 0x6c6f6f70;
5869c6ff
XL
848 pub const XFS_SUPER_MAGIC: ::c_uint = 0x58465342;
849 }
850}
476ff2be 851
476ff2be
SL
852pub const CPU_SETSIZE: ::c_int = 0x400;
853
476ff2be
SL
854pub const PTRACE_TRACEME: ::c_uint = 0;
855pub const PTRACE_PEEKTEXT: ::c_uint = 1;
856pub const PTRACE_PEEKDATA: ::c_uint = 2;
857pub const PTRACE_PEEKUSER: ::c_uint = 3;
858pub const PTRACE_POKETEXT: ::c_uint = 4;
859pub const PTRACE_POKEDATA: ::c_uint = 5;
860pub const PTRACE_POKEUSER: ::c_uint = 6;
861pub const PTRACE_CONT: ::c_uint = 7;
862pub const PTRACE_KILL: ::c_uint = 8;
863pub const PTRACE_SINGLESTEP: ::c_uint = 9;
864pub const PTRACE_ATTACH: ::c_uint = 16;
476ff2be
SL
865pub const PTRACE_SYSCALL: ::c_uint = 24;
866pub const PTRACE_SETOPTIONS: ::c_uint = 0x4200;
867pub const PTRACE_GETEVENTMSG: ::c_uint = 0x4201;
868pub const PTRACE_GETSIGINFO: ::c_uint = 0x4202;
869pub const PTRACE_SETSIGINFO: ::c_uint = 0x4203;
870pub const PTRACE_GETREGSET: ::c_uint = 0x4204;
871pub const PTRACE_SETREGSET: ::c_uint = 0x4205;
872pub const PTRACE_SEIZE: ::c_uint = 0x4206;
873pub const PTRACE_INTERRUPT: ::c_uint = 0x4207;
874pub const PTRACE_LISTEN: ::c_uint = 0x4208;
875pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209;
5099ac24 876pub const PTRACE_GET_SYSCALL_INFO: ::c_uint = 0x420e;
476ff2be 877
6a06907d 878// linux/fs.h
476ff2be 879
6a06907d
XL
880// Flags for preadv2/pwritev2
881pub const RWF_HIPRI: ::c_int = 0x00000001;
882pub const RWF_DSYNC: ::c_int = 0x00000002;
883pub const RWF_SYNC: ::c_int = 0x00000004;
884pub const RWF_NOWAIT: ::c_int = 0x00000008;
885pub const RWF_APPEND: ::c_int = 0x00000010;
476ff2be 886
416331ca
XL
887// linux/rtnetlink.h
888pub const TCA_PAD: ::c_ushort = 9;
889pub const TCA_DUMP_INVISIBLE: ::c_ushort = 10;
890pub const TCA_CHAIN: ::c_ushort = 11;
891pub const TCA_HW_OFFLOAD: ::c_ushort = 12;
892
893pub const RTM_DELNETCONF: u16 = 81;
894pub const RTM_NEWSTATS: u16 = 92;
895pub const RTM_GETSTATS: u16 = 94;
896pub const RTM_NEWCACHEREPORT: u16 = 96;
897
898pub const RTM_F_LOOKUP_TABLE: ::c_uint = 0x1000;
899pub const RTM_F_FIB_MATCH: ::c_uint = 0x2000;
900
901pub const RTA_VIA: ::c_ushort = 18;
902pub const RTA_NEWDST: ::c_ushort = 19;
903pub const RTA_PREF: ::c_ushort = 20;
904pub const RTA_ENCAP_TYPE: ::c_ushort = 21;
905pub const RTA_ENCAP: ::c_ushort = 22;
906pub const RTA_EXPIRES: ::c_ushort = 23;
907pub const RTA_PAD: ::c_ushort = 24;
908pub const RTA_UID: ::c_ushort = 25;
909pub const RTA_TTL_PROPAGATE: ::c_ushort = 26;
910
911// linux/neighbor.h
912pub const NTF_EXT_LEARNED: u8 = 0x10;
913pub const NTF_OFFLOADED: u8 = 0x20;
914
915pub const NDA_MASTER: ::c_ushort = 9;
916pub const NDA_LINK_NETNSID: ::c_ushort = 10;
917pub const NDA_SRC_VNI: ::c_ushort = 11;
918
3dfed10e
XL
919// linux/personality.h
920pub const UNAME26: ::c_int = 0x0020000;
921pub const FDPIC_FUNCPTRS: ::c_int = 0x0080000;
922
416331ca
XL
923// linux/if_addr.h
924pub const IFA_FLAGS: ::c_ushort = 8;
925
926pub const IFA_F_MANAGETEMPADDR: u32 = 0x100;
927pub const IFA_F_NOPREFIXROUTE: u32 = 0x200;
928pub const IFA_F_MCAUTOJOIN: u32 = 0x400;
929pub const IFA_F_STABLE_PRIVACY: u32 = 0x800;
930
476ff2be
SL
931pub const MAX_LINKS: ::c_int = 32;
932
2c00a5a8
XL
933pub const GENL_UNS_ADMIN_PERM: ::c_int = 0x10;
934
935pub const GENL_ID_VFS_DQUOT: ::c_int = ::NLMSG_MIN_TYPE + 1;
936pub const GENL_ID_PMCRAID: ::c_int = ::NLMSG_MIN_TYPE + 2;
937
3c0e092e
XL
938// elf.h
939pub const NT_PRSTATUS: ::c_int = 1;
940pub const NT_PRFPREG: ::c_int = 2;
941pub const NT_FPREGSET: ::c_int = 2;
942pub const NT_PRPSINFO: ::c_int = 3;
943pub const NT_PRXREG: ::c_int = 4;
944pub const NT_TASKSTRUCT: ::c_int = 4;
945pub const NT_PLATFORM: ::c_int = 5;
946pub const NT_AUXV: ::c_int = 6;
947pub const NT_GWINDOWS: ::c_int = 7;
948pub const NT_ASRS: ::c_int = 8;
949pub const NT_PSTATUS: ::c_int = 10;
950pub const NT_PSINFO: ::c_int = 13;
951pub const NT_PRCRED: ::c_int = 14;
952pub const NT_UTSNAME: ::c_int = 15;
953pub const NT_LWPSTATUS: ::c_int = 16;
954pub const NT_LWPSINFO: ::c_int = 17;
955pub const NT_PRFPXREG: ::c_int = 20;
956
2b03887a
FG
957pub const ELFOSABI_ARM_AEABI: u8 = 64;
958
ba9703b0
XL
959// linux/keyctl.h
960pub const KEYCTL_DH_COMPUTE: u32 = 23;
961pub const KEYCTL_PKEY_QUERY: u32 = 24;
962pub const KEYCTL_PKEY_ENCRYPT: u32 = 25;
963pub const KEYCTL_PKEY_DECRYPT: u32 = 26;
964pub const KEYCTL_PKEY_SIGN: u32 = 27;
965pub const KEYCTL_PKEY_VERIFY: u32 = 28;
966pub const KEYCTL_RESTRICT_KEYRING: u32 = 29;
967
968pub const KEYCTL_SUPPORTS_ENCRYPT: u32 = 0x01;
969pub const KEYCTL_SUPPORTS_DECRYPT: u32 = 0x02;
970pub const KEYCTL_SUPPORTS_SIGN: u32 = 0x04;
971pub const KEYCTL_SUPPORTS_VERIFY: u32 = 0x08;
972cfg_if! {
973 if #[cfg(not(any(target_arch="mips", target_arch="mips64")))] {
974 pub const KEYCTL_MOVE: u32 = 30;
975 pub const KEYCTL_CAPABILITIES: u32 = 31;
976
977 pub const KEYCTL_CAPS0_CAPABILITIES: u32 = 0x01;
978 pub const KEYCTL_CAPS0_PERSISTENT_KEYRINGS: u32 = 0x02;
979 pub const KEYCTL_CAPS0_DIFFIE_HELLMAN: u32 = 0x04;
980 pub const KEYCTL_CAPS0_PUBLIC_KEY: u32 = 0x08;
981 pub const KEYCTL_CAPS0_BIG_KEY: u32 = 0x10;
982 pub const KEYCTL_CAPS0_INVALIDATE: u32 = 0x20;
983 pub const KEYCTL_CAPS0_RESTRICT_KEYRING: u32 = 0x40;
984 pub const KEYCTL_CAPS0_MOVE: u32 = 0x80;
985 pub const KEYCTL_CAPS1_NS_KEYRING_NAME: u32 = 0x01;
986 pub const KEYCTL_CAPS1_NS_KEY_TAG: u32 = 0x02;
987 }
988}
989
69743fb6
XL
990pub const M_MXFAST: ::c_int = 1;
991pub const M_NLBLKS: ::c_int = 2;
992pub const M_GRAIN: ::c_int = 3;
993pub const M_KEEP: ::c_int = 4;
994pub const M_TRIM_THRESHOLD: ::c_int = -1;
995pub const M_TOP_PAD: ::c_int = -2;
996pub const M_MMAP_THRESHOLD: ::c_int = -3;
997pub const M_MMAP_MAX: ::c_int = -4;
998pub const M_CHECK_ACTION: ::c_int = -5;
999pub const M_PERTURB: ::c_int = -6;
1000pub const M_ARENA_TEST: ::c_int = -7;
1001pub const M_ARENA_MAX: ::c_int = -8;
1002
416331ca
XL
1003pub const AT_STATX_SYNC_TYPE: ::c_int = 0x6000;
1004pub const AT_STATX_SYNC_AS_STAT: ::c_int = 0x0000;
1005pub const AT_STATX_FORCE_SYNC: ::c_int = 0x2000;
1006pub const AT_STATX_DONT_SYNC: ::c_int = 0x4000;
1007pub const STATX_TYPE: ::c_uint = 0x0001;
1008pub const STATX_MODE: ::c_uint = 0x0002;
1009pub const STATX_NLINK: ::c_uint = 0x0004;
1010pub const STATX_UID: ::c_uint = 0x0008;
1011pub const STATX_GID: ::c_uint = 0x0010;
1012pub const STATX_ATIME: ::c_uint = 0x0020;
1013pub const STATX_MTIME: ::c_uint = 0x0040;
1014pub const STATX_CTIME: ::c_uint = 0x0080;
1015pub const STATX_INO: ::c_uint = 0x0100;
1016pub const STATX_SIZE: ::c_uint = 0x0200;
1017pub const STATX_BLOCKS: ::c_uint = 0x0400;
1018pub const STATX_BASIC_STATS: ::c_uint = 0x07ff;
1019pub const STATX_BTIME: ::c_uint = 0x0800;
6a06907d 1020pub const STATX_MNT_ID: ::c_uint = 0x1000;
416331ca
XL
1021pub const STATX_ALL: ::c_uint = 0x0fff;
1022pub const STATX__RESERVED: ::c_int = 0x80000000;
1023pub const STATX_ATTR_COMPRESSED: ::c_int = 0x0004;
1024pub const STATX_ATTR_IMMUTABLE: ::c_int = 0x0010;
1025pub const STATX_ATTR_APPEND: ::c_int = 0x0020;
1026pub const STATX_ATTR_NODUMP: ::c_int = 0x0040;
1027pub const STATX_ATTR_ENCRYPTED: ::c_int = 0x0800;
1028pub const STATX_ATTR_AUTOMOUNT: ::c_int = 0x1000;
2b03887a
FG
1029pub const STATX_ATTR_MOUNT_ROOT: ::c_int = 0x2000;
1030pub const STATX_ATTR_VERITY: ::c_int = 0x00100000;
1031pub const STATX_ATTR_DAX: ::c_int = 0x00200000;
abe05a73 1032
f2b60f7d
FG
1033pub const SOMAXCONN: ::c_int = 4096;
1034
ba9703b0
XL
1035//sys/timex.h
1036pub const ADJ_OFFSET: ::c_uint = 0x0001;
1037pub const ADJ_FREQUENCY: ::c_uint = 0x0002;
1038pub const ADJ_MAXERROR: ::c_uint = 0x0004;
1039pub const ADJ_ESTERROR: ::c_uint = 0x0008;
1040pub const ADJ_STATUS: ::c_uint = 0x0010;
1041pub const ADJ_TIMECONST: ::c_uint = 0x0020;
1042pub const ADJ_TAI: ::c_uint = 0x0080;
1043pub const ADJ_SETOFFSET: ::c_uint = 0x0100;
1044pub const ADJ_MICRO: ::c_uint = 0x1000;
1045pub const ADJ_NANO: ::c_uint = 0x2000;
1046pub const ADJ_TICK: ::c_uint = 0x4000;
1047pub const ADJ_OFFSET_SINGLESHOT: ::c_uint = 0x8001;
1048pub const ADJ_OFFSET_SS_READ: ::c_uint = 0xa001;
1049pub const MOD_OFFSET: ::c_uint = ADJ_OFFSET;
1050pub const MOD_FREQUENCY: ::c_uint = ADJ_FREQUENCY;
1051pub const MOD_MAXERROR: ::c_uint = ADJ_MAXERROR;
1052pub const MOD_ESTERROR: ::c_uint = ADJ_ESTERROR;
1053pub const MOD_STATUS: ::c_uint = ADJ_STATUS;
1054pub const MOD_TIMECONST: ::c_uint = ADJ_TIMECONST;
1055pub const MOD_CLKB: ::c_uint = ADJ_TICK;
1056pub const MOD_CLKA: ::c_uint = ADJ_OFFSET_SINGLESHOT;
1057pub const MOD_TAI: ::c_uint = ADJ_TAI;
1058pub const MOD_MICRO: ::c_uint = ADJ_MICRO;
1059pub const MOD_NANO: ::c_uint = ADJ_NANO;
1060pub const STA_PLL: ::c_int = 0x0001;
1061pub const STA_PPSFREQ: ::c_int = 0x0002;
1062pub const STA_PPSTIME: ::c_int = 0x0004;
1063pub const STA_FLL: ::c_int = 0x0008;
1064pub const STA_INS: ::c_int = 0x0010;
1065pub const STA_DEL: ::c_int = 0x0020;
1066pub const STA_UNSYNC: ::c_int = 0x0040;
1067pub const STA_FREQHOLD: ::c_int = 0x0080;
1068pub const STA_PPSSIGNAL: ::c_int = 0x0100;
1069pub const STA_PPSJITTER: ::c_int = 0x0200;
1070pub const STA_PPSWANDER: ::c_int = 0x0400;
1071pub const STA_PPSERROR: ::c_int = 0x0800;
1072pub const STA_CLOCKERR: ::c_int = 0x1000;
1073pub const STA_NANO: ::c_int = 0x2000;
1074pub const STA_MODE: ::c_int = 0x4000;
1075pub const STA_CLK: ::c_int = 0x8000;
1076pub const STA_RONLY: ::c_int = STA_PPSSIGNAL
1077 | STA_PPSJITTER
1078 | STA_PPSWANDER
1079 | STA_PPSERROR
1080 | STA_CLOCKERR
1081 | STA_NANO
1082 | STA_MODE
1083 | STA_CLK;
1084pub const NTP_API: ::c_int = 4;
1085pub const TIME_OK: ::c_int = 0;
1086pub const TIME_INS: ::c_int = 1;
1087pub const TIME_DEL: ::c_int = 2;
1088pub const TIME_OOP: ::c_int = 3;
1089pub const TIME_WAIT: ::c_int = 4;
1090pub const TIME_ERROR: ::c_int = 5;
1091pub const TIME_BAD: ::c_int = TIME_ERROR;
1092pub const MAXTC: ::c_long = 6;
1093
476ff2be 1094cfg_if! {
416331ca
XL
1095 if #[cfg(any(
1096 target_arch = "arm",
1097 target_arch = "x86",
1098 target_arch = "x86_64",
ba9703b0 1099 target_arch = "s390x",
29967ef6
XL
1100 target_arch = "riscv64",
1101 target_arch = "riscv32"
416331ca 1102 ))] {
476ff2be 1103 pub const PTHREAD_STACK_MIN: ::size_t = 16384;
dfeec247
XL
1104 } else if #[cfg(any(
1105 target_arch = "sparc",
1106 target_arch = "sparc64"
1107 ))] {
8bb4bdeb 1108 pub const PTHREAD_STACK_MIN: ::size_t = 0x6000;
476ff2be
SL
1109 } else {
1110 pub const PTHREAD_STACK_MIN: ::size_t = 131072;
1111 }
1112}
8faf50e0 1113pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 3;
476ff2be 1114
ba9703b0
XL
1115pub const REG_STARTEND: ::c_int = 4;
1116
1117pub const REG_EEND: ::c_int = 14;
1118pub const REG_ESIZE: ::c_int = 15;
1119pub const REG_ERPAREN: ::c_int = 16;
1120
e74abb32 1121extern "C" {
ba9703b0
XL
1122 pub fn fgetspent_r(
1123 fp: *mut ::FILE,
1124 spbuf: *mut ::spwd,
1125 buf: *mut ::c_char,
1126 buflen: ::size_t,
1127 spbufp: *mut *mut ::spwd,
1128 ) -> ::c_int;
1129 pub fn sgetspent_r(
1130 s: *const ::c_char,
1131 spbuf: *mut ::spwd,
1132 buf: *mut ::c_char,
1133 buflen: ::size_t,
1134 spbufp: *mut *mut ::spwd,
1135 ) -> ::c_int;
1136 pub fn getspent_r(
1137 spbuf: *mut ::spwd,
1138 buf: *mut ::c_char,
1139 buflen: ::size_t,
1140 spbufp: *mut *mut ::spwd,
1141 ) -> ::c_int;
1142 pub fn qsort_r(
1143 base: *mut ::c_void,
1144 num: ::size_t,
1145 size: ::size_t,
1146 compar: ::Option<
cdc7bbd5 1147 unsafe extern "C" fn(*const ::c_void, *const ::c_void, *mut ::c_void) -> ::c_int,
ba9703b0
XL
1148 >,
1149 arg: *mut ::c_void,
1150 );
e74abb32
XL
1151 pub fn sendmmsg(
1152 sockfd: ::c_int,
1153 msgvec: *mut ::mmsghdr,
1154 vlen: ::c_uint,
1155 flags: ::c_int,
1156 ) -> ::c_int;
1157 pub fn recvmmsg(
1158 sockfd: ::c_int,
1159 msgvec: *mut ::mmsghdr,
1160 vlen: ::c_uint,
1161 flags: ::c_int,
1162 timeout: *mut ::timespec,
1163 ) -> ::c_int;
1164
cdc7bbd5
XL
1165 pub fn getrlimit64(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit64) -> ::c_int;
1166 pub fn setrlimit64(resource: ::__rlimit_resource_t, rlim: *const ::rlimit64) -> ::c_int;
1167 pub fn getrlimit(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit) -> ::c_int;
1168 pub fn setrlimit(resource: ::__rlimit_resource_t, rlim: *const ::rlimit) -> ::c_int;
e74abb32
XL
1169 pub fn prlimit(
1170 pid: ::pid_t,
1171 resource: ::__rlimit_resource_t,
1172 new_limit: *const ::rlimit,
1173 old_limit: *mut ::rlimit,
1174 ) -> ::c_int;
1175 pub fn prlimit64(
1176 pid: ::pid_t,
1177 resource: ::__rlimit_resource_t,
1178 new_limit: *const ::rlimit64,
1179 old_limit: *mut ::rlimit64,
1180 ) -> ::c_int;
1181 pub fn utmpname(file: *const ::c_char) -> ::c_int;
476ff2be
SL
1182 pub fn utmpxname(file: *const ::c_char) -> ::c_int;
1183 pub fn getutxent() -> *mut utmpx;
1184 pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
1185 pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
1186 pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
1187 pub fn setutxent();
1188 pub fn endutxent();
8bb4bdeb 1189 pub fn getpt() -> ::c_int;
69743fb6 1190 pub fn mallopt(param: ::c_int, value: ::c_int) -> ::c_int;
e74abb32
XL
1191 pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int;
1192 pub fn statx(
1193 dirfd: ::c_int,
1194 pathname: *const c_char,
1195 flags: ::c_int,
1196 mask: ::c_uint,
1197 statxbuf: *mut statx,
1198 ) -> ::c_int;
5e7ed085 1199 pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
cdc7bbd5 1200 pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t;
ba9703b0
XL
1201 pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;
1202
1203 pub fn adjtimex(buf: *mut timex) -> ::c_int;
1204 pub fn ntp_adjtime(buf: *mut timex) -> ::c_int;
1205 #[link_name = "ntp_gettimex"]
1206 pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
c295e0f8
XL
1207 pub fn clock_adjtime(clk_id: ::clockid_t, buf: *mut ::timex) -> ::c_int;
1208
ba9703b0
XL
1209 pub fn copy_file_range(
1210 fd_in: ::c_int,
1211 off_in: *mut ::off64_t,
1212 fd_out: ::c_int,
1213 off_out: *mut ::off64_t,
1214 len: ::size_t,
1215 flags: ::c_uint,
1216 ) -> ::ssize_t;
1217 pub fn fanotify_mark(
1218 fd: ::c_int,
1219 flags: ::c_uint,
1220 mask: u64,
1221 dirfd: ::c_int,
1222 path: *const ::c_char,
1223 ) -> ::c_int;
6a06907d
XL
1224 pub fn preadv2(
1225 fd: ::c_int,
1226 iov: *const ::iovec,
1227 iovcnt: ::c_int,
1228 offset: ::off_t,
1229 flags: ::c_int,
1230 ) -> ::ssize_t;
1231 pub fn pwritev2(
1232 fd: ::c_int,
1233 iov: *const ::iovec,
1234 iovcnt: ::c_int,
1235 offset: ::off_t,
1236 flags: ::c_int,
1237 ) -> ::ssize_t;
136023e0
XL
1238 pub fn preadv64v2(
1239 fd: ::c_int,
1240 iov: *const ::iovec,
1241 iovcnt: ::c_int,
1242 offset: ::off64_t,
1243 flags: ::c_int,
1244 ) -> ::ssize_t;
1245 pub fn pwritev64v2(
1246 fd: ::c_int,
1247 iov: *const ::iovec,
1248 iovcnt: ::c_int,
1249 offset: ::off64_t,
1250 flags: ::c_int,
1251 ) -> ::ssize_t;
cdc7bbd5
XL
1252 pub fn renameat2(
1253 olddirfd: ::c_int,
1254 oldpath: *const ::c_char,
1255 newdirfd: ::c_int,
1256 newpath: *const ::c_char,
1257 flags: ::c_uint,
1258 ) -> ::c_int;
17df50a5
XL
1259
1260 // Added in `glibc` 2.25
1261 pub fn explicit_bzero(s: *mut ::c_void, len: ::size_t);
94222f64
XL
1262 // Added in `glibc` 2.29
1263 pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void;
a2a8927a
XL
1264
1265 pub fn ctermid(s: *mut ::c_char) -> *mut ::c_char;
476ff2be
SL
1266}
1267
e74abb32 1268extern "C" {
476ff2be 1269 pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
e74abb32
XL
1270 pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int;
1271 pub fn glob64(
1272 pattern: *const ::c_char,
1273 flags: ::c_int,
cdc7bbd5 1274 errfunc: ::Option<extern "C" fn(epath: *const ::c_char, errno: ::c_int) -> ::c_int>,
e74abb32
XL
1275 pglob: *mut glob64_t,
1276 ) -> ::c_int;
476ff2be
SL
1277 pub fn globfree64(pglob: *mut glob64_t);
1278 pub fn ptrace(request: ::c_uint, ...) -> ::c_long;
e74abb32
XL
1279 pub fn pthread_attr_getaffinity_np(
1280 attr: *const ::pthread_attr_t,
1281 cpusetsize: ::size_t,
1282 cpuset: *mut ::cpu_set_t,
1283 ) -> ::c_int;
1284 pub fn pthread_attr_setaffinity_np(
1285 attr: *mut ::pthread_attr_t,
1286 cpusetsize: ::size_t,
1287 cpuset: *const ::cpu_set_t,
1288 ) -> ::c_int;
476ff2be 1289 pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int;
cdc7bbd5 1290 pub fn setpriority(which: ::__priority_which_t, who: ::id_t, prio: ::c_int) -> ::c_int;
e74abb32
XL
1291 pub fn pthread_rwlockattr_getkind_np(
1292 attr: *const ::pthread_rwlockattr_t,
1293 val: *mut ::c_int,
1294 ) -> ::c_int;
1295 pub fn pthread_rwlockattr_setkind_np(
1296 attr: *mut ::pthread_rwlockattr_t,
1297 val: ::c_int,
1298 ) -> ::c_int;
f2b60f7d 1299 pub fn pthread_sigqueue(thread: ::pthread_t, sig: ::c_int, value: ::sigval) -> ::c_int;
2c00a5a8 1300 pub fn mallinfo() -> ::mallinfo;
136023e0 1301 pub fn mallinfo2() -> ::mallinfo2;
c295e0f8 1302 pub fn malloc_info(options: ::c_int, stream: *mut ::FILE) -> ::c_int;
2c00a5a8 1303 pub fn malloc_usable_size(ptr: *mut ::c_void) -> ::size_t;
e74abb32
XL
1304 pub fn getpwent_r(
1305 pwd: *mut ::passwd,
1306 buf: *mut ::c_char,
1307 buflen: ::size_t,
1308 result: *mut *mut ::passwd,
1309 ) -> ::c_int;
e74abb32
XL
1310 pub fn getgrent_r(
1311 grp: *mut ::group,
1312 buf: *mut ::c_char,
1313 buflen: ::size_t,
1314 result: *mut *mut ::group,
1315 ) -> ::c_int;
2b03887a
FG
1316 pub fn fgetpwent_r(
1317 stream: *mut ::FILE,
1318 pwd: *mut ::passwd,
1319 buf: *mut ::c_char,
1320 buflen: ::size_t,
1321 result: *mut *mut ::passwd,
1322 ) -> ::c_int;
1323 pub fn fgetgrent_r(
1324 stream: *mut ::FILE,
1325 grp: *mut ::group,
1326 buf: *mut ::c_char,
1327 buflen: ::size_t,
1328 result: *mut *mut ::group,
1329 ) -> ::c_int;
c295e0f8
XL
1330
1331 pub fn sethostid(hostid: ::c_long) -> ::c_int;
a2a8927a
XL
1332
1333 pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int;
5099ac24 1334 pub fn mlock2(addr: *const ::c_void, len: ::size_t, flags: ::c_uint) -> ::c_int;
2b03887a
FG
1335
1336 pub fn euidaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;
1337 pub fn eaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;
487cf647
FG
1338
1339 pub fn asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char;
1340 pub fn ctime_r(timep: *const time_t, buf: *mut ::c_char) -> *mut ::c_char;
1341
1342 pub fn strftime(
1343 s: *mut ::c_char,
1344 max: ::size_t,
1345 format: *const ::c_char,
1346 tm: *const ::tm,
1347 ) -> ::size_t;
1348 pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char;
1349
1350 pub fn dirname(path: *mut ::c_char) -> *mut ::c_char;
1351 /// POSIX version of `basename(3)`, defined in `libgen.h`.
1352 #[link_name = "__xpg_basename"]
1353 pub fn posix_basename(path: *mut ::c_char) -> *mut ::c_char;
1354 /// GNU version of `basename(3)`, defined in `string.h`.
1355 #[link_name = "basename"]
1356 pub fn gnu_basename(path: *const ::c_char) -> *mut ::c_char;
476ff2be
SL
1357}
1358
ba9703b0 1359extern "C" {
cdc7bbd5
XL
1360 pub fn dlmopen(lmid: Lmid_t, filename: *const ::c_char, flag: ::c_int) -> *mut ::c_void;
1361 pub fn dlinfo(handle: *mut ::c_void, request: ::c_int, info: *mut ::c_void) -> ::c_int;
136023e0
XL
1362 pub fn dladdr1(
1363 addr: *const ::c_void,
1364 info: *mut ::Dl_info,
1365 extra_info: *mut *mut ::c_void,
1366 flags: ::c_int,
1367 ) -> ::c_int;
5099ac24 1368 pub fn malloc_trim(__pad: ::size_t) -> ::c_int;
ba9703b0
XL
1369}
1370
f2b60f7d
FG
1371extern "C" {
1372 pub fn gnu_get_libc_release() -> *const ::c_char;
1373 pub fn gnu_get_libc_version() -> *const ::c_char;
1374}
1375
476ff2be
SL
1376cfg_if! {
1377 if #[cfg(any(target_arch = "x86",
1378 target_arch = "arm",
5e7ed085 1379 target_arch = "m68k",
416331ca 1380 target_arch = "mips",
dfeec247 1381 target_arch = "powerpc",
29967ef6
XL
1382 target_arch = "sparc",
1383 target_arch = "riscv32"))] {
476ff2be
SL
1384 mod b32;
1385 pub use self::b32::*;
1386 } else if #[cfg(any(target_arch = "x86_64",
1387 target_arch = "aarch64",
8bb4bdeb 1388 target_arch = "powerpc64",
416331ca
XL
1389 target_arch = "mips64",
1390 target_arch = "s390x",
dfeec247 1391 target_arch = "sparc64",
04454e1e
FG
1392 target_arch = "riscv64",
1393 target_arch = "loongarch64"))] {
476ff2be
SL
1394 mod b64;
1395 pub use self::b64::*;
1396 } else {
1397 // Unknown target_arch
1398 }
1399}
532ac7d7
XL
1400
1401cfg_if! {
1402 if #[cfg(libc_align)] {
1403 mod align;
1404 pub use self::align::*;
1405 } else {
1406 mod no_align;
1407 pub use self::no_align::*;
1408 }
1409}