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