1 pub type pthread_t = *mut ::c_void; 2 pub type clock_t = c_long; 3 #[cfg_attr( 4 not(feature = "rustc-dep-of-std"), 5 deprecated( 6 since = "0.2.80", 7 note = "This type is changed to 64-bit in musl 1.2.0, \ 8 we'll follow that change in the future release. \ 9 See #1848 for more info." 10 ) 11 )] 12 pub type time_t = c_long; 13 pub type suseconds_t = c_long; 14 pub type ino_t = u64; 15 pub type off_t = i64; 16 pub type blkcnt_t = i64; 17 18 pub type shmatt_t = ::c_ulong; 19 pub type msgqnum_t = ::c_ulong; 20 pub type msglen_t = ::c_ulong; 21 pub type fsblkcnt_t = ::c_ulonglong; 22 pub type fsfilcnt_t = ::c_ulonglong; 23 pub type rlim_t = ::c_ulonglong; 24 25 cfg_if! { 26 if #[cfg(doc)] { 27 // Used in `linux::arch` to define ioctl constants. 28 pub(crate) type Ioctl = ::c_int; 29 } else { 30 #[doc(hidden)] 31 pub type Ioctl = ::c_int; 32 } 33 } 34 35 impl siginfo_t { 36 pub unsafe fn si_addr(&self) -> *mut ::c_void { 37 #[repr(C)] 38 struct siginfo_sigfault { 39 _si_signo: ::c_int, 40 _si_errno: ::c_int, 41 _si_code: ::c_int, 42 si_addr: *mut ::c_void, 43 } 44 (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr 45 } 46 47 pub unsafe fn si_value(&self) -> ::sigval { 48 #[repr(C)] 49 struct siginfo_si_value { 50 _si_signo: ::c_int, 51 _si_errno: ::c_int, 52 _si_code: ::c_int, 53 _si_timerid: ::c_int, 54 _si_overrun: ::c_int, 55 si_value: ::sigval, 56 } 57 (*(self as *const siginfo_t as *const siginfo_si_value)).si_value 58 } 59 } 60 61 // Internal, for casts to access union fields 62 #[repr(C)] 63 struct sifields_sigchld { 64 si_pid: ::pid_t, 65 si_uid: ::uid_t, 66 si_status: ::c_int, 67 si_utime: ::c_long, 68 si_stime: ::c_long, 69 } 70 impl ::Copy for sifields_sigchld {} 71 impl ::Clone for sifields_sigchld { 72 fn clone(&self) -> sifields_sigchld { 73 *self 74 } 75 } 76 77 // Internal, for casts to access union fields 78 #[repr(C)] 79 union sifields { 80 _align_pointer: *mut ::c_void, 81 sigchld: sifields_sigchld, 82 } 83 84 // Internal, for casts to access union fields. Note that some variants 85 // of sifields start with a pointer, which makes the alignment of 86 // sifields vary on 32-bit and 64-bit architectures. 87 #[repr(C)] 88 struct siginfo_f { 89 _siginfo_base: [::c_int; 3], 90 sifields: sifields, 91 } 92 93 impl siginfo_t { 94 unsafe fn sifields(&self) -> &sifields { 95 &(*(self as *const siginfo_t as *const siginfo_f)).sifields 96 } 97 98 pub unsafe fn si_pid(&self) -> ::pid_t { 99 self.sifields().sigchld.si_pid 100 } 101 102 pub unsafe fn si_uid(&self) -> ::uid_t { 103 self.sifields().sigchld.si_uid 104 } 105 106 pub unsafe fn si_status(&self) -> ::c_int { 107 self.sifields().sigchld.si_status 108 } 109 110 pub unsafe fn si_utime(&self) -> ::c_long { 111 self.sifields().sigchld.si_utime 112 } 113 114 pub unsafe fn si_stime(&self) -> ::c_long { 115 self.sifields().sigchld.si_stime 116 } 117 } 118 119 s! { 120 pub struct aiocb { 121 pub aio_fildes: ::c_int, 122 pub aio_lio_opcode: ::c_int, 123 pub aio_reqprio: ::c_int, 124 pub aio_buf: *mut ::c_void, 125 pub aio_nbytes: ::size_t, 126 pub aio_sigevent: ::sigevent, 127 __td: *mut ::c_void, 128 __lock: [::c_int; 2], 129 __err: ::c_int, 130 __ret: ::ssize_t, 131 pub aio_offset: off_t, 132 __next: *mut ::c_void, 133 __prev: *mut ::c_void, 134 #[cfg(target_pointer_width = "32")] 135 __dummy4: [::c_char; 24], 136 #[cfg(target_pointer_width = "64")] 137 __dummy4: [::c_char; 16], 138 } 139 140 pub struct sigaction { 141 pub sa_sigaction: ::sighandler_t, 142 pub sa_mask: ::sigset_t, 143 pub sa_flags: ::c_int, 144 pub sa_restorer: ::Option<extern "C" fn()>, 145 } 146 147 pub struct statvfs { 148 pub f_bsize: ::c_ulong, 149 pub f_frsize: ::c_ulong, 150 pub f_blocks: ::fsblkcnt_t, 151 pub f_bfree: ::fsblkcnt_t, 152 pub f_bavail: ::fsblkcnt_t, 153 pub f_files: ::fsfilcnt_t, 154 pub f_ffree: ::fsfilcnt_t, 155 pub f_favail: ::fsfilcnt_t, 156 #[cfg(target_endian = "little")] 157 pub f_fsid: ::c_ulong, 158 #[cfg(target_pointer_width = "32")] 159 __f_unused: ::c_int, 160 #[cfg(target_endian = "big")] 161 pub f_fsid: ::c_ulong, 162 pub f_flag: ::c_ulong, 163 pub f_namemax: ::c_ulong, 164 __f_spare: [::c_int; 6], 165 } 166 167 pub struct termios { 168 pub c_iflag: ::tcflag_t, 169 pub c_oflag: ::tcflag_t, 170 pub c_cflag: ::tcflag_t, 171 pub c_lflag: ::tcflag_t, 172 pub c_line: ::cc_t, 173 pub c_cc: [::cc_t; ::NCCS], 174 pub __c_ispeed: ::speed_t, 175 pub __c_ospeed: ::speed_t, 176 } 177 178 pub struct flock { 179 pub l_type: ::c_short, 180 pub l_whence: ::c_short, 181 pub l_start: ::off_t, 182 pub l_len: ::off_t, 183 pub l_pid: ::pid_t, 184 } 185 186 pub struct flock64 { 187 pub l_type: ::c_short, 188 pub l_whence: ::c_short, 189 pub l_start: ::off64_t, 190 pub l_len: ::off64_t, 191 pub l_pid: ::pid_t, 192 } 193 194 pub struct regex_t { 195 __re_nsub: ::size_t, 196 __opaque: *mut ::c_void, 197 __padding: [*mut ::c_void; 4usize], 198 __nsub2: ::size_t, 199 __padding2: ::c_char, 200 } 201 202 pub struct rtentry { 203 pub rt_pad1: ::c_ulong, 204 pub rt_dst: ::sockaddr, 205 pub rt_gateway: ::sockaddr, 206 pub rt_genmask: ::sockaddr, 207 pub rt_flags: ::c_ushort, 208 pub rt_pad2: ::c_short, 209 pub rt_pad3: ::c_ulong, 210 pub rt_tos: ::c_uchar, 211 pub rt_class: ::c_uchar, 212 #[cfg(target_pointer_width = "64")] 213 pub rt_pad4: [::c_short; 3usize], 214 #[cfg(not(target_pointer_width = "64"))] 215 pub rt_pad4: [::c_short; 1usize], 216 pub rt_metric: ::c_short, 217 pub rt_dev: *mut ::c_char, 218 pub rt_mtu: ::c_ulong, 219 pub rt_window: ::c_ulong, 220 pub rt_irtt: ::c_ushort, 221 } 222 223 pub struct __exit_status { 224 pub e_termination: ::c_short, 225 pub e_exit: ::c_short, 226 } 227 228 pub struct Elf64_Chdr { 229 pub ch_type: ::Elf64_Word, 230 pub ch_reserved: ::Elf64_Word, 231 pub ch_size: ::Elf64_Xword, 232 pub ch_addralign: ::Elf64_Xword, 233 } 234 235 pub struct Elf32_Chdr { 236 pub ch_type: ::Elf32_Word, 237 pub ch_size: ::Elf32_Word, 238 pub ch_addralign: ::Elf32_Word, 239 } 240 241 pub struct timex { 242 pub modes: ::c_uint, 243 pub offset: ::c_long, 244 pub freq: ::c_long, 245 pub maxerror: ::c_long, 246 pub esterror: ::c_long, 247 pub status: ::c_int, 248 pub constant: ::c_long, 249 pub precision: ::c_long, 250 pub tolerance: ::c_long, 251 pub time: ::timeval, 252 pub tick: ::c_long, 253 pub ppsfreq: ::c_long, 254 pub jitter: ::c_long, 255 pub shift: ::c_int, 256 pub stabil: ::c_long, 257 pub jitcnt: ::c_long, 258 pub calcnt: ::c_long, 259 pub errcnt: ::c_long, 260 pub stbcnt: ::c_long, 261 pub tai: ::c_int, 262 pub __padding: [::c_int; 11], 263 } 264 265 pub struct ntptimeval { 266 pub time: ::timeval, 267 pub maxerror: ::c_long, 268 pub esterror: ::c_long, 269 } 270 271 // linux/if_xdp.h 272 273 pub struct sockaddr_xdp { 274 pub sxdp_family: ::__u16, 275 pub sxdp_flags: ::__u16, 276 pub sxdp_ifindex: ::__u32, 277 pub sxdp_queue_id: ::__u32, 278 pub sxdp_shared_umem_fd: ::__u32, 279 } 280 281 pub struct xdp_ring_offset { 282 pub producer: ::__u64, 283 pub consumer: ::__u64, 284 pub desc: ::__u64, 285 pub flags: ::__u64, 286 } 287 288 pub struct xdp_mmap_offsets { 289 pub rx: xdp_ring_offset, 290 pub tx: xdp_ring_offset, 291 pub fr: xdp_ring_offset, 292 pub cr: xdp_ring_offset, 293 } 294 295 pub struct xdp_ring_offset_v1 { 296 pub producer: ::__u64, 297 pub consumer: ::__u64, 298 pub desc: ::__u64, 299 } 300 301 pub struct xdp_mmap_offsets_v1 { 302 pub rx: xdp_ring_offset_v1, 303 pub tx: xdp_ring_offset_v1, 304 pub fr: xdp_ring_offset_v1, 305 pub cr: xdp_ring_offset_v1, 306 } 307 308 pub struct xdp_umem_reg { 309 pub addr: ::__u64, 310 pub len: ::__u64, 311 pub chunk_size: ::__u32, 312 pub headroom: ::__u32, 313 pub flags: ::__u32, 314 pub tx_metadata_len: ::__u32, 315 } 316 317 pub struct xdp_umem_reg_v1 { 318 pub addr: ::__u64, 319 pub len: ::__u64, 320 pub chunk_size: ::__u32, 321 pub headroom: ::__u32, 322 } 323 324 pub struct xdp_statistics { 325 pub rx_dropped: ::__u64, 326 pub rx_invalid_descs: ::__u64, 327 pub tx_invalid_descs: ::__u64, 328 pub rx_ring_full: ::__u64, 329 pub rx_fill_ring_empty_descs: ::__u64, 330 pub tx_ring_empty_descs: ::__u64, 331 } 332 333 pub struct xdp_statistics_v1 { 334 pub rx_dropped: ::__u64, 335 pub rx_invalid_descs: ::__u64, 336 pub tx_invalid_descs: ::__u64, 337 } 338 339 pub struct xdp_options { 340 pub flags: ::__u32, 341 } 342 343 pub struct xdp_desc { 344 pub addr: ::__u64, 345 pub len: ::__u32, 346 pub options: ::__u32, 347 } 348 349 pub struct xsk_tx_metadata_completion { 350 pub tx_timestamp: ::__u64, 351 } 352 353 pub struct xsk_tx_metadata_request { 354 pub csum_start: ::__u16, 355 pub csum_offset: ::__u16, 356 } 357 358 // netinet/tcp.h 359 360 pub struct tcp_info { 361 pub tcpi_state: u8, 362 pub tcpi_ca_state: u8, 363 pub tcpi_retransmits: u8, 364 pub tcpi_probes: u8, 365 pub tcpi_backoff: u8, 366 pub tcpi_options: u8, 367 /* 368 * FIXME(musl): enable on all targets once musl headers are more up to date 369 */ 370 /// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`. 371 /// Each is 4 bits. 372 #[cfg(target_arch = "loongarch64")] 373 pub tcpi_snd_rcv_wscale: u8, 374 /// This contains the bitfields `tcpi_delivery_rate_app_limited` (1 bit) and 375 /// `tcpi_fastopen_client_fail` (2 bits). 376 #[cfg(target_arch = "loongarch64")] 377 pub tcpi_delivery_fastopen_bitfields: u8, 378 pub tcpi_rto: u32, 379 pub tcpi_ato: u32, 380 pub tcpi_snd_mss: u32, 381 pub tcpi_rcv_mss: u32, 382 pub tcpi_unacked: u32, 383 pub tcpi_sacked: u32, 384 pub tcpi_lost: u32, 385 pub tcpi_retrans: u32, 386 pub tcpi_fackets: u32, 387 pub tcpi_last_data_sent: u32, 388 pub tcpi_last_ack_sent: u32, 389 pub tcpi_last_data_recv: u32, 390 pub tcpi_last_ack_recv: u32, 391 pub tcpi_pmtu: u32, 392 pub tcpi_rcv_ssthresh: u32, 393 pub tcpi_rtt: u32, 394 pub tcpi_rttvar: u32, 395 pub tcpi_snd_ssthresh: u32, 396 pub tcpi_snd_cwnd: u32, 397 pub tcpi_advmss: u32, 398 pub tcpi_reordering: u32, 399 pub tcpi_rcv_rtt: u32, 400 pub tcpi_rcv_space: u32, 401 pub tcpi_total_retrans: u32, 402 pub tcpi_pacing_rate: u64, 403 pub tcpi_max_pacing_rate: u64, 404 pub tcpi_bytes_acked: u64, 405 pub tcpi_bytes_received: u64, 406 pub tcpi_segs_out: u32, 407 pub tcpi_segs_in: u32, 408 pub tcpi_notsent_bytes: u32, 409 pub tcpi_min_rtt: u32, 410 pub tcpi_data_segs_in: u32, 411 pub tcpi_data_segs_out: u32, 412 pub tcpi_delivery_rate: u64, 413 pub tcpi_busy_time: u64, 414 pub tcpi_rwnd_limited: u64, 415 pub tcpi_sndbuf_limited: u64, 416 pub tcpi_delivered: u32, 417 pub tcpi_delivered_ce: u32, 418 pub tcpi_bytes_sent: u64, 419 pub tcpi_bytes_retrans: u64, 420 pub tcpi_dsack_dups: u32, 421 pub tcpi_reord_seen: u32, 422 // FIXME(musl): enable on all targets once CI musl is updated 423 #[cfg(target_arch = "loongarch64")] 424 pub tcpi_rcv_ooopack: u32, 425 #[cfg(target_arch = "loongarch64")] 426 pub tcpi_snd_wnd: u32, 427 } 428 } 429 430 s_no_extra_traits! { 431 pub struct sysinfo { 432 pub uptime: ::c_ulong, 433 pub loads: [::c_ulong; 3], 434 pub totalram: ::c_ulong, 435 pub freeram: ::c_ulong, 436 pub sharedram: ::c_ulong, 437 pub bufferram: ::c_ulong, 438 pub totalswap: ::c_ulong, 439 pub freeswap: ::c_ulong, 440 pub procs: ::c_ushort, 441 pub pad: ::c_ushort, 442 pub totalhigh: ::c_ulong, 443 pub freehigh: ::c_ulong, 444 pub mem_unit: ::c_uint, 445 pub __reserved: [::c_char; 256], 446 } 447 448 // FIXME: musl added paddings and adjusted 449 // layout in 1.2.0 but our CI is still 1.1.24. 450 // So, I'm leaving some fields as cfg for now. 451 // ref. https://github.com/bminor/musl/commit/ 452 // 1e7f0fcd7ff2096904fd93a2ee6d12a2392be392 453 // 454 // OpenHarmony uses the musl 1.2 layout. 455 pub struct utmpx { 456 pub ut_type: ::c_short, 457 __ut_pad1: ::c_short, 458 pub ut_pid: ::pid_t, 459 pub ut_line: [::c_char; 32], 460 pub ut_id: [::c_char; 4], 461 pub ut_user: [::c_char; 32], 462 pub ut_host: [::c_char; 256], 463 pub ut_exit: __exit_status, 464 465 #[cfg(target_env = "musl")] 466 #[cfg(not(target_arch = "loongarch64"))] 467 pub ut_session: ::c_long, 468 469 #[cfg(target_env = "musl")] 470 #[cfg(target_arch = "loongarch64")] 471 pub ut_session: ::c_int, 472 473 #[cfg(target_env = "musl")] 474 #[cfg(target_arch = "loongarch64")] 475 __ut_pad2: ::c_int, 476 477 #[cfg(target_env = "ohos")] 478 #[cfg(target_endian = "little")] 479 pub ut_session: ::c_int, 480 #[cfg(target_env = "ohos")] 481 #[cfg(target_endian = "little")] 482 __ut_pad2: ::c_int, 483 484 #[cfg(target_env = "ohos")] 485 #[cfg(not(target_endian = "little"))] 486 __ut_pad2: ::c_int, 487 #[cfg(target_env = "ohos")] 488 #[cfg(not(target_endian = "little"))] 489 pub ut_session: ::c_int, 490 491 pub ut_tv: ::timeval, 492 pub ut_addr_v6: [::c_uint; 4], 493 __unused: [::c_char; 20], 494 } 495 496 #[allow(missing_debug_implementations)] 497 pub struct xsk_tx_metadata { 498 pub flags: ::__u64, 499 pub xsk_tx_metadata_union: __c_anonymous_xsk_tx_metadata_union, 500 } 501 502 #[allow(missing_debug_implementations)] 503 pub union __c_anonymous_xsk_tx_metadata_union { 504 pub request: xsk_tx_metadata_request, 505 pub completion: xsk_tx_metadata_completion, 506 } 507 } 508 509 cfg_if! { 510 if #[cfg(feature = "extra_traits")] { 511 impl PartialEq for sysinfo { 512 fn eq(&self, other: &sysinfo) -> bool { 513 self.uptime == other.uptime 514 && self.loads == other.loads 515 && self.totalram == other.totalram 516 && self.freeram == other.freeram 517 && self.sharedram == other.sharedram 518 && self.bufferram == other.bufferram 519 && self.totalswap == other.totalswap 520 && self.freeswap == other.freeswap 521 && self.procs == other.procs 522 && self.pad == other.pad 523 && self.totalhigh == other.totalhigh 524 && self.freehigh == other.freehigh 525 && self.mem_unit == other.mem_unit 526 && self 527 .__reserved 528 .iter() 529 .zip(other.__reserved.iter()) 530 .all(|(a, b)| a == b) 531 } 532 } 533 534 impl Eq for sysinfo {} 535 536 impl ::fmt::Debug for sysinfo { 537 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { 538 f.debug_struct("sysinfo") 539 .field("uptime", &self.uptime) 540 .field("loads", &self.loads) 541 .field("totalram", &self.totalram) 542 .field("freeram", &self.freeram) 543 .field("sharedram", &self.sharedram) 544 .field("bufferram", &self.bufferram) 545 .field("totalswap", &self.totalswap) 546 .field("freeswap", &self.freeswap) 547 .field("procs", &self.procs) 548 .field("pad", &self.pad) 549 .field("totalhigh", &self.totalhigh) 550 .field("freehigh", &self.freehigh) 551 .field("mem_unit", &self.mem_unit) 552 // FIXME: .field("__reserved", &self.__reserved) 553 .finish() 554 } 555 } 556 557 impl ::hash::Hash for sysinfo { 558 fn hash<H: ::hash::Hasher>(&self, state: &mut H) { 559 self.uptime.hash(state); 560 self.loads.hash(state); 561 self.totalram.hash(state); 562 self.freeram.hash(state); 563 self.sharedram.hash(state); 564 self.bufferram.hash(state); 565 self.totalswap.hash(state); 566 self.freeswap.hash(state); 567 self.procs.hash(state); 568 self.pad.hash(state); 569 self.totalhigh.hash(state); 570 self.freehigh.hash(state); 571 self.mem_unit.hash(state); 572 self.__reserved.hash(state); 573 } 574 } 575 576 impl PartialEq for utmpx { 577 fn eq(&self, other: &utmpx) -> bool { 578 self.ut_type == other.ut_type 579 //&& self.__ut_pad1 == other.__ut_pad1 580 && self.ut_pid == other.ut_pid 581 && self.ut_line == other.ut_line 582 && self.ut_id == other.ut_id 583 && self.ut_user == other.ut_user 584 && self 585 .ut_host 586 .iter() 587 .zip(other.ut_host.iter()) 588 .all(|(a,b)| a == b) 589 && self.ut_exit == other.ut_exit 590 && self.ut_session == other.ut_session 591 //&& self.__ut_pad2 == other.__ut_pad2 592 && self.ut_tv == other.ut_tv 593 && self.ut_addr_v6 == other.ut_addr_v6 594 && self.__unused == other.__unused 595 } 596 } 597 598 impl Eq for utmpx {} 599 600 impl ::fmt::Debug for utmpx { 601 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { 602 f.debug_struct("utmpx") 603 .field("ut_type", &self.ut_type) 604 //.field("__ut_pad1", &self.__ut_pad1) 605 .field("ut_pid", &self.ut_pid) 606 .field("ut_line", &self.ut_line) 607 .field("ut_id", &self.ut_id) 608 .field("ut_user", &self.ut_user) 609 //FIXME: .field("ut_host", &self.ut_host) 610 .field("ut_exit", &self.ut_exit) 611 .field("ut_session", &self.ut_session) 612 //.field("__ut_pad2", &self.__ut_pad2) 613 .field("ut_tv", &self.ut_tv) 614 .field("ut_addr_v6", &self.ut_addr_v6) 615 .field("__unused", &self.__unused) 616 .finish() 617 } 618 } 619 620 impl ::hash::Hash for utmpx { 621 fn hash<H: ::hash::Hasher>(&self, state: &mut H) { 622 self.ut_type.hash(state); 623 //self.__ut_pad1.hash(state); 624 self.ut_pid.hash(state); 625 self.ut_line.hash(state); 626 self.ut_id.hash(state); 627 self.ut_user.hash(state); 628 self.ut_host.hash(state); 629 self.ut_exit.hash(state); 630 self.ut_session.hash(state); 631 //self.__ut_pad2.hash(state); 632 self.ut_tv.hash(state); 633 self.ut_addr_v6.hash(state); 634 self.__unused.hash(state); 635 } 636 } 637 } 638 } 639 640 // include/sys/mman.h 641 /* 642 * Huge page size encoding when MAP_HUGETLB is specified, and a huge page 643 * size other than the default is desired. See hugetlb_encode.h. 644 * All known huge page size encodings are provided here. It is the 645 * responsibility of the application to know which sizes are supported on 646 * the running system. See mmap(2) man page for details. 647 */ 648 pub const MAP_HUGE_SHIFT: ::c_int = 26; 649 pub const MAP_HUGE_MASK: ::c_int = 0x3f; 650 651 pub const MAP_HUGE_64KB: ::c_int = 16 << MAP_HUGE_SHIFT; 652 pub const MAP_HUGE_512KB: ::c_int = 19 << MAP_HUGE_SHIFT; 653 pub const MAP_HUGE_1MB: ::c_int = 20 << MAP_HUGE_SHIFT; 654 pub const MAP_HUGE_2MB: ::c_int = 21 << MAP_HUGE_SHIFT; 655 pub const MAP_HUGE_8MB: ::c_int = 23 << MAP_HUGE_SHIFT; 656 pub const MAP_HUGE_16MB: ::c_int = 24 << MAP_HUGE_SHIFT; 657 pub const MAP_HUGE_32MB: ::c_int = 25 << MAP_HUGE_SHIFT; 658 pub const MAP_HUGE_256MB: ::c_int = 28 << MAP_HUGE_SHIFT; 659 pub const MAP_HUGE_512MB: ::c_int = 29 << MAP_HUGE_SHIFT; 660 pub const MAP_HUGE_1GB: ::c_int = 30 << MAP_HUGE_SHIFT; 661 pub const MAP_HUGE_2GB: ::c_int = 31 << MAP_HUGE_SHIFT; 662 pub const MAP_HUGE_16GB: ::c_int = 34 << MAP_HUGE_SHIFT; 663 664 pub const MS_RMT_MASK: ::c_ulong = 0x02800051; 665 666 // include/utmpx.h 667 pub const EMPTY: ::c_short = 0; 668 pub const RUN_LVL: ::c_short = 1; 669 pub const BOOT_TIME: ::c_short = 2; 670 pub const NEW_TIME: ::c_short = 3; 671 pub const OLD_TIME: ::c_short = 4; 672 pub const INIT_PROCESS: ::c_short = 5; 673 pub const LOGIN_PROCESS: ::c_short = 6; 674 pub const USER_PROCESS: ::c_short = 7; 675 pub const DEAD_PROCESS: ::c_short = 8; 676 // musl does not define ACCOUNTING 677 678 pub const SFD_CLOEXEC: ::c_int = 0x080000; 679 680 pub const NCCS: usize = 32; 681 682 pub const O_TRUNC: ::c_int = 512; 683 pub const O_NOATIME: ::c_int = 0o1000000; 684 pub const O_CLOEXEC: ::c_int = 0x80000; 685 pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; 686 687 pub const EBFONT: ::c_int = 59; 688 pub const ENOSTR: ::c_int = 60; 689 pub const ENODATA: ::c_int = 61; 690 pub const ETIME: ::c_int = 62; 691 pub const ENOSR: ::c_int = 63; 692 pub const ENONET: ::c_int = 64; 693 pub const ENOPKG: ::c_int = 65; 694 pub const EREMOTE: ::c_int = 66; 695 pub const ENOLINK: ::c_int = 67; 696 pub const EADV: ::c_int = 68; 697 pub const ESRMNT: ::c_int = 69; 698 pub const ECOMM: ::c_int = 70; 699 pub const EPROTO: ::c_int = 71; 700 pub const EDOTDOT: ::c_int = 73; 701 702 pub const F_OFD_GETLK: ::c_int = 36; 703 pub const F_OFD_SETLK: ::c_int = 37; 704 pub const F_OFD_SETLKW: ::c_int = 38; 705 706 pub const F_RDLCK: ::c_int = 0; 707 pub const F_WRLCK: ::c_int = 1; 708 pub const F_UNLCK: ::c_int = 2; 709 710 pub const SA_NODEFER: ::c_int = 0x40000000; 711 pub const SA_RESETHAND: ::c_int = 0x80000000; 712 pub const SA_RESTART: ::c_int = 0x10000000; 713 pub const SA_NOCLDSTOP: ::c_int = 0x00000001; 714 715 pub const EPOLL_CLOEXEC: ::c_int = 0x80000; 716 717 pub const EFD_CLOEXEC: ::c_int = 0x80000; 718 719 pub const BUFSIZ: ::c_uint = 1024; 720 pub const TMP_MAX: ::c_uint = 10000; 721 pub const FOPEN_MAX: ::c_uint = 1000; 722 pub const FILENAME_MAX: ::c_uint = 4096; 723 pub const O_PATH: ::c_int = 0o10000000; 724 pub const O_EXEC: ::c_int = 0o10000000; 725 pub const O_SEARCH: ::c_int = 0o10000000; 726 pub const O_ACCMODE: ::c_int = 0o10000003; 727 pub const O_NDELAY: ::c_int = O_NONBLOCK; 728 pub const NI_MAXHOST: ::socklen_t = 255; 729 pub const PTHREAD_STACK_MIN: ::size_t = 2048; 730 731 pub const POSIX_MADV_DONTNEED: ::c_int = 4; 732 733 pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; 734 735 pub const SOCK_SEQPACKET: ::c_int = 5; 736 pub const SOCK_DCCP: ::c_int = 6; 737 pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK; 738 pub const SOCK_PACKET: ::c_int = 10; 739 740 pub const SOMAXCONN: ::c_int = 128; 741 742 #[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] 743 pub const SIGUNUSED: ::c_int = ::SIGSYS; 744 745 pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; 746 pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; 747 pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; 748 pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; 749 750 #[cfg(not(target_arch = "loongarch64"))] 751 pub const CPU_SETSIZE: ::c_int = 128; 752 #[cfg(target_arch = "loongarch64")] 753 pub const CPU_SETSIZE: ::c_int = 1024; 754 755 pub const PTRACE_TRACEME: ::c_int = 0; 756 pub const PTRACE_PEEKTEXT: ::c_int = 1; 757 pub const PTRACE_PEEKDATA: ::c_int = 2; 758 pub const PTRACE_PEEKUSER: ::c_int = 3; 759 pub const PTRACE_POKETEXT: ::c_int = 4; 760 pub const PTRACE_POKEDATA: ::c_int = 5; 761 pub const PTRACE_POKEUSER: ::c_int = 6; 762 pub const PTRACE_CONT: ::c_int = 7; 763 pub const PTRACE_KILL: ::c_int = 8; 764 pub const PTRACE_SINGLESTEP: ::c_int = 9; 765 pub const PTRACE_GETREGS: ::c_int = 12; 766 pub const PTRACE_SETREGS: ::c_int = 13; 767 pub const PTRACE_GETFPREGS: ::c_int = 14; 768 pub const PTRACE_SETFPREGS: ::c_int = 15; 769 pub const PTRACE_ATTACH: ::c_int = 16; 770 pub const PTRACE_DETACH: ::c_int = 17; 771 pub const PTRACE_GETFPXREGS: ::c_int = 18; 772 pub const PTRACE_SETFPXREGS: ::c_int = 19; 773 pub const PTRACE_SYSCALL: ::c_int = 24; 774 pub const PTRACE_SETOPTIONS: ::c_int = 0x4200; 775 pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201; 776 pub const PTRACE_GETSIGINFO: ::c_int = 0x4202; 777 pub const PTRACE_SETSIGINFO: ::c_int = 0x4203; 778 pub const PTRACE_GETREGSET: ::c_int = 0x4204; 779 pub const PTRACE_SETREGSET: ::c_int = 0x4205; 780 pub const PTRACE_SEIZE: ::c_int = 0x4206; 781 pub const PTRACE_INTERRUPT: ::c_int = 0x4207; 782 pub const PTRACE_LISTEN: ::c_int = 0x4208; 783 pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209; 784 pub const PTRACE_GETSIGMASK: ::c_uint = 0x420a; 785 pub const PTRACE_SETSIGMASK: ::c_uint = 0x420b; 786 787 pub const RWF_HIPRI: ::c_int = 0x00000001; 788 pub const RWF_DSYNC: ::c_int = 0x00000002; 789 pub const RWF_SYNC: ::c_int = 0x00000004; 790 pub const RWF_NOWAIT: ::c_int = 0x00000008; 791 pub const RWF_APPEND: ::c_int = 0x00000010; 792 793 pub const AF_IB: ::c_int = 27; 794 pub const AF_MPLS: ::c_int = 28; 795 pub const AF_NFC: ::c_int = 39; 796 pub const AF_VSOCK: ::c_int = 40; 797 pub const AF_XDP: ::c_int = 44; 798 pub const PF_IB: ::c_int = AF_IB; 799 pub const PF_MPLS: ::c_int = AF_MPLS; 800 pub const PF_NFC: ::c_int = AF_NFC; 801 pub const PF_VSOCK: ::c_int = AF_VSOCK; 802 pub const PF_XDP: ::c_int = AF_XDP; 803 804 pub const EFD_NONBLOCK: ::c_int = ::O_NONBLOCK; 805 806 pub const SFD_NONBLOCK: ::c_int = ::O_NONBLOCK; 807 808 pub const PIDFD_NONBLOCK: ::c_uint = O_NONBLOCK as ::c_uint; 809 810 pub const TCSANOW: ::c_int = 0; 811 pub const TCSADRAIN: ::c_int = 1; 812 pub const TCSAFLUSH: ::c_int = 2; 813 814 pub const RTLD_GLOBAL: ::c_int = 0x100; 815 pub const RTLD_NOLOAD: ::c_int = 0x4; 816 817 pub const CLOCK_SGI_CYCLE: ::clockid_t = 10; 818 819 pub const B0: ::speed_t = 0o000000; 820 pub const B50: ::speed_t = 0o000001; 821 pub const B75: ::speed_t = 0o000002; 822 pub const B110: ::speed_t = 0o000003; 823 pub const B134: ::speed_t = 0o000004; 824 pub const B150: ::speed_t = 0o000005; 825 pub const B200: ::speed_t = 0o000006; 826 pub const B300: ::speed_t = 0o000007; 827 pub const B600: ::speed_t = 0o000010; 828 pub const B1200: ::speed_t = 0o000011; 829 pub const B1800: ::speed_t = 0o000012; 830 pub const B2400: ::speed_t = 0o000013; 831 pub const B4800: ::speed_t = 0o000014; 832 pub const B9600: ::speed_t = 0o000015; 833 pub const B19200: ::speed_t = 0o000016; 834 pub const B38400: ::speed_t = 0o000017; 835 pub const EXTA: ::speed_t = B19200; 836 pub const EXTB: ::speed_t = B38400; 837 838 pub const REG_OK: ::c_int = 0; 839 840 pub const PRIO_PROCESS: ::c_int = 0; 841 pub const PRIO_PGRP: ::c_int = 1; 842 pub const PRIO_USER: ::c_int = 2; 843 844 pub const ADJ_OFFSET: ::c_uint = 0x0001; 845 pub const ADJ_FREQUENCY: ::c_uint = 0x0002; 846 pub const ADJ_MAXERROR: ::c_uint = 0x0004; 847 pub const ADJ_ESTERROR: ::c_uint = 0x0008; 848 pub const ADJ_STATUS: ::c_uint = 0x0010; 849 pub const ADJ_TIMECONST: ::c_uint = 0x0020; 850 pub const ADJ_TAI: ::c_uint = 0x0080; 851 pub const ADJ_SETOFFSET: ::c_uint = 0x0100; 852 pub const ADJ_MICRO: ::c_uint = 0x1000; 853 pub const ADJ_NANO: ::c_uint = 0x2000; 854 pub const ADJ_TICK: ::c_uint = 0x4000; 855 pub const ADJ_OFFSET_SINGLESHOT: ::c_uint = 0x8001; 856 pub const ADJ_OFFSET_SS_READ: ::c_uint = 0xa001; 857 pub const MOD_OFFSET: ::c_uint = ADJ_OFFSET; 858 pub const MOD_FREQUENCY: ::c_uint = ADJ_FREQUENCY; 859 pub const MOD_MAXERROR: ::c_uint = ADJ_MAXERROR; 860 pub const MOD_ESTERROR: ::c_uint = ADJ_ESTERROR; 861 pub const MOD_STATUS: ::c_uint = ADJ_STATUS; 862 pub const MOD_TIMECONST: ::c_uint = ADJ_TIMECONST; 863 pub const MOD_CLKB: ::c_uint = ADJ_TICK; 864 pub const MOD_CLKA: ::c_uint = ADJ_OFFSET_SINGLESHOT; 865 pub const MOD_TAI: ::c_uint = ADJ_TAI; 866 pub const MOD_MICRO: ::c_uint = ADJ_MICRO; 867 pub const MOD_NANO: ::c_uint = ADJ_NANO; 868 pub const STA_PLL: ::c_int = 0x0001; 869 pub const STA_PPSFREQ: ::c_int = 0x0002; 870 pub const STA_PPSTIME: ::c_int = 0x0004; 871 pub const STA_FLL: ::c_int = 0x0008; 872 pub const STA_INS: ::c_int = 0x0010; 873 pub const STA_DEL: ::c_int = 0x0020; 874 pub const STA_UNSYNC: ::c_int = 0x0040; 875 pub const STA_FREQHOLD: ::c_int = 0x0080; 876 pub const STA_PPSSIGNAL: ::c_int = 0x0100; 877 pub const STA_PPSJITTER: ::c_int = 0x0200; 878 pub const STA_PPSWANDER: ::c_int = 0x0400; 879 pub const STA_PPSERROR: ::c_int = 0x0800; 880 pub const STA_CLOCKERR: ::c_int = 0x1000; 881 pub const STA_NANO: ::c_int = 0x2000; 882 pub const STA_MODE: ::c_int = 0x4000; 883 pub const STA_CLK: ::c_int = 0x8000; 884 pub const STA_RONLY: ::c_int = STA_PPSSIGNAL 885 | STA_PPSJITTER 886 | STA_PPSWANDER 887 | STA_PPSERROR 888 | STA_CLOCKERR 889 | STA_NANO 890 | STA_MODE 891 | STA_CLK; 892 893 pub const TIME_OK: ::c_int = 0; 894 pub const TIME_INS: ::c_int = 1; 895 pub const TIME_DEL: ::c_int = 2; 896 pub const TIME_OOP: ::c_int = 3; 897 pub const TIME_WAIT: ::c_int = 4; 898 pub const TIME_ERROR: ::c_int = 5; 899 pub const TIME_BAD: ::c_int = TIME_ERROR; 900 pub const MAXTC: ::c_long = 6; 901 902 pub const SOL_XDP: ::c_int = 283; 903 904 // linux/if_xdp.h 905 pub const XDP_SHARED_UMEM: ::__u16 = 1 << 0; 906 pub const XDP_COPY: ::__u16 = 1 << 1; 907 pub const XDP_ZEROCOPY: ::__u16 = 1 << 2; 908 pub const XDP_USE_NEED_WAKEUP: ::__u16 = 1 << 3; 909 pub const XDP_USE_SG: ::__u16 = 1 << 4; 910 911 pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG: ::__u32 = 1 << 0; 912 pub const XDP_UMEM_TX_SW_CSUM: ::__u32 = 1 << 1; 913 pub const XDP_UMEM_TX_METADATA_LEN: ::__u32 = 1 << 2; 914 915 pub const XDP_RING_NEED_WAKEUP: ::__u32 = 1 << 0; 916 917 pub const XDP_MMAP_OFFSETS: ::c_int = 1; 918 pub const XDP_RX_RING: ::c_int = 2; 919 pub const XDP_TX_RING: ::c_int = 3; 920 pub const XDP_UMEM_REG: ::c_int = 4; 921 pub const XDP_UMEM_FILL_RING: ::c_int = 5; 922 pub const XDP_UMEM_COMPLETION_RING: ::c_int = 6; 923 pub const XDP_STATISTICS: ::c_int = 7; 924 pub const XDP_OPTIONS: ::c_int = 8; 925 926 pub const XDP_OPTIONS_ZEROCOPY: ::__u32 = 1 << 0; 927 928 pub const XDP_PGOFF_RX_RING: ::off_t = 0; 929 pub const XDP_PGOFF_TX_RING: ::off_t = 0x80000000; 930 pub const XDP_UMEM_PGOFF_FILL_RING: ::c_ulonglong = 0x100000000; 931 pub const XDP_UMEM_PGOFF_COMPLETION_RING: ::c_ulonglong = 0x180000000; 932 933 pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: ::c_int = 48; 934 pub const XSK_UNALIGNED_BUF_ADDR_MASK: ::c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1; 935 936 pub const XDP_TXMD_FLAGS_TIMESTAMP: ::__u32 = 1 << 0; 937 pub const XDP_TXMD_FLAGS_CHECKSUM: ::__u32 = 1 << 1; 938 939 pub const XDP_PKT_CONTD: ::__u32 = 1 << 0; 940 pub const XDP_TX_METADATA: ::__u32 = 1 << 1; 941 942 pub const _CS_V6_ENV: ::c_int = 1148; 943 pub const _CS_V7_ENV: ::c_int = 1149; 944 945 cfg_if! { 946 if #[cfg(target_arch = "s390x")] { 947 pub const POSIX_FADV_DONTNEED: ::c_int = 6; 948 pub const POSIX_FADV_NOREUSE: ::c_int = 7; 949 } else { 950 pub const POSIX_FADV_DONTNEED: ::c_int = 4; 951 pub const POSIX_FADV_NOREUSE: ::c_int = 5; 952 } 953 } 954 955 extern "C" { 956 pub fn sendmmsg( 957 sockfd: ::c_int, 958 msgvec: *mut ::mmsghdr, 959 vlen: ::c_uint, 960 flags: ::c_uint, 961 ) -> ::c_int; 962 pub fn recvmmsg( 963 sockfd: ::c_int, 964 msgvec: *mut ::mmsghdr, 965 vlen: ::c_uint, 966 flags: ::c_uint, 967 timeout: *mut ::timespec, 968 ) -> ::c_int; 969 970 pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; 971 pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; 972 pub fn prlimit( 973 pid: ::pid_t, 974 resource: ::c_int, 975 new_limit: *const ::rlimit, 976 old_limit: *mut ::rlimit, 977 ) -> ::c_int; 978 pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; 979 pub fn ptrace(request: ::c_int, ...) -> ::c_long; 980 pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; 981 pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; 982 // Musl targets need the `mask` argument of `fanotify_mark` be specified 983 // `::c_ulonglong` instead of `u64` or there will be a type mismatch between 984 // `long long unsigned int` and the expected `uint64_t`. 985 pub fn fanotify_mark( 986 fd: ::c_int, 987 flags: ::c_uint, 988 mask: ::c_ulonglong, 989 dirfd: ::c_int, 990 path: *const ::c_char, 991 ) -> ::c_int; 992 pub fn preadv2( 993 fd: ::c_int, 994 iov: *const ::iovec, 995 iovcnt: ::c_int, 996 offset: ::off_t, 997 flags: ::c_int, 998 ) -> ::ssize_t; 999 pub fn pwritev2( 1000 fd: ::c_int, 1001 iov: *const ::iovec, 1002 iovcnt: ::c_int, 1003 offset: ::off_t, 1004 flags: ::c_int, 1005 ) -> ::ssize_t; 1006 pub fn getauxval(type_: ::c_ulong) -> ::c_ulong; 1007 1008 // Added in `musl` 1.1.20 1009 pub fn explicit_bzero(s: *mut ::c_void, len: ::size_t); 1010 // Added in `musl` 1.2.2 1011 pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void; 1012 1013 pub fn adjtimex(buf: *mut ::timex) -> ::c_int; 1014 pub fn clock_adjtime(clk_id: ::clockid_t, buf: *mut ::timex) -> ::c_int; 1015 1016 pub fn ctermid(s: *mut ::c_char) -> *mut ::c_char; 1017 1018 pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int; 1019 pub fn mlock2(addr: *const ::c_void, len: ::size_t, flags: ::c_uint) -> ::c_int; 1020 pub fn malloc_usable_size(ptr: *mut ::c_void) -> ::size_t; 1021 1022 pub fn euidaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int; 1023 pub fn eaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int; 1024 1025 pub fn asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char; 1026 1027 pub fn dirname(path: *mut ::c_char) -> *mut ::c_char; 1028 pub fn basename(path: *mut ::c_char) -> *mut ::c_char; 1029 1030 // Added in `musl` 1.1.24 1031 pub fn posix_spawn_file_actions_addchdir_np( 1032 actions: *mut ::posix_spawn_file_actions_t, 1033 path: *const ::c_char, 1034 ) -> ::c_int; 1035 // Added in `musl` 1.1.24 1036 pub fn posix_spawn_file_actions_addfchdir_np( 1037 actions: *mut ::posix_spawn_file_actions_t, 1038 fd: ::c_int, 1039 ) -> ::c_int; 1040 1041 pub fn getutxent() -> *mut utmpx; 1042 pub fn getutxid(ut: *const utmpx) -> *mut utmpx; 1043 pub fn getutxline(ut: *const utmpx) -> *mut utmpx; 1044 pub fn pututxline(ut: *const utmpx) -> *mut utmpx; 1045 pub fn setutxent(); 1046 pub fn endutxent(); 1047 } 1048 1049 // Alias <foo> to <foo>64 to mimic glibc's LFS64 support 1050 mod lfs64; 1051 pub use self::lfs64::*; 1052 1053 cfg_if! { 1054 if #[cfg(any( 1055 target_arch = "x86_64", 1056 target_arch = "aarch64", 1057 target_arch = "mips64", 1058 target_arch = "powerpc64", 1059 target_arch = "s390x", 1060 target_arch = "riscv64", 1061 target_arch = "loongarch64" 1062 ))] { 1063 mod b64; 1064 pub use self::b64::*; 1065 } else if #[cfg(any( 1066 target_arch = "x86", 1067 target_arch = "mips", 1068 target_arch = "powerpc", 1069 target_arch = "hexagon", 1070 target_arch = "riscv32", 1071 target_arch = "arm" 1072 ))] { 1073 mod b32; 1074 pub use self::b32::*; 1075 } else { 1076 } 1077 } 1078