Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/libc/src/unix/linux_like/mod.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / libc / src / unix / linux_like / mod.rs` 2234 lines ยท 80253 bytes Raw Blame History 1 use crate::prelude::*; 2 3 pub type sa_family_t = u16; 4 pub type speed_t = c_uint; 5 pub type tcflag_t = c_uint; 6 pub type clockid_t = c_int; 7 pub type timer_t = *mut c_void; 8 pub type useconds_t = u32; 9 pub type key_t = c_int; 10 pub type id_t = c_uint; 11 12 extern_ty! { 13 pub type timezone; 14 } 15 16 s! { 17 pub struct in_addr { 18 pub s_addr: crate::in_addr_t, 19 } 20 21 pub struct ip_mreq { 22 pub imr_multiaddr: in_addr, 23 pub imr_interface: in_addr, 24 } 25 26 pub struct ip_mreqn { 27 pub imr_multiaddr: in_addr, 28 pub imr_address: in_addr, 29 pub imr_ifindex: c_int, 30 } 31 32 pub struct ip_mreq_source { 33 pub imr_multiaddr: in_addr, 34 pub imr_interface: in_addr, 35 pub imr_sourceaddr: in_addr, 36 } 37 38 pub struct sockaddr { 39 pub sa_family: sa_family_t, 40 pub sa_data: [c_char; 14], 41 } 42 43 pub struct sockaddr_in { 44 pub sin_family: sa_family_t, 45 pub sin_port: crate::in_port_t, 46 pub sin_addr: crate::in_addr, 47 pub sin_zero: [u8; 8], 48 } 49 50 pub struct sockaddr_in6 { 51 pub sin6_family: sa_family_t, 52 pub sin6_port: crate::in_port_t, 53 pub sin6_flowinfo: u32, 54 pub sin6_addr: crate::in6_addr, 55 pub sin6_scope_id: u32, 56 } 57 58 // The order of the `ai_addr` field in this struct is crucial 59 // for converting between the Rust and C types. 60 pub struct addrinfo { 61 pub ai_flags: c_int, 62 pub ai_family: c_int, 63 pub ai_socktype: c_int, 64 pub ai_protocol: c_int, 65 pub ai_addrlen: socklen_t, 66 67 #[cfg(not(target_os = "android"))] 68 pub ai_addr: *mut crate::sockaddr, 69 70 pub ai_canonname: *mut c_char, 71 72 #[cfg(target_os = "android")] 73 pub ai_addr: *mut crate::sockaddr, 74 75 pub ai_next: *mut addrinfo, 76 } 77 78 pub struct sockaddr_ll { 79 pub sll_family: c_ushort, 80 pub sll_protocol: c_ushort, 81 pub sll_ifindex: c_int, 82 pub sll_hatype: c_ushort, 83 pub sll_pkttype: c_uchar, 84 pub sll_halen: c_uchar, 85 pub sll_addr: [c_uchar; 8], 86 } 87 88 pub struct fd_set { 89 fds_bits: [c_ulong; FD_SETSIZE as usize / ULONG_SIZE], 90 } 91 92 pub struct tm { 93 pub tm_sec: c_int, 94 pub tm_min: c_int, 95 pub tm_hour: c_int, 96 pub tm_mday: c_int, 97 pub tm_mon: c_int, 98 pub tm_year: c_int, 99 pub tm_wday: c_int, 100 pub tm_yday: c_int, 101 pub tm_isdst: c_int, 102 pub tm_gmtoff: c_long, 103 pub tm_zone: *const c_char, 104 } 105 106 #[cfg(not(any(target_env = "musl", target_os = "emscripten", target_env = "ohos")))] 107 pub struct sched_param { 108 pub sched_priority: c_int, 109 } 110 111 pub struct Dl_info { 112 pub dli_fname: *const c_char, 113 pub dli_fbase: *mut c_void, 114 pub dli_sname: *const c_char, 115 pub dli_saddr: *mut c_void, 116 } 117 118 pub struct lconv { 119 pub decimal_point: *mut c_char, 120 pub thousands_sep: *mut c_char, 121 pub grouping: *mut c_char, 122 pub int_curr_symbol: *mut c_char, 123 pub currency_symbol: *mut c_char, 124 pub mon_decimal_point: *mut c_char, 125 pub mon_thousands_sep: *mut c_char, 126 pub mon_grouping: *mut c_char, 127 pub positive_sign: *mut c_char, 128 pub negative_sign: *mut c_char, 129 pub int_frac_digits: c_char, 130 pub frac_digits: c_char, 131 pub p_cs_precedes: c_char, 132 pub p_sep_by_space: c_char, 133 pub n_cs_precedes: c_char, 134 pub n_sep_by_space: c_char, 135 pub p_sign_posn: c_char, 136 pub n_sign_posn: c_char, 137 pub int_p_cs_precedes: c_char, 138 pub int_p_sep_by_space: c_char, 139 pub int_n_cs_precedes: c_char, 140 pub int_n_sep_by_space: c_char, 141 pub int_p_sign_posn: c_char, 142 pub int_n_sign_posn: c_char, 143 } 144 145 pub struct in_pktinfo { 146 pub ipi_ifindex: c_int, 147 pub ipi_spec_dst: crate::in_addr, 148 pub ipi_addr: crate::in_addr, 149 } 150 151 pub struct ifaddrs { 152 pub ifa_next: *mut ifaddrs, 153 pub ifa_name: *mut c_char, 154 pub ifa_flags: c_uint, 155 pub ifa_addr: *mut crate::sockaddr, 156 pub ifa_netmask: *mut crate::sockaddr, 157 pub ifa_ifu: *mut crate::sockaddr, // FIXME(union) This should be a union 158 pub ifa_data: *mut c_void, 159 } 160 161 pub struct in6_rtmsg { 162 rtmsg_dst: crate::in6_addr, 163 rtmsg_src: crate::in6_addr, 164 rtmsg_gateway: crate::in6_addr, 165 rtmsg_type: u32, 166 rtmsg_dst_len: u16, 167 rtmsg_src_len: u16, 168 rtmsg_metric: u32, 169 rtmsg_info: c_ulong, 170 rtmsg_flags: u32, 171 rtmsg_ifindex: c_int, 172 } 173 174 pub struct arpreq { 175 pub arp_pa: crate::sockaddr, 176 pub arp_ha: crate::sockaddr, 177 pub arp_flags: c_int, 178 pub arp_netmask: crate::sockaddr, 179 pub arp_dev: [c_char; 16], 180 } 181 182 pub struct arpreq_old { 183 pub arp_pa: crate::sockaddr, 184 pub arp_ha: crate::sockaddr, 185 pub arp_flags: c_int, 186 pub arp_netmask: crate::sockaddr, 187 } 188 189 pub struct arphdr { 190 pub ar_hrd: u16, 191 pub ar_pro: u16, 192 pub ar_hln: u8, 193 pub ar_pln: u8, 194 pub ar_op: u16, 195 } 196 197 pub struct mmsghdr { 198 pub msg_hdr: crate::msghdr, 199 pub msg_len: c_uint, 200 } 201 202 pub struct sockaddr_un { 203 pub sun_family: sa_family_t, 204 pub sun_path: [c_char; 108], 205 } 206 207 pub struct sockaddr_storage { 208 pub ss_family: sa_family_t, 209 #[cfg(target_pointer_width = "32")] 210 __ss_pad2: Padding<[u8; 128 - 2 - 4]>, 211 #[cfg(target_pointer_width = "64")] 212 __ss_pad2: Padding<[u8; 128 - 2 - 8]>, 213 __ss_align: size_t, 214 } 215 216 pub struct utsname { 217 pub sysname: [c_char; 65], 218 pub nodename: [c_char; 65], 219 pub release: [c_char; 65], 220 pub version: [c_char; 65], 221 pub machine: [c_char; 65], 222 pub domainname: [c_char; 65], 223 } 224 225 pub struct if_nameindex { 226 pub if_index: c_uint, 227 pub if_name: *mut c_char, 228 } 229 } 230 231 cfg_if! { 232 if #[cfg(not(any(target_os = "emscripten", target_os = "l4re")))] { 233 s! { 234 pub struct file_clone_range { 235 pub src_fd: crate::__s64, 236 pub src_offset: crate::__u64, 237 pub src_length: crate::__u64, 238 pub dest_offset: crate::__u64, 239 } 240 241 // linux/filter.h 242 pub struct sock_filter { 243 pub code: crate::__u16, 244 pub jt: crate::__u8, 245 pub jf: crate::__u8, 246 pub k: crate::__u32, 247 } 248 249 pub struct sock_fprog { 250 pub len: c_ushort, 251 pub filter: *mut sock_filter, 252 } 253 } 254 } 255 } 256 257 cfg_if! { 258 if #[cfg(any( 259 target_env = "gnu", 260 target_os = "android", 261 all(target_env = "musl", musl_v1_2_3) 262 ))] { 263 s! { 264 pub struct statx { 265 pub stx_mask: crate::__u32, 266 pub stx_blksize: crate::__u32, 267 pub stx_attributes: crate::__u64, 268 pub stx_nlink: crate::__u32, 269 pub stx_uid: crate::__u32, 270 pub stx_gid: crate::__u32, 271 pub stx_mode: crate::__u16, 272 __statx_pad1: Padding<[crate::__u16; 1]>, 273 pub stx_ino: crate::__u64, 274 pub stx_size: crate::__u64, 275 pub stx_blocks: crate::__u64, 276 pub stx_attributes_mask: crate::__u64, 277 pub stx_atime: statx_timestamp, 278 pub stx_btime: statx_timestamp, 279 pub stx_ctime: statx_timestamp, 280 pub stx_mtime: statx_timestamp, 281 pub stx_rdev_major: crate::__u32, 282 pub stx_rdev_minor: crate::__u32, 283 pub stx_dev_major: crate::__u32, 284 pub stx_dev_minor: crate::__u32, 285 pub stx_mnt_id: crate::__u64, 286 pub stx_dio_mem_align: crate::__u32, 287 pub stx_dio_offset_align: crate::__u32, 288 // The following fields are not available on Android as of 289 // 2026-06. 290 #[cfg(target_os = "linux")] 291 pub stx_subvol: crate::__u64, 292 #[cfg(target_os = "linux")] 293 pub stx_atomic_write_unit_min: crate::__u32, 294 #[cfg(target_os = "linux")] 295 pub stx_atomic_write_unit_max: crate::__u32, 296 #[cfg(target_os = "linux")] 297 pub stx_atomic_write_segments_max: crate::__u32, 298 #[cfg(target_os = "linux")] 299 pub stx_dio_read_offset_align: crate::__u32, 300 #[cfg(target_os = "linux")] 301 pub stx_atomic_write_unit_max_opt: crate::__u32, 302 #[cfg(target_os = "linux")] 303 __statx_pad2: Padding<[crate::__u32; 1]>, 304 #[cfg(target_os = "linux")] 305 __statx_pad3: Padding<[crate::__u64; 8]>, 306 #[cfg(not(target_os = "linux"))] 307 __statx_pad3: Padding<[crate::__u64; 12]>, 308 } 309 310 pub struct statx_timestamp { 311 pub tv_sec: crate::__s64, 312 pub tv_nsec: crate::__u32, 313 __statx_timestamp_pad1: Padding<[crate::__s32; 1]>, 314 } 315 } 316 } 317 } 318 319 s_no_extra_traits! { 320 #[cfg_attr( 321 any(target_arch = "x86_64", all(target_arch = "x86", target_env = "gnu")), 322 repr(packed) 323 )] 324 pub struct epoll_event { 325 pub events: u32, 326 pub u64: u64, 327 } 328 329 pub struct sigevent { 330 pub sigev_value: crate::sigval, 331 pub sigev_signo: c_int, 332 pub sigev_notify: c_int, 333 // Actually a union. We only expose sigev_notify_thread_id because it's 334 // the most useful member 335 pub sigev_notify_thread_id: c_int, 336 #[cfg(target_pointer_width = "64")] 337 __unused1: Padding<[c_int; 11]>, 338 #[cfg(target_pointer_width = "32")] 339 __unused1: Padding<[c_int; 12]>, 340 } 341 } 342 343 cfg_if! { 344 if #[cfg(all(feature = "extra_traits", not(target_os = "l4re")))] { 345 impl PartialEq for epoll_event { 346 fn eq(&self, other: &epoll_event) -> bool { 347 self.events == other.events && self.u64 == other.u64 348 } 349 } 350 impl Eq for epoll_event {} 351 impl hash::Hash for epoll_event { 352 fn hash(&self, state: &mut H) { 353 let events = self.events; 354 let u64 = self.u64; 355 events.hash(state); 356 u64.hash(state); 357 } 358 } 359 360 impl PartialEq for sigevent { 361 fn eq(&self, other: &sigevent) -> bool { 362 self.sigev_value == other.sigev_value 363 && self.sigev_signo == other.sigev_signo 364 && self.sigev_notify == other.sigev_notify 365 && self.sigev_notify_thread_id == other.sigev_notify_thread_id 366 } 367 } 368 impl Eq for sigevent {} 369 impl hash::Hash for sigevent { 370 fn hash(&self, state: &mut H) { 371 self.sigev_value.hash(state); 372 self.sigev_signo.hash(state); 373 self.sigev_notify.hash(state); 374 self.sigev_notify_thread_id.hash(state); 375 } 376 } 377 } 378 } 379 380 // intentionally not public, only used for fd_set 381 cfg_if! { 382 if #[cfg(target_pointer_width = "32")] { 383 const ULONG_SIZE: usize = 32; 384 } else if #[cfg(target_pointer_width = "64")] { 385 const ULONG_SIZE: usize = 64; 386 } else { 387 // Unknown target_pointer_width 388 } 389 } 390 391 pub const EXIT_FAILURE: c_int = 1; 392 pub const EXIT_SUCCESS: c_int = 0; 393 pub const RAND_MAX: c_int = `2147483647`; 394 pub const EOF: c_int = -1; 395 pub const SEEK_SET: c_int = 0; 396 pub const SEEK_CUR: c_int = 1; 397 pub const SEEK_END: c_int = 2; 398 pub const _IOFBF: c_int = 0; 399 pub const _IONBF: c_int = 2; 400 pub const _IOLBF: c_int = 1; 401 402 pub const F_DUPFD: c_int = 0; 403 pub const F_GETFD: c_int = 1; 404 pub const F_SETFD: c_int = 2; 405 pub const F_GETFL: c_int = 3; 406 pub const F_SETFL: c_int = 4; 407 408 // Linux-specific fcntls 409 pub const F_SETLEASE: c_int = 1024; 410 pub const F_GETLEASE: c_int = 1025; 411 pub const F_NOTIFY: c_int = 1026; 412 pub const F_CANCELLK: c_int = 1029; 413 pub const F_DUPFD_CLOEXEC: c_int = 1030; 414 pub const F_SETPIPE_SZ: c_int = 1031; 415 pub const F_GETPIPE_SZ: c_int = 1032; 416 pub const F_ADD_SEALS: c_int = 1033; 417 pub const F_GET_SEALS: c_int = 1034; 418 419 pub const F_SEAL_SEAL: c_int = 0x0001; 420 pub const F_SEAL_SHRINK: c_int = 0x0002; 421 pub const F_SEAL_GROW: c_int = 0x0004; 422 pub const F_SEAL_WRITE: c_int = 0x0008; 423 424 // FIXME(#235): Include file sealing fcntls once we have a way to verify them. 425 426 pub const SIGTRAP: c_int = 5; 427 428 pub const PTHREAD_CREATE_JOINABLE: c_int = 0; 429 pub const PTHREAD_CREATE_DETACHED: c_int = 1; 430 431 pub const CLOCK_REALTIME: crate::clockid_t = 0; 432 pub const CLOCK_MONOTONIC: crate::clockid_t = 1; 433 pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 2; 434 pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 3; 435 pub const CLOCK_MONOTONIC_RAW: crate::clockid_t = 4; 436 pub const CLOCK_REALTIME_COARSE: crate::clockid_t = 5; 437 pub const CLOCK_MONOTONIC_COARSE: crate::clockid_t = 6; 438 pub const CLOCK_BOOTTIME: crate::clockid_t = 7; 439 pub const CLOCK_REALTIME_ALARM: crate::clockid_t = 8; 440 pub const CLOCK_BOOTTIME_ALARM: crate::clockid_t = 9; 441 pub const CLOCK_TAI: crate::clockid_t = 11; 442 pub const TIMER_ABSTIME: c_int = 1; 443 444 pub const RUSAGE_SELF: c_int = 0; 445 446 pub const O_RDONLY: c_int = 0; 447 pub const O_WRONLY: c_int = 1; 448 pub const O_RDWR: c_int = 2; 449 450 pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; 451 452 pub const S_IFIFO: mode_t = 0o1_0000; 453 pub const S_IFCHR: mode_t = 0o2_0000; 454 pub const S_IFBLK: mode_t = 0o6_0000; 455 pub const S_IFDIR: mode_t = 0o4_0000; 456 pub const S_IFREG: mode_t = 0o10_0000; 457 pub const S_IFLNK: mode_t = 0o12_0000; 458 pub const S_IFSOCK: mode_t = 0o14_0000; 459 pub const S_IFMT: mode_t = 0o17_0000; 460 pub const S_IRWXU: mode_t = 0o0700; 461 pub const S_IXUSR: mode_t = 0o0100; 462 pub const S_IWUSR: mode_t = 0o0200; 463 pub const S_IRUSR: mode_t = 0o0400; 464 pub const S_IRWXG: mode_t = 0o0070; 465 pub const S_IXGRP: mode_t = 0o0010; 466 pub const S_IWGRP: mode_t = 0o0020; 467 pub const S_IRGRP: mode_t = 0o0040; 468 pub const S_IRWXO: mode_t = 0o0007; 469 pub const S_IXOTH: mode_t = 0o0001; 470 pub const S_IWOTH: mode_t = 0o0002; 471 pub const S_IROTH: mode_t = 0o0004; 472 pub const F_OK: c_int = 0; 473 pub const R_OK: c_int = 4; 474 pub const W_OK: c_int = 2; 475 pub const X_OK: c_int = 1; 476 pub const SIGHUP: c_int = 1; 477 pub const SIGINT: c_int = 2; 478 pub const SIGQUIT: c_int = 3; 479 pub const SIGILL: c_int = 4; 480 pub const SIGABRT: c_int = 6; 481 pub const SIGFPE: c_int = 8; 482 pub const SIGKILL: c_int = 9; 483 pub const SIGSEGV: c_int = 11; 484 pub const SIGPIPE: c_int = 13; 485 pub const SIGALRM: c_int = 14; 486 pub const SIGTERM: c_int = 15; 487 488 pub const PROT_NONE: c_int = 0; 489 pub const PROT_READ: c_int = 1; 490 pub const PROT_WRITE: c_int = 2; 491 pub const PROT_EXEC: c_int = 4; 492 493 #[cfg(not(target_os = "l4re"))] 494 pub const XATTR_CREATE: c_int = 0x1; 495 #[cfg(not(target_os = "l4re"))] 496 pub const XATTR_REPLACE: c_int = 0x2; 497 498 cfg_if! { 499 if #[cfg(target_os = "android")] { 500 pub const RLIM64_INFINITY: c_ulonglong = !0; 501 } else { 502 pub const RLIM64_INFINITY: crate::rlim64_t = !0; 503 } 504 } 505 506 cfg_if! { 507 if #[cfg(target_env = "ohos")] { 508 pub const LC_CTYPE: c_int = 0; 509 pub const LC_NUMERIC: c_int = 1; 510 pub const LC_TIME: c_int = 2; 511 pub const LC_COLLATE: c_int = 3; 512 pub const LC_MONETARY: c_int = 4; 513 pub const LC_MESSAGES: c_int = 5; 514 pub const LC_PAPER: c_int = 6; 515 pub const LC_NAME: c_int = 7; 516 pub const LC_ADDRESS: c_int = 8; 517 pub const LC_TELEPHONE: c_int = 9; 518 pub const LC_MEASUREMENT: c_int = 10; 519 pub const LC_IDENTIFICATION: c_int = 11; 520 pub const LC_ALL: c_int = 12; 521 } else if #[cfg(not(target_env = "uclibc"))] { 522 pub const LC_CTYPE: c_int = 0; 523 pub const LC_NUMERIC: c_int = 1; 524 pub const LC_TIME: c_int = 2; 525 pub const LC_COLLATE: c_int = 3; 526 pub const LC_MONETARY: c_int = 4; 527 pub const LC_MESSAGES: c_int = 5; 528 pub const LC_ALL: c_int = 6; 529 } 530 } 531 532 pub const LC_CTYPE_MASK: c_int = 1 << LC_CTYPE; 533 pub const LC_NUMERIC_MASK: c_int = 1 << LC_NUMERIC; 534 pub const LC_TIME_MASK: c_int = 1 << LC_TIME; 535 pub const LC_COLLATE_MASK: c_int = 1 << LC_COLLATE; 536 pub const LC_MONETARY_MASK: c_int = 1 << LC_MONETARY; 537 pub const LC_MESSAGES_MASK: c_int = 1 << LC_MESSAGES; 538 // LC_ALL_MASK defined per platform 539 540 pub const MAP_FILE: c_int = 0x0000; 541 pub const MAP_SHARED: c_int = 0x0001; 542 pub const MAP_PRIVATE: c_int = 0x0002; 543 pub const MAP_FIXED: c_int = 0x0010; 544 545 pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; 546 547 // MS_ flags for msync(2) 548 pub const MS_ASYNC: c_int = 0x0001; 549 pub const MS_INVALIDATE: c_int = 0x0002; 550 pub const MS_SYNC: c_int = 0x0004; 551 552 // MS_ flags for mount(2) 553 pub const MS_RDONLY: c_ulong = 0x01; 554 pub const MS_NOSUID: c_ulong = 0x02; 555 pub const MS_NODEV: c_ulong = 0x04; 556 pub const MS_NOEXEC: c_ulong = 0x08; 557 pub const MS_SYNCHRONOUS: c_ulong = 0x10; 558 pub const MS_REMOUNT: c_ulong = 0x20; 559 pub const MS_MANDLOCK: c_ulong = 0x40; 560 pub const MS_DIRSYNC: c_ulong = 0x80; 561 pub const MS_NOSYMFOLLOW: c_ulong = 0x100; 562 pub const MS_NOATIME: c_ulong = 0x0400; 563 pub const MS_NODIRATIME: c_ulong = 0x0800; 564 pub const MS_BIND: c_ulong = 0x1000; 565 pub const MS_MOVE: c_ulong = 0x2000; 566 pub const MS_REC: c_ulong = 0x4000; 567 // MS_VERBOSE is deprecated 568 pub const MS_SILENT: c_ulong = 0x8000; 569 pub const MS_POSIXACL: c_ulong = 0x010000; 570 pub const MS_UNBINDABLE: c_ulong = 0x020000; 571 pub const MS_PRIVATE: c_ulong = 0x040000; 572 pub const MS_SLAVE: c_ulong = 0x080000; 573 pub const MS_SHARED: c_ulong = 0x100000; 574 pub const MS_RELATIME: c_ulong = 0x200000; 575 pub const MS_KERNMOUNT: c_ulong = 0x400000; 576 pub const MS_I_VERSION: c_ulong = 0x800000; 577 pub const MS_STRICTATIME: c_ulong = 0x1000000; 578 pub const MS_LAZYTIME: c_ulong = 0x2000000; 579 pub const MS_ACTIVE: c_ulong = 0x40000000; 580 pub const MS_MGC_VAL: c_ulong = 0xc0ed0000; 581 pub const MS_MGC_MSK: c_ulong = 0xffff0000; 582 583 pub const SCM_RIGHTS: c_int = 0x01; 584 pub const SCM_CREDENTIALS: c_int = 0x02; 585 586 pub const PROT_GROWSDOWN: c_int = 0x1000000; 587 pub const PROT_GROWSUP: c_int = 0x2000000; 588 589 pub const MAP_TYPE: c_int = 0x000f; 590 591 pub const MADV_NORMAL: c_int = 0; 592 pub const MADV_RANDOM: c_int = 1; 593 pub const MADV_SEQUENTIAL: c_int = 2; 594 pub const MADV_WILLNEED: c_int = 3; 595 pub const MADV_DONTNEED: c_int = 4; 596 pub const MADV_FREE: c_int = 8; 597 pub const MADV_REMOVE: c_int = 9; 598 pub const MADV_DONTFORK: c_int = 10; 599 pub const MADV_DOFORK: c_int = 11; 600 pub const MADV_MERGEABLE: c_int = 12; 601 pub const MADV_UNMERGEABLE: c_int = 13; 602 pub const MADV_HUGEPAGE: c_int = 14; 603 pub const MADV_NOHUGEPAGE: c_int = 15; 604 pub const MADV_DONTDUMP: c_int = 16; 605 pub const MADV_DODUMP: c_int = 17; 606 pub const MADV_WIPEONFORK: c_int = 18; 607 pub const MADV_KEEPONFORK: c_int = 19; 608 #[cfg(not(target_os = "l4re"))] 609 pub const MADV_COLD: c_int = 20; 610 #[cfg(not(target_os = "l4re"))] 611 pub const MADV_PAGEOUT: c_int = 21; 612 pub const MADV_HWPOISON: c_int = 100; 613 cfg_if! { 614 if #[cfg(not(any(target_os = "emscripten", target_os = "l4re")))] { 615 pub const MADV_POPULATE_READ: c_int = 22; 616 pub const MADV_POPULATE_WRITE: c_int = 23; 617 pub const MADV_DONTNEED_LOCKED: c_int = 24; 618 } 619 } 620 621 pub const IFF_UP: c_int = 0x1; 622 pub const IFF_BROADCAST: c_int = 0x2; 623 pub const IFF_DEBUG: c_int = 0x4; 624 pub const IFF_LOOPBACK: c_int = 0x8; 625 pub const IFF_POINTOPOINT: c_int = 0x10; 626 pub const IFF_NOTRAILERS: c_int = 0x20; 627 pub const IFF_RUNNING: c_int = 0x40; 628 pub const IFF_NOARP: c_int = 0x80; 629 pub const IFF_PROMISC: c_int = 0x100; 630 pub const IFF_ALLMULTI: c_int = 0x200; 631 pub const IFF_MASTER: c_int = 0x400; 632 pub const IFF_SLAVE: c_int = 0x800; 633 pub const IFF_MULTICAST: c_int = 0x1000; 634 pub const IFF_PORTSEL: c_int = 0x2000; 635 pub const IFF_AUTOMEDIA: c_int = 0x4000; 636 pub const IFF_DYNAMIC: c_int = 0x8000; 637 638 pub const SOL_IP: c_int = 0; 639 pub const SOL_TCP: c_int = 6; 640 pub const SOL_UDP: c_int = 17; 641 pub const SOL_IPV6: c_int = 41; 642 pub const SOL_ICMPV6: c_int = 58; 643 pub const SOL_RAW: c_int = 255; 644 pub const SOL_DECNET: c_int = 261; 645 pub const SOL_X25: c_int = 262; 646 pub const SOL_PACKET: c_int = 263; 647 pub const SOL_ATM: c_int = 264; 648 pub const SOL_AAL: c_int = 265; 649 pub const SOL_IRDA: c_int = 266; 650 pub const SOL_NETBEUI: c_int = 267; 651 pub const SOL_LLC: c_int = 268; 652 pub const SOL_DCCP: c_int = 269; 653 pub const SOL_NETLINK: c_int = 270; 654 pub const SOL_TIPC: c_int = 271; 655 pub const SOL_BLUETOOTH: c_int = 274; 656 pub const SOL_ALG: c_int = 279; 657 658 pub const AF_UNSPEC: c_int = 0; 659 pub const AF_UNIX: c_int = 1; 660 pub const AF_LOCAL: c_int = 1; 661 pub const AF_INET: c_int = 2; 662 pub const AF_AX25: c_int = 3; 663 pub const AF_IPX: c_int = 4; 664 pub const AF_APPLETALK: c_int = 5; 665 pub const AF_NETROM: c_int = 6; 666 pub const AF_BRIDGE: c_int = 7; 667 pub const AF_ATMPVC: c_int = 8; 668 pub const AF_X25: c_int = 9; 669 pub const AF_INET6: c_int = 10; 670 pub const AF_ROSE: c_int = 11; 671 pub const AF_DECnet: c_int = 12; 672 pub const AF_NETBEUI: c_int = 13; 673 pub const AF_SECURITY: c_int = 14; 674 pub const AF_KEY: c_int = 15; 675 pub const AF_NETLINK: c_int = 16; 676 pub const AF_ROUTE: c_int = AF_NETLINK; 677 pub const AF_PACKET: c_int = 17; 678 pub const AF_ASH: c_int = 18; 679 pub const AF_ECONET: c_int = 19; 680 pub const AF_ATMSVC: c_int = 20; 681 pub const AF_RDS: c_int = 21; 682 pub const AF_SNA: c_int = 22; 683 pub const AF_IRDA: c_int = 23; 684 pub const AF_PPPOX: c_int = 24; 685 pub const AF_WANPIPE: c_int = 25; 686 pub const AF_LLC: c_int = 26; 687 pub const AF_CAN: c_int = 29; 688 pub const AF_TIPC: c_int = 30; 689 pub const AF_BLUETOOTH: c_int = 31; 690 pub const AF_IUCV: c_int = 32; 691 pub const AF_RXRPC: c_int = 33; 692 pub const AF_ISDN: c_int = 34; 693 pub const AF_PHONET: c_int = 35; 694 pub const AF_IEEE802154: c_int = 36; 695 pub const AF_CAIF: c_int = 37; 696 pub const AF_ALG: c_int = 38; 697 698 pub const PF_UNSPEC: c_int = AF_UNSPEC; 699 pub const PF_UNIX: c_int = AF_UNIX; 700 pub const PF_LOCAL: c_int = AF_LOCAL; 701 pub const PF_INET: c_int = AF_INET; 702 pub const PF_AX25: c_int = AF_AX25; 703 pub const PF_IPX: c_int = AF_IPX; 704 pub const PF_APPLETALK: c_int = AF_APPLETALK; 705 pub const PF_NETROM: c_int = AF_NETROM; 706 pub const PF_BRIDGE: c_int = AF_BRIDGE; 707 pub const PF_ATMPVC: c_int = AF_ATMPVC; 708 pub const PF_X25: c_int = AF_X25; 709 pub const PF_INET6: c_int = AF_INET6; 710 pub const PF_ROSE: c_int = AF_ROSE; 711 pub const PF_DECnet: c_int = AF_DECnet; 712 pub const PF_NETBEUI: c_int = AF_NETBEUI; 713 pub const PF_SECURITY: c_int = AF_SECURITY; 714 pub const PF_KEY: c_int = AF_KEY; 715 pub const PF_NETLINK: c_int = AF_NETLINK; 716 pub const PF_ROUTE: c_int = AF_ROUTE; 717 pub const PF_PACKET: c_int = AF_PACKET; 718 pub const PF_ASH: c_int = AF_ASH; 719 pub const PF_ECONET: c_int = AF_ECONET; 720 pub const PF_ATMSVC: c_int = AF_ATMSVC; 721 pub const PF_RDS: c_int = AF_RDS; 722 pub const PF_SNA: c_int = AF_SNA; 723 pub const PF_IRDA: c_int = AF_IRDA; 724 pub const PF_PPPOX: c_int = AF_PPPOX; 725 pub const PF_WANPIPE: c_int = AF_WANPIPE; 726 pub const PF_LLC: c_int = AF_LLC; 727 pub const PF_CAN: c_int = AF_CAN; 728 pub const PF_TIPC: c_int = AF_TIPC; 729 pub const PF_BLUETOOTH: c_int = AF_BLUETOOTH; 730 pub const PF_IUCV: c_int = AF_IUCV; 731 pub const PF_RXRPC: c_int = AF_RXRPC; 732 pub const PF_ISDN: c_int = AF_ISDN; 733 pub const PF_PHONET: c_int = AF_PHONET; 734 pub const PF_IEEE802154: c_int = AF_IEEE802154; 735 pub const PF_CAIF: c_int = AF_CAIF; 736 pub const PF_ALG: c_int = AF_ALG; 737 738 pub const MSG_OOB: c_int = 1; 739 pub const MSG_PEEK: c_int = 2; 740 pub const MSG_DONTROUTE: c_int = 4; 741 pub const MSG_CTRUNC: c_int = 8; 742 pub const MSG_TRUNC: c_int = 0x20; 743 pub const MSG_DONTWAIT: c_int = 0x40; 744 pub const MSG_EOR: c_int = 0x80; 745 pub const MSG_WAITALL: c_int = 0x100; 746 pub const MSG_FIN: c_int = 0x200; 747 pub const MSG_SYN: c_int = 0x400; 748 pub const MSG_CONFIRM: c_int = 0x800; 749 pub const MSG_RST: c_int = 0x1000; 750 pub const MSG_ERRQUEUE: c_int = 0x2000; 751 pub const MSG_NOSIGNAL: c_int = 0x4000; 752 pub const MSG_MORE: c_int = 0x8000; 753 pub const MSG_WAITFORONE: c_int = 0x10000; 754 pub const MSG_FASTOPEN: c_int = 0x20000000; 755 pub const MSG_CMSG_CLOEXEC: c_int = 0x40000000; 756 757 pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; 758 759 pub const SOCK_RAW: c_int = 3; 760 pub const SOCK_RDM: c_int = 4; 761 pub const IP_TOS: c_int = 1; 762 pub const IP_TTL: c_int = 2; 763 pub const IP_HDRINCL: c_int = 3; 764 pub const IP_OPTIONS: c_int = 4; 765 pub const IP_ROUTER_ALERT: c_int = 5; 766 pub const IP_RECVOPTS: c_int = 6; 767 pub const IP_RETOPTS: c_int = 7; 768 pub const IP_PKTINFO: c_int = 8; 769 pub const IP_PKTOPTIONS: c_int = 9; 770 pub const IP_MTU_DISCOVER: c_int = 10; 771 pub const IP_RECVERR: c_int = 11; 772 pub const IP_RECVTTL: c_int = 12; 773 pub const IP_RECVTOS: c_int = 13; 774 pub const IP_MTU: c_int = 14; 775 pub const IP_FREEBIND: c_int = 15; 776 pub const IP_IPSEC_POLICY: c_int = 16; 777 pub const IP_XFRM_POLICY: c_int = 17; 778 pub const IP_PASSSEC: c_int = 18; 779 pub const IP_TRANSPARENT: c_int = 19; 780 pub const IP_ORIGDSTADDR: c_int = 20; 781 pub const IP_RECVORIGDSTADDR: c_int = IP_ORIGDSTADDR; 782 pub const IP_MINTTL: c_int = 21; 783 #[cfg(not(target_os = "l4re"))] 784 pub const IP_NODEFRAG: c_int = 22; 785 #[cfg(not(target_os = "l4re"))] 786 pub const IP_CHECKSUM: c_int = 23; 787 #[cfg(not(target_os = "l4re"))] 788 pub const IP_BIND_ADDRESS_NO_PORT: c_int = 24; 789 pub const IP_MULTICAST_IF: c_int = 32; 790 pub const IP_MULTICAST_TTL: c_int = 33; 791 pub const IP_MULTICAST_LOOP: c_int = 34; 792 pub const IP_ADD_MEMBERSHIP: c_int = 35; 793 pub const IP_DROP_MEMBERSHIP: c_int = 36; 794 pub const IP_UNBLOCK_SOURCE: c_int = 37; 795 pub const IP_BLOCK_SOURCE: c_int = 38; 796 pub const IP_ADD_SOURCE_MEMBERSHIP: c_int = 39; 797 pub const IP_DROP_SOURCE_MEMBERSHIP: c_int = 40; 798 pub const IP_MSFILTER: c_int = 41; 799 pub const IP_MULTICAST_ALL: c_int = 49; 800 pub const IP_UNICAST_IF: c_int = 50; 801 802 pub const IP_DEFAULT_MULTICAST_TTL: c_int = 1; 803 pub const IP_DEFAULT_MULTICAST_LOOP: c_int = 1; 804 805 pub const IP_PMTUDISC_DONT: c_int = 0; 806 pub const IP_PMTUDISC_WANT: c_int = 1; 807 pub const IP_PMTUDISC_DO: c_int = 2; 808 pub const IP_PMTUDISC_PROBE: c_int = 3; 809 #[cfg(not(target_os = "l4re"))] 810 pub const IP_PMTUDISC_INTERFACE: c_int = 4; 811 #[cfg(not(target_os = "l4re"))] 812 pub const IP_PMTUDISC_OMIT: c_int = 5; 813 814 // IPPROTO_IP defined in src/unix/mod.rs 815 /// Hop-by-hop option header 816 pub const IPPROTO_HOPOPTS: c_int = 0; 817 // IPPROTO_ICMP defined in src/unix/mod.rs 818 /// group mgmt protocol 819 pub const IPPROTO_IGMP: c_int = 2; 820 /// for compatibility 821 pub const IPPROTO_IPIP: c_int = 4; 822 // IPPROTO_TCP defined in src/unix/mod.rs 823 /// exterior gateway protocol 824 pub const IPPROTO_EGP: c_int = 8; 825 /// pup 826 pub const IPPROTO_PUP: c_int = 12; 827 // IPPROTO_UDP defined in src/unix/mod.rs 828 /// xns idp 829 pub const IPPROTO_IDP: c_int = 22; 830 /// tp-4 w/ class negotiation 831 pub const IPPROTO_TP: c_int = 29; 832 /// DCCP 833 pub const IPPROTO_DCCP: c_int = 33; 834 // IPPROTO_IPV6 defined in src/unix/mod.rs 835 /// IP6 routing header 836 pub const IPPROTO_ROUTING: c_int = 43; 837 /// IP6 fragmentation header 838 pub const IPPROTO_FRAGMENT: c_int = 44; 839 /// resource reservation 840 pub const IPPROTO_RSVP: c_int = 46; 841 /// General Routing Encap. 842 pub const IPPROTO_GRE: c_int = 47; 843 /// IP6 Encap Sec. Payload 844 pub const IPPROTO_ESP: c_int = 50; 845 /// IP6 Auth Header 846 pub const IPPROTO_AH: c_int = 51; 847 // IPPROTO_ICMPV6 defined in src/unix/mod.rs 848 /// IP6 no next header 849 pub const IPPROTO_NONE: c_int = 59; 850 /// IP6 destination option 851 pub const IPPROTO_DSTOPTS: c_int = 60; 852 pub const IPPROTO_MTP: c_int = 92; 853 /// encapsulation header 854 pub const IPPROTO_ENCAP: c_int = 98; 855 /// Protocol indep. multicast 856 pub const IPPROTO_PIM: c_int = 103; 857 /// IP Payload Comp. Protocol 858 pub const IPPROTO_COMP: c_int = 108; 859 /// SCTP 860 pub const IPPROTO_SCTP: c_int = 132; 861 pub const IPPROTO_MH: c_int = 135; 862 pub const IPPROTO_UDPLITE: c_int = 136; 863 /// raw IP packet 864 pub const IPPROTO_RAW: c_int = 255; 865 pub const IPPROTO_BEETPH: c_int = 94; 866 pub const IPPROTO_MPLS: c_int = 137; 867 /// Multipath TCP 868 #[cfg(not(target_os = "l4re"))] 869 pub const IPPROTO_MPTCP: c_int = 262; 870 /// Ethernet-within-IPv6 encapsulation. 871 #[cfg(not(target_os = "l4re"))] 872 pub const IPPROTO_ETHERNET: c_int = 143; 873 874 pub const MCAST_EXCLUDE: c_int = 0; 875 pub const MCAST_INCLUDE: c_int = 1; 876 pub const MCAST_JOIN_GROUP: c_int = 42; 877 pub const MCAST_BLOCK_SOURCE: c_int = 43; 878 pub const MCAST_UNBLOCK_SOURCE: c_int = 44; 879 pub const MCAST_LEAVE_GROUP: c_int = 45; 880 pub const MCAST_JOIN_SOURCE_GROUP: c_int = 46; 881 pub const MCAST_LEAVE_SOURCE_GROUP: c_int = 47; 882 pub const MCAST_MSFILTER: c_int = 48; 883 884 pub const IPV6_ADDRFORM: c_int = 1; 885 pub const IPV6_2292PKTINFO: c_int = 2; 886 pub const IPV6_2292HOPOPTS: c_int = 3; 887 pub const IPV6_2292DSTOPTS: c_int = 4; 888 pub const IPV6_2292RTHDR: c_int = 5; 889 pub const IPV6_2292PKTOPTIONS: c_int = 6; 890 pub const IPV6_CHECKSUM: c_int = 7; 891 pub const IPV6_2292HOPLIMIT: c_int = 8; 892 pub const IPV6_NEXTHOP: c_int = 9; 893 pub const IPV6_AUTHHDR: c_int = 10; 894 pub const IPV6_UNICAST_HOPS: c_int = 16; 895 pub const IPV6_MULTICAST_IF: c_int = 17; 896 pub const IPV6_MULTICAST_HOPS: c_int = 18; 897 pub const IPV6_MULTICAST_LOOP: c_int = 19; 898 pub const IPV6_ADD_MEMBERSHIP: c_int = 20; 899 pub const IPV6_DROP_MEMBERSHIP: c_int = 21; 900 pub const IPV6_ROUTER_ALERT: c_int = 22; 901 pub const IPV6_MTU_DISCOVER: c_int = 23; 902 pub const IPV6_MTU: c_int = 24; 903 pub const IPV6_RECVERR: c_int = 25; 904 pub const IPV6_V6ONLY: c_int = 26; 905 pub const IPV6_JOIN_ANYCAST: c_int = 27; 906 pub const IPV6_LEAVE_ANYCAST: c_int = 28; 907 pub const IPV6_IPSEC_POLICY: c_int = 34; 908 pub const IPV6_XFRM_POLICY: c_int = 35; 909 pub const IPV6_HDRINCL: c_int = 36; 910 pub const IPV6_RECVPKTINFO: c_int = 49; 911 pub const IPV6_PKTINFO: c_int = 50; 912 pub const IPV6_RECVHOPLIMIT: c_int = 51; 913 pub const IPV6_HOPLIMIT: c_int = 52; 914 pub const IPV6_RECVHOPOPTS: c_int = 53; 915 pub const IPV6_HOPOPTS: c_int = 54; 916 pub const IPV6_RTHDRDSTOPTS: c_int = 55; 917 pub const IPV6_RECVRTHDR: c_int = 56; 918 pub const IPV6_RTHDR: c_int = 57; 919 pub const IPV6_RECVDSTOPTS: c_int = 58; 920 pub const IPV6_DSTOPTS: c_int = 59; 921 #[cfg(not(target_os = "l4re"))] 922 pub const IPV6_RECVPATHMTU: c_int = 60; 923 #[cfg(not(target_os = "l4re"))] 924 pub const IPV6_PATHMTU: c_int = 61; 925 #[cfg(not(target_os = "l4re"))] 926 pub const IPV6_DONTFRAG: c_int = 62; 927 pub const IPV6_RECVTCLASS: c_int = 66; 928 pub const IPV6_TCLASS: c_int = 67; 929 cfg_if! { 930 if #[cfg(not(target_os = "l4re"))] { 931 pub const IPV6_AUTOFLOWLABEL: c_int = 70; 932 pub const IPV6_ADDR_PREFERENCES: c_int = 72; 933 pub const IPV6_MINHOPCOUNT: c_int = 73; 934 pub const IPV6_ORIGDSTADDR: c_int = 74; 935 pub const IPV6_RECVORIGDSTADDR: c_int = IPV6_ORIGDSTADDR; 936 pub const IPV6_TRANSPARENT: c_int = 75; 937 pub const IPV6_UNICAST_IF: c_int = 76; 938 pub const IPV6_PREFER_SRC_TMP: c_int = 0x0001; 939 pub const IPV6_PREFER_SRC_PUBLIC: c_int = 0x0002; 940 pub const IPV6_PREFER_SRC_PUBTMP_DEFAULT: c_int = 0x0100; 941 pub const IPV6_PREFER_SRC_COA: c_int = 0x0004; 942 pub const IPV6_PREFER_SRC_HOME: c_int = 0x0400; 943 pub const IPV6_PREFER_SRC_CGA: c_int = 0x0008; 944 pub const IPV6_PREFER_SRC_NONCGA: c_int = 0x0800; 945 } 946 } 947 948 pub const IPV6_PMTUDISC_DONT: c_int = 0; 949 pub const IPV6_PMTUDISC_WANT: c_int = 1; 950 pub const IPV6_PMTUDISC_DO: c_int = 2; 951 pub const IPV6_PMTUDISC_PROBE: c_int = 3; 952 pub const IPV6_PMTUDISC_INTERFACE: c_int = 4; 953 pub const IPV6_PMTUDISC_OMIT: c_int = 5; 954 955 pub const TCP_NODELAY: c_int = 1; 956 pub const TCP_MAXSEG: c_int = 2; 957 pub const TCP_CORK: c_int = 3; 958 pub const TCP_KEEPIDLE: c_int = 4; 959 pub const TCP_KEEPINTVL: c_int = 5; 960 pub const TCP_KEEPCNT: c_int = 6; 961 pub const TCP_SYNCNT: c_int = 7; 962 pub const TCP_LINGER2: c_int = 8; 963 pub const TCP_DEFER_ACCEPT: c_int = 9; 964 pub const TCP_WINDOW_CLAMP: c_int = 10; 965 pub const TCP_INFO: c_int = 11; 966 pub const TCP_QUICKACK: c_int = 12; 967 pub const TCP_CONGESTION: c_int = 13; 968 pub const TCP_MD5SIG: c_int = 14; 969 cfg_if! { 970 if #[cfg(all( 971 target_os = "linux", 972 any(target_env = "gnu", target_env = "musl", target_env = "ohos") 973 ))] { 974 // WARN: deprecated 975 pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; 976 } 977 } 978 pub const TCP_THIN_LINEAR_TIMEOUTS: c_int = 16; 979 pub const TCP_THIN_DUPACK: c_int = 17; 980 pub const TCP_USER_TIMEOUT: c_int = 18; 981 pub const TCP_REPAIR: c_int = 19; 982 pub const TCP_REPAIR_QUEUE: c_int = 20; 983 pub const TCP_QUEUE_SEQ: c_int = 21; 984 pub const TCP_REPAIR_OPTIONS: c_int = 22; 985 pub const TCP_FASTOPEN: c_int = 23; 986 pub const TCP_TIMESTAMP: c_int = 24; 987 pub const TCP_NOTSENT_LOWAT: c_int = 25; 988 pub const TCP_CC_INFO: c_int = 26; 989 pub const TCP_SAVE_SYN: c_int = 27; 990 pub const TCP_SAVED_SYN: c_int = 28; 991 cfg_if! { 992 if #[cfg(not(target_os = "emscripten"))] { 993 // NOTE: emscripten doesn't support these options yet. 994 995 pub const TCP_REPAIR_WINDOW: c_int = 29; 996 pub const TCP_FASTOPEN_CONNECT: c_int = 30; 997 pub const TCP_ULP: c_int = 31; 998 pub const TCP_MD5SIG_EXT: c_int = 32; 999 pub const TCP_FASTOPEN_KEY: c_int = 33; 1000 pub const TCP_FASTOPEN_NO_COOKIE: c_int = 34; 1001 pub const TCP_ZEROCOPY_RECEIVE: c_int = 35; 1002 pub const TCP_INQ: c_int = 36; 1003 pub const TCP_CM_INQ: c_int = TCP_INQ; 1004 // NOTE: Some CI images doesn't have this option yet. 1005 // pub const TCP_TX_DELAY: c_int = 37; 1006 pub const TCP_MD5SIG_MAXKEYLEN: usize = 80; 1007 } 1008 } 1009 1010 pub const SO_DEBUG: c_int = 1; 1011 1012 pub const SHUT_RD: c_int = 0; 1013 pub const SHUT_WR: c_int = 1; 1014 pub const SHUT_RDWR: c_int = 2; 1015 1016 pub const LOCK_SH: c_int = 1; 1017 pub const LOCK_EX: c_int = 2; 1018 pub const LOCK_NB: c_int = 4; 1019 pub const LOCK_UN: c_int = 8; 1020 1021 pub const SS_ONSTACK: c_int = 1; 1022 pub const SS_DISABLE: c_int = 2; 1023 1024 /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) 1025 /// for details. 1026 pub const NAME_MAX: c_int = 255; 1027 1028 /// Constants may change across releases. See the [usage guidelines](crate#usage-guidelines) 1029 /// for details. 1030 pub const PATH_MAX: c_int = 4096; 1031 1032 pub const UIO_MAXIOV: c_int = 1024; 1033 1034 pub const FD_SETSIZE: usize = 1024; 1035 1036 pub const EPOLLIN: c_int = 0x1; 1037 pub const EPOLLPRI: c_int = 0x2; 1038 pub const EPOLLOUT: c_int = 0x4; 1039 pub const EPOLLERR: c_int = 0x8; 1040 pub const EPOLLHUP: c_int = 0x10; 1041 pub const EPOLLRDNORM: c_int = 0x40; 1042 pub const EPOLLRDBAND: c_int = 0x80; 1043 pub const EPOLLWRNORM: c_int = 0x100; 1044 pub const EPOLLWRBAND: c_int = 0x200; 1045 pub const EPOLLMSG: c_int = 0x400; 1046 pub const EPOLLRDHUP: c_int = 0x2000; 1047 pub const EPOLLEXCLUSIVE: c_int = 0x10000000; 1048 pub const EPOLLWAKEUP: c_int = 0x20000000; 1049 pub const EPOLLONESHOT: c_int = 0x40000000; 1050 pub const EPOLLET: c_int = u32_cast_int(0x80000000); 1051 1052 pub const EPOLL_CTL_ADD: c_int = 1; 1053 pub const EPOLL_CTL_MOD: c_int = 3; 1054 pub const EPOLL_CTL_DEL: c_int = 2; 1055 1056 pub const MNT_FORCE: c_int = 0x1; 1057 pub const MNT_DETACH: c_int = 0x2; 1058 pub const MNT_EXPIRE: c_int = 0x4; 1059 pub const UMOUNT_NOFOLLOW: c_int = 0x8; 1060 1061 cfg_if! { 1062 if #[cfg(not(target_os = "l4re"))] { 1063 pub const Q_GETFMT: c_int = 0x800004; 1064 pub const Q_GETINFO: c_int = 0x800005; 1065 pub const Q_SETINFO: c_int = 0x800006; 1066 pub const QIF_BLIMITS: u32 = 1; 1067 pub const QIF_SPACE: u32 = 2; 1068 pub const QIF_ILIMITS: u32 = 4; 1069 pub const QIF_INODES: u32 = 8; 1070 pub const QIF_BTIME: u32 = 16; 1071 pub const QIF_ITIME: u32 = 32; 1072 pub const QIF_LIMITS: u32 = 5; 1073 pub const QIF_USAGE: u32 = 10; 1074 pub const QIF_TIMES: u32 = 48; 1075 pub const QIF_ALL: u32 = 63; 1076 1077 pub const Q_SYNC: c_int = 0x800001; 1078 pub const Q_QUOTAON: c_int = 0x800002; 1079 pub const Q_QUOTAOFF: c_int = 0x800003; 1080 pub const Q_GETQUOTA: c_int = 0x800007; 1081 pub const Q_SETQUOTA: c_int = 0x800008; 1082 } 1083 } 1084 1085 pub const TCIOFF: c_int = 2; 1086 pub const TCION: c_int = 3; 1087 pub const TCOOFF: c_int = 0; 1088 pub const TCOON: c_int = 1; 1089 pub const TCIFLUSH: c_int = 0; 1090 pub const TCOFLUSH: c_int = 1; 1091 pub const TCIOFLUSH: c_int = 2; 1092 pub const NL0: crate::tcflag_t = 0x00000000; 1093 pub const NL1: crate::tcflag_t = 0x00000100; 1094 pub const TAB0: crate::tcflag_t = 0x00000000; 1095 pub const CR0: crate::tcflag_t = 0x00000000; 1096 pub const FF0: crate::tcflag_t = 0x00000000; 1097 pub const BS0: crate::tcflag_t = 0x00000000; 1098 pub const VT0: crate::tcflag_t = 0x00000000; 1099 pub const VERASE: usize = 2; 1100 pub const VKILL: usize = 3; 1101 pub const VINTR: usize = 0; 1102 pub const VQUIT: usize = 1; 1103 pub const VLNEXT: usize = 15; 1104 pub const IGNBRK: crate::tcflag_t = 0x00000001; 1105 pub const BRKINT: crate::tcflag_t = 0x00000002; 1106 pub const IGNPAR: crate::tcflag_t = 0x00000004; 1107 pub const PARMRK: crate::tcflag_t = 0x00000008; 1108 pub const INPCK: crate::tcflag_t = 0x00000010; 1109 pub const ISTRIP: crate::tcflag_t = 0x00000020; 1110 pub const INLCR: crate::tcflag_t = 0x00000040; 1111 pub const IGNCR: crate::tcflag_t = 0x00000080; 1112 pub const ICRNL: crate::tcflag_t = 0x00000100; 1113 pub const IXANY: crate::tcflag_t = 0x00000800; 1114 pub const IMAXBEL: crate::tcflag_t = 0x00002000; 1115 pub const OPOST: crate::tcflag_t = 0x1; 1116 pub const CS5: crate::tcflag_t = 0x00000000; 1117 pub const CRTSCTS: crate::tcflag_t = 0x80000000; 1118 pub const ECHO: crate::tcflag_t = 0x00000008; 1119 pub const OCRNL: crate::tcflag_t = 0o000010; 1120 pub const ONOCR: crate::tcflag_t = 0o000020; 1121 pub const ONLRET: crate::tcflag_t = 0o000040; 1122 pub const OFILL: crate::tcflag_t = 0o000100; 1123 pub const OFDEL: crate::tcflag_t = 0o000200; 1124 1125 pub const CLONE_VM: c_int = 0x100; 1126 pub const CLONE_FS: c_int = 0x200; 1127 pub const CLONE_FILES: c_int = 0x400; 1128 pub const CLONE_SIGHAND: c_int = 0x800; 1129 pub const CLONE_PTRACE: c_int = 0x2000; 1130 pub const CLONE_VFORK: c_int = 0x4000; 1131 pub const CLONE_PARENT: c_int = 0x8000; 1132 pub const CLONE_THREAD: c_int = 0x10000; 1133 pub const CLONE_NEWNS: c_int = 0x20000; 1134 pub const CLONE_SYSVSEM: c_int = 0x40000; 1135 pub const CLONE_SETTLS: c_int = 0x80000; 1136 pub const CLONE_PARENT_SETTID: c_int = 0x100000; 1137 pub const CLONE_CHILD_CLEARTID: c_int = 0x200000; 1138 pub const CLONE_DETACHED: c_int = 0x400000; 1139 pub const CLONE_UNTRACED: c_int = 0x800000; 1140 pub const CLONE_CHILD_SETTID: c_int = 0x01000000; 1141 #[cfg(not(target_os = "l4re"))] 1142 pub const CLONE_NEWCGROUP: c_int = 0x02000000; 1143 pub const CLONE_NEWUTS: c_int = 0x04000000; 1144 pub const CLONE_NEWIPC: c_int = 0x08000000; 1145 pub const CLONE_NEWUSER: c_int = 0x10000000; 1146 pub const CLONE_NEWPID: c_int = 0x20000000; 1147 pub const CLONE_NEWNET: c_int = 0x40000000; 1148 pub const CLONE_IO: c_int = u32_cast_int(0x80000000); 1149 1150 pub const WNOHANG: c_int = 0x00000001; 1151 pub const WUNTRACED: c_int = 0x00000002; 1152 pub const WSTOPPED: c_int = WUNTRACED; 1153 pub const WEXITED: c_int = 0x00000004; 1154 pub const WCONTINUED: c_int = 0x00000008; 1155 pub const WNOWAIT: c_int = 0x01000000; 1156 1157 cfg_if! { 1158 if #[cfg(not(target_os = "l4re"))] { 1159 // Options for personality(2). 1160 pub const ADDR_NO_RANDOMIZE: c_int = 0x0040000; 1161 pub const MMAP_PAGE_ZERO: c_int = 0x0100000; 1162 pub const ADDR_COMPAT_LAYOUT: c_int = 0x0200000; 1163 pub const READ_IMPLIES_EXEC: c_int = 0x0400000; 1164 pub const ADDR_LIMIT_32BIT: c_int = 0x0800000; 1165 pub const SHORT_INODE: c_int = 0x1000000; 1166 pub const WHOLE_SECONDS: c_int = 0x2000000; 1167 pub const STICKY_TIMEOUTS: c_int = 0x4000000; 1168 pub const ADDR_LIMIT_3GB: c_int = 0x8000000; 1169 1170 // Options set using PTRACE_SETOPTIONS. 1171 pub const PTRACE_O_TRACESYSGOOD: c_int = 0x00000001; 1172 pub const PTRACE_O_TRACEFORK: c_int = 0x00000002; 1173 pub const PTRACE_O_TRACEVFORK: c_int = 0x00000004; 1174 pub const PTRACE_O_TRACECLONE: c_int = 0x00000008; 1175 pub const PTRACE_O_TRACEEXEC: c_int = 0x00000010; 1176 pub const PTRACE_O_TRACEVFORKDONE: c_int = 0x00000020; 1177 pub const PTRACE_O_TRACEEXIT: c_int = 0x00000040; 1178 pub const PTRACE_O_TRACESECCOMP: c_int = 0x00000080; 1179 pub const PTRACE_O_SUSPEND_SECCOMP: c_int = 0x00200000; 1180 pub const PTRACE_O_EXITKILL: c_int = 0x00100000; 1181 pub const PTRACE_O_MASK: c_int = 0x003000ff; 1182 1183 // Wait extended result codes for the above trace options. 1184 pub const PTRACE_EVENT_FORK: c_int = 1; 1185 pub const PTRACE_EVENT_VFORK: c_int = 2; 1186 pub const PTRACE_EVENT_CLONE: c_int = 3; 1187 pub const PTRACE_EVENT_EXEC: c_int = 4; 1188 pub const PTRACE_EVENT_VFORK_DONE: c_int = 5; 1189 pub const PTRACE_EVENT_EXIT: c_int = 6; 1190 pub const PTRACE_EVENT_SECCOMP: c_int = 7; 1191 } 1192 } 1193 1194 pub const __WNOTHREAD: c_int = 0x20000000; 1195 pub const __WALL: c_int = 0x40000000; 1196 pub const __WCLONE: c_int = u32_cast_int(0x80000000); 1197 1198 cfg_if! { 1199 if #[cfg(not(target_os = "l4re"))] { 1200 pub const SPLICE_F_MOVE: c_uint = 0x01; 1201 pub const SPLICE_F_NONBLOCK: c_uint = 0x02; 1202 pub const SPLICE_F_MORE: c_uint = 0x04; 1203 pub const SPLICE_F_GIFT: c_uint = 0x08; 1204 } 1205 } 1206 1207 pub const RTLD_LOCAL: c_int = 0; 1208 pub const RTLD_LAZY: c_int = 1; 1209 1210 pub const POSIX_FADV_NORMAL: c_int = 0; 1211 pub const POSIX_FADV_RANDOM: c_int = 1; 1212 pub const POSIX_FADV_SEQUENTIAL: c_int = 2; 1213 pub const POSIX_FADV_WILLNEED: c_int = 3; 1214 1215 pub const AT_FDCWD: c_int = -100; 1216 pub const AT_SYMLINK_NOFOLLOW: c_int = 0x100; 1217 pub const AT_REMOVEDIR: c_int = 0x200; 1218 pub const AT_SYMLINK_FOLLOW: c_int = 0x400; 1219 pub const AT_NO_AUTOMOUNT: c_int = 0x800; 1220 pub const AT_EMPTY_PATH: c_int = 0x1000; 1221 pub const AT_RECURSIVE: c_int = 0x8000; 1222 1223 pub const LOG_CRON: c_int = 9 << 3; 1224 pub const LOG_AUTHPRIV: c_int = 10 << 3; 1225 pub const LOG_FTP: c_int = 11 << 3; 1226 pub const LOG_PERROR: c_int = 0x20; 1227 1228 #[cfg(not(target_os = "l4re"))] 1229 pub const PIPE_BUF: usize = 4096; 1230 1231 pub const SI_LOAD_SHIFT: c_uint = 16; 1232 1233 // si_code values 1234 pub const SI_USER: c_int = 0; 1235 pub const SI_KERNEL: c_int = 0x80; 1236 pub const SI_QUEUE: c_int = -1; 1237 cfg_if! { 1238 if #[cfg(not(any( 1239 target_arch = "mips", 1240 target_arch = "mips32r6", 1241 target_arch = "mips64" 1242 )))] { 1243 pub const SI_TIMER: c_int = -2; 1244 pub const SI_MESGQ: c_int = -3; 1245 pub const SI_ASYNCIO: c_int = -4; 1246 } else { 1247 pub const SI_TIMER: c_int = -3; 1248 pub const SI_MESGQ: c_int = -4; 1249 pub const SI_ASYNCIO: c_int = -2; 1250 } 1251 } 1252 pub const SI_SIGIO: c_int = -5; 1253 pub const SI_TKILL: c_int = -6; 1254 pub const SI_ASYNCNL: c_int = -60; 1255 1256 // si_code values for SIGBUS signal 1257 pub const BUS_ADRALN: c_int = 1; 1258 pub const BUS_ADRERR: c_int = 2; 1259 pub const BUS_OBJERR: c_int = 3; 1260 // Linux-specific si_code values for SIGBUS signal 1261 #[cfg(not(target_os = "l4re"))] 1262 pub const BUS_MCEERR_AR: c_int = 4; 1263 #[cfg(not(target_os = "l4re"))] 1264 pub const BUS_MCEERR_AO: c_int = 5; 1265 1266 // si_code values for SIGTRAP 1267 pub const TRAP_BRKPT: c_int = 1; 1268 pub const TRAP_TRACE: c_int = 2; 1269 #[cfg(not(target_os = "l4re"))] 1270 pub const TRAP_BRANCH: c_int = 3; 1271 #[cfg(not(target_os = "l4re"))] 1272 pub const TRAP_HWBKPT: c_int = 4; 1273 #[cfg(not(target_os = "l4re"))] 1274 pub const TRAP_UNK: c_int = 5; 1275 1276 // si_code values for SIGCHLD signal 1277 pub const CLD_EXITED: c_int = 1; 1278 pub const CLD_KILLED: c_int = 2; 1279 pub const CLD_DUMPED: c_int = 3; 1280 pub const CLD_TRAPPED: c_int = 4; 1281 pub const CLD_STOPPED: c_int = 5; 1282 pub const CLD_CONTINUED: c_int = 6; 1283 1284 pub const SIGEV_SIGNAL: c_int = 0; 1285 pub const SIGEV_NONE: c_int = 1; 1286 pub const SIGEV_THREAD: c_int = 2; 1287 1288 pub const P_ALL: idtype_t = 0; 1289 pub const P_PID: idtype_t = 1; 1290 pub const P_PGID: idtype_t = 2; 1291 cfg_if! { 1292 if #[cfg(not(target_os = "emscripten"))] { 1293 pub const P_PIDFD: idtype_t = 3; 1294 } 1295 } 1296 1297 pub const UTIME_OMIT: c_long = `1073741822`; 1298 pub const UTIME_NOW: c_long = `1073741823`; 1299 1300 pub const POLLIN: c_short = 0x1; 1301 pub const POLLPRI: c_short = 0x2; 1302 pub const POLLOUT: c_short = 0x4; 1303 pub const POLLERR: c_short = 0x8; 1304 pub const POLLHUP: c_short = 0x10; 1305 pub const POLLNVAL: c_short = 0x20; 1306 pub const POLLRDNORM: c_short = 0x040; 1307 pub const POLLRDBAND: c_short = 0x080; 1308 #[cfg(not(any(target_arch = "sparc", target_arch = "sparc64")))] 1309 pub const POLLRDHUP: c_short = 0x2000; 1310 #[cfg(any(target_arch = "sparc", target_arch = "sparc64"))] 1311 pub const POLLRDHUP: c_short = 0x800; 1312 1313 pub const IPTOS_LOWDELAY: u8 = 0x10; 1314 pub const IPTOS_THROUGHPUT: u8 = 0x08; 1315 pub const IPTOS_RELIABILITY: u8 = 0x04; 1316 pub const IPTOS_MINCOST: u8 = 0x02; 1317 1318 pub const IPTOS_PREC_NETCONTROL: u8 = 0xe0; 1319 pub const IPTOS_PREC_INTERNETCONTROL: u8 = 0xc0; 1320 pub const IPTOS_PREC_CRITIC_ECP: u8 = 0xa0; 1321 pub const IPTOS_PREC_FLASHOVERRIDE: u8 = 0x80; 1322 pub const IPTOS_PREC_FLASH: u8 = 0x60; 1323 pub const IPTOS_PREC_IMMEDIATE: u8 = 0x40; 1324 pub const IPTOS_PREC_PRIORITY: u8 = 0x20; 1325 pub const IPTOS_PREC_ROUTINE: u8 = 0x00; 1326 1327 pub const IPTOS_ECN_MASK: u8 = 0x03; 1328 pub const IPTOS_ECN_ECT1: u8 = 0x01; 1329 pub const IPTOS_ECN_ECT0: u8 = 0x02; 1330 pub const IPTOS_ECN_CE: u8 = 0x03; 1331 1332 pub const IPOPT_COPY: u8 = 0x80; 1333 pub const IPOPT_CLASS_MASK: u8 = 0x60; 1334 pub const IPOPT_NUMBER_MASK: u8 = 0x1f; 1335 1336 pub const IPOPT_CONTROL: u8 = 0x00; 1337 pub const IPOPT_RESERVED1: u8 = 0x20; 1338 pub const IPOPT_MEASUREMENT: u8 = 0x40; 1339 pub const IPOPT_RESERVED2: u8 = 0x60; 1340 pub const IPOPT_END: u8 = 0 | IPOPT_CONTROL; 1341 pub const IPOPT_NOOP: u8 = 1 | IPOPT_CONTROL; 1342 pub const IPOPT_SEC: u8 = 2 | IPOPT_CONTROL | IPOPT_COPY; 1343 pub const IPOPT_LSRR: u8 = 3 | IPOPT_CONTROL | IPOPT_COPY; 1344 pub const IPOPT_TIMESTAMP: u8 = 4 | IPOPT_MEASUREMENT; 1345 pub const IPOPT_RR: u8 = 7 | IPOPT_CONTROL; 1346 pub const IPOPT_SID: u8 = 8 | IPOPT_CONTROL | IPOPT_COPY; 1347 pub const IPOPT_SSRR: u8 = 9 | IPOPT_CONTROL | IPOPT_COPY; 1348 pub const IPOPT_RA: u8 = 20 | IPOPT_CONTROL | IPOPT_COPY; 1349 pub const IPVERSION: u8 = 4; 1350 pub const MAXTTL: u8 = 255; 1351 pub const IPDEFTTL: u8 = 64; 1352 pub const IPOPT_OPTVAL: u8 = 0; 1353 pub const IPOPT_OLEN: u8 = 1; 1354 pub const IPOPT_OFFSET: u8 = 2; 1355 pub const IPOPT_MINOFF: u8 = 4; 1356 pub const MAX_IPOPTLEN: u8 = 40; 1357 pub const IPOPT_NOP: u8 = IPOPT_NOOP; 1358 pub const IPOPT_EOL: u8 = IPOPT_END; 1359 pub const IPOPT_TS: u8 = IPOPT_TIMESTAMP; 1360 pub const IPOPT_TS_TSONLY: u8 = 0; 1361 pub const IPOPT_TS_TSANDADDR: u8 = 1; 1362 pub const IPOPT_TS_PRESPEC: u8 = 3; 1363 1364 pub const ARPOP_RREQUEST: u16 = 3; 1365 pub const ARPOP_RREPLY: u16 = 4; 1366 pub const ARPOP_InREQUEST: u16 = 8; 1367 pub const ARPOP_InREPLY: u16 = 9; 1368 pub const ARPOP_NAK: u16 = 10; 1369 1370 pub const ATF_NETMASK: c_int = 0x20; 1371 pub const ATF_DONTPUB: c_int = 0x40; 1372 1373 pub const ARPHRD_NETROM: u16 = 0; 1374 pub const ARPHRD_ETHER: u16 = 1; 1375 pub const ARPHRD_EETHER: u16 = 2; 1376 pub const ARPHRD_AX25: u16 = 3; 1377 pub const ARPHRD_PRONET: u16 = 4; 1378 pub const ARPHRD_CHAOS: u16 = 5; 1379 pub const ARPHRD_IEEE802: u16 = 6; 1380 pub const ARPHRD_ARCNET: u16 = 7; 1381 pub const ARPHRD_APPLETLK: u16 = 8; 1382 pub const ARPHRD_DLCI: u16 = 15; 1383 pub const ARPHRD_ATM: u16 = 19; 1384 pub const ARPHRD_METRICOM: u16 = 23; 1385 pub const ARPHRD_IEEE1394: u16 = 24; 1386 pub const ARPHRD_EUI64: u16 = 27; 1387 pub const ARPHRD_INFINIBAND: u16 = 32; 1388 1389 pub const ARPHRD_SLIP: u16 = 256; 1390 pub const ARPHRD_CSLIP: u16 = 257; 1391 pub const ARPHRD_SLIP6: u16 = 258; 1392 pub const ARPHRD_CSLIP6: u16 = 259; 1393 pub const ARPHRD_RSRVD: u16 = 260; 1394 pub const ARPHRD_ADAPT: u16 = 264; 1395 pub const ARPHRD_ROSE: u16 = 270; 1396 pub const ARPHRD_X25: u16 = 271; 1397 pub const ARPHRD_HWX25: u16 = 272; 1398 pub const ARPHRD_CAN: u16 = 280; 1399 pub const ARPHRD_PPP: u16 = 512; 1400 pub const ARPHRD_CISCO: u16 = 513; 1401 pub const ARPHRD_HDLC: u16 = ARPHRD_CISCO; 1402 pub const ARPHRD_LAPB: u16 = 516; 1403 pub const ARPHRD_DDCMP: u16 = 517; 1404 pub const ARPHRD_RAWHDLC: u16 = 518; 1405 1406 pub const ARPHRD_TUNNEL: u16 = 768; 1407 pub const ARPHRD_TUNNEL6: u16 = 769; 1408 pub const ARPHRD_FRAD: u16 = 770; 1409 pub const ARPHRD_SKIP: u16 = 771; 1410 pub const ARPHRD_LOOPBACK: u16 = 772; 1411 pub const ARPHRD_LOCALTLK: u16 = 773; 1412 pub const ARPHRD_FDDI: u16 = 774; 1413 pub const ARPHRD_BIF: u16 = 775; 1414 pub const ARPHRD_SIT: u16 = 776; 1415 pub const ARPHRD_IPDDP: u16 = 777; 1416 pub const ARPHRD_IPGRE: u16 = 778; 1417 pub const ARPHRD_PIMREG: u16 = 779; 1418 pub const ARPHRD_HIPPI: u16 = 780; 1419 pub const ARPHRD_ASH: u16 = 781; 1420 pub const ARPHRD_ECONET: u16 = 782; 1421 pub const ARPHRD_IRDA: u16 = 783; 1422 pub const ARPHRD_FCPP: u16 = 784; 1423 pub const ARPHRD_FCAL: u16 = 785; 1424 pub const ARPHRD_FCPL: u16 = 786; 1425 pub const ARPHRD_FCFABRIC: u16 = 787; 1426 pub const ARPHRD_IEEE802_TR: u16 = 800; 1427 pub const ARPHRD_IEEE80211: u16 = 801; 1428 pub const ARPHRD_IEEE80211_PRISM: u16 = 802; 1429 pub const ARPHRD_IEEE80211_RADIOTAP: u16 = 803; 1430 pub const ARPHRD_IEEE802154: u16 = 804; 1431 1432 pub const ARPHRD_VOID: u16 = 0xFFFF; 1433 pub const ARPHRD_NONE: u16 = 0xFFFE; 1434 1435 cfg_if! { 1436 if #[cfg(not(any(target_os = "emscripten", target_os = "l4re")))] { 1437 // linux/if_tun.h 1438 /* TUNSETIFF ifr flags */ 1439 pub const IFF_TUN: c_int = 0x0001; 1440 pub const IFF_TAP: c_int = 0x0002; 1441 pub const IFF_NAPI: c_int = 0x0010; 1442 pub const IFF_NAPI_FRAGS: c_int = 0x0020; 1443 // Used in TUNSETIFF to bring up tun/tap without carrier 1444 pub const IFF_NO_CARRIER: c_int = 0x0040; 1445 pub const IFF_NO_PI: c_int = 0x1000; 1446 // Read queue size 1447 pub const TUN_READQ_SIZE: c_short = 500; 1448 // TUN device type flags: deprecated. Use IFF_TUN/IFF_TAP instead. 1449 pub const TUN_TUN_DEV: c_short = crate::IFF_TUN as c_short; 1450 pub const TUN_TAP_DEV: c_short = crate::IFF_TAP as c_short; 1451 pub const TUN_TYPE_MASK: c_short = 0x000f; 1452 // This flag has no real effect 1453 pub const IFF_ONE_QUEUE: c_int = 0x2000; 1454 pub const IFF_VNET_HDR: c_int = 0x4000; 1455 pub const IFF_TUN_EXCL: c_int = 0x8000; 1456 pub const IFF_MULTI_QUEUE: c_int = 0x0100; 1457 pub const IFF_ATTACH_QUEUE: c_int = 0x0200; 1458 pub const IFF_DETACH_QUEUE: c_int = 0x0400; 1459 // read-only flag 1460 pub const IFF_PERSIST: c_int = 0x0800; 1461 pub const IFF_NOFILTER: c_int = 0x1000; 1462 // Socket options 1463 pub const TUN_TX_TIMESTAMP: c_int = 1; 1464 // Features for GSO (TUNSETOFFLOAD) 1465 pub const TUN_F_CSUM: c_uint = 0x01; 1466 pub const TUN_F_TSO4: c_uint = 0x02; 1467 pub const TUN_F_TSO6: c_uint = 0x04; 1468 pub const TUN_F_TSO_ECN: c_uint = 0x08; 1469 pub const TUN_F_UFO: c_uint = 0x10; 1470 pub const TUN_F_USO4: c_uint = 0x20; 1471 pub const TUN_F_USO6: c_uint = 0x40; 1472 // Protocol info prepended to the packets (when IFF_NO_PI is not set) 1473 pub const TUN_PKT_STRIP: c_int = 0x0001; 1474 // Accept all multicast packets 1475 pub const TUN_FLT_ALLMULTI: c_int = 0x0001; 1476 // Ioctl operation codes 1477 const T_TYPE: u32 = b'T' as u32; 1478 pub const TUNSETNOCSUM: Ioctl = _IOW::(T_TYPE, 200); 1479 pub const TUNSETDEBUG: Ioctl = _IOW::(T_TYPE, 201); 1480 pub const TUNSETIFF: Ioctl = _IOW::(T_TYPE, 202); 1481 pub const TUNSETPERSIST: Ioctl = _IOW::(T_TYPE, 203); 1482 pub const TUNSETOWNER: Ioctl = _IOW::(T_TYPE, 204); 1483 pub const TUNSETLINK: Ioctl = _IOW::(T_TYPE, 205); 1484 pub const TUNSETGROUP: Ioctl = _IOW::(T_TYPE, 206); 1485 pub const TUNGETFEATURES: Ioctl = _IOR::(T_TYPE, 207); 1486 pub const TUNSETOFFLOAD: Ioctl = _IOW::(T_TYPE, 208); 1487 pub const TUNSETTXFILTER: Ioctl = _IOW::(T_TYPE, 209); 1488 pub const TUNGETIFF: Ioctl = _IOR::(T_TYPE, 210); 1489 pub const TUNGETSNDBUF: Ioctl = _IOR::(T_TYPE, 211); 1490 pub const TUNSETSNDBUF: Ioctl = _IOW::(T_TYPE, 212); 1491 pub const TUNATTACHFILTER: Ioctl = _IOW::(T_TYPE, 213); 1492 pub const TUNDETACHFILTER: Ioctl = _IOW::(T_TYPE, 214); 1493 pub const TUNGETVNETHDRSZ: Ioctl = _IOR::(T_TYPE, 215); 1494 pub const TUNSETVNETHDRSZ: Ioctl = _IOW::(T_TYPE, 216); 1495 pub const TUNSETQUEUE: Ioctl = _IOW::(T_TYPE, 217); 1496 pub const TUNSETIFINDEX: Ioctl = _IOW::(T_TYPE, 218); 1497 pub const TUNGETFILTER: Ioctl = _IOR::(T_TYPE, 219); 1498 pub const TUNSETVNETLE: Ioctl = _IOW::(T_TYPE, 220); 1499 pub const TUNGETVNETLE: Ioctl = _IOR::(T_TYPE, 221); 1500 pub const TUNSETVNETBE: Ioctl = _IOW::(T_TYPE, 222); 1501 pub const TUNGETVNETBE: Ioctl = _IOR::(T_TYPE, 223); 1502 pub const TUNSETSTEERINGEBPF: Ioctl = _IOR::(T_TYPE, 224); 1503 pub const TUNSETFILTEREBPF: Ioctl = _IOR::(T_TYPE, 225); 1504 pub const TUNSETCARRIER: Ioctl = _IOW::(T_TYPE, 226); 1505 pub const TUNGETDEVNETNS: Ioctl = _IO(T_TYPE, 227); 1506 1507 // linux/fs.h 1508 pub const FS_IOC_GETFLAGS: Ioctl = _IOR::('f' as u32, 1); 1509 pub const FS_IOC_SETFLAGS: Ioctl = _IOW::('f' as u32, 2); 1510 pub const FS_IOC_GETVERSION: Ioctl = _IOR::('v' as u32, 1); 1511 pub const FS_IOC_SETVERSION: Ioctl = _IOW::('v' as u32, 2); 1512 pub const FS_IOC32_GETFLAGS: Ioctl = _IOR::('f' as u32, 1); 1513 pub const FS_IOC32_SETFLAGS: Ioctl = _IOW::('f' as u32, 2); 1514 pub const FS_IOC32_GETVERSION: Ioctl = _IOR::('v' as u32, 1); 1515 pub const FS_IOC32_SETVERSION: Ioctl = _IOW::('v' as u32, 2); 1516 1517 pub const FICLONE: Ioctl = _IOW::(0x94, 9); 1518 pub const FICLONERANGE: Ioctl = _IOW::(0x94, 13); 1519 } 1520 } 1521 1522 cfg_if! { 1523 if #[cfg(any(target_os = "emscripten", target_os = "l4re"))] { 1524 // Emscripten does not define any `*_SUPER_MAGIC` constants. 1525 } else if #[cfg(not(target_arch = "s390x"))] { 1526 pub const ADFS_SUPER_MAGIC: c_long = 0x0000adf5; 1527 pub const AFFS_SUPER_MAGIC: c_long = 0x0000adff; 1528 pub const AFS_SUPER_MAGIC: c_long = 0x5346414f; 1529 pub const AUTOFS_SUPER_MAGIC: c_long = 0x0187; 1530 pub const BPF_FS_MAGIC: c_long = u32_cast_long(0xcafe4a11); 1531 pub const BTRFS_SUPER_MAGIC: c_long = u32_cast_long(0x9123683e); 1532 pub const CGROUP2_SUPER_MAGIC: c_long = 0x63677270; 1533 pub const CGROUP_SUPER_MAGIC: c_long = 0x27e0eb; 1534 pub const CODA_SUPER_MAGIC: c_long = 0x73757245; 1535 pub const CRAMFS_MAGIC: c_long = 0x28cd3d45; 1536 pub const DEBUGFS_MAGIC: c_long = 0x64626720; 1537 pub const DEVPTS_SUPER_MAGIC: c_long = 0x1cd1; 1538 pub const ECRYPTFS_SUPER_MAGIC: c_long = 0xf15f; 1539 pub const EFS_SUPER_MAGIC: c_long = 0x00414a53; 1540 pub const EXT2_SUPER_MAGIC: c_long = 0x0000ef53; 1541 pub const EXT3_SUPER_MAGIC: c_long = 0x0000ef53; 1542 pub const EXT4_SUPER_MAGIC: c_long = 0x0000ef53; 1543 pub const F2FS_SUPER_MAGIC: c_long = u32_cast_long(0xf2f52010); 1544 pub const FUSE_SUPER_MAGIC: c_long = 0x65735546; 1545 pub const FUTEXFS_SUPER_MAGIC: c_long = 0xbad1dea; 1546 pub const HOSTFS_SUPER_MAGIC: c_long = 0x00c0ffee; 1547 pub const HPFS_SUPER_MAGIC: c_long = u32_cast_long(0xf995e849); 1548 pub const HUGETLBFS_MAGIC: c_long = u32_cast_long(0x958458f6); 1549 pub const ISOFS_SUPER_MAGIC: c_long = 0x00009660; 1550 pub const JFFS2_SUPER_MAGIC: c_long = 0x000072b6; 1551 pub const MINIX2_SUPER_MAGIC2: c_long = 0x00002478; 1552 pub const MINIX2_SUPER_MAGIC: c_long = 0x00002468; 1553 pub const MINIX3_SUPER_MAGIC: c_long = 0x4d5a; 1554 pub const MINIX_SUPER_MAGIC2: c_long = 0x0000138f; 1555 pub const MINIX_SUPER_MAGIC: c_long = 0x0000137f; 1556 pub const MSDOS_SUPER_MAGIC: c_long = 0x00004d44; 1557 pub const NCP_SUPER_MAGIC: c_long = 0x0000564c; 1558 pub const NFS_SUPER_MAGIC: c_long = 0x00006969; 1559 pub const NILFS_SUPER_MAGIC: c_long = 0x3434; 1560 pub const OCFS2_SUPER_MAGIC: c_long = 0x7461636f; 1561 pub const OPENPROM_SUPER_MAGIC: c_long = 0x00009fa1; 1562 pub const OVERLAYFS_SUPER_MAGIC: c_long = 0x794c7630; 1563 pub const PROC_SUPER_MAGIC: c_long = 0x00009fa0; 1564 pub const QNX4_SUPER_MAGIC: c_long = 0x0000002f; 1565 pub const QNX6_SUPER_MAGIC: c_long = 0x68191122; 1566 pub const RDTGROUP_SUPER_MAGIC: c_long = 0x7655821; 1567 pub const REISERFS_SUPER_MAGIC: c_long = 0x52654973; 1568 pub const SECURITYFS_MAGIC: c_long = 0x73636673; 1569 pub const SELINUX_MAGIC: c_long = u32_cast_long(0xf97cff8c); 1570 pub const SMACK_MAGIC: c_long = 0x43415d53; 1571 pub const SMB_SUPER_MAGIC: c_long = 0x0000517b; 1572 pub const SYSFS_MAGIC: c_long = 0x62656572; 1573 pub const TMPFS_MAGIC: c_long = 0x01021994; 1574 pub const TRACEFS_MAGIC: c_long = 0x74726163; 1575 pub const UDF_SUPER_MAGIC: c_long = 0x15013346; 1576 pub const USBDEVICE_SUPER_MAGIC: c_long = 0x00009fa2; 1577 pub const XENFS_SUPER_MAGIC: c_long = u32_cast_long(0xabba1974); 1578 pub const NSFS_MAGIC: c_long = 0x6e736673; 1579 } else if #[cfg(target_arch = "s390x")] { 1580 pub const ADFS_SUPER_MAGIC: c_uint = 0x0000adf5; 1581 pub const AFFS_SUPER_MAGIC: c_uint = 0x0000adff; 1582 pub const AFS_SUPER_MAGIC: c_uint = 0x5346414f; 1583 pub const AUTOFS_SUPER_MAGIC: c_uint = 0x0187; 1584 pub const BPF_FS_MAGIC: c_uint = 0xcafe4a11; 1585 pub const BTRFS_SUPER_MAGIC: c_uint = 0x9123683e; 1586 pub const CGROUP2_SUPER_MAGIC: c_uint = 0x63677270; 1587 pub const CGROUP_SUPER_MAGIC: c_uint = 0x27e0eb; 1588 pub const CODA_SUPER_MAGIC: c_uint = 0x73757245; 1589 pub const CRAMFS_MAGIC: c_uint = 0x28cd3d45; 1590 pub const DEBUGFS_MAGIC: c_uint = 0x64626720; 1591 pub const DEVPTS_SUPER_MAGIC: c_uint = 0x1cd1; 1592 pub const ECRYPTFS_SUPER_MAGIC: c_uint = 0xf15f; 1593 pub const EFS_SUPER_MAGIC: c_uint = 0x00414a53; 1594 pub const EXT2_SUPER_MAGIC: c_uint = 0x0000ef53; 1595 pub const EXT3_SUPER_MAGIC: c_uint = 0x0000ef53; 1596 pub const EXT4_SUPER_MAGIC: c_uint = 0x0000ef53; 1597 pub const F2FS_SUPER_MAGIC: c_uint = 0xf2f52010; 1598 pub const FUSE_SUPER_MAGIC: c_uint = 0x65735546; 1599 pub const FUTEXFS_SUPER_MAGIC: c_uint = 0xbad1dea; 1600 pub const HOSTFS_SUPER_MAGIC: c_uint = 0x00c0ffee; 1601 pub const HPFS_SUPER_MAGIC: c_uint = 0xf995e849; 1602 pub const HUGETLBFS_MAGIC: c_uint = 0x958458f6; 1603 pub const ISOFS_SUPER_MAGIC: c_uint = 0x00009660; 1604 pub const JFFS2_SUPER_MAGIC: c_uint = 0x000072b6; 1605 pub const MINIX2_SUPER_MAGIC2: c_uint = 0x00002478; 1606 pub const MINIX2_SUPER_MAGIC: c_uint = 0x00002468; 1607 pub const MINIX3_SUPER_MAGIC: c_uint = 0x4d5a; 1608 pub const MINIX_SUPER_MAGIC2: c_uint = 0x0000138f; 1609 pub const MINIX_SUPER_MAGIC: c_uint = 0x0000137f; 1610 pub const MSDOS_SUPER_MAGIC: c_uint = 0x00004d44; 1611 pub const NCP_SUPER_MAGIC: c_uint = 0x0000564c; 1612 pub const NFS_SUPER_MAGIC: c_uint = 0x00006969; 1613 pub const NILFS_SUPER_MAGIC: c_uint = 0x3434; 1614 pub const OCFS2_SUPER_MAGIC: c_uint = 0x7461636f; 1615 pub const OPENPROM_SUPER_MAGIC: c_uint = 0x00009fa1; 1616 pub const OVERLAYFS_SUPER_MAGIC: c_uint = 0x794c7630; 1617 pub const PROC_SUPER_MAGIC: c_uint = 0x00009fa0; 1618 pub const QNX4_SUPER_MAGIC: c_uint = 0x0000002f; 1619 pub const QNX6_SUPER_MAGIC: c_uint = 0x68191122; 1620 pub const RDTGROUP_SUPER_MAGIC: c_uint = 0x7655821; 1621 pub const REISERFS_SUPER_MAGIC: c_uint = 0x52654973; 1622 pub const SECURITYFS_MAGIC: c_uint = 0x73636673; 1623 pub const SELINUX_MAGIC: c_uint = 0xf97cff8c; 1624 pub const SMACK_MAGIC: c_uint = 0x43415d53; 1625 pub const SMB_SUPER_MAGIC: c_uint = 0x0000517b; 1626 pub const SYSFS_MAGIC: c_uint = 0x62656572; 1627 pub const TMPFS_MAGIC: c_uint = 0x01021994; 1628 pub const TRACEFS_MAGIC: c_uint = 0x74726163; 1629 pub const UDF_SUPER_MAGIC: c_uint = 0x15013346; 1630 pub const USBDEVICE_SUPER_MAGIC: c_uint = 0x00009fa2; 1631 pub const XENFS_SUPER_MAGIC: c_uint = 0xabba1974; 1632 pub const NSFS_MAGIC: c_uint = 0x6e736673; 1633 } 1634 } 1635 1636 cfg_if! { 1637 if #[cfg(any( 1638 target_env = "gnu", 1639 target_os = "android", 1640 all(target_env = "musl", musl_v1_2_3), 1641 target_os = "l4re" 1642 ))] { 1643 pub const AT_STATX_SYNC_TYPE: c_int = 0x6000; 1644 pub const AT_STATX_SYNC_AS_STAT: c_int = 0x0000; 1645 pub const AT_STATX_FORCE_SYNC: c_int = 0x2000; 1646 pub const AT_STATX_DONT_SYNC: c_int = 0x4000; 1647 pub const STATX_TYPE: c_uint = 0x0001; 1648 pub const STATX_MODE: c_uint = 0x0002; 1649 pub const STATX_NLINK: c_uint = 0x0004; 1650 pub const STATX_UID: c_uint = 0x0008; 1651 pub const STATX_GID: c_uint = 0x0010; 1652 pub const STATX_ATIME: c_uint = 0x0020; 1653 pub const STATX_MTIME: c_uint = 0x0040; 1654 pub const STATX_CTIME: c_uint = 0x0080; 1655 pub const STATX_INO: c_uint = 0x0100; 1656 pub const STATX_SIZE: c_uint = 0x0200; 1657 pub const STATX_BLOCKS: c_uint = 0x0400; 1658 pub const STATX_BASIC_STATS: c_uint = 0x07ff; 1659 pub const STATX_BTIME: c_uint = 0x0800; 1660 pub const STATX_ALL: c_uint = 0x0fff; 1661 pub const STATX_MNT_ID: c_uint = 0x1000; 1662 pub const STATX_DIOALIGN: c_uint = 0x2000; 1663 pub const STATX__RESERVED: c_int = u32_cast_int(0x80000000); 1664 pub const STATX_ATTR_COMPRESSED: c_int = 0x0004; 1665 pub const STATX_ATTR_IMMUTABLE: c_int = 0x0010; 1666 pub const STATX_ATTR_APPEND: c_int = 0x0020; 1667 pub const STATX_ATTR_NODUMP: c_int = 0x0040; 1668 pub const STATX_ATTR_ENCRYPTED: c_int = 0x0800; 1669 pub const STATX_ATTR_AUTOMOUNT: c_int = 0x1000; 1670 pub const STATX_ATTR_MOUNT_ROOT: c_int = 0x2000; 1671 pub const STATX_ATTR_VERITY: c_int = 0x100000; 1672 pub const STATX_ATTR_DAX: c_int = 0x200000; 1673 } 1674 } 1675 1676 // https://github.com/search?q=repo%3Atorvalds%2Flinux+%22%23define+_IOC_NONE%22&type=code 1677 cfg_if! { 1678 if #[cfg(not(target_os = "emscripten"))] { 1679 const _IOC_NRBITS: u32 = 8; 1680 const _IOC_TYPEBITS: u32 = 8; 1681 1682 cfg_if! { 1683 if #[cfg(any( 1684 any(target_arch = "powerpc", target_arch = "powerpc64"), 1685 any(target_arch = "sparc", target_arch = "sparc64"), 1686 any(target_arch = "mips", target_arch = "mips64"), 1687 ))] { 1688 // https://github.com/torvalds/linux/blob/`b311c1b497e51a628aa89e7cb954481e5f9dced2`/arch/powerpc/include/uapi/asm/ioctl.h 1689 // https://github.com/torvalds/linux/blob/`b311c1b497e51a628aa89e7cb954481e5f9dced2`/arch/sparc/include/uapi/asm/ioctl.h 1690 // https://github.com/torvalds/linux/blob/`b311c1b497e51a628aa89e7cb954481e5f9dced2`/arch/mips/include/uapi/asm/ioctl.h 1691 1692 const _IOC_SIZEBITS: u32 = 13; 1693 const _IOC_DIRBITS: u32 = 3; 1694 1695 const _IOC_NONE: u32 = 1; 1696 const _IOC_READ: u32 = 2; 1697 const _IOC_WRITE: u32 = 4; 1698 } else { 1699 // https://github.com/torvalds/linux/blob/`b311c1b497e51a628aa89e7cb954481e5f9dced2`/include/uapi/asm-generic/ioctl.h 1700 1701 const _IOC_SIZEBITS: u32 = 14; 1702 const _IOC_DIRBITS: u32 = 2; 1703 1704 const _IOC_NONE: u32 = 0; 1705 const _IOC_WRITE: u32 = 1; 1706 const _IOC_READ: u32 = 2; 1707 } 1708 } 1709 const _IOC_NRMASK: u32 = (1 << _IOC_NRBITS) - 1; 1710 const _IOC_TYPEMASK: u32 = (1 << _IOC_TYPEBITS) - 1; 1711 const _IOC_SIZEMASK: u32 = (1 << _IOC_SIZEBITS) - 1; 1712 const _IOC_DIRMASK: u32 = (1 << _IOC_DIRBITS) - 1; 1713 1714 const _IOC_NRSHIFT: u32 = 0; 1715 const _IOC_TYPESHIFT: u32 = _IOC_NRSHIFT + _IOC_NRBITS; 1716 const _IOC_SIZESHIFT: u32 = _IOC_TYPESHIFT + _IOC_TYPEBITS; 1717 const _IOC_DIRSHIFT: u32 = _IOC_SIZESHIFT + _IOC_SIZEBITS; 1718 1719 // adapted from https://github.com/torvalds/linux/blob/`8a696a29c6905594e4abf78eaafcb62165ac61f1`/rust/kernel/ioctl.rs 1720 1721 /// Build an ioctl number, analogous to the C macro of the same name. 1722 const fn _IOC(dir: u32, ty: u32, nr: u32, size: usize) -> Ioctl { 1723 core::debug_assert!(dir <= _IOC_DIRMASK); 1724 core::debug_assert!(ty <= _IOC_TYPEMASK); 1725 core::debug_assert!(nr <= _IOC_NRMASK); 1726 core::debug_assert!(size <= (_IOC_SIZEMASK as usize)); 1727 1728 ((dir << _IOC_DIRSHIFT) 1729 | (ty << _IOC_TYPESHIFT) 1730 | (nr << _IOC_NRSHIFT) 1731 | ((size as u32) << _IOC_SIZESHIFT)) as Ioctl 1732 } 1733 1734 /// Build an ioctl number for an argumentless ioctl. 1735 pub const fn _IO(ty: u32, nr: u32) -> Ioctl { 1736 _IOC(_IOC_NONE, ty, nr, 0) 1737 } 1738 1739 /// Build an ioctl number for an read-only ioctl. 1740 pub const fn _IOR(ty: u32, nr: u32) -> Ioctl { 1741 _IOC(_IOC_READ, ty, nr, size_of::()) 1742 } 1743 1744 /// Build an ioctl number for an write-only ioctl. 1745 pub const fn _IOW(ty: u32, nr: u32) -> Ioctl { 1746 _IOC(_IOC_WRITE, ty, nr, size_of::()) 1747 } 1748 1749 /// Build an ioctl number for a read-write ioctl. 1750 pub const fn _IOWR(ty: u32, nr: u32) -> Ioctl { 1751 _IOC(_IOC_READ | _IOC_WRITE, ty, nr, size_of::()) 1752 } 1753 1754 extern "C" { 1755 #[cfg_attr(gnu_time_bits64, link_name = "__ioctl_time64")] 1756 pub fn ioctl(fd: c_int, request: Ioctl, ...) -> c_int; 1757 } 1758 } 1759 } 1760 1761 const fn CMSG_ALIGN(len: usize) -> usize { 1762 (len + size_of::() - 1) & !(size_of::() - 1) 1763 } 1764 1765 f! { 1766 pub unsafe fn CMSG_FIRSTHDR(mhdr: *const crate::msghdr) -> *mut crate::cmsghdr { 1767 if (*mhdr).msg_controllen as usize >= size_of::() { 1768 (*mhdr).msg_control.cast() 1769 } else { 1770 ptr::null_mut() 1771 } 1772 } 1773 1774 pub unsafe fn CMSG_DATA(cmsg: *const crate::cmsghdr) -> *mut c_uchar { 1775 cmsg.offset(1) as *mut c_uchar 1776 } 1777 1778 pub const unsafe fn CMSG_SPACE(length: c_uint) -> c_uint { 1779 (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::())) as c_uint 1780 } 1781 1782 pub const unsafe fn CMSG_LEN(length: c_uint) -> c_uint { 1783 CMSG_ALIGN(size_of::()) as c_uint + length 1784 } 1785 1786 pub unsafe fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { 1787 let fd = fd as usize; 1788 let size = size_of_val(&(*set).fds_bits[0]) * 8; 1789 (*set).fds_bits[fd / size] &= !(1 << (fd % size)); 1790 return; 1791 } 1792 1793 pub unsafe fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { 1794 let fd = fd as usize; 1795 let size = size_of_val(&(*set).fds_bits[0]) * 8; 1796 return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; 1797 } 1798 1799 pub unsafe fn FD_SET(fd: c_int, set: *mut fd_set) -> () { 1800 let fd = fd as usize; 1801 let size = size_of_val(&(*set).fds_bits[0]) * 8; 1802 (*set).fds_bits[fd / size] |= 1 << (fd % size); 1803 return; 1804 } 1805 1806 pub unsafe fn FD_ZERO(set: *mut fd_set) -> () { 1807 (*set).fds_bits.fill(0); 1808 } 1809 } 1810 1811 safe_f! { 1812 pub safe fn SIGRTMAX() -> c_int { 1813 unsafe { __libc_current_sigrtmax() } 1814 } 1815 1816 pub safe fn SIGRTMIN() -> c_int { 1817 unsafe { __libc_current_sigrtmin() } 1818 } 1819 1820 pub const safe fn WIFSTOPPED(status: c_int) -> bool { 1821 (status & 0xff) == 0x7f 1822 } 1823 1824 pub const safe fn WSTOPSIG(status: c_int) -> c_int { 1825 (status >> 8) & 0xff 1826 } 1827 1828 pub const safe fn WIFCONTINUED(status: c_int) -> bool { 1829 status == 0xffff 1830 } 1831 1832 pub const safe fn WIFSIGNALED(status: c_int) -> bool { 1833 ((status & 0x7f) + 1) as i8 >= 2 1834 } 1835 1836 pub const safe fn WTERMSIG(status: c_int) -> c_int { 1837 status & 0x7f 1838 } 1839 1840 pub const safe fn WIFEXITED(status: c_int) -> bool { 1841 (status & 0x7f) == 0 1842 } 1843 1844 pub const safe fn WEXITSTATUS(status: c_int) -> c_int { 1845 (status >> 8) & 0xff 1846 } 1847 1848 pub const safe fn WCOREDUMP(status: c_int) -> bool { 1849 (status & 0x80) != 0 1850 } 1851 1852 pub const safe fn W_EXITCODE(ret: c_int, sig: c_int) -> c_int { 1853 (ret << 8) | sig 1854 } 1855 1856 pub const safe fn W_STOPCODE(sig: c_int) -> c_int { 1857 (sig << 8) | 0x7f 1858 } 1859 1860 pub const safe fn QCMD(cmd: c_int, type_: c_int) -> c_int { 1861 (cmd << 8) | (type_ & 0x00ff) 1862 } 1863 1864 pub const safe fn IPOPT_COPIED(o: u8) -> u8 { 1865 o & IPOPT_COPY 1866 } 1867 1868 pub const safe fn IPOPT_CLASS(o: u8) -> u8 { 1869 o & IPOPT_CLASS_MASK 1870 } 1871 1872 pub const safe fn IPOPT_NUMBER(o: u8) -> u8 { 1873 o & IPOPT_NUMBER_MASK 1874 } 1875 1876 pub const safe fn IPTOS_ECN(x: u8) -> u8 { 1877 x & crate::IPTOS_ECN_MASK 1878 } 1879 1880 #[allow(ellipsis_inclusive_range_patterns)] 1881 pub const safe fn KERNEL_VERSION(a: u32, b: u32, c: u32) -> u32 { 1882 ((a << 16) + (b << 8)) + if c > 255 { 255 } else { c } 1883 } 1884 } 1885 1886 extern "C" { 1887 #[doc(hidden)] 1888 pub fn __libc_current_sigrtmax() -> c_int; 1889 #[doc(hidden)] 1890 pub fn __libc_current_sigrtmin() -> c_int; 1891 1892 pub fn sem_destroy(sem: *mut sem_t) -> c_int; 1893 pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; 1894 pub fn fdatasync(fd: c_int) -> c_int; 1895 #[cfg(not(target_os = "l4re"))] 1896 pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar) -> c_int; 1897 1898 #[cfg_attr(gnu_time_bits64, link_name = "__clock_getres64")] 1899 #[cfg_attr(musl_redir_time64, link_name = "__clock_getres_time64")] 1900 pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; 1901 #[cfg_attr( 1902 any(gnu_time_bits64, musl_redir_time64), 1903 link_name = "__clock_gettime64" 1904 )] 1905 pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; 1906 #[cfg_attr( 1907 any(gnu_time_bits64, musl_redir_time64), 1908 link_name = "__clock_settime64" 1909 )] 1910 pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; 1911 #[cfg(not(target_os = "l4re"))] 1912 pub fn clock_getcpuclockid(pid: crate::pid_t, clk_id: *mut crate::clockid_t) -> c_int; 1913 1914 #[cfg_attr(gnu_time_bits64, link_name = "__getitimer64")] 1915 #[cfg_attr(musl_redir_time64, link_name = "__getitimer_time64")] 1916 pub fn getitimer(which: c_int, curr_value: *mut crate::itimerval) -> c_int; 1917 #[cfg_attr(gnu_time_bits64, link_name = "__setitimer64")] 1918 #[cfg_attr(musl_redir_time64, link_name = "__setitimer_time64")] 1919 pub fn setitimer( 1920 which: c_int, 1921 new_value: *const crate::itimerval, 1922 old_value: *mut crate::itimerval, 1923 ) -> c_int; 1924 1925 pub fn dirfd(dirp: *mut crate::DIR) -> c_int; 1926 1927 pub fn memalign(align: size_t, size: size_t) -> *mut c_void; 1928 pub fn setgroups(ngroups: size_t, ptr: *const crate::gid_t) -> c_int; 1929 #[cfg(not(target_os = "l4re"))] 1930 pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; 1931 #[cfg_attr(gnu_file_offset_bits64, link_name = "statfs64")] 1932 pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; 1933 #[cfg_attr(gnu_file_offset_bits64, link_name = "fstatfs64")] 1934 pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; 1935 pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; 1936 #[cfg_attr(gnu_file_offset_bits64, link_name = "posix_fadvise64")] 1937 pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; 1938 #[cfg_attr(gnu_time_bits64, link_name = "__futimens64")] 1939 #[cfg_attr(musl_redir_time64, link_name = "__futimens_time64")] 1940 #[cfg(not(target_os = "l4re"))] 1941 pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; 1942 #[cfg_attr(gnu_time_bits64, link_name = "__utimensat64")] 1943 #[cfg_attr(musl_redir_time64, link_name = "__utimensat_time64")] 1944 pub fn utimensat( 1945 dirfd: c_int, 1946 path: *const c_char, 1947 times: *const crate::timespec, 1948 flag: c_int, 1949 ) -> c_int; 1950 #[cfg(not(target_os = "l4re"))] 1951 pub fn duplocale(base: crate::locale_t) -> crate::locale_t; 1952 pub fn freelocale(loc: crate::locale_t); 1953 pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t; 1954 pub fn uselocale(loc: crate::locale_t) -> crate::locale_t; 1955 #[cfg(not(target_os = "l4re"))] 1956 pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; 1957 1958 #[cfg(not(target_os = "l4re"))] 1959 pub fn ptsname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int; 1960 pub fn clearenv() -> c_int; 1961 #[cfg(not(target_os = "l4re"))] 1962 pub fn waitid( 1963 idtype: idtype_t, 1964 id: id_t, 1965 infop: *mut crate::siginfo_t, 1966 options: c_int, 1967 ) -> c_int; 1968 #[cfg(not(target_os = "l4re"))] 1969 pub fn getresuid( 1970 ruid: *mut crate::uid_t, 1971 euid: *mut crate::uid_t, 1972 suid: *mut crate::uid_t, 1973 ) -> c_int; 1974 #[cfg(not(target_os = "l4re"))] 1975 pub fn getresgid( 1976 rgid: *mut crate::gid_t, 1977 egid: *mut crate::gid_t, 1978 sgid: *mut crate::gid_t, 1979 ) -> c_int; 1980 #[cfg(not(target_os = "l4re"))] 1981 pub fn acct(filename: *const c_char) -> c_int; 1982 #[cfg(not(target_os = "l4re"))] 1983 pub fn brk(addr: *mut c_void) -> c_int; 1984 #[cfg(not(target_os = "l4re"))] 1985 pub fn sbrk(increment: intptr_t) -> *mut c_void; 1986 #[deprecated( 1987 since = "0.2.66", 1988 note = "causes memory corruption, see rust-lang/libc#1596" 1989 )] 1990 pub fn vfork() -> crate::pid_t; 1991 #[cfg(not(target_os = "l4re"))] 1992 pub fn setresgid(rgid: crate::gid_t, egid: crate::gid_t, sgid: crate::gid_t) -> c_int; 1993 #[cfg(not(target_os = "l4re"))] 1994 pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int; 1995 #[cfg_attr(any(gnu_time_bits64, musl_redir_time64), link_name = "__wait4_time64")] 1996 #[cfg(not(target_os = "l4re"))] 1997 pub fn wait4( 1998 pid: crate::pid_t, 1999 status: *mut c_int, 2000 options: c_int, 2001 rusage: *mut crate::rusage, 2002 ) -> crate::pid_t; 2003 #[cfg(not(target_os = "l4re"))] 2004 pub fn login_tty(fd: c_int) -> c_int; 2005 2006 // DIFF(main): changed to `*const *mut` in `e77f551de9` 2007 #[cfg(not(target_os = "l4re"))] 2008 pub fn execvpe( 2009 file: *const c_char, 2010 argv: *const *const c_char, 2011 envp: *const *const c_char, 2012 ) -> c_int; 2013 #[cfg(not(target_os = "l4re"))] 2014 pub fn fexecve(fd: c_int, argv: *const *const c_char, envp: *const *const c_char) -> c_int; 2015 #[cfg(not(target_os = "l4re"))] 2016 pub fn getifaddrs(ifap: *mut *mut crate::ifaddrs) -> c_int; 2017 #[cfg(not(target_os = "l4re"))] 2018 pub fn freeifaddrs(ifa: *mut crate::ifaddrs); 2019 pub fn bind( 2020 socket: c_int, 2021 address: *const crate::sockaddr, 2022 address_len: crate::socklen_t, 2023 ) -> c_int; 2024 2025 pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; 2026 pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; 2027 2028 #[cfg_attr(gnu_time_bits64, link_name = "__sendmsg64")] 2029 pub fn sendmsg(fd: c_int, msg: *const crate::msghdr, flags: c_int) -> ssize_t; 2030 #[cfg_attr(gnu_time_bits64, link_name = "__recvmsg64")] 2031 pub fn recvmsg(fd: c_int, msg: *mut crate::msghdr, flags: c_int) -> ssize_t; 2032 pub fn uname(buf: *mut crate::utsname) -> c_int; 2033 2034 pub fn strchrnul(s: *const c_char, c: c_int) -> *mut c_char; 2035 2036 pub fn strftime( 2037 s: *mut c_char, 2038 max: size_t, 2039 format: *const c_char, 2040 tm: *const crate::tm, 2041 ) -> size_t; 2042 pub fn strftime_l( 2043 s: *mut c_char, 2044 max: size_t, 2045 format: *const c_char, 2046 tm: *const crate::tm, 2047 locale: crate::locale_t, 2048 ) -> size_t; 2049 pub fn strptime(s: *const c_char, format: *const c_char, tm: *mut crate::tm) -> *mut c_char; 2050 2051 #[cfg_attr(gnu_file_offset_bits64, link_name = "mkostemp64")] 2052 pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int; 2053 #[cfg_attr(gnu_file_offset_bits64, link_name = "mkostemps64")] 2054 #[cfg(not(target_os = "l4re"))] 2055 pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int; 2056 2057 #[cfg(not(target_os = "l4re"))] 2058 pub fn getdomainname(name: *mut c_char, len: size_t) -> c_int; 2059 #[cfg(not(target_os = "l4re"))] 2060 pub fn setdomainname(name: *const c_char, len: size_t) -> c_int; 2061 2062 pub fn if_nameindex() -> *mut if_nameindex; 2063 pub fn if_freenameindex(ptr: *mut if_nameindex); 2064 2065 pub fn getpwnam_r( 2066 name: *const c_char, 2067 pwd: *mut passwd, 2068 buf: *mut c_char, 2069 buflen: size_t, 2070 result: *mut *mut passwd, 2071 ) -> c_int; 2072 pub fn getpwuid_r( 2073 uid: crate::uid_t, 2074 pwd: *mut passwd, 2075 buf: *mut c_char, 2076 buflen: size_t, 2077 result: *mut *mut passwd, 2078 ) -> c_int; 2079 } 2080 2081 // LFS64 extensions 2082 // 2083 // * musl and Emscripten has 64-bit versions only so aliases the LFS64 symbols to the standard ones 2084 // * ulibc doesn't have preadv64/pwritev64 2085 cfg_if! { 2086 if #[cfg(not(any( 2087 target_env = "musl", 2088 target_env = "ohos", 2089 target_os = "emscripten", 2090 )))] { 2091 extern "C" { 2092 pub fn fstatfs64(fd: c_int, buf: *mut statfs64) -> c_int; 2093 pub fn statvfs64(path: *const c_char, buf: *mut statvfs64) -> c_int; 2094 pub fn fstatvfs64(fd: c_int, buf: *mut statvfs64) -> c_int; 2095 pub fn statfs64(path: *const c_char, buf: *mut statfs64) -> c_int; 2096 pub fn creat64(path: *const c_char, mode: mode_t) -> c_int; 2097 #[cfg_attr(gnu_time_bits64, link_name = "__fstat64_time64")] 2098 pub fn fstat64(fildes: c_int, buf: *mut stat64) -> c_int; 2099 #[cfg_attr(gnu_time_bits64, link_name = "__fstatat64_time64")] 2100 #[cfg(not(target_os = "l4re"))] 2101 pub fn fstatat64( 2102 dirfd: c_int, 2103 pathname: *const c_char, 2104 buf: *mut stat64, 2105 flags: c_int, 2106 ) -> c_int; 2107 pub fn ftruncate64(fd: c_int, length: off64_t) -> c_int; 2108 pub fn lseek64(fd: c_int, offset: off64_t, whence: c_int) -> off64_t; 2109 #[cfg_attr(gnu_time_bits64, link_name = "__lstat64_time64")] 2110 #[cfg(not(target_os = "l4re"))] 2111 pub fn lstat64(path: *const c_char, buf: *mut stat64) -> c_int; 2112 pub fn mmap64( 2113 addr: *mut c_void, 2114 len: size_t, 2115 prot: c_int, 2116 flags: c_int, 2117 fd: c_int, 2118 offset: off64_t, 2119 ) -> *mut c_void; 2120 pub fn open64(path: *const c_char, oflag: c_int, ...) -> c_int; 2121 pub fn openat64(fd: c_int, path: *const c_char, oflag: c_int, ...) -> c_int; 2122 pub fn posix_fadvise64( 2123 fd: c_int, 2124 offset: off64_t, 2125 len: off64_t, 2126 advise: c_int, 2127 ) -> c_int; 2128 pub fn pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: off64_t) -> ssize_t; 2129 pub fn pwrite64( 2130 fd: c_int, 2131 buf: *const c_void, 2132 count: size_t, 2133 offset: off64_t, 2134 ) -> ssize_t; 2135 pub fn readdir64(dirp: *mut crate::DIR) -> *mut crate::dirent64; 2136 pub fn readdir64_r( 2137 dirp: *mut crate::DIR, 2138 entry: *mut crate::dirent64, 2139 result: *mut *mut crate::dirent64, 2140 ) -> c_int; 2141 #[cfg_attr(gnu_time_bits64, link_name = "__stat64_time64")] 2142 #[cfg(not(target_os = "l4re"))] 2143 pub fn stat64(path: *const c_char, buf: *mut stat64) -> c_int; 2144 pub fn truncate64(path: *const c_char, length: off64_t) -> c_int; 2145 } 2146 } 2147 } 2148 2149 cfg_if! { 2150 if #[cfg(not(any( 2151 target_env = "uclibc", 2152 target_env = "musl", 2153 target_env = "ohos", 2154 target_os = "emscripten", 2155 )))] { 2156 extern "C" { 2157 pub fn preadv64( 2158 fd: c_int, 2159 iov: *const crate::iovec, 2160 iovcnt: c_int, 2161 offset: off64_t, 2162 ) -> ssize_t; 2163 pub fn pwritev64( 2164 fd: c_int, 2165 iov: *const crate::iovec, 2166 iovcnt: c_int, 2167 offset: off64_t, 2168 ) -> ssize_t; 2169 } 2170 } 2171 } 2172 2173 cfg_if! { 2174 if #[cfg(not(target_env = "uclibc"))] { 2175 extern "C" { 2176 // uclibc has separate non-const version of this function 2177 pub fn forkpty( 2178 amaster: *mut c_int, 2179 name: *mut c_char, 2180 termp: *const termios, 2181 winp: *const crate::winsize, 2182 ) -> crate::pid_t; 2183 // uclibc has separate non-const version of this function 2184 pub fn openpty( 2185 amaster: *mut c_int, 2186 aslave: *mut c_int, 2187 name: *mut c_char, 2188 termp: *const termios, 2189 winp: *const crate::winsize, 2190 ) -> c_int; 2191 } 2192 } 2193 } 2194 2195 // The statx syscall, available on some libcs. 2196 cfg_if! { 2197 if #[cfg(any( 2198 target_env = "gnu", 2199 target_os = "android", 2200 all(target_env = "musl", musl_v1_2_3) 2201 ))] { 2202 extern "C" { 2203 pub fn statx( 2204 dirfd: c_int, 2205 pathname: *const c_char, 2206 flags: c_int, 2207 mask: c_uint, 2208 statxbuf: *mut statx, 2209 ) -> c_int; 2210 } 2211 } 2212 } 2213 2214 cfg_if! { 2215 if #[cfg(target_os = "emscripten")] { 2216 mod emscripten; 2217 pub use self::emscripten::*; 2218 } else if #[cfg(target_os = "linux")] { 2219 mod linux; 2220 pub use self::linux::*; 2221 mod linux_l4re_shared; 2222 pub use self::linux_l4re_shared::*; 2223 } else if #[cfg(target_os = "l4re")] { 2224 mod l4re; 2225 pub use self::l4re::*; 2226 mod linux_l4re_shared; 2227 pub use self::linux_l4re_shared::*; 2228 } else if #[cfg(target_os = "android")] { 2229 mod android; 2230 pub use self::android::*; 2231 } else { 2232 // Unknown target_os 2233 } 2234 }