diff options
author | David LeGare <legare@google.com> | 2022-03-03 02:20:11 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-03-03 02:20:11 +0000 |
commit | f0ba2fe9a737672ab1683464daaaf440664b632e (patch) | |
tree | 139aa06070b10793d1606ba6a7744b50058e1212 | |
parent | 78f4e648455ce8a7461593b8427c67063f814f36 (diff) | |
parent | 249226736c435367f1bc55f64d22e5ad7fbd9d62 (diff) | |
download | libc-f0ba2fe9a737672ab1683464daaaf440664b632e.tar.gz |
Update libc to 0.2.119 am: b38fde0ab9 am: 12b87a91bd am: ca63fa5d3e am: 249226736c
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/libc/+/2004794
Change-Id: Ia8133bbb758c8ac564706dedbe3d88d54f87fb47
106 files changed, 10612 insertions, 1944 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 3d928f03..4280cdd7 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,6 @@ { "git": { - "sha1": "e2aabf1411134eac3dfd42d1c2e2f44b5b0d0c46" - } -} + "sha1": "abb9b4bb0528a218f23789456d5c1aa0715cace1" + }, + "path_in_vcs": "" +}
\ No newline at end of file @@ -42,7 +42,7 @@ rust_library { host_supported: true, crate_name: "libc", cargo_env_compat: true, - cargo_pkg_version: "0.2.102", + cargo_pkg_version: "0.2.119", srcs: ["src/lib.rs"], edition: "2015", features: [ @@ -56,8 +56,10 @@ rust_library { "libc_cfg_target_vendor", "libc_const_size_of", "libc_core_cvoid", + "libc_non_exhaustive", "libc_packedN", "libc_priv_mod_use", + "libc_ptr_addr_of", "libc_union", ], apex_available: [ @@ -11,20 +11,42 @@ [package] name = "libc" -version = "0.2.102" +version = "0.2.119" authors = ["The Rust Project Developers"] build = "build.rs" -exclude = ["/ci/*", "/.github/*", "/.cirrus.yml", "/triagebot.toml"] -description = "Raw FFI bindings to platform libraries like libc.\n" +exclude = [ + "/ci/*", + "/.github/*", + "/.cirrus.yml", + "/triagebot.toml", +] +description = """ +Raw FFI bindings to platform libraries like libc. +""" homepage = "https://github.com/rust-lang/libc" documentation = "https://docs.rs/libc/" readme = "README.md" -keywords = ["libc", "ffi", "bindings", "operating", "system"] -categories = ["external-ffi-bindings", "no-std", "os"] +keywords = [ + "libc", + "ffi", + "bindings", + "operating", + "system", +] +categories = [ + "external-ffi-bindings", + "no-std", + "os", +] license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/libc" + [package.metadata.docs.rs] -features = ["const-extern-fn", "extra_traits"] +features = [ + "const-extern-fn", + "extra_traits", +] + [dependencies.rustc-std-workspace-core] version = "1.0.0" optional = true @@ -34,6 +56,9 @@ align = [] const-extern-fn = [] default = ["std"] extra_traits = [] -rustc-dep-of-std = ["align", "rustc-std-workspace-core"] +rustc-dep-of-std = [ + "align", + "rustc-std-workspace-core", +] std = [] use_std = ["std"] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 57c3a4ce..70650d9a 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "libc" -version = "0.2.102" +version = "0.2.119" authors = ["The Rust Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/LICENSE-APACHE b/LICENSE-APACHE index 16fe87b0..1b5ec8b7 100644 --- a/LICENSE-APACHE +++ b/LICENSE-APACHE @@ -174,28 +174,3 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS - -APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - -Copyright [yyyy] [name of copyright owner] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/libc/libc-0.2.102.crate" + value: "https://static.crates.io/crates/libc/libc-0.2.119.crate" } - version: "0.2.102" + version: "0.2.119" license_type: NOTICE last_upgrade_date { - year: 2021 - month: 9 - day: 22 + year: 2022 + month: 3 + day: 1 } } @@ -31,6 +31,7 @@ fn main() { Some(11) if libc_ci => println!("cargo:rustc-cfg=freebsd11"), Some(12) if libc_ci => println!("cargo:rustc-cfg=freebsd12"), Some(13) if libc_ci => println!("cargo:rustc-cfg=freebsd13"), + Some(14) if libc_ci => println!("cargo:rustc-cfg=freebsd14"), Some(_) | None => println!("cargo:rustc-cfg=freebsd11"), } @@ -72,6 +73,15 @@ fn main() { println!("cargo:rustc-cfg=libc_cfg_target_vendor"); } + // Rust >= 1.40 supports #[non_exhaustive]. + if rustc_minor_ver >= 40 || rustc_dep_of_std { + println!("cargo:rustc-cfg=libc_non_exhaustive"); + } + + if rustc_minor_ver >= 51 || rustc_dep_of_std { + println!("cargo:rustc-cfg=libc_ptr_addr_of"); + } + // #[thread_local] is currently unstable if rustc_dep_of_std { println!("cargo:rustc-cfg=libc_thread_local"); @@ -141,6 +151,7 @@ fn which_freebsd() -> Option<i32> { s if s.starts_with("11") => Some(11), s if s.starts_with("12") => Some(12), s if s.starts_with("13") => Some(13), + s if s.starts_with("14") => Some(14), _ => None, } } diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 7b94f641..99b7791b 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -1313,6 +1313,7 @@ pub const SIG_DFL: sighandler_t = 0 as sighandler_t; pub const SIG_IGN: sighandler_t = 1 as sighandler_t; pub const SIG_ERR: sighandler_t = !0 as sighandler_t; +pub const DT_UNKNOWN: u8 = 0; pub const DT_FIFO: u8 = 1; pub const DT_CHR: u8 = 2; pub const DT_DIR: u8 = 4; @@ -26,7 +26,7 @@ #![cfg_attr(feature = "rustc-dep-of-std", no_core)] #![cfg_attr( any(feature = "rustc-dep-of-std", target_os = "redox"), - feature(static_nobundle) + feature(static_nobundle, native_link_modifiers, native_link_modifiers_bundle) )] #![cfg_attr(libc_const_extern_fn, feature(const_extern_fn))] @@ -66,7 +66,7 @@ cfg_if! { use core::clone::Clone; #[doc(hidden)] #[allow(unused_imports)] - use core::marker::Copy; + use core::marker::{Copy, Send, Sync}; #[doc(hidden)] #[allow(unused_imports)] use core::option::Option; @@ -88,7 +88,7 @@ cfg_if! { pub use core::clone::Clone; #[doc(hidden)] #[allow(unused_imports)] - pub use core::marker::Copy; + pub use core::marker::{Copy, Send, Sync}; #[doc(hidden)] #[allow(unused_imports)] pub use core::option::Option; @@ -126,6 +126,12 @@ cfg_if! { mod vxworks; pub use vxworks::*; + } else if #[cfg(target_os = "solid_asp3")] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + + mod solid; + pub use solid::*; } else if #[cfg(unix)] { mod fixed_width_ints; pub use fixed_width_ints::*; diff --git a/src/macros.rs b/src/macros.rs index 1871cfaf..9fb7f7a7 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -307,13 +307,13 @@ macro_rules! align_const { )*) } -// This macro is used to deprecate items that should be accessed via the mach crate +// This macro is used to deprecate items that should be accessed via the mach2 crate #[allow(unused_macros)] macro_rules! deprecated_mach { (pub const $id:ident: $ty:ty = $expr:expr;) => { #[deprecated( since = "0.2.55", - note = "Use the `mach` crate instead", + note = "Use the `mach2` crate instead", )] #[allow(deprecated)] pub const $id: $ty = $expr; @@ -328,7 +328,7 @@ macro_rules! deprecated_mach { (pub type $id:ident = $ty:ty;) => { #[deprecated( since = "0.2.55", - note = "Use the `mach` crate instead", + note = "Use the `mach2` crate instead", )] #[allow(deprecated)] pub type $id = $ty; @@ -341,3 +341,19 @@ macro_rules! deprecated_mach { )* } } + +#[allow(unused_macros)] +#[cfg(not(libc_ptr_addr_of))] +macro_rules! ptr_addr_of { + ($place:expr) => { + &$place + }; +} + +#[allow(unused_macros)] +#[cfg(libc_ptr_addr_of)] +macro_rules! ptr_addr_of { + ($place:expr) => { + ::core::ptr::addr_of!($place) + }; +} diff --git a/src/solid/aarch64.rs b/src/solid/aarch64.rs new file mode 100644 index 00000000..ceabea39 --- /dev/null +++ b/src/solid/aarch64.rs @@ -0,0 +1,4 @@ +pub type c_char = i8; +pub type wchar_t = u32; +pub type c_long = i64; +pub type c_ulong = u64; diff --git a/src/solid/arm.rs b/src/solid/arm.rs new file mode 100644 index 00000000..04cc1542 --- /dev/null +++ b/src/solid/arm.rs @@ -0,0 +1,4 @@ +pub type c_char = i8; +pub type wchar_t = u32; +pub type c_long = i32; +pub type c_ulong = u32; diff --git a/src/solid/mod.rs b/src/solid/mod.rs new file mode 100644 index 00000000..670e430f --- /dev/null +++ b/src/solid/mod.rs @@ -0,0 +1,904 @@ +//! Interface to the [SOLID] C library +//! +//! [SOLID]: https://solid.kmckk.com/ + +pub type c_schar = i8; +pub type c_uchar = u8; +pub type c_short = i16; +pub type c_ushort = u16; +pub type c_int = i32; +pub type c_uint = u32; +pub type c_float = f32; +pub type c_double = f64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type uintptr_t = usize; +pub type intptr_t = isize; +pub type ptrdiff_t = isize; +pub type size_t = ::uintptr_t; +pub type ssize_t = ::intptr_t; + +pub type clock_t = c_uint; +pub type time_t = i64; +pub type clockid_t = c_int; +pub type timer_t = c_int; +pub type suseconds_t = c_int; +pub type useconds_t = c_uint; + +pub type sighandler_t = size_t; + +// sys/ansi.h +pub type __caddr_t = *mut c_char; +pub type __gid_t = u32; +pub type __in_addr_t = u32; +pub type __in_port_t = u16; +pub type __mode_t = u32; +pub type __off_t = i64; +pub type __pid_t = i32; +pub type __sa_family_t = u8; +pub type __socklen_t = c_uint; +pub type __uid_t = u32; +pub type __fsblkcnt_t = u64; +pub type __fsfilcnt_t = u64; + +// locale.h +pub type locale_t = usize; + +// nl_types.h +pub type nl_item = c_long; + +// sys/types.h +pub type __va_list = *mut c_char; +pub type u_int8_t = u8; +pub type u_int16_t = u16; +pub type u_int32_t = u32; +pub type u_int64_t = u64; +pub type u_char = c_uchar; +pub type u_short = c_ushort; +pub type u_int = c_uint; +pub type u_long = c_ulong; +pub type unchar = c_uchar; +pub type ushort = c_ushort; +pub type uint = c_uint; +pub type ulong = c_ulong; +pub type u_quad_t = u64; +pub type quad_t = i64; +pub type qaddr_t = *mut quad_t; +pub type longlong_t = i64; +pub type u_longlong_t = u64; +pub type blkcnt_t = i64; +pub type blksize_t = i32; +pub type fsblkcnt_t = __fsblkcnt_t; +pub type fsfilcnt_t = __fsfilcnt_t; +pub type caddr_t = __caddr_t; +pub type daddr_t = i64; +pub type dev_t = u64; +pub type fixpt_t = u32; +pub type gid_t = __gid_t; +pub type idtype_t = c_int; +pub type id_t = u32; +pub type ino_t = u64; +pub type key_t = c_long; +pub type mode_t = __mode_t; +pub type nlink_t = u32; +pub type off_t = __off_t; +pub type pid_t = __pid_t; +pub type lwpid_t = i32; +pub type rlim_t = u64; +pub type segsz_t = i32; +pub type swblk_t = i32; +pub type mqd_t = c_int; +pub type cpuid_t = c_ulong; +pub type psetid_t = c_int; + +s! { + // stat.h + pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: c_short, + pub st_nlink: c_short, + pub st_uid: c_short, + pub st_gid: c_short, + pub st_rdev: dev_t, + pub st_size: off_t, + pub st_atime: time_t, + pub st_mtime: time_t, + pub st_ctime: time_t, + pub st_blksize: blksize_t, + } + + // time.h + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub tm_gmtoff: c_long, + pub tm_zone: *mut c_char, + } + + // stdlib.h + pub struct qdiv_t { + pub quot: quad_t, + pub rem: quad_t, + } + pub struct lldiv_t { + pub quot: c_longlong, + pub rem: c_longlong, + } + pub struct div_t { + pub quot: c_int, + pub rem: c_int, + } + pub struct ldiv_t { + pub quot: c_long, + pub rem: c_long, + } + + // locale.h + pub struct lconv { + pub decimal_point: *mut c_char, + pub thousands_sep: *mut c_char, + pub grouping: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub currency_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub mon_grouping: *mut c_char, + pub positive_sign: *mut c_char, + pub negative_sign: *mut c_char, + pub int_frac_digits: c_char, + pub frac_digits: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_n_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_n_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + pub int_n_sign_posn: c_char, + } + + pub struct iovec { + pub iov_base: *mut c_void, + pub iov_len: size_t, + } + + pub struct timeval { + pub tv_sec: c_long, + pub tv_usec: c_long, + } +} + +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + +pub const EXIT_FAILURE: c_int = 1; +pub const EXIT_SUCCESS: c_int = 0; +pub const RAND_MAX: c_int = 0x7fffffff; +pub const EOF: c_int = -1; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; +pub const _IOFBF: c_int = 0; +pub const _IONBF: c_int = 2; +pub const _IOLBF: c_int = 1; +pub const BUFSIZ: c_uint = 1024; +pub const FOPEN_MAX: c_uint = 20; +pub const FILENAME_MAX: c_uint = 1024; + +pub const O_RDONLY: c_int = 1; +pub const O_WRONLY: c_int = 2; +pub const O_RDWR: c_int = 4; +pub const O_APPEND: c_int = 8; +pub const O_CREAT: c_int = 0x10; +pub const O_EXCL: c_int = 0x400; +pub const O_TEXT: c_int = 0x100; +pub const O_BINARY: c_int = 0x200; +pub const O_TRUNC: c_int = 0x20; +pub const S_IEXEC: c_short = 0x0040; +pub const S_IWRITE: c_short = 0x0080; +pub const S_IREAD: c_short = 0x0100; +pub const S_IFCHR: c_short = 0x2000; +pub const S_IFDIR: c_short = 0x4000; +pub const S_IFMT: c_short = 0o160000; +pub const S_IFIFO: c_short = 0o0010000; +pub const S_IFBLK: c_short = 0o0060000; +pub const S_IFREG: c_short = 0o0100000; + +pub const LC_ALL: c_int = 0; +pub const LC_COLLATE: c_int = 1; +pub const LC_CTYPE: c_int = 2; +pub const LC_MONETARY: c_int = 3; +pub const LC_NUMERIC: c_int = 4; +pub const LC_TIME: c_int = 5; +pub const LC_MESSAGES: c_int = 6; +pub const _LC_LAST: c_int = 7; + +pub const EPERM: c_int = 1; +pub const ENOENT: c_int = 2; +pub const ESRCH: c_int = 3; +pub const EINTR: c_int = 4; +pub const EIO: c_int = 5; +pub const ENXIO: c_int = 6; +pub const E2BIG: c_int = 7; +pub const ENOEXEC: c_int = 8; +pub const EBADF: c_int = 9; +pub const ECHILD: c_int = 10; +pub const EAGAIN: c_int = 11; +pub const ENOMEM: c_int = 12; +pub const EACCES: c_int = 13; +pub const EFAULT: c_int = 14; +pub const ENOTBLK: c_int = 15; +pub const EBUSY: c_int = 16; +pub const EEXIST: c_int = 17; +pub const EXDEV: c_int = 18; +pub const ENODEV: c_int = 19; +pub const ENOTDIR: c_int = 20; +pub const EISDIR: c_int = 21; +pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; +pub const ETXTBSY: c_int = 26; +pub const EFBIG: c_int = 27; +pub const ENOSPC: c_int = 28; +pub const ESPIPE: c_int = 29; +pub const EROFS: c_int = 30; +pub const EMLINK: c_int = 31; +pub const EPIPE: c_int = 32; +pub const EDOM: c_int = 33; +pub const ERANGE: c_int = 34; + +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const EWOULDBLOCK: c_int = EAGAIN; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; + +pub const EDEADLOCK: c_int = EDEADLK; + +pub const EBFONT: c_int = 59; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENONET: c_int = 64; +pub const ENOPKG: c_int = 65; +pub const EREMOTE: c_int = 66; +pub const ENOLINK: c_int = 67; +pub const EADV: c_int = 68; +pub const ESRMNT: c_int = 69; +pub const ECOMM: c_int = 70; +pub const EPROTO: c_int = 71; +pub const EMULTIHOP: c_int = 72; +pub const EDOTDOT: c_int = 73; +pub const EBADMSG: c_int = 74; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDQUOT: c_int = 122; + +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; + +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; + +pub const ENOTSUP: c_int = 132; +pub const EFTYPE: c_int = 133; + +// signal codes +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGTRAP: c_int = 5; +pub const SIGABRT: c_int = 6; +pub const SIGIOT: c_int = SIGABRT; +pub const SIGEMT: c_int = 7; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGBUS: c_int = 10; +pub const SIGSEGV: c_int = 11; +pub const SIGSYS: c_int = 12; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; +pub const SIGURG: c_int = 16; +pub const SIGSTOP: c_int = 17; +pub const SIGTSTP: c_int = 18; +pub const SIGCONT: c_int = 19; +pub const SIGCHLD: c_int = 20; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGIO: c_int = 23; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGINFO: c_int = 29; +pub const SIGUSR1: c_int = 30; +pub const SIGUSR2: c_int = 31; +pub const SIGPWR: c_int = 32; + +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum FILE {} +impl ::Copy for FILE {} +impl ::Clone for FILE { + fn clone(&self) -> FILE { + *self + } +} +#[cfg_attr(feature = "extra_traits", derive(Debug))] +pub enum fpos_t {} +impl ::Copy for fpos_t {} +impl ::Clone for fpos_t { + fn clone(&self) -> fpos_t { + *self + } +} + +extern "C" { + // ctype.h + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn isblank(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + + // stdio.h + pub fn __get_stdio_file(fileno: c_int) -> *mut FILE; + pub fn clearerr(arg1: *mut FILE); + pub fn fclose(arg1: *mut FILE) -> c_int; + pub fn feof(arg1: *mut FILE) -> c_int; + pub fn ferror(arg1: *mut FILE) -> c_int; + pub fn fflush(arg1: *mut FILE) -> c_int; + pub fn fgetc(arg1: *mut FILE) -> c_int; + pub fn fgets(arg1: *mut c_char, arg2: c_int, arg3: *mut FILE) -> *mut c_char; + pub fn fopen(arg1: *const c_char, arg2: *const c_char) -> *mut FILE; + pub fn fprintf(arg1: *mut FILE, arg2: *const c_char, ...) -> c_int; + pub fn fputc(arg1: c_int, arg2: *mut FILE) -> c_int; + pub fn fputs(arg1: *const c_char, arg2: *mut FILE) -> c_int; + pub fn fread(arg1: *mut c_void, arg2: size_t, arg3: size_t, arg4: *mut FILE) -> size_t; + pub fn freopen(arg1: *const c_char, arg2: *const c_char, arg3: *mut FILE) -> *mut FILE; + pub fn fscanf(arg1: *mut FILE, arg2: *const c_char, ...) -> c_int; + pub fn fseek(arg1: *mut FILE, arg2: c_long, arg3: c_int) -> c_int; + pub fn ftell(arg1: *mut FILE) -> c_long; + pub fn fwrite(arg1: *const c_void, arg2: size_t, arg3: size_t, arg4: *mut FILE) -> size_t; + pub fn getc(arg1: *mut FILE) -> c_int; + pub fn getchar() -> c_int; + pub fn perror(arg1: *const c_char); + pub fn printf(arg1: *const c_char, ...) -> c_int; + pub fn putc(arg1: c_int, arg2: *mut FILE) -> c_int; + pub fn putchar(arg1: c_int) -> c_int; + pub fn puts(arg1: *const c_char) -> c_int; + pub fn remove(arg1: *const c_char) -> c_int; + pub fn rewind(arg1: *mut FILE); + pub fn scanf(arg1: *const c_char, ...) -> c_int; + pub fn setbuf(arg1: *mut FILE, arg2: *mut c_char); + pub fn setvbuf(arg1: *mut FILE, arg2: *mut c_char, arg3: c_int, arg4: size_t) -> c_int; + pub fn sscanf(arg1: *const c_char, arg2: *const c_char, ...) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn ungetc(arg1: c_int, arg2: *mut FILE) -> c_int; + pub fn vfprintf(arg1: *mut FILE, arg2: *const c_char, arg3: __va_list) -> c_int; + pub fn vprintf(arg1: *const c_char, arg2: __va_list) -> c_int; + pub fn gets(arg1: *mut c_char) -> *mut c_char; + pub fn sprintf(arg1: *mut c_char, arg2: *const c_char, ...) -> c_int; + pub fn tmpnam(arg1: *const c_char) -> *mut c_char; + pub fn vsprintf(arg1: *mut c_char, arg2: *const c_char, arg3: __va_list) -> c_int; + pub fn rename(arg1: *const c_char, arg2: *const c_char) -> c_int; + pub fn asiprintf(arg1: *mut *mut c_char, arg2: *const c_char, ...) -> c_int; + pub fn fiprintf(arg1: *mut FILE, arg2: *const c_char, ...) -> c_int; + pub fn fiscanf(arg1: *mut FILE, arg2: *const c_char, ...) -> c_int; + pub fn iprintf(arg1: *const c_char, ...) -> c_int; + pub fn iscanf(arg1: *const c_char, ...) -> c_int; + pub fn siprintf(arg1: *mut c_char, arg2: *const c_char, ...) -> c_int; + pub fn siscanf(arg1: *mut c_char, arg2: *const c_char, ...) -> c_int; + pub fn sniprintf(arg1: *mut c_char, arg2: size_t, arg3: *const c_char, ...) -> c_int; + pub fn vasiprintf(arg1: *mut *mut c_char, arg2: *const c_char, arg3: __va_list) -> c_int; + pub fn vfiprintf(arg1: *mut FILE, arg2: *const c_char, arg3: __va_list) -> c_int; + pub fn vfiscanf(arg1: *mut FILE, arg2: *const c_char, arg3: __va_list) -> c_int; + pub fn viprintf(arg1: *const c_char, arg2: __va_list) -> c_int; + pub fn viscanf(arg1: *const c_char, arg2: __va_list) -> c_int; + pub fn vsiprintf(arg1: *mut c_char, arg2: *const c_char, arg3: __va_list) -> c_int; + pub fn vsiscanf(arg1: *const c_char, arg2: *const c_char, arg3: __va_list) -> c_int; + pub fn vsniprintf( + arg1: *mut c_char, + arg2: size_t, + arg3: *const c_char, + arg4: __va_list, + ) -> c_int; + pub fn vdiprintf(arg1: c_int, arg2: *const c_char, arg3: __va_list) -> c_int; + pub fn diprintf(arg1: c_int, arg2: *const c_char, ...) -> c_int; + pub fn fgetpos(arg1: *mut FILE, arg2: *mut fpos_t) -> c_int; + pub fn fsetpos(arg1: *mut FILE, arg2: *const fpos_t) -> c_int; + pub fn fdopen(arg1: c_int, arg2: *const c_char) -> *mut FILE; + pub fn fileno(arg1: *mut FILE) -> c_int; + pub fn flockfile(arg1: *mut FILE); + pub fn ftrylockfile(arg1: *mut FILE) -> c_int; + pub fn funlockfile(arg1: *mut FILE); + pub fn getc_unlocked(arg1: *mut FILE) -> c_int; + pub fn getchar_unlocked() -> c_int; + pub fn putc_unlocked(arg1: c_int, arg2: *mut FILE) -> c_int; + pub fn putchar_unlocked(arg1: c_int) -> c_int; + pub fn snprintf(arg1: *mut c_char, arg2: size_t, arg3: *const c_char, ...) -> c_int; + pub fn vsnprintf( + arg1: *mut c_char, + arg2: size_t, + arg3: *const c_char, + arg4: __va_list, + ) -> c_int; + pub fn getw(arg1: *mut FILE) -> c_int; + pub fn putw(arg1: c_int, arg2: *mut FILE) -> c_int; + pub fn tempnam(arg1: *const c_char, arg2: *const c_char) -> *mut c_char; + pub fn fseeko(stream: *mut FILE, offset: off_t, whence: c_int) -> c_int; + pub fn ftello(stream: *mut FILE) -> off_t; + + // stdlib.h + pub fn atof(arg1: *const c_char) -> f64; + pub fn strtod(arg1: *const c_char, arg2: *mut *mut c_char) -> f64; + pub fn drand48() -> f64; + pub fn erand48(arg1: *mut c_ushort) -> f64; + pub fn strtof(arg1: *const c_char, arg2: *mut *mut c_char) -> f32; + pub fn strtold(arg1: *const c_char, arg2: *mut *mut c_char) -> f64; + pub fn strtod_l(arg1: *const c_char, arg2: *mut *mut c_char, arg3: locale_t) -> f64; + pub fn strtof_l(arg1: *const c_char, arg2: *mut *mut c_char, arg3: locale_t) -> f32; + pub fn strtold_l(arg1: *const c_char, arg2: *mut *mut c_char, arg3: locale_t) -> f64; + pub fn _Exit(arg1: c_int); + pub fn abort(); + pub fn abs(arg1: c_int) -> c_int; + pub fn atexit(arg1: ::Option<unsafe extern "C" fn()>) -> c_int; + pub fn atoi(arg1: *const c_char) -> c_int; + pub fn atol(arg1: *const c_char) -> c_long; + pub fn itoa(arg1: c_int, arg2: *mut c_char, arg3: c_int) -> *mut c_char; + pub fn ltoa(arg1: c_long, arg2: *mut c_char, arg3: c_int) -> *mut c_char; + pub fn ultoa(arg1: c_ulong, arg2: *mut c_char, arg3: c_int) -> *mut c_char; + pub fn bsearch( + arg1: *const c_void, + arg2: *const c_void, + arg3: size_t, + arg4: size_t, + arg5: ::Option<unsafe extern "C" fn(arg1: *const c_void, arg2: *const c_void) -> c_int>, + ) -> *mut c_void; + pub fn calloc(arg1: size_t, arg2: size_t) -> *mut c_void; + pub fn div(arg1: c_int, arg2: c_int) -> div_t; + pub fn exit(arg1: c_int); + pub fn free(arg1: *mut c_void); + pub fn getenv(arg1: *const c_char) -> *mut c_char; + pub fn labs(arg1: c_long) -> c_long; + pub fn ldiv(arg1: c_long, arg2: c_long) -> ldiv_t; + pub fn malloc(arg1: size_t) -> *mut c_void; + pub fn qsort( + arg1: *mut c_void, + arg2: size_t, + arg3: size_t, + arg4: ::Option<unsafe extern "C" fn(arg1: *const c_void, arg2: *const c_void) -> c_int>, + ); + pub fn rand() -> c_int; + pub fn realloc(arg1: *mut c_void, arg2: size_t) -> *mut c_void; + pub fn srand(arg1: c_uint); + pub fn strtol(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_long; + pub fn strtoul(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_ulong; + pub fn mblen(arg1: *const c_char, arg2: size_t) -> c_int; + pub fn mbstowcs(arg1: *mut wchar_t, arg2: *const c_char, arg3: size_t) -> size_t; + pub fn wctomb(arg1: *mut c_char, arg2: wchar_t) -> c_int; + pub fn mbtowc(arg1: *mut wchar_t, arg2: *const c_char, arg3: size_t) -> c_int; + pub fn wcstombs(arg1: *mut c_char, arg2: *const wchar_t, arg3: size_t) -> size_t; + pub fn rand_r(arg1: *mut c_uint) -> c_int; + pub fn jrand48(arg1: *mut c_ushort) -> c_long; + pub fn lcong48(arg1: *mut c_ushort); + pub fn lrand48() -> c_long; + pub fn mrand48() -> c_long; + pub fn nrand48(arg1: *mut c_ushort) -> c_long; + pub fn seed48(arg1: *mut c_ushort) -> *mut c_ushort; + pub fn srand48(arg1: c_long); + pub fn putenv(arg1: *mut c_char) -> c_int; + pub fn a64l(arg1: *const c_char) -> c_long; + pub fn l64a(arg1: c_long) -> *mut c_char; + pub fn random() -> c_long; + pub fn setstate(arg1: *mut c_char) -> *mut c_char; + pub fn initstate(arg1: c_uint, arg2: *mut c_char, arg3: size_t) -> *mut c_char; + pub fn srandom(arg1: c_uint); + pub fn mkostemp(arg1: *mut c_char, arg2: c_int) -> c_int; + pub fn mkostemps(arg1: *mut c_char, arg2: c_int, arg3: c_int) -> c_int; + pub fn mkdtemp(arg1: *mut c_char) -> *mut c_char; + pub fn mkstemp(arg1: *mut c_char) -> c_int; + pub fn mktemp(arg1: *mut c_char) -> *mut c_char; + pub fn atoll(arg1: *const c_char) -> c_longlong; + pub fn llabs(arg1: c_longlong) -> c_longlong; + pub fn lldiv(arg1: c_longlong, arg2: c_longlong) -> lldiv_t; + pub fn strtoll(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_longlong; + pub fn strtoull(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_ulonglong; + pub fn aligned_alloc(arg1: size_t, arg2: size_t) -> *mut c_void; + pub fn at_quick_exit(arg1: ::Option<unsafe extern "C" fn()>) -> c_int; + pub fn quick_exit(arg1: c_int); + pub fn setenv(arg1: *const c_char, arg2: *const c_char, arg3: c_int) -> c_int; + pub fn unsetenv(arg1: *const c_char) -> c_int; + pub fn humanize_number( + arg1: *mut c_char, + arg2: size_t, + arg3: i64, + arg4: *const c_char, + arg5: c_int, + arg6: c_int, + ) -> c_int; + pub fn dehumanize_number(arg1: *const c_char, arg2: *mut i64) -> c_int; + pub fn getenv_r(arg1: *const c_char, arg2: *mut c_char, arg3: size_t) -> c_int; + pub fn heapsort( + arg1: *mut c_void, + arg2: size_t, + arg3: size_t, + arg4: ::Option<unsafe extern "C" fn(arg1: *const c_void, arg2: *const c_void) -> c_int>, + ) -> c_int; + pub fn mergesort( + arg1: *mut c_void, + arg2: size_t, + arg3: size_t, + arg4: ::Option<unsafe extern "C" fn(arg1: *const c_void, arg2: *const c_void) -> c_int>, + ) -> c_int; + pub fn radixsort( + arg1: *mut *const c_uchar, + arg2: c_int, + arg3: *const c_uchar, + arg4: c_uint, + ) -> c_int; + pub fn sradixsort( + arg1: *mut *const c_uchar, + arg2: c_int, + arg3: *const c_uchar, + arg4: c_uint, + ) -> c_int; + pub fn getprogname() -> *const c_char; + pub fn setprogname(arg1: *const c_char); + pub fn qabs(arg1: quad_t) -> quad_t; + pub fn strtoq(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> quad_t; + pub fn strtouq(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> u_quad_t; + pub fn strsuftoll( + arg1: *const c_char, + arg2: *const c_char, + arg3: c_longlong, + arg4: c_longlong, + ) -> c_longlong; + pub fn strsuftollx( + arg1: *const c_char, + arg2: *const c_char, + arg3: c_longlong, + arg4: c_longlong, + arg5: *mut c_char, + arg6: size_t, + ) -> c_longlong; + pub fn l64a_r(arg1: c_long, arg2: *mut c_char, arg3: c_int) -> c_int; + pub fn qdiv(arg1: quad_t, arg2: quad_t) -> qdiv_t; + pub fn strtol_l( + arg1: *const c_char, + arg2: *mut *mut c_char, + arg3: c_int, + arg4: locale_t, + ) -> c_long; + pub fn strtoul_l( + arg1: *const c_char, + arg2: *mut *mut c_char, + arg3: c_int, + arg4: locale_t, + ) -> c_ulong; + pub fn strtoll_l( + arg1: *const c_char, + arg2: *mut *mut c_char, + arg3: c_int, + arg4: locale_t, + ) -> c_longlong; + pub fn strtoull_l( + arg1: *const c_char, + arg2: *mut *mut c_char, + arg3: c_int, + arg4: locale_t, + ) -> c_ulonglong; + pub fn strtoq_l( + arg1: *const c_char, + arg2: *mut *mut c_char, + arg3: c_int, + arg4: locale_t, + ) -> quad_t; + pub fn strtouq_l( + arg1: *const c_char, + arg2: *mut *mut c_char, + arg3: c_int, + arg4: locale_t, + ) -> u_quad_t; + pub fn _mb_cur_max_l(arg1: locale_t) -> size_t; + pub fn mblen_l(arg1: *const c_char, arg2: size_t, arg3: locale_t) -> c_int; + pub fn mbstowcs_l( + arg1: *mut wchar_t, + arg2: *const c_char, + arg3: size_t, + arg4: locale_t, + ) -> size_t; + pub fn wctomb_l(arg1: *mut c_char, arg2: wchar_t, arg3: locale_t) -> c_int; + pub fn mbtowc_l(arg1: *mut wchar_t, arg2: *const c_char, arg3: size_t, arg4: locale_t) + -> c_int; + pub fn wcstombs_l( + arg1: *mut c_char, + arg2: *const wchar_t, + arg3: size_t, + arg4: locale_t, + ) -> size_t; + + // string.h + pub fn memchr(arg1: *const c_void, arg2: c_int, arg3: size_t) -> *mut c_void; + pub fn memcmp(arg1: *const c_void, arg2: *const c_void, arg3: size_t) -> c_int; + pub fn memcpy(arg1: *mut c_void, arg2: *const c_void, arg3: size_t) -> *mut c_void; + pub fn memmove(arg1: *mut c_void, arg2: *const c_void, arg3: size_t) -> *mut c_void; + pub fn memset(arg1: *mut c_void, arg2: c_int, arg3: size_t) -> *mut c_void; + pub fn strcat(arg1: *mut c_char, arg2: *const c_char) -> *mut c_char; + pub fn strchr(arg1: *const c_char, arg2: c_int) -> *mut c_char; + pub fn strcmp(arg1: *const c_char, arg2: *const c_char) -> c_int; + pub fn strcoll(arg1: *const c_char, arg2: *const c_char) -> c_int; + pub fn strcpy(arg1: *mut c_char, arg2: *const c_char) -> *mut c_char; + pub fn strcspn(arg1: *const c_char, arg2: *const c_char) -> size_t; + pub fn strerror(arg1: c_int) -> *mut c_char; + pub fn strlen(arg1: *const c_char) -> size_t; + pub fn strncat(arg1: *mut c_char, arg2: *const c_char, arg3: size_t) -> *mut c_char; + pub fn strncmp(arg1: *const c_char, arg2: *const c_char, arg3: size_t) -> c_int; + pub fn strncpy(arg1: *mut c_char, arg2: *const c_char, arg3: size_t) -> *mut c_char; + pub fn strpbrk(arg1: *const c_char, arg2: *const c_char) -> *mut c_char; + pub fn strrchr(arg1: *const c_char, arg2: c_int) -> *mut c_char; + pub fn strspn(arg1: *const c_char, arg2: *const c_char) -> size_t; + pub fn strstr(arg1: *const c_char, arg2: *const c_char) -> *mut c_char; + pub fn strtok(arg1: *mut c_char, arg2: *const c_char) -> *mut c_char; + pub fn strtok_r(arg1: *mut c_char, arg2: *const c_char, arg3: *mut *mut c_char) -> *mut c_char; + pub fn strerror_r(arg1: c_int, arg2: *mut c_char, arg3: size_t) -> c_int; + pub fn strxfrm(arg1: *mut c_char, arg2: *const c_char, arg3: size_t) -> size_t; + pub fn memccpy( + arg1: *mut c_void, + arg2: *const c_void, + arg3: c_int, + arg4: size_t, + ) -> *mut c_void; + pub fn strdup(arg1: *const c_char) -> *mut c_char; + pub fn stpcpy(arg1: *mut c_char, arg2: *const c_char) -> *mut c_char; + pub fn stpncpy(arg1: *mut c_char, arg2: *const c_char, arg3: size_t) -> *mut c_char; + pub fn strnlen(arg1: *const c_char, arg2: size_t) -> size_t; + pub fn memmem( + arg1: *const c_void, + arg2: size_t, + arg3: *const c_void, + arg4: size_t, + ) -> *mut c_void; + pub fn strcasestr(arg1: *const c_char, arg2: *const c_char) -> *mut c_char; + pub fn strlcat(arg1: *mut c_char, arg2: *const c_char, arg3: size_t) -> size_t; + pub fn strlcpy(arg1: *mut c_char, arg2: *const c_char, arg3: size_t) -> size_t; + pub fn strsep(arg1: *mut *mut c_char, arg2: *const c_char) -> *mut c_char; + pub fn stresep(arg1: *mut *mut c_char, arg2: *const c_char, arg3: c_int) -> *mut c_char; + pub fn strndup(arg1: *const c_char, arg2: size_t) -> *mut c_char; + pub fn memrchr(arg1: *const c_void, arg2: c_int, arg3: size_t) -> *mut c_void; + pub fn explicit_memset(arg1: *mut c_void, arg2: c_int, arg3: size_t) -> *mut c_void; + pub fn consttime_memequal(arg1: *const c_void, arg2: *const c_void, arg3: size_t) -> c_int; + pub fn strcoll_l(arg1: *const c_char, arg2: *const c_char, arg3: locale_t) -> c_int; + pub fn strxfrm_l( + arg1: *mut c_char, + arg2: *const c_char, + arg3: size_t, + arg4: locale_t, + ) -> size_t; + pub fn strerror_l(arg1: c_int, arg2: locale_t) -> *mut c_char; + + // strings.h + pub fn bcmp(arg1: *const c_void, arg2: *const c_void, arg3: size_t) -> c_int; + pub fn bcopy(arg1: *const c_void, arg2: *mut c_void, arg3: size_t); + pub fn bzero(arg1: *mut c_void, arg2: size_t); + pub fn ffs(arg1: c_int) -> c_int; + pub fn popcount(arg1: c_uint) -> c_uint; + pub fn popcountl(arg1: c_ulong) -> c_uint; + pub fn popcountll(arg1: c_ulonglong) -> c_uint; + pub fn popcount32(arg1: u32) -> c_uint; + pub fn popcount64(arg1: u64) -> c_uint; + pub fn rindex(arg1: *const c_char, arg2: c_int) -> *mut c_char; + pub fn strcasecmp(arg1: *const c_char, arg2: *const c_char) -> c_int; + pub fn strncasecmp(arg1: *const c_char, arg2: *const c_char, arg3: size_t) -> c_int; + + // signal.h + pub fn signal(arg1: c_int, arg2: sighandler_t) -> sighandler_t; + pub fn raise(arg1: c_int) -> c_int; + + // time.h + pub fn asctime(arg1: *const tm) -> *mut c_char; + pub fn clock() -> clock_t; + pub fn ctime(arg1: *const time_t) -> *mut c_char; + pub fn difftime(arg1: time_t, arg2: time_t) -> f64; + pub fn gmtime(arg1: *const time_t) -> *mut tm; + pub fn localtime(arg1: *const time_t) -> *mut tm; + pub fn time(arg1: *mut time_t) -> time_t; + pub fn mktime(arg1: *mut tm) -> time_t; + pub fn strftime( + arg1: *mut c_char, + arg2: size_t, + arg3: *const c_char, + arg4: *const tm, + ) -> size_t; + pub fn utime(arg1: *const c_char, arg2: *mut time_t) -> c_int; + pub fn asctime_r(arg1: *const tm, arg2: *mut c_char) -> *mut c_char; + pub fn ctime_r(arg1: *const time_t, arg2: *mut c_char) -> *mut c_char; + pub fn gmtime_r(arg1: *const time_t, arg2: *mut tm) -> *mut tm; + pub fn localtime_r(arg1: *const time_t, arg2: *mut tm) -> *mut tm; + + // sys/stat.h + pub fn stat(arg1: *const c_char, arg2: *mut stat) -> c_int; + pub fn lstat(arg1: *const c_char, arg2: *mut stat) -> c_int; + pub fn fstat(arg1: c_int, arg2: *mut stat) -> c_int; + pub fn chmod(arg1: *const c_char, arg2: __mode_t) -> c_int; + pub fn mkdir(arg1: *const c_char, arg2: __mode_t) -> c_int; + + // fcntl.h + pub fn open(arg1: *const c_char, arg2: c_int, ...) -> c_int; + pub fn creat(arg1: *const c_char, arg2: c_int) -> c_int; + pub fn close(arg1: c_int) -> c_int; + pub fn read(arg1: c_int, arg2: *mut c_void, arg3: c_int) -> c_int; + pub fn write(arg1: c_int, arg2: *const c_void, arg3: c_int) -> c_int; + pub fn unlink(arg1: *const c_char) -> c_int; + pub fn tell(arg1: c_int) -> c_long; + pub fn dup(arg1: c_int) -> c_int; + pub fn dup2(arg1: c_int, arg2: c_int) -> c_int; + pub fn access(arg1: *const c_char, arg2: c_int) -> c_int; + pub fn rmdir(arg1: *const c_char) -> c_int; + pub fn chdir(arg1: *const c_char) -> c_int; + pub fn _exit(arg1: c_int); + pub fn getwd(arg1: *mut c_char) -> *mut c_char; + pub fn getcwd(arg1: *mut c_char, arg2: size_t) -> *mut c_char; + pub static mut optarg: *mut c_char; + pub static mut opterr: c_int; + pub static mut optind: c_int; + pub static mut optopt: c_int; + pub static mut optreset: c_int; + pub fn getopt(arg1: c_int, arg2: *mut *mut c_char, arg3: *const c_char) -> c_int; + pub static mut suboptarg: *mut c_char; + pub fn getsubopt( + arg1: *mut *mut c_char, + arg2: *const *mut c_char, + arg3: *mut *mut c_char, + ) -> c_int; + pub fn fcntl(arg1: c_int, arg2: c_int, ...) -> c_int; + pub fn getpid() -> pid_t; + pub fn sleep(arg1: c_uint) -> c_uint; + pub fn usleep(arg1: useconds_t) -> c_int; + + // locale.h + pub fn localeconv() -> *mut lconv; + pub fn setlocale(arg1: c_int, arg2: *const c_char) -> *mut c_char; + pub fn duplocale(arg1: locale_t) -> locale_t; + pub fn freelocale(arg1: locale_t); + pub fn localeconv_l(arg1: locale_t) -> *mut lconv; + pub fn newlocale(arg1: c_int, arg2: *const c_char, arg3: locale_t) -> locale_t; + + // langinfo.h + pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; + pub fn nl_langinfo_l(item: ::nl_item, locale: locale_t) -> *mut ::c_char; + + // malloc.h + pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; + + // sys/types.h + pub fn lseek(arg1: c_int, arg2: __off_t, arg3: c_int) -> __off_t; +} + +cfg_if! { + if #[cfg(libc_core_cvoid)] { + pub use ::ffi::c_void; + } else { + // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help + // enable more optimization opportunities around it recognizing things + // like malloc/free. + #[repr(u8)] + #[allow(missing_copy_implementations)] + #[allow(missing_debug_implementations)] + pub enum c_void { + // Two dummy variants so the #[repr] attribute can be used. + #[doc(hidden)] + __variant1, + #[doc(hidden)] + __variant2, + } + } +} + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(any(target_arch = "arm"))] { + mod arm; + pub use self::arm::*; + } else { + // Unknown target_arch + } +} diff --git a/src/unix/bsd/apple/b32/mod.rs b/src/unix/bsd/apple/b32/mod.rs index 9248e3ad..0f1722f9 100644 --- a/src/unix/bsd/apple/b32/mod.rs +++ b/src/unix/bsd/apple/b32/mod.rs @@ -43,6 +43,10 @@ s! { pub bh_datalen: u32, pub bh_hdrlen: ::c_ushort, } + + pub struct malloc_zone_t { + __private: [::uintptr_t; 18], // FIXME: keeping private for now + } } s_no_extra_traits! { diff --git a/src/unix/bsd/apple/b64/aarch64/mod.rs b/src/unix/bsd/apple/b64/aarch64/mod.rs index 83b62e97..67f0f703 100644 --- a/src/unix/bsd/apple/b64/aarch64/mod.rs +++ b/src/unix/bsd/apple/b64/aarch64/mod.rs @@ -1,5 +1,13 @@ pub type boolean_t = ::c_int; +s! { + pub struct malloc_zone_t { + __private: [::uintptr_t; 18], // FIXME: needs arm64 auth pointers support + } +} + +pub const CLOCK_UPTIME_RAW: ::clockid_t = 8; + cfg_if! { if #[cfg(libc_align)] { mod align; diff --git a/src/unix/bsd/apple/b64/x86_64/mod.rs b/src/unix/bsd/apple/b64/x86_64/mod.rs index 07866665..653650c2 100644 --- a/src/unix/bsd/apple/b64/x86_64/mod.rs +++ b/src/unix/bsd/apple/b64/x86_64/mod.rs @@ -102,6 +102,74 @@ s! { pub struct __darwin_xmm_reg { pub __xmm_reg: [::c_char; 16], } + + pub struct malloc_introspection_t { + _private: [::uintptr_t; 16], // FIXME: keeping private for now + } + + pub struct malloc_zone_t { + _reserved1: *mut ::c_void, + _reserved2: *mut ::c_void, + pub size: ::Option<unsafe extern "C" fn( + zone: *mut malloc_zone_t, + ptr: *const ::c_void, + ) -> ::size_t>, + pub malloc: ::Option<unsafe extern "C" fn( + zone: *mut malloc_zone_t, + size: ::size_t, + ) -> *mut ::c_void>, + pub calloc: ::Option<unsafe extern "C" fn( + zone: *mut malloc_zone_t, + num_items: ::size_t, + size: ::size_t, + ) -> *mut ::c_void>, + pub valloc: ::Option<unsafe extern "C" fn( + zone: *mut malloc_zone_t, + size: ::size_t + ) -> *mut ::c_void>, + pub free: ::Option<unsafe extern "C" fn( + zone: *mut malloc_zone_t, + ptr: *mut ::c_void + )>, + pub realloc: ::Option<unsafe extern "C" fn( + zone: *mut malloc_zone_t, + ptr: *mut ::c_void, + size: ::size_t, + ) -> *mut ::c_void>, + pub destroy: ::Option<unsafe extern "C" fn(zone: *mut malloc_zone_t)>, + pub zone_name: *const ::c_char, + pub batch_malloc: ::Option<unsafe extern "C" fn( + zone: *mut malloc_zone_t, + size: ::size_t, + results: *mut *mut ::c_void, + num_requested: ::c_uint, + ) -> ::c_uint>, + pub batch_free: ::Option<unsafe extern "C" fn( + zone: *mut malloc_zone_t, + to_be_freed: *mut *mut ::c_void, + num_to_be_freed: ::c_uint, + )>, + pub introspect: *mut malloc_introspection_t, + pub version: ::c_uint, + pub memalign: ::Option<unsafe extern "C" fn( + zone: *mut malloc_zone_t, + alignment: ::size_t, + size: ::size_t, + ) -> *mut ::c_void>, + pub free_definite_size: ::Option<unsafe extern "C" fn( + zone: *mut malloc_zone_t, + ptr: *mut ::c_void, + size: ::size_t + )>, + pub pressure_relief: ::Option<unsafe extern "C" fn( + zone: *mut malloc_zone_t, + goal: ::size_t, + ) -> ::size_t>, + pub claimed_address: ::Option<unsafe extern "C" fn( + zone: *mut malloc_zone_t, + ptr: *mut ::c_void, + ) -> ::boolean_t>, + } } cfg_if! { diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index e63d26dc..5d10a003 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -30,6 +30,13 @@ pub type natural_t = u32; pub type mach_msg_type_number_t = natural_t; pub type kern_return_t = ::c_int; pub type uuid_t = [u8; 16]; +pub type task_info_t = *mut integer_t; +pub type host_info_t = *mut integer_t; +pub type task_flavor_t = natural_t; +pub type rusage_info_t = *mut ::c_void; +pub type vm_offset_t = ::uintptr_t; +pub type vm_size_t = ::uintptr_t; +pub type vm_address_t = vm_offset_t; pub type posix_spawnattr_t = *mut ::c_void; pub type posix_spawn_file_actions_t = *mut ::c_void; @@ -45,7 +52,7 @@ pub type host_flavor_t = integer_t; pub type host_info64_t = *mut integer_t; pub type processor_flavor_t = ::c_int; pub type thread_flavor_t = natural_t; -pub type thread_inspect_t = mach_port_t; +pub type thread_inspect_t = ::mach_port_t; pub type policy_t = ::c_int; pub type mach_vm_address_t = u64; pub type mach_vm_offset_t = u64; @@ -70,6 +77,11 @@ pub type processor_set_load_info_t = *mut processor_set_load_info; pub type processor_info_t = *mut integer_t; pub type processor_info_array_t = *mut integer_t; +pub type mach_task_basic_info_data_t = mach_task_basic_info; +pub type mach_task_basic_info_t = *mut mach_task_basic_info; +pub type task_thread_times_info_data_t = task_thread_times_info; +pub type task_thread_times_info_t = *mut task_thread_times_info; + pub type thread_info_t = *mut integer_t; pub type thread_basic_info_t = *mut thread_basic_info; pub type thread_basic_info_data_t = thread_basic_info; @@ -78,7 +90,7 @@ pub type thread_identifier_info_data_t = thread_identifier_info; pub type thread_extended_info_t = *mut thread_extended_info; pub type thread_extended_info_data_t = thread_extended_info; -pub type thread_t = mach_port_t; +pub type thread_t = ::mach_port_t; pub type thread_policy_flavor_t = natural_t; pub type thread_policy_t = *mut integer_t; pub type thread_latency_qos_t = integer_t; @@ -100,19 +112,26 @@ pub type thread_latency_qos_policy_t = *mut thread_latency_qos_policy; pub type thread_throughput_qos_policy_data_t = thread_throughput_qos_policy; pub type thread_throughput_qos_policy_t = *mut thread_throughput_qos_policy; +pub type pthread_introspection_hook_t = + extern "C" fn(event: ::c_uint, thread: ::pthread_t, addr: *mut ::c_void, size: ::size_t); + pub type vm_statistics_t = *mut vm_statistics; pub type vm_statistics_data_t = vm_statistics; pub type vm_statistics64_t = *mut vm_statistics64; pub type vm_statistics64_data_t = vm_statistics64; +pub type task_t = ::mach_port_t; + pub type sysdir_search_path_enumeration_state = ::c_uint; pub type CCStatus = i32; pub type CCCryptorStatus = i32; pub type CCRNGStatus = ::CCCryptorStatus; +pub type copyfile_state_t = *mut ::c_void; +pub type copyfile_flags_t = u32; + deprecated_mach! { - pub type vm_size_t = ::uintptr_t; pub type mach_timebase_info_data_t = mach_timebase_info; } @@ -199,6 +218,12 @@ s! { pub imr_interface: in_addr, } + pub struct ip_mreqn { + pub imr_multiaddr: in_addr, + pub imr_address: in_addr, + pub imr_ifindex: ::c_int, + } + pub struct aiocb { pub aio_fildes: ::c_int, pub aio_offset: ::off_t, @@ -238,7 +263,7 @@ s! { #[deprecated( since = "0.2.55", - note = "Use the `mach` crate instead", + note = "Use the `mach2` crate instead", )] pub struct mach_timebase_info { pub numer: u32, @@ -506,7 +531,7 @@ s! { #[deprecated( since = "0.2.55", - note = "Use the `mach` crate instead", + note = "Use the `mach2` crate instead", )] pub struct mach_header { pub magic: u32, @@ -520,7 +545,7 @@ s! { #[deprecated( since = "0.2.55", - note = "Use the `mach` crate instead", + note = "Use the `mach2` crate instead", )] pub struct mach_header_64 { pub magic: u32, @@ -730,8 +755,9 @@ s! { pub bytes_free: ::size_t, } - pub struct malloc_zone_t { - __private: [::uintptr_t; 18], // FIXME: keeping private for now + pub struct vm_range_t { + pub address: ::vm_address_t, + pub size: ::vm_size_t, } // sched.h @@ -800,6 +826,142 @@ s! { pub purges: natural_t, pub speculative_count: natural_t, } + + pub struct task_thread_times_info { + pub user_time: time_value_t, + pub system_time: time_value_t, + } + + pub struct rusage_info_v0 { + pub ri_uuid: [u8; 16], + pub ri_user_time: u64, + pub ri_system_time: u64, + pub ri_pkg_idle_wkups: u64, + pub ri_interrupt_wkups: u64, + pub ri_pageins: u64, + pub ri_wired_size: u64, + pub ri_resident_size: u64, + pub ri_phys_footprint: u64, + pub ri_proc_start_abstime: u64, + pub ri_proc_exit_abstime: u64, + } + + pub struct rusage_info_v1 { + pub ri_uuid: [u8; 16], + pub ri_user_time: u64, + pub ri_system_time: u64, + pub ri_pkg_idle_wkups: u64, + pub ri_interrupt_wkups: u64, + pub ri_pageins: u64, + pub ri_wired_size: u64, + pub ri_resident_size: u64, + pub ri_phys_footprint: u64, + pub ri_proc_start_abstime: u64, + pub ri_proc_exit_abstime: u64, + pub ri_child_user_time: u64, + pub ri_child_system_time: u64, + pub ri_child_pkg_idle_wkups: u64, + pub ri_child_interrupt_wkups: u64, + pub ri_child_pageins: u64, + pub ri_child_elapsed_abstime: u64, + } + + pub struct rusage_info_v2 { + pub ri_uuid: [u8; 16], + pub ri_user_time: u64, + pub ri_system_time: u64, + pub ri_pkg_idle_wkups: u64, + pub ri_interrupt_wkups: u64, + pub ri_pageins: u64, + pub ri_wired_size: u64, + pub ri_resident_size: u64, + pub ri_phys_footprint: u64, + pub ri_proc_start_abstime: u64, + pub ri_proc_exit_abstime: u64, + pub ri_child_user_time: u64, + pub ri_child_system_time: u64, + pub ri_child_pkg_idle_wkups: u64, + pub ri_child_interrupt_wkups: u64, + pub ri_child_pageins: u64, + pub ri_child_elapsed_abstime: u64, + pub ri_diskio_bytesread: u64, + pub ri_diskio_byteswritten: u64, + } + + pub struct rusage_info_v3 { + pub ri_uuid: [u8; 16], + pub ri_user_time: u64, + pub ri_system_time: u64, + pub ri_pkg_idle_wkups: u64, + pub ri_interrupt_wkups: u64, + pub ri_pageins: u64, + pub ri_wired_size: u64, + pub ri_resident_size: u64, + pub ri_phys_footprint: u64, + pub ri_proc_start_abstime: u64, + pub ri_proc_exit_abstime: u64, + pub ri_child_user_time: u64, + pub ri_child_system_time: u64, + pub ri_child_pkg_idle_wkups: u64, + pub ri_child_interrupt_wkups: u64, + pub ri_child_pageins: u64, + pub ri_child_elapsed_abstime: u64, + pub ri_diskio_bytesread: u64, + pub ri_diskio_byteswritten: u64, + pub ri_cpu_time_qos_default: u64, + pub ri_cpu_time_qos_maintenance: u64, + pub ri_cpu_time_qos_background: u64, + pub ri_cpu_time_qos_utility: u64, + pub ri_cpu_time_qos_legacy: u64, + pub ri_cpu_time_qos_user_initiated: u64, + pub ri_cpu_time_qos_user_interactive: u64, + pub ri_billed_system_time: u64, + pub ri_serviced_system_time: u64, + } + + pub struct rusage_info_v4 { + pub ri_uuid: [u8; 16], + pub ri_user_time: u64, + pub ri_system_time: u64, + pub ri_pkg_idle_wkups: u64, + pub ri_interrupt_wkups: u64, + pub ri_pageins: u64, + pub ri_wired_size: u64, + pub ri_resident_size: u64, + pub ri_phys_footprint: u64, + pub ri_proc_start_abstime: u64, + pub ri_proc_exit_abstime: u64, + pub ri_child_user_time: u64, + pub ri_child_system_time: u64, + pub ri_child_pkg_idle_wkups: u64, + pub ri_child_interrupt_wkups: u64, + pub ri_child_pageins: u64, + pub ri_child_elapsed_abstime: u64, + pub ri_diskio_bytesread: u64, + pub ri_diskio_byteswritten: u64, + pub ri_cpu_time_qos_default: u64, + pub ri_cpu_time_qos_maintenance: u64, + pub ri_cpu_time_qos_background: u64, + pub ri_cpu_time_qos_utility: u64, + pub ri_cpu_time_qos_legacy: u64, + pub ri_cpu_time_qos_user_initiated: u64, + pub ri_cpu_time_qos_user_interactive: u64, + pub ri_billed_system_time: u64, + pub ri_serviced_system_time: u64, + pub ri_logical_writes: u64, + pub ri_lifetime_max_phys_footprint: u64, + pub ri_instructions: u64, + pub ri_cycles: u64, + pub ri_billed_energy: u64, + pub ri_serviced_energy: u64, + pub ri_interval_max_phys_footprint: u64, + pub ri_runnable_time: u64, + } + + pub struct image_offset { + pub uuid: ::uuid_t, + pub offset: u32, + } } s_no_extra_traits! { @@ -1058,6 +1220,24 @@ s_no_extra_traits! { pub internal_page_count: natural_t, pub total_uncompressed_pages_in_compressor: u64, } + + #[cfg_attr(libc_packedN, repr(packed(4)))] + pub struct mach_task_basic_info { + pub virtual_size: mach_vm_size_t, + pub resident_size: mach_vm_size_t, + pub resident_size_max: mach_vm_size_t, + pub user_time: time_value_t, + pub system_time: time_value_t, + pub policy: ::policy_t, + pub suspend_count: integer_t, + } + + #[cfg_attr(libc_packedN, repr(packed(4)))] + pub struct log2phys { + pub l2p_flags: ::c_uint, + pub l2p_contigbytes: ::off_t, + pub l2p_devoffset: ::off_t, + } } impl siginfo_t { @@ -2257,6 +2437,88 @@ cfg_if! { total_uncompressed.hash(state); } } + + impl PartialEq for mach_task_basic_info { + fn eq(&self, other: &mach_task_basic_info) -> bool { + self.virtual_size == other.virtual_size + && self.resident_size == other.resident_size + && self.resident_size_max == other.resident_size_max + && self.user_time == other.user_time + && self.system_time == other.system_time + && self.policy == other.policy + && self.suspend_count == other.suspend_count + } + } + impl Eq for mach_task_basic_info {} + impl ::fmt::Debug for mach_task_basic_info { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let virtual_size = self.virtual_size; + let resident_size = self.resident_size; + let resident_size_max = self.resident_size_max; + let user_time = self.user_time; + let system_time = self.system_time; + let policy = self.policy; + let suspend_count = self.suspend_count; + f.debug_struct("mach_task_basic_info") + .field("virtual_size", &virtual_size) + .field("resident_size", &resident_size) + .field("resident_size_max", &resident_size_max) + .field("user_time", &user_time) + .field("system_time", &system_time) + .field("policy", &policy) + .field("suspend_count", &suspend_count) + .finish() + } + } + impl ::hash::Hash for mach_task_basic_info { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + let virtual_size = self.virtual_size; + let resident_size = self.resident_size; + let resident_size_max = self.resident_size_max; + let user_time = self.user_time; + let system_time = self.system_time; + let policy = self.policy; + let suspend_count = self.suspend_count; + virtual_size.hash(state); + resident_size.hash(state); + resident_size_max.hash(state); + user_time.hash(state); + system_time.hash(state); + policy.hash(state); + suspend_count.hash(state); + } + } + + impl PartialEq for log2phys { + fn eq(&self, other: &log2phys) -> bool { + self.l2p_flags == other.l2p_flags + && self.l2p_contigbytes == other.l2p_contigbytes + && self.l2p_devoffset == other.l2p_devoffset + } + } + impl Eq for log2phys {} + impl ::fmt::Debug for log2phys { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let l2p_flags = self.l2p_flags; + let l2p_contigbytes = self.l2p_contigbytes; + let l2p_devoffset = self.l2p_devoffset; + f.debug_struct("log2phys") + .field("l2p_flags", &l2p_flags) + .field("l2p_contigbytes", &l2p_contigbytes) + .field("l2p_devoffset", &l2p_devoffset) + .finish() + } + } + impl ::hash::Hash for log2phys { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + let l2p_flags = self.l2p_flags; + let l2p_contigbytes = self.l2p_contigbytes; + let l2p_devoffset = self.l2p_devoffset; + l2p_flags.hash(state); + l2p_contigbytes.hash(state); + l2p_devoffset.hash(state); + } + } } } @@ -2733,12 +2995,16 @@ pub const F_PREALLOCATE: ::c_int = 42; pub const F_RDADVISE: ::c_int = 44; pub const F_RDAHEAD: ::c_int = 45; pub const F_NOCACHE: ::c_int = 48; +pub const F_LOG2PHYS: ::c_int = 49; pub const F_GETPATH: ::c_int = 50; pub const F_FULLFSYNC: ::c_int = 51; pub const F_FREEZE_FS: ::c_int = 53; pub const F_THAW_FS: ::c_int = 54; pub const F_GLOBAL_NOCACHE: ::c_int = 55; pub const F_NODIRECT: ::c_int = 62; +pub const F_LOG2PHYS_EXT: ::c_int = 65; +pub const F_BARRIERFSYNC: ::c_int = 85; +pub const F_GETPATH_NOFIRMLINK: ::c_int = 102; pub const F_ALLOCATECONTIG: ::c_uint = 0x02; pub const F_ALLOCATEALL: ::c_uint = 0x04; @@ -2752,6 +3018,11 @@ pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x0020; pub const AT_SYMLINK_FOLLOW: ::c_int = 0x0040; pub const AT_REMOVEDIR: ::c_int = 0x0080; +pub const PTHREAD_INTROSPECTION_THREAD_CREATE: ::c_uint = 1; +pub const PTHREAD_INTROSPECTION_THREAD_START: ::c_uint = 2; +pub const PTHREAD_INTROSPECTION_THREAD_TERMINATE: ::c_uint = 3; +pub const PTHREAD_INTROSPECTION_THREAD_DESTROY: ::c_uint = 4; + pub const TIOCMODG: ::c_ulong = 0x40047403; pub const TIOCMODS: ::c_ulong = 0x80047404; pub const TIOCM_LE: ::c_int = 0x1; @@ -3261,6 +3532,7 @@ pub const IP_RECVIF: ::c_int = 20; pub const IP_BOUND_IF: ::c_int = 25; pub const IP_PKTINFO: ::c_int = 26; pub const IP_RECVTOS: ::c_int = 27; +pub const IP_DONTFRAG: ::c_int = 28; pub const IPV6_JOIN_GROUP: ::c_int = 12; pub const IPV6_LEAVE_GROUP: ::c_int = 13; pub const IPV6_CHECKSUM: ::c_int = 26; @@ -3269,6 +3541,7 @@ pub const IPV6_TCLASS: ::c_int = 36; pub const IPV6_PKTINFO: ::c_int = 46; pub const IPV6_HOPLIMIT: ::c_int = 47; pub const IPV6_RECVPKTINFO: ::c_int = 61; +pub const IPV6_DONTFRAG: ::c_int = 62; pub const TCP_NOPUSH: ::c_int = 4; pub const TCP_NOOPT: ::c_int = 8; @@ -4022,6 +4295,8 @@ pub const RTF_CONDEMNED: ::c_int = 0x2000000; pub const RTF_IFREF: ::c_int = 0x4000000; pub const RTF_PROXY: ::c_int = 0x8000000; pub const RTF_ROUTER: ::c_int = 0x10000000; +pub const RTF_DEAD: ::c_int = 0x20000000; +pub const RTF_GLOBAL: ::c_int = 0x40000000; pub const RTM_VERSION: ::c_int = 5; @@ -4085,6 +4360,9 @@ pub const PROC_PIDTASKINFO: ::c_int = 4; pub const PROC_PIDTHREADINFO: ::c_int = 5; pub const PROC_PIDVNODEPATHINFO: ::c_int = 9; pub const PROC_PIDPATHINFO_MAXSIZE: ::c_int = 4096; +pub const PROC_CSM_ALL: ::c_uint = 0x0001; +pub const PROC_CSM_NOSMT: ::c_uint = 0x0002; +pub const PROC_CSM_TECS: ::c_uint = 0x0004; pub const MAXCOMLEN: usize = 16; pub const MAXTHREADNAMESIZE: usize = 64; @@ -4323,6 +4601,56 @@ pub const VM_PAGE_QUERY_PAGE_CS_VALIDATED: i32 = 0x100; pub const VM_PAGE_QUERY_PAGE_CS_TAINTED: i32 = 0x200; pub const VM_PAGE_QUERY_PAGE_CS_NX: i32 = 0x400; +// mach/task_info.h +pub const TASK_THREAD_TIMES_INFO: u32 = 3; +pub const HOST_CPU_LOAD_INFO_COUNT: u32 = 4; +pub const MACH_TASK_BASIC_INFO: u32 = 20; + +pub const MACH_PORT_NULL: i32 = 0; + +pub const RUSAGE_INFO_V0: ::c_int = 0; +pub const RUSAGE_INFO_V1: ::c_int = 1; +pub const RUSAGE_INFO_V2: ::c_int = 2; +pub const RUSAGE_INFO_V3: ::c_int = 3; +pub const RUSAGE_INFO_V4: ::c_int = 4; + +// copyfile.h +pub const COPYFILE_ACL: ::copyfile_flags_t = 1 << 0; +pub const COPYFILE_STAT: ::copyfile_flags_t = 1 << 1; +pub const COPYFILE_XATTR: ::copyfile_flags_t = 1 << 2; +pub const COPYFILE_DATA: ::copyfile_flags_t = 1 << 3; +pub const COPYFILE_SECURITY: ::copyfile_flags_t = COPYFILE_STAT | COPYFILE_ACL; +pub const COPYFILE_METADATA: ::copyfile_flags_t = COPYFILE_SECURITY | COPYFILE_XATTR; +pub const COPYFILE_RECURSIVE: ::copyfile_flags_t = 1 << 15; +pub const COPYFILE_CHECK: ::copyfile_flags_t = 1 << 16; +pub const COPYFILE_EXCL: ::copyfile_flags_t = 1 << 17; +pub const COPYFILE_NOFOLLOW_SRC: ::copyfile_flags_t = 1 << 18; +pub const COPYFILE_NOFOLLOW_DST: ::copyfile_flags_t = 1 << 19; +pub const COPYFILE_MOVE: ::copyfile_flags_t = 1 << 20; +pub const COPYFILE_UNLINK: ::copyfile_flags_t = 1 << 21; +pub const COPYFILE_NOFOLLOW: ::copyfile_flags_t = COPYFILE_NOFOLLOW_SRC | COPYFILE_NOFOLLOW_DST; +pub const COPYFILE_PACK: ::copyfile_flags_t = 1 << 22; +pub const COPYFILE_UNPACK: ::copyfile_flags_t = 1 << 23; +pub const COPYFILE_CLONE: ::copyfile_flags_t = 1 << 24; +pub const COPYFILE_CLONE_FORCE: ::copyfile_flags_t = 1 << 25; +pub const COPYFILE_RUN_IN_PLACE: ::copyfile_flags_t = 1 << 26; +pub const COPYFILE_DATA_SPARSE: ::copyfile_flags_t = 1 << 27; +pub const COPYFILE_PRESERVE_DST_TRACKED: ::copyfile_flags_t = 1 << 28; +pub const COPYFILE_VERBOSE: ::copyfile_flags_t = 1 << 30; +pub const COPYFILE_RECURSE_ERROR: ::c_int = 0; +pub const COPYFILE_RECURSE_FILE: ::c_int = 1; +pub const COPYFILE_RECURSE_DIR: ::c_int = 2; +pub const COPYFILE_RECURSE_DIR_CLEANUP: ::c_int = 3; +pub const COPYFILE_COPY_DATA: ::c_int = 4; +pub const COPYFILE_COPY_XATTR: ::c_int = 5; +pub const COPYFILE_START: ::c_int = 1; +pub const COPYFILE_FINISH: ::c_int = 2; +pub const COPYFILE_ERR: ::c_int = 3; +pub const COPYFILE_PROGRESS: ::c_int = 4; +pub const COPYFILE_CONTINUE: ::c_int = 0; +pub const COPYFILE_SKIP: ::c_int = 1; +pub const COPYFILE_QUIT: ::c_int = 2; + cfg_if! { if #[cfg(libc_const_extern_fn)] { const fn __DARWIN_ALIGN32(p: usize) -> usize { @@ -4364,6 +4692,15 @@ cfg_if! { pub const THREAD_EXTENDED_INFO_COUNT: mach_msg_type_number_t = (::mem::size_of::<thread_extended_info_data_t>() / ::mem::size_of::<integer_t>()) as mach_msg_type_number_t; + + pub const TASK_THREAD_TIMES_INFO_COUNT: u32 = + (::mem::size_of::<task_thread_times_info_data_t>() + / ::mem::size_of::<natural_t>()) as u32; + pub const MACH_TASK_BASIC_INFO_COUNT: u32 = (::mem::size_of::<mach_task_basic_info_data_t>() + / ::mem::size_of::<natural_t>()) as u32; + pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t = + (::mem::size_of::<vm_statistics64_data_t>() / ::mem::size_of::<integer_t>()) + as mach_msg_type_number_t; } else { fn __DARWIN_ALIGN32(p: usize) -> usize { let __DARWIN_ALIGNBYTES32: usize = ::mem::size_of::<u32>() - 1; @@ -4379,6 +4716,9 @@ cfg_if! { pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t = 10; pub const THREAD_IDENTIFIER_INFO_COUNT: mach_msg_type_number_t = 6; pub const THREAD_EXTENDED_INFO_COUNT: mach_msg_type_number_t = 28; + pub const TASK_THREAD_TIMES_INFO_COUNT: u32 = 4; + pub const MACH_TASK_BASIC_INFO_COUNT: u32 = 12; + pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t = 38; } } @@ -4545,9 +4885,9 @@ extern "C" { newp: *mut ::c_void, newlen: ::size_t, ) -> ::c_int; - #[deprecated(since = "0.2.55", note = "Use the mach crate")] + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn mach_absolute_time() -> u64; - #[deprecated(since = "0.2.55", note = "Use the mach crate")] + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] #[allow(deprecated)] pub fn mach_timebase_info(info: *mut ::mach_timebase_info) -> ::c_int; pub fn mach_host_self() -> mach_port_t; @@ -4556,6 +4896,12 @@ extern "C" { pub fn pthread_getname_np(thread: ::pthread_t, name: *mut ::c_char, len: ::size_t) -> ::c_int; pub fn pthread_mach_thread_np(thread: ::pthread_t) -> ::mach_port_t; pub fn pthread_from_mach_thread_np(port: ::mach_port_t) -> ::pthread_t; + pub fn pthread_create_from_mach_thread( + thread: *mut ::pthread_t, + attr: *const ::pthread_attr_t, + f: extern "C" fn(*mut ::c_void) -> *mut ::c_void, + value: *mut ::c_void, + ) -> ::c_int; pub fn pthread_get_stackaddr_np(thread: ::pthread_t) -> *mut ::c_void; pub fn pthread_get_stacksize_np(thread: ::pthread_t) -> ::size_t; pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, pshared: ::c_int) -> ::c_int; @@ -4611,6 +4957,24 @@ extern "C" { policy: ::c_int, param: *const sched_param, ) -> ::c_int; + + // Available from Big Sur + pub fn pthread_introspection_hook_install( + hook: ::pthread_introspection_hook_t, + ) -> ::pthread_introspection_hook_t; + pub fn pthread_introspection_setspecific_np( + thread: ::pthread_t, + key: ::pthread_key_t, + value: *const ::c_void, + ) -> ::c_int; + pub fn pthread_introspection_getspecific_np( + thread: ::pthread_t, + key: ::pthread_key_t, + ) -> *mut ::c_void; + pub fn pthread_jit_write_protect_np(enabled: ::c_int); + pub fn pthread_jit_write_protect_supported_np() -> ::c_int; + pub fn pthread_cpu_number_np(cpu_number_out: *mut ::size_t) -> ::c_int; + pub fn thread_policy_set( thread: thread_t, flavor: thread_policy_flavor_t, @@ -4632,6 +4996,23 @@ extern "C" { ) -> kern_return_t; pub fn __error() -> *mut ::c_int; pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int; + pub fn backtrace_symbols(addrs: *const *mut ::c_void, sz: ::c_int) -> *mut *mut ::c_char; + pub fn backtrace_symbols_fd(addrs: *const *mut ::c_void, sz: ::c_int, fd: ::c_int); + pub fn backtrace_from_fp( + startfp: *mut ::c_void, + array: *mut *mut ::c_void, + size: ::c_int, + ) -> ::c_int; + pub fn backtrace_image_offsets( + array: *const *mut ::c_void, + image_offsets: *mut image_offset, + size: ::c_int, + ); + pub fn backtrace_async( + array: *mut *mut ::c_void, + length: ::size_t, + task_id: *mut u32, + ) -> ::size_t; #[cfg_attr( all(target_os = "macos", not(target_arch = "aarch64")), link_name = "statfs$INODE64" @@ -4665,6 +5046,12 @@ extern "C" { flags: ::c_int, data: *mut ::c_void, ) -> ::c_int; + pub fn fmount( + src: *const ::c_char, + fd: ::c_int, + flags: ::c_int, + data: *mut ::c_void, + ) -> ::c_int; pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: *mut ::c_char, data: ::c_int) -> ::c_int; pub fn quotactl( special: *const ::c_char, @@ -4787,14 +5174,14 @@ extern "C" { pub fn brk(addr: *const ::c_void) -> *mut ::c_void; pub fn sbrk(increment: ::c_int) -> *mut ::c_void; pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int; - #[deprecated(since = "0.2.55", note = "Use the mach crate")] + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn _dyld_image_count() -> u32; - #[deprecated(since = "0.2.55", note = "Use the mach crate")] + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] #[allow(deprecated)] pub fn _dyld_get_image_header(image_index: u32) -> *const mach_header; - #[deprecated(since = "0.2.55", note = "Use the mach crate")] + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn _dyld_get_image_vmaddr_slide(image_index: u32) -> ::intptr_t; - #[deprecated(since = "0.2.55", note = "Use the mach crate")] + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn _dyld_get_image_name(image_index: u32) -> *const ::c_char; pub fn posix_spawn( @@ -4841,6 +5228,20 @@ extern "C" { flags: *mut ::pid_t, ) -> ::c_int; pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: ::pid_t) -> ::c_int; + pub fn posix_spawnattr_setarchpref_np( + attr: *mut posix_spawnattr_t, + count: ::size_t, + pref: *mut ::cpu_type_t, + subpref: *mut ::cpu_subtype_t, + ocount: *mut ::size_t, + ) -> ::c_int; + pub fn posix_spawnattr_getarchpref_np( + attr: *const posix_spawnattr_t, + count: ::size_t, + pref: *mut ::cpu_type_t, + subpref: *mut ::cpu_subtype_t, + ocount: *mut ::size_t, + ) -> ::c_int; pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> ::c_int; pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> ::c_int; @@ -4906,6 +5307,19 @@ extern "C" { flags: u32, ) -> ::c_int; + pub fn copyfile( + from: *const ::c_char, + to: *const ::c_char, + state: copyfile_state_t, + flags: copyfile_flags_t, + ) -> ::c_int; + pub fn fcopyfile( + from: ::c_int, + to: ::c_int, + state: copyfile_state_t, + flags: copyfile_flags_t, + ) -> ::c_int; + // Added in macOS 10.13 // ISO/IEC 9899:2011 ("ISO C11") K.3.7.4.1 pub fn memset_s(s: *mut ::c_void, smax: ::size_t, c: ::c_int, n: ::size_t) -> ::c_int; @@ -4914,6 +5328,14 @@ extern "C" { pub fn memset_pattern8(b: *mut ::c_void, pattern8: *const ::c_void, len: ::size_t); pub fn memset_pattern16(b: *mut ::c_void, pattern16: *const ::c_void, len: ::size_t); + // Inherited from BSD but available from Big Sur only + pub fn strtonum( + __numstr: *const ::c_char, + __minval: ::c_longlong, + __maxval: ::c_longlong, + errstrp: *mut *const ::c_char, + ) -> ::c_longlong; + pub fn mstats() -> mstats; pub fn malloc_printf(format: *const ::c_char, ...); pub fn malloc_zone_check(zone: *mut ::malloc_zone_t) -> ::boolean_t; @@ -4982,6 +5404,13 @@ extern "C" { ) -> ::c_int; pub fn proc_kmsgbuf(buffer: *mut ::c_void, buffersize: u32) -> ::c_int; pub fn proc_libversion(major: *mut ::c_int, mintor: *mut ::c_int) -> ::c_int; + pub fn proc_pid_rusage(pid: ::c_int, flavor: ::c_int, buffer: *mut rusage_info_t) -> ::c_int; + + // Available from Big Sur + pub fn proc_set_no_smt() -> ::c_int; + pub fn proc_setthread_no_smt() -> ::c_int; + pub fn proc_set_csm(flags: u32) -> ::c_int; + pub fn proc_setthread_csm(flags: u32) -> ::c_int; /// # Notes /// /// `id` is of type [`uuid_t`]. @@ -5009,6 +5438,12 @@ extern "C" { inheritance: ::vm_inherit_t, ) -> ::kern_return_t; + pub fn vm_deallocate( + target_task: vm_map_t, + address: vm_address_t, + size: vm_size_t, + ) -> ::kern_return_t; + pub fn host_statistics64( host_priv: host_t, flavor: host_flavor_t, @@ -5023,7 +5458,24 @@ extern "C" { out_processor_infoCnt: *mut mach_msg_type_number_t, ) -> ::kern_return_t; - pub static mut mach_task_self_: mach_port_t; + pub static mut mach_task_self_: ::mach_port_t; + pub fn task_for_pid( + host: ::mach_port_t, + pid: ::pid_t, + task: *mut ::mach_port_t, + ) -> ::kern_return_t; + pub fn task_info( + host: ::mach_port_t, + flavor: task_flavor_t, + task_info_out: task_info_t, + task_info_count: *mut mach_msg_type_number_t, + ) -> ::kern_return_t; + pub fn host_statistics( + host_priv: host_t, + flavor: host_flavor_t, + host_info_out: host_info_t, + host_info_outCnt: *mut mach_msg_type_number_t, + ) -> ::kern_return_t; // sysdir.h pub fn sysdir_start_search_path_enumeration( @@ -5034,15 +5486,18 @@ extern "C" { state: ::sysdir_search_path_enumeration_state, path: *mut ::c_char, ) -> ::sysdir_search_path_enumeration_state; + + pub static vm_page_size: vm_size_t; } -pub unsafe fn mach_task_self() -> mach_port_t { +pub unsafe fn mach_task_self() -> ::mach_port_t { mach_task_self_ } cfg_if! { if #[cfg(target_os = "macos")] { extern "C" { + pub fn clock_settime(clock_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; pub fn memmem( haystack: *const ::c_void, haystacklen: ::size_t, diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index c3e49a12..f4fa6047 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -123,11 +123,11 @@ s! { pub st_ctime_nsec: ::c_long, pub st_size: ::off_t, pub st_blocks: i64, - pub st_blksize: u32, + pub __old_st_blksize: u32, pub st_flags: u32, pub st_gen: u32, pub st_lspare: i32, - pub st_qspare1: i64, + pub st_blksize: i64, pub st_qspare2: i64, } @@ -210,6 +210,54 @@ s! { pub shm_ctime: ::time_t, shm_internal: *mut ::c_void, } + + pub struct kinfo_file { + pub f_size: ::size_t, + pub f_pid: ::pid_t, + pub f_uid: ::uid_t, + pub f_fd: ::c_int, + pub f_file: *mut ::c_void, + pub f_type: ::c_short, + pub f_count: ::c_int, + pub f_msgcount: ::c_int, + pub f_offset: ::off_t, + pub f_data: *mut ::c_void, + pub f_flag: ::c_uint, + } + + pub struct kinfo_cputime { + pub cp_user: u64, + pub cp_nice: u64, + pub cp_sys: u64, + pub cp_intr: u64, + pub cp_idel: u64, + cp_unused01: u64, + cp_unused02: u64, + pub cp_sample_pc: u64, + pub cp_sample_sp: u64, + pub cp_msg: [::c_char; 32], + } + + pub struct cpuctl_msr_args_t { + pub msr: ::c_int, + pub data: u64, + } + + pub struct cpuctl_cpuid_args_t { + pub level: ::c_int, + pub data: [u32; 4], + } + + pub struct cpuctl_cpuid_count_args_t { + pub level: ::c_int, + pub level_type: ::c_int, + pub data: [u32; 4], + } + + pub struct cpuctl_update_args_t { + pub data: *mut ::c_void, + pub size: ::size_t, + } } s_no_extra_traits! { @@ -701,6 +749,10 @@ cfg_if! { pub const RAND_MAX: ::c_int = 0x7fff_ffff; pub const PTHREAD_STACK_MIN: ::size_t = 16384; pub const SIGSTKSZ: ::size_t = 40960; +pub const SIGCKPT: ::c_int = 33; +pub const SIGCKPTEXIT: ::c_int = 34; +pub const CKPT_FREEZE: ::c_int = 0x1; +pub const CKPT_THAW: ::c_int = 0x2; pub const MADV_INVAL: ::c_int = 10; pub const MADV_SETMAP: ::c_int = 11; pub const O_CLOEXEC: ::c_int = 0x00020000; @@ -708,7 +760,10 @@ pub const O_DIRECTORY: ::c_int = 0x08000000; pub const F_GETLK: ::c_int = 7; pub const F_SETLK: ::c_int = 8; pub const F_SETLKW: ::c_int = 9; +pub const F_GETPATH: ::c_int = 19; pub const ENOMEDIUM: ::c_int = 93; +pub const ENOTRECOVERABLE: ::c_int = 94; +pub const EOWNERDEAD: ::c_int = 95; pub const EASYNC: ::c_int = 99; pub const ELAST: ::c_int = 99; pub const RLIMIT_POSIXLOCKS: ::c_int = 11; @@ -850,6 +905,14 @@ pub const CTL_P1003_1B_SIGQUEUE_MAX: ::c_int = 24; pub const CTL_P1003_1B_TIMER_MAX: ::c_int = 25; pub const CTL_P1003_1B_MAXID: ::c_int = 26; +pub const CPUCTL_RSMSR: ::c_int = 0xc0106301; +pub const CPUCTL_WRMSR: ::c_int = 0xc0106302; +pub const CPUCTL_CPUID: ::c_int = 0xc0106303; +pub const CPUCTL_UPDATE: ::c_int = 0xc0106304; +pub const CPUCTL_MSRSBIT: ::c_int = 0xc0106305; +pub const CPUCTL_MSRCBIT: ::c_int = 0xc0106306; +pub const CPUCTL_CPUID_COUNT: ::c_int = 0xc0106307; + pub const EVFILT_READ: i16 = -1; pub const EVFILT_WRITE: i16 = -2; pub const EVFILT_AIO: i16 = -3; @@ -875,6 +938,8 @@ pub const EV_ERROR: u16 = 0x4000; pub const EV_EOF: u16 = 0x8000; pub const EV_SYSFLAGS: u16 = 0xf000; +pub const FIODNAME: ::c_ulong = 0x80106678; + pub const NOTE_TRIGGER: u32 = 0x01000000; pub const NOTE_FFNOP: u32 = 0x00000000; pub const NOTE_FFAND: u32 = 0x40000000; @@ -902,6 +967,7 @@ pub const NOTE_CHILD: u32 = 0x00000004; pub const SO_SNDSPACE: ::c_int = 0x100a; pub const SO_CPUHINT: ::c_int = 0x1030; +pub const SO_PASSCRED: ::c_int = 0x4000; pub const PT_FIRSTMACH: ::c_int = 32; @@ -1223,11 +1289,11 @@ pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK | LC_NUMERIC_MASK | LC_TIME_MASK; -pub const TIOCSIG: ::c_uint = 0x2000745f; +pub const TIOCSIG: ::c_ulong = 0x2000745f; pub const BTUARTDISC: ::c_int = 0x7; -pub const TIOCDCDTIMESTAMP: ::c_uint = 0x40107458; -pub const TIOCISPTMASTER: ::c_uint = 0x20007455; -pub const TIOCMODG: ::c_uint = 0x40047403; +pub const TIOCDCDTIMESTAMP: ::c_ulong = 0x40107458; +pub const TIOCISPTMASTER: ::c_ulong = 0x20007455; +pub const TIOCMODG: ::c_ulong = 0x40047403; pub const TIOCMODS: ::c_ulong = 0x80047404; pub const TIOCREMOTE: ::c_ulong = 0x80047469; @@ -1280,9 +1346,11 @@ pub const SF_XLINK: ::c_ulong = 0x01000000; pub const UTIME_OMIT: c_long = -2; pub const UTIME_NOW: c_long = -1; +pub const MINCORE_SUPER: ::c_int = 0x20; + const_fn! { {const} fn _CMSG_ALIGN(n: usize) -> usize { - (n + 3) & !3 + (n + (::mem::size_of::<::c_long>() - 1)) & !(::mem::size_of::<::c_long>() - 1) } } @@ -1335,7 +1403,7 @@ f! { () } - pub fn CPU_ISSET(cpu: usize, cpuset: &mut cpu_set_t) -> bool { + pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { let (idx, offset) = ((cpu >> 6) & 3, cpu & 63); 0 != cpuset.ary[idx] & (1 << offset) } @@ -1356,6 +1424,13 @@ extern "C" { pub fn aio_waitcomplete(iocbp: *mut *mut aiocb, timeout: *mut ::timespec) -> ::c_int; + pub fn devname_r( + dev: ::dev_t, + mode: ::mode_t, + buf: *mut ::c_char, + len: ::size_t, + ) -> *mut ::c_char; + pub fn waitid( idtype: idtype_t, id: ::id_t, @@ -1390,6 +1465,7 @@ extern "C" { pub fn sched_getaffinity(pid: ::pid_t, cpusetsize: ::size_t, mask: *mut cpu_set_t) -> ::c_int; pub fn sched_setaffinity(pid: ::pid_t, cpusetsize: ::size_t, mask: *const cpu_set_t) -> ::c_int; + pub fn sched_getcpu() -> ::c_int; pub fn setproctitle(fmt: *const ::c_char, ...); pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; @@ -1403,6 +1479,8 @@ extern "C" { pub fn updlastlogx(fname: *const ::c_char, uid: ::uid_t, ll: *mut lastlogx) -> ::c_int; pub fn getutxuser(name: *const ::c_char) -> utmpx; pub fn utmpxname(file: *const ::c_char) -> ::c_int; + + pub fn sys_checkpoint(tpe: ::c_int, fd: ::c_int, pid: ::pid_t, retval: ::c_int) -> ::c_int; } #[link(name = "rt")] diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index a0b51051..1af555fa 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -29,6 +29,186 @@ s! { pub shm_dtime: ::time_t, pub shm_ctime: ::time_t, } + + pub struct kinfo_proc { + /// Size of this structure. + pub ki_structsize: ::c_int, + /// Reserved: layout identifier. + pub ki_layout: ::c_int, + /// Address of command arguments. + pub ki_args: *mut ::pargs, + // This is normally "struct proc". + /// Address of proc. + pub ki_paddr: *mut ::c_void, + // This is normally "struct user". + /// Kernel virtual address of u-area. + pub ki_addr: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to trace file. + pub ki_tracep: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to executable file. + pub ki_textvp: *mut ::c_void, + // This is normally "struct filedesc". + /// Pointer to open file info. + pub ki_fd: *mut ::c_void, + // This is normally "struct vmspace". + /// Pointer to kernel vmspace struct. + pub ki_vmspace: *mut ::c_void, + /// Sleep address. + pub ki_wchan: *mut ::c_void, + /// Process identifier. + pub ki_pid: ::pid_t, + /// Parent process ID. + pub ki_ppid: ::pid_t, + /// Process group ID. + pub ki_pgid: ::pid_t, + /// tty process group ID. + pub ki_tpgid: ::pid_t, + /// Process session ID. + pub ki_sid: ::pid_t, + /// Terminal session ID. + pub ki_tsid: ::pid_t, + /// Job control counter. + pub ki_jobc: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short1: ::c_short, + /// Controlling tty dev. + pub ki_tdev: ::dev_t, + /// Signals arrived but not delivered. + pub ki_siglist: ::sigset_t, + /// Current signal mask. + pub ki_sigmask: ::sigset_t, + /// Signals being ignored. + pub ki_sigignore: ::sigset_t, + /// Signals being caught by user. + pub ki_sigcatch: ::sigset_t, + /// Effective user ID. + pub ki_uid: ::uid_t, + /// Real user ID. + pub ki_ruid: ::uid_t, + /// Saved effective user ID. + pub ki_svuid: ::uid_t, + /// Real group ID. + pub ki_rgid: ::gid_t, + /// Saved effective group ID. + pub ki_svgid: ::gid_t, + /// Number of groups. + pub ki_ngroups: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short2: ::c_short, + /// Groups. + pub ki_groups: [::gid_t; ::KI_NGROUPS], + /// Virtual size. + pub ki_size: ::vm_size_t, + /// Current resident set size in pages. + pub ki_rssize: ::segsz_t, + /// Resident set size before last swap. + pub ki_swrss: ::segsz_t, + /// Text size (pages) XXX. + pub ki_tsize: ::segsz_t, + /// Data size (pages) XXX. + pub ki_dsize: ::segsz_t, + /// Stack size (pages). + pub ki_ssize: ::segsz_t, + /// Exit status for wait & stop signal. + pub ki_xstat: ::u_short, + /// Accounting flags. + pub ki_acflag: ::u_short, + /// %cpu for process during `ki_swtime`. + pub ki_pctcpu: ::fixpt_t, + /// Time averaged value of `ki_cpticks`. + pub ki_estcpu: ::u_int, + /// Time since last blocked. + pub ki_slptime: ::u_int, + /// Time swapped in or out. + pub ki_swtime: ::u_int, + /// Number of copy-on-write faults. + pub ki_cow: ::u_int, + /// Real time in microsec. + pub ki_runtime: u64, + /// Starting time. + pub ki_start: ::timeval, + /// Time used by process children. + pub ki_childtime: ::timeval, + /// P_* flags. + pub ki_flag: ::c_long, + /// KI_* flags (below). + pub ki_kiflag: ::c_long, + /// Kernel trace points. + pub ki_traceflag: ::c_int, + /// S* process status. + pub ki_stat: ::c_char, + /// Process "nice" value. + pub ki_nice: i8, // signed char + /// Process lock (prevent swap) count. + pub ki_lock: ::c_char, + /// Run queue index. + pub ki_rqindex: ::c_char, + /// Which cpu we are on. + pub ki_oncpu_old: ::c_uchar, + /// Last cpu we were on. + pub ki_lastcpu_old: ::c_uchar, + /// Thread name. + pub ki_tdname: [::c_char; ::TDNAMLEN + 1], + /// Wchan message. + pub ki_wmesg: [::c_char; ::WMESGLEN + 1], + /// Setlogin name. + pub ki_login: [::c_char; ::LOGNAMELEN + 1], + /// Lock name. + pub ki_lockname: [::c_char; ::LOCKNAMELEN + 1], + /// Command name. + pub ki_comm: [::c_char; ::COMMLEN + 1], + /// Emulation name. + pub ki_emul: [::c_char; ::KI_EMULNAMELEN + 1], + /// Login class. + pub ki_loginclass: [::c_char; ::LOGINCLASSLEN + 1], + /// More thread name. + pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], + /// Spare string space. + pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + /// Spare room for growth. + pub ki_spareints: [::c_int; ::KI_NSPARE_INT], + /// Which cpu we are on. + pub ki_oncpu: ::c_int, + /// Last cpu we were on. + pub ki_lastcpu: ::c_int, + /// PID of tracing process. + pub ki_tracer: ::c_int, + /// P2_* flags. + pub ki_flag2: ::c_int, + /// Default FIB number. + pub ki_fibnum: ::c_int, + /// Credential flags. + pub ki_cr_flags: ::u_int, + /// Process jail ID. + pub ki_jid: ::c_int, + /// Number of threads in total. + pub ki_numthreads: ::c_int, + /// Thread ID. + pub ki_tid: ::lwpid_t, + /// Process priority. + pub ki_pri: ::priority, + /// Process rusage statistics. + pub ki_rusage: ::rusage, + /// rusage of children processes. + pub ki_rusage_ch: ::rusage, + // This is normally "struct pcb". + /// Kernel virtual addr of pcb. + pub ki_pcb: *mut ::c_void, + /// Kernel virtual addr of stack. + pub ki_kstack: *mut ::c_void, + /// User convenience pointer. + pub ki_udata: *mut ::c_void, + // This is normally "struct thread". + pub ki_tdaddr: *mut ::c_void, + pub ki_spareptrs: [*mut ::c_void; ::KI_NSPARE_PTR], + pub ki_sparelongs: [::c_long; ::KI_NSPARE_LONG], + /// PS_* flags. + pub ki_sflag: ::c_long, + /// kthread flag. + pub ki_tdflags: ::c_long, + } } s_no_extra_traits! { @@ -67,6 +247,17 @@ s_no_extra_traits! { // Array length changed from 88 to 1024 in FreeBSD 12: pub f_mntonname: [::c_char; 88], } + + pub struct vnstat { + pub vn_fileid: u64, + pub vn_size: u64, + pub vn_mntdir: *mut ::c_char, + pub vn_dev: u32, + pub vn_fsid: u32, + pub vn_type: ::c_int, + pub vn_mode: u16, + pub vn_devname: [::c_char; ::SPECNAMELEN as usize + 1], + } } cfg_if! { @@ -186,11 +377,62 @@ cfg_if! { self.d_name[..self.d_namlen as _].hash(state); } } + + impl PartialEq for vnstat { + fn eq(&self, other: &vnstat) -> bool { + let self_vn_devname: &[::c_char] = &self.vn_devname; + let other_vn_devname: &[::c_char] = &other.vn_devname; + + self.vn_fileid == other.vn_fileid && + self.vn_size == other.vn_size && + self.vn_mntdir == other.vn_mntdir && + self.vn_dev == other.vn_dev && + self.vn_fsid == other.vn_fsid && + self.vn_type == other.vn_type && + self.vn_mode == other.vn_mode && + self_vn_devname == other_vn_devname + } + } + impl Eq for vnstat {} + impl ::fmt::Debug for vnstat { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let self_vn_devname: &[::c_char] = &self.vn_devname; + + f.debug_struct("vnstat") + .field("vn_fileid", &self.vn_fileid) + .field("vn_size", &self.vn_size) + .field("vn_mntdir", &self.vn_mntdir) + .field("vn_dev", &self.vn_dev) + .field("vn_fsid", &self.vn_fsid) + .field("vn_type", &self.vn_type) + .field("vn_mode", &self.vn_mode) + .field("vn_devname", &self_vn_devname) + .finish() + } + } + impl ::hash::Hash for vnstat { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + let self_vn_devname: &[::c_char] = &self.vn_devname; + + self.vn_fileid.hash(state); + self.vn_size.hash(state); + self.vn_mntdir.hash(state); + self.vn_dev.hash(state); + self.vn_fsid.hash(state); + self.vn_type.hash(state); + self.vn_mode.hash(state); + self_vn_devname.hash(state); + } + } } } pub const ELAST: ::c_int = 96; pub const RAND_MAX: ::c_int = 0x7fff_fffd; +pub const KI_NSPARE_PTR: usize = 6; +pub const MINCORE_SUPER: ::c_int = 0x20; +/// max length of devicename +pub const SPECNAMELEN: ::c_int = 63; extern "C" { // Return type ::c_int was removed in FreeBSD 12 @@ -217,7 +459,8 @@ extern "C" { cfg_if! { if #[cfg(any(target_arch = "x86_64", - target_arch = "aarch64"))] { + target_arch = "aarch64", + target_arch = "riscv64"))] { mod b64; pub use self::b64::*; } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index 05cadd1d..25c70c89 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -26,6 +26,198 @@ s! { pub udata: *mut ::c_void, pub ext: [u64; 4], } + + pub struct kvm_page { + pub version: ::c_uint, + pub paddr: ::c_ulong, + pub kmap_vaddr: ::c_ulong, + pub dmap_vaddr: ::c_ulong, + pub prot: ::vm_prot_t, + pub offset: ::u_long, + pub len: ::size_t, + } + + pub struct kinfo_proc { + /// Size of this structure. + pub ki_structsize: ::c_int, + /// Reserved: layout identifier. + pub ki_layout: ::c_int, + /// Address of command arguments. + pub ki_args: *mut ::pargs, + // This is normally "struct proc". + /// Address of proc. + pub ki_paddr: *mut ::c_void, + // This is normally "struct user". + /// Kernel virtual address of u-area. + pub ki_addr: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to trace file. + pub ki_tracep: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to executable file. + pub ki_textvp: *mut ::c_void, + // This is normally "struct filedesc". + /// Pointer to open file info. + pub ki_fd: *mut ::c_void, + // This is normally "struct vmspace". + /// Pointer to kernel vmspace struct. + pub ki_vmspace: *mut ::c_void, + /// Sleep address. + pub ki_wchan: *mut ::c_void, + /// Process identifier. + pub ki_pid: ::pid_t, + /// Parent process ID. + pub ki_ppid: ::pid_t, + /// Process group ID. + pub ki_pgid: ::pid_t, + /// tty process group ID. + pub ki_tpgid: ::pid_t, + /// Process session ID. + pub ki_sid: ::pid_t, + /// Terminal session ID. + pub ki_tsid: ::pid_t, + /// Job control counter. + pub ki_jobc: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short1: ::c_short, + /// Controlling tty dev. + pub ki_tdev_freebsd11: u32, + /// Signals arrived but not delivered. + pub ki_siglist: ::sigset_t, + /// Current signal mask. + pub ki_sigmask: ::sigset_t, + /// Signals being ignored. + pub ki_sigignore: ::sigset_t, + /// Signals being caught by user. + pub ki_sigcatch: ::sigset_t, + /// Effective user ID. + pub ki_uid: ::uid_t, + /// Real user ID. + pub ki_ruid: ::uid_t, + /// Saved effective user ID. + pub ki_svuid: ::uid_t, + /// Real group ID. + pub ki_rgid: ::gid_t, + /// Saved effective group ID. + pub ki_svgid: ::gid_t, + /// Number of groups. + pub ki_ngroups: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short2: ::c_short, + /// Groups. + pub ki_groups: [::gid_t; ::KI_NGROUPS], + /// Virtual size. + pub ki_size: ::vm_size_t, + /// Current resident set size in pages. + pub ki_rssize: ::segsz_t, + /// Resident set size before last swap. + pub ki_swrss: ::segsz_t, + /// Text size (pages) XXX. + pub ki_tsize: ::segsz_t, + /// Data size (pages) XXX. + pub ki_dsize: ::segsz_t, + /// Stack size (pages). + pub ki_ssize: ::segsz_t, + /// Exit status for wait & stop signal. + pub ki_xstat: ::u_short, + /// Accounting flags. + pub ki_acflag: ::u_short, + /// %cpu for process during `ki_swtime`. + pub ki_pctcpu: ::fixpt_t, + /// Time averaged value of `ki_cpticks`. + pub ki_estcpu: ::u_int, + /// Time since last blocked. + pub ki_slptime: ::u_int, + /// Time swapped in or out. + pub ki_swtime: ::u_int, + /// Number of copy-on-write faults. + pub ki_cow: ::u_int, + /// Real time in microsec. + pub ki_runtime: u64, + /// Starting time. + pub ki_start: ::timeval, + /// Time used by process children. + pub ki_childtime: ::timeval, + /// P_* flags. + pub ki_flag: ::c_long, + /// KI_* flags (below). + pub ki_kiflag: ::c_long, + /// Kernel trace points. + pub ki_traceflag: ::c_int, + /// S* process status. + pub ki_stat: ::c_char, + /// Process "nice" value. + pub ki_nice: i8, // signed char + /// Process lock (prevent swap) count. + pub ki_lock: ::c_char, + /// Run queue index. + pub ki_rqindex: ::c_char, + /// Which cpu we are on. + pub ki_oncpu_old: ::c_uchar, + /// Last cpu we were on. + pub ki_lastcpu_old: ::c_uchar, + /// Thread name. + pub ki_tdname: [::c_char; ::TDNAMLEN + 1], + /// Wchan message. + pub ki_wmesg: [::c_char; ::WMESGLEN + 1], + /// Setlogin name. + pub ki_login: [::c_char; ::LOGNAMELEN + 1], + /// Lock name. + pub ki_lockname: [::c_char; ::LOCKNAMELEN + 1], + /// Command name. + pub ki_comm: [::c_char; ::COMMLEN + 1], + /// Emulation name. + pub ki_emul: [::c_char; ::KI_EMULNAMELEN + 1], + /// Login class. + pub ki_loginclass: [::c_char; ::LOGINCLASSLEN + 1], + /// More thread name. + pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], + /// Spare string space. + pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + /// Spare room for growth. + pub ki_spareints: [::c_int; ::KI_NSPARE_INT], + /// Controlling tty dev. + pub ki_tdev: ::dev_t, + /// Which cpu we are on. + pub ki_oncpu: ::c_int, + /// Last cpu we were on. + pub ki_lastcpu: ::c_int, + /// PID of tracing process. + pub ki_tracer: ::c_int, + /// P2_* flags. + pub ki_flag2: ::c_int, + /// Default FIB number. + pub ki_fibnum: ::c_int, + /// Credential flags. + pub ki_cr_flags: ::u_int, + /// Process jail ID. + pub ki_jid: ::c_int, + /// Number of threads in total. + pub ki_numthreads: ::c_int, + /// Thread ID. + pub ki_tid: ::lwpid_t, + /// Process priority. + pub ki_pri: ::priority, + /// Process rusage statistics. + pub ki_rusage: ::rusage, + /// rusage of children processes. + pub ki_rusage_ch: ::rusage, + // This is normally "struct pcb". + /// Kernel virtual addr of pcb. + pub ki_pcb: *mut ::c_void, + /// Kernel virtual addr of stack. + pub ki_kstack: *mut ::c_void, + /// User convenience pointer. + pub ki_udata: *mut ::c_void, + // This is normally "struct thread". + pub ki_tdaddr: *mut ::c_void, + pub ki_spareptrs: [*mut ::c_void; ::KI_NSPARE_PTR], + pub ki_sparelongs: [::c_long; ::KI_NSPARE_LONG], + /// PS_* flags. + pub ki_sflag: ::c_long, + /// kthread flag. + pub ki_tdflags: ::c_long, + } } s_no_extra_traits! { @@ -64,6 +256,17 @@ s_no_extra_traits! { pub f_mntfromname: [::c_char; 1024], pub f_mntonname: [::c_char; 1024], } + + pub struct vnstat { + pub vn_fileid: u64, + pub vn_size: u64, + pub vn_dev: u64, + pub vn_fsid: u64, + pub vn_mntdir: *mut ::c_char, + pub vn_type: ::c_int, + pub vn_mode: u16, + pub vn_devname: [::c_char; ::SPECNAMELEN as usize + 1], + } } cfg_if! { @@ -187,30 +390,64 @@ cfg_if! { self.d_name[..self.d_namlen as _].hash(state); } } - } -} -pub const F_ADD_SEALS: ::c_int = 19; -pub const F_GET_SEALS: ::c_int = 20; -pub const F_SEAL_SEAL: ::c_int = 0x0001; -pub const F_SEAL_SHRINK: ::c_int = 0x0002; -pub const F_SEAL_GROW: ::c_int = 0x0004; -pub const F_SEAL_WRITE: ::c_int = 0x0008; + impl PartialEq for vnstat { + fn eq(&self, other: &vnstat) -> bool { + let self_vn_devname: &[::c_char] = &self.vn_devname; + let other_vn_devname: &[::c_char] = &other.vn_devname; -pub const GRND_NONBLOCK: ::c_uint = 0x1; -pub const GRND_RANDOM: ::c_uint = 0x2; + self.vn_fileid == other.vn_fileid && + self.vn_size == other.vn_size && + self.vn_dev == other.vn_dev && + self.vn_fsid == other.vn_fsid && + self.vn_mntdir == other.vn_mntdir && + self.vn_type == other.vn_type && + self.vn_mode == other.vn_mode && + self_vn_devname == other_vn_devname + } + } + impl Eq for vnstat {} + impl ::fmt::Debug for vnstat { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let self_vn_devname: &[::c_char] = &self.vn_devname; -pub const RAND_MAX: ::c_int = 0x7fff_fffd; + f.debug_struct("vnstat") + .field("vn_fileid", &self.vn_fileid) + .field("vn_size", &self.vn_size) + .field("vn_dev", &self.vn_dev) + .field("vn_fsid", &self.vn_fsid) + .field("vn_mntdir", &self.vn_mntdir) + .field("vn_type", &self.vn_type) + .field("vn_mode", &self.vn_mode) + .field("vn_devname", &self_vn_devname) + .finish() + } + } + impl ::hash::Hash for vnstat { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + let self_vn_devname: &[::c_char] = &self.vn_devname; -pub const PROC_ASLR_CTL: ::c_int = 13; -pub const PROC_ASLR_STATUS: ::c_int = 14; + self.vn_fileid.hash(state); + self.vn_size.hash(state); + self.vn_dev.hash(state); + self.vn_fsid.hash(state); + self.vn_mntdir.hash(state); + self.vn_type.hash(state); + self.vn_mode.hash(state); + self_vn_devname.hash(state); + } + } + } +} -pub const PROC_PROCCTL_MD_MIN: ::c_int = 0x10000000; +pub const RAND_MAX: ::c_int = 0x7fff_fffd; +pub const ELAST: ::c_int = 97; -pub const SO_DOMAIN: ::c_int = 0x1019; +/// max length of devicename +pub const SPECNAMELEN: ::c_int = 63; +pub const KI_NSPARE_PTR: usize = 6; -pub const EINTEGRITY: ::c_int = 97; -pub const ELAST: ::c_int = 97; +pub const MINCORE_SUPER: ::c_int = 0x20; extern "C" { pub fn setgrent(); @@ -241,7 +478,8 @@ extern "C" { cfg_if! { if #[cfg(any(target_arch = "x86_64", - target_arch = "aarch64"))] { + target_arch = "aarch64", + target_arch = "riscv64"))] { mod b64; pub use self::b64::*; } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index 93ef2a2a..cc92b175 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -1,9 +1,12 @@ -// APIs in FreeBSD 13 that have changed since 11. +// APIs in FreeBSD 14 that have changed since 11. pub type nlink_t = u64; pub type dev_t = u64; pub type ino_t = ::c_ulong; pub type shmatt_t = ::c_uint; +pub type kpaddr_t = u64; +pub type kssize_t = i64; +pub type domainset_t = __c_anonymous_domainset; s! { pub struct shmid_ds { @@ -27,15 +30,203 @@ s! { pub ext: [u64; 4], } - pub struct sockcred2 { - pub sc_version: ::c_int, - pub sc_pid: ::pid_t, - pub sc_uid: ::uid_t, - pub sc_euid: ::uid_t, - pub sc_gid: ::gid_t, - pub sc_egid: ::gid_t, - pub sc_ngroups: ::c_int, - pub sc_groups: [::gid_t; 1], + pub struct kvm_page { + pub kp_version: ::u_int, + pub kp_paddr: ::kpaddr_t, + pub kp_kmap_vaddr: ::kvaddr_t, + pub kp_dmap_vaddr: ::kvaddr_t, + pub kp_prot: ::vm_prot_t, + pub kp_offset: ::off_t, + pub kp_len: ::size_t, + } + + pub struct __c_anonymous_domainset { + _priv: [::uintptr_t; 4], + } + + pub struct kinfo_proc { + /// Size of this structure. + pub ki_structsize: ::c_int, + /// Reserved: layout identifier. + pub ki_layout: ::c_int, + /// Address of command arguments. + pub ki_args: *mut ::pargs, + // This is normally "struct proc". + /// Address of proc. + pub ki_paddr: *mut ::c_void, + // This is normally "struct user". + /// Kernel virtual address of u-area. + pub ki_addr: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to trace file. + pub ki_tracep: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to executable file. + pub ki_textvp: *mut ::c_void, + // This is normally "struct filedesc". + /// Pointer to open file info. + pub ki_fd: *mut ::c_void, + // This is normally "struct vmspace". + /// Pointer to kernel vmspace struct. + pub ki_vmspace: *mut ::c_void, + /// Sleep address. + pub ki_wchan: *const ::c_void, + /// Process identifier. + pub ki_pid: ::pid_t, + /// Parent process ID. + pub ki_ppid: ::pid_t, + /// Process group ID. + pub ki_pgid: ::pid_t, + /// tty process group ID. + pub ki_tpgid: ::pid_t, + /// Process session ID. + pub ki_sid: ::pid_t, + /// Terminal session ID. + pub ki_tsid: ::pid_t, + /// Job control counter. + pub ki_jobc: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short1: ::c_short, + /// Controlling tty dev. + pub ki_tdev_freebsd11: u32, + /// Signals arrived but not delivered. + pub ki_siglist: ::sigset_t, + /// Current signal mask. + pub ki_sigmask: ::sigset_t, + /// Signals being ignored. + pub ki_sigignore: ::sigset_t, + /// Signals being caught by user. + pub ki_sigcatch: ::sigset_t, + /// Effective user ID. + pub ki_uid: ::uid_t, + /// Real user ID. + pub ki_ruid: ::uid_t, + /// Saved effective user ID. + pub ki_svuid: ::uid_t, + /// Real group ID. + pub ki_rgid: ::gid_t, + /// Saved effective group ID. + pub ki_svgid: ::gid_t, + /// Number of groups. + pub ki_ngroups: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short2: ::c_short, + /// Groups. + pub ki_groups: [::gid_t; ::KI_NGROUPS], + /// Virtual size. + pub ki_size: ::vm_size_t, + /// Current resident set size in pages. + pub ki_rssize: ::segsz_t, + /// Resident set size before last swap. + pub ki_swrss: ::segsz_t, + /// Text size (pages) XXX. + pub ki_tsize: ::segsz_t, + /// Data size (pages) XXX. + pub ki_dsize: ::segsz_t, + /// Stack size (pages). + pub ki_ssize: ::segsz_t, + /// Exit status for wait & stop signal. + pub ki_xstat: ::u_short, + /// Accounting flags. + pub ki_acflag: ::u_short, + /// %cpu for process during `ki_swtime`. + pub ki_pctcpu: ::fixpt_t, + /// Time averaged value of `ki_cpticks`. + pub ki_estcpu: ::u_int, + /// Time since last blocked. + pub ki_slptime: ::u_int, + /// Time swapped in or out. + pub ki_swtime: ::u_int, + /// Number of copy-on-write faults. + pub ki_cow: ::u_int, + /// Real time in microsec. + pub ki_runtime: u64, + /// Starting time. + pub ki_start: ::timeval, + /// Time used by process children. + pub ki_childtime: ::timeval, + /// P_* flags. + pub ki_flag: ::c_long, + /// KI_* flags (below). + pub ki_kiflag: ::c_long, + /// Kernel trace points. + pub ki_traceflag: ::c_int, + /// S* process status. + pub ki_stat: ::c_char, + /// Process "nice" value. + pub ki_nice: i8, // signed char + /// Process lock (prevent swap) count. + pub ki_lock: ::c_char, + /// Run queue index. + pub ki_rqindex: ::c_char, + /// Which cpu we are on. + pub ki_oncpu_old: ::c_uchar, + /// Last cpu we were on. + pub ki_lastcpu_old: ::c_uchar, + /// Thread name. + pub ki_tdname: [::c_char; ::TDNAMLEN + 1], + /// Wchan message. + pub ki_wmesg: [::c_char; ::WMESGLEN + 1], + /// Setlogin name. + pub ki_login: [::c_char; ::LOGNAMELEN + 1], + /// Lock name. + pub ki_lockname: [::c_char; ::LOCKNAMELEN + 1], + /// Command name. + pub ki_comm: [::c_char; ::COMMLEN + 1], + /// Emulation name. + pub ki_emul: [::c_char; ::KI_EMULNAMELEN + 1], + /// Login class. + pub ki_loginclass: [::c_char; ::LOGINCLASSLEN + 1], + /// More thread name. + pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], + /// Spare string space. + pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + /// Spare room for growth. + pub ki_spareints: [::c_int; ::KI_NSPARE_INT], + /// Controlling tty dev. + pub ki_tdev: u64, + /// Which cpu we are on. + pub ki_oncpu: ::c_int, + /// Last cpu we were on. + pub ki_lastcpu: ::c_int, + /// PID of tracing process. + pub ki_tracer: ::c_int, + /// P2_* flags. + pub ki_flag2: ::c_int, + /// Default FIB number. + pub ki_fibnum: ::c_int, + /// Credential flags. + pub ki_cr_flags: ::u_int, + /// Process jail ID. + pub ki_jid: ::c_int, + /// Number of threads in total. + pub ki_numthreads: ::c_int, + /// Thread ID. + pub ki_tid: ::lwpid_t, + /// Process priority. + pub ki_pri: ::priority, + /// Process rusage statistics. + pub ki_rusage: ::rusage, + /// rusage of children processes. + pub ki_rusage_ch: ::rusage, + // This is normally "struct pcb". + /// Kernel virtual addr of pcb. + pub ki_pcb: *mut ::c_void, + /// Kernel virtual addr of stack. + pub ki_kstack: *mut ::c_void, + /// User convenience pointer. + pub ki_udata: *mut ::c_void, + // This is normally "struct thread". + pub ki_tdaddr: *mut ::c_void, + // This is normally "struct pwddesc". + /// Pointer to process paths info. + pub ki_pd: *mut ::c_void, + pub ki_spareptrs: [*mut ::c_void; ::KI_NSPARE_PTR], + pub ki_sparelongs: [::c_long; ::KI_NSPARE_LONG], + /// PS_* flags. + pub ki_sflag: ::c_long, + /// kthread flag. + pub ki_tdflags: ::c_long, } } @@ -75,6 +266,17 @@ s_no_extra_traits! { pub f_mntfromname: [::c_char; 1024], pub f_mntonname: [::c_char; 1024], } + + pub struct vnstat { + pub vn_fileid: u64, + pub vn_size: u64, + pub vn_dev: u64, + pub vn_fsid: u64, + pub vn_mntdir: *mut ::c_char, + pub vn_type: ::c_int, + pub vn_mode: u16, + pub vn_devname: [::c_char; ::SPECNAMELEN as usize + 1], + } } cfg_if! { @@ -198,46 +400,73 @@ cfg_if! { self.d_name[..self.d_namlen as _].hash(state); } } - } -} -pub const F_ADD_SEALS: ::c_int = 19; -pub const F_GET_SEALS: ::c_int = 20; -pub const F_SEAL_SEAL: ::c_int = 0x0001; -pub const F_SEAL_SHRINK: ::c_int = 0x0002; -pub const F_SEAL_GROW: ::c_int = 0x0004; -pub const F_SEAL_WRITE: ::c_int = 0x0008; + impl PartialEq for vnstat { + fn eq(&self, other: &vnstat) -> bool { + let self_vn_devname: &[::c_char] = &self.vn_devname; + let other_vn_devname: &[::c_char] = &other.vn_devname; -pub const GRND_NONBLOCK: ::c_uint = 0x1; -pub const GRND_RANDOM: ::c_uint = 0x2; + self.vn_fileid == other.vn_fileid && + self.vn_size == other.vn_size && + self.vn_dev == other.vn_dev && + self.vn_fsid == other.vn_fsid && + self.vn_mntdir == other.vn_mntdir && + self.vn_type == other.vn_type && + self.vn_mode == other.vn_mode && + self_vn_devname == other_vn_devname + } + } + impl Eq for vnstat {} + impl ::fmt::Debug for vnstat { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let self_vn_devname: &[::c_char] = &self.vn_devname; -pub const RAND_MAX: ::c_int = 0x7fff_ffff; + f.debug_struct("vnstat") + .field("vn_fileid", &self.vn_fileid) + .field("vn_size", &self.vn_size) + .field("vn_dev", &self.vn_dev) + .field("vn_fsid", &self.vn_fsid) + .field("vn_mntdir", &self.vn_mntdir) + .field("vn_type", &self.vn_type) + .field("vn_mode", &self.vn_mode) + .field("vn_devname", &self_vn_devname) + .finish() + } + } + impl ::hash::Hash for vnstat { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + let self_vn_devname: &[::c_char] = &self.vn_devname; -pub const SO_DOMAIN: ::c_int = 0x1019; + self.vn_fileid.hash(state); + self.vn_size.hash(state); + self.vn_dev.hash(state); + self.vn_fsid.hash(state); + self.vn_mntdir.hash(state); + self.vn_type.hash(state); + self.vn_mode.hash(state); + self_vn_devname.hash(state); + } + } + } +} -pub const EINTEGRITY: ::c_int = 97; +pub const RAND_MAX: ::c_int = 0x7fff_ffff; pub const ELAST: ::c_int = 97; -pub const GRND_INSECURE: ::c_uint = 0x4; -pub const PROC_ASLR_CTL: ::c_int = 13; -pub const PROC_ASLR_STATUS: ::c_int = 14; -pub const PROC_PROTMAX_CTL: ::c_int = 15; -pub const PROC_PROTMAX_STATUS: ::c_int = 16; -pub const PROC_PROCCTL_MD_MIN: ::c_int = 0x10000000; +pub const KF_TYPE_EVENTFD: ::c_int = 13; -pub const LOCAL_CREDS_PERSISTENT: ::c_int = 3; -pub const SCM_CREDS2: ::c_int = 0x08; +/// max length of devicename +pub const SPECNAMELEN: ::c_int = 255; +pub const KI_NSPARE_PTR: usize = 5; -f! { - pub fn SOCKCRED2SIZE(ngrps: usize) -> usize { - let ngrps = if ngrps > 0 { - ngrps - 1 - } else { - 0 - }; - ::mem::size_of::<sockcred2>() + ::mem::size_of::<::gid_t>() * ngrps - } -} +/// domainset policies +pub const DOMAINSET_POLICY_INVALID: ::c_int = 0; +pub const DOMAINSET_POLICY_ROUNDROBIN: ::c_int = 1; +pub const DOMAINSET_POLICY_FIRSTTOUCH: ::c_int = 2; +pub const DOMAINSET_POLICY_PREFER: ::c_int = 3; +pub const DOMAINSET_POLICY_INTERLEAVE: ::c_int = 4; + +pub const MINCORE_SUPER: ::c_int = 0x20; extern "C" { pub fn aio_readv(aiocbp: *mut ::aiocb) -> ::c_int; @@ -259,6 +488,8 @@ extern "C" { rmtp: *mut ::timespec, ) -> ::c_int; + pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; + pub fn fdatasync(fd: ::c_int) -> ::c_int; pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t; @@ -267,11 +498,43 @@ extern "C" { pub fn setproctitle_fast(fmt: *const ::c_char, ...); pub fn timingsafe_bcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int; pub fn timingsafe_memcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int; + + pub fn cpuset_getdomain( + level: ::cpulevel_t, + which: ::cpuwhich_t, + id: ::id_t, + setsize: ::size_t, + mask: *mut ::domainset_t, + policy: *mut ::c_int, + ) -> ::c_int; + pub fn cpuset_setdomain( + level: ::cpulevel_t, + which: ::cpuwhich_t, + id: ::id_t, + setsize: ::size_t, + mask: *const ::domainset_t, + policy: ::c_int, + ) -> ::c_int; + + pub fn copy_file_range( + infd: ::c_int, + inoffp: *mut ::off_t, + outfd: ::c_int, + outoffp: *mut ::off_t, + len: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; +} + +#[link(name = "kvm")] +extern "C" { + pub fn kvm_kerndisp(kd: *mut ::kvm_t) -> ::kssize_t; } cfg_if! { if #[cfg(any(target_arch = "x86_64", - target_arch = "aarch64"))] { + target_arch = "aarch64", + target_arch = "riscv64"))] { mod b64; pub use self::b64::*; } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/b64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/b64.rs new file mode 100644 index 00000000..80c6fa16 --- /dev/null +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/b64.rs @@ -0,0 +1,34 @@ +#[repr(C)] +#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] +pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + st_padding0: i16, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + st_padding1: i32, + pub st_rdev: ::dev_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: u64, + pub st_spare: [u64; 10], +} + +impl ::Copy for ::stat {} +impl ::Clone for ::stat { + fn clone(&self) -> ::stat { + *self + } +} diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs new file mode 100644 index 00000000..56b6412b --- /dev/null +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -0,0 +1,548 @@ +// APIs in FreeBSD 13 that have changed since 11. + +pub type nlink_t = u64; +pub type dev_t = u64; +pub type ino_t = ::c_ulong; +pub type shmatt_t = ::c_uint; +pub type kpaddr_t = u64; +pub type kssize_t = i64; +pub type domainset_t = __c_anonymous_domainset; + +s! { + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_lpid: ::pid_t, + pub shm_cpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + } + + pub struct kevent { + pub ident: ::uintptr_t, + pub filter: ::c_short, + pub flags: ::c_ushort, + pub fflags: ::c_uint, + pub data: ::intptr_t, + pub udata: *mut ::c_void, + pub ext: [u64; 4], + } + + pub struct kvm_page { + pub kp_version: ::u_int, + pub kp_paddr: ::kpaddr_t, + pub kp_kmap_vaddr: ::kvaddr_t, + pub kp_dmap_vaddr: ::kvaddr_t, + pub kp_prot: ::vm_prot_t, + pub kp_offset: ::off_t, + pub kp_len: ::size_t, + } + + pub struct __c_anonymous_domainset { + _priv: [::uintptr_t; 4], + } + + pub struct kinfo_proc { + /// Size of this structure. + pub ki_structsize: ::c_int, + /// Reserved: layout identifier. + pub ki_layout: ::c_int, + /// Address of command arguments. + pub ki_args: *mut ::pargs, + // This is normally "struct proc". + /// Address of proc. + pub ki_paddr: *mut ::c_void, + // This is normally "struct user". + /// Kernel virtual address of u-area. + pub ki_addr: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to trace file. + pub ki_tracep: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to executable file. + pub ki_textvp: *mut ::c_void, + // This is normally "struct filedesc". + /// Pointer to open file info. + pub ki_fd: *mut ::c_void, + // This is normally "struct vmspace". + /// Pointer to kernel vmspace struct. + pub ki_vmspace: *mut ::c_void, + /// Sleep address. + pub ki_wchan: *const ::c_void, + /// Process identifier. + pub ki_pid: ::pid_t, + /// Parent process ID. + pub ki_ppid: ::pid_t, + /// Process group ID. + pub ki_pgid: ::pid_t, + /// tty process group ID. + pub ki_tpgid: ::pid_t, + /// Process session ID. + pub ki_sid: ::pid_t, + /// Terminal session ID. + pub ki_tsid: ::pid_t, + /// Job control counter. + pub ki_jobc: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short1: ::c_short, + /// Controlling tty dev. + pub ki_tdev_freebsd11: u32, + /// Signals arrived but not delivered. + pub ki_siglist: ::sigset_t, + /// Current signal mask. + pub ki_sigmask: ::sigset_t, + /// Signals being ignored. + pub ki_sigignore: ::sigset_t, + /// Signals being caught by user. + pub ki_sigcatch: ::sigset_t, + /// Effective user ID. + pub ki_uid: ::uid_t, + /// Real user ID. + pub ki_ruid: ::uid_t, + /// Saved effective user ID. + pub ki_svuid: ::uid_t, + /// Real group ID. + pub ki_rgid: ::gid_t, + /// Saved effective group ID. + pub ki_svgid: ::gid_t, + /// Number of groups. + pub ki_ngroups: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short2: ::c_short, + /// Groups. + pub ki_groups: [::gid_t; ::KI_NGROUPS], + /// Virtual size. + pub ki_size: ::vm_size_t, + /// Current resident set size in pages. + pub ki_rssize: ::segsz_t, + /// Resident set size before last swap. + pub ki_swrss: ::segsz_t, + /// Text size (pages) XXX. + pub ki_tsize: ::segsz_t, + /// Data size (pages) XXX. + pub ki_dsize: ::segsz_t, + /// Stack size (pages). + pub ki_ssize: ::segsz_t, + /// Exit status for wait & stop signal. + pub ki_xstat: ::u_short, + /// Accounting flags. + pub ki_acflag: ::u_short, + /// %cpu for process during `ki_swtime`. + pub ki_pctcpu: ::fixpt_t, + /// Time averaged value of `ki_cpticks`. + pub ki_estcpu: ::u_int, + /// Time since last blocked. + pub ki_slptime: ::u_int, + /// Time swapped in or out. + pub ki_swtime: ::u_int, + /// Number of copy-on-write faults. + pub ki_cow: ::u_int, + /// Real time in microsec. + pub ki_runtime: u64, + /// Starting time. + pub ki_start: ::timeval, + /// Time used by process children. + pub ki_childtime: ::timeval, + /// P_* flags. + pub ki_flag: ::c_long, + /// KI_* flags (below). + pub ki_kiflag: ::c_long, + /// Kernel trace points. + pub ki_traceflag: ::c_int, + /// S* process status. + pub ki_stat: ::c_char, + /// Process "nice" value. + pub ki_nice: i8, // signed char + /// Process lock (prevent swap) count. + pub ki_lock: ::c_char, + /// Run queue index. + pub ki_rqindex: ::c_char, + /// Which cpu we are on. + pub ki_oncpu_old: ::c_uchar, + /// Last cpu we were on. + pub ki_lastcpu_old: ::c_uchar, + /// Thread name. + pub ki_tdname: [::c_char; ::TDNAMLEN + 1], + /// Wchan message. + pub ki_wmesg: [::c_char; ::WMESGLEN + 1], + /// Setlogin name. + pub ki_login: [::c_char; ::LOGNAMELEN + 1], + /// Lock name. + pub ki_lockname: [::c_char; ::LOCKNAMELEN + 1], + /// Command name. + pub ki_comm: [::c_char; ::COMMLEN + 1], + /// Emulation name. + pub ki_emul: [::c_char; ::KI_EMULNAMELEN + 1], + /// Login class. + pub ki_loginclass: [::c_char; ::LOGINCLASSLEN + 1], + /// More thread name. + pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], + /// Spare string space. + pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + /// Spare room for growth. + pub ki_spareints: [::c_int; ::KI_NSPARE_INT], + /// Controlling tty dev. + pub ki_tdev: u64, + /// Which cpu we are on. + pub ki_oncpu: ::c_int, + /// Last cpu we were on. + pub ki_lastcpu: ::c_int, + /// PID of tracing process. + pub ki_tracer: ::c_int, + /// P2_* flags. + pub ki_flag2: ::c_int, + /// Default FIB number. + pub ki_fibnum: ::c_int, + /// Credential flags. + pub ki_cr_flags: ::u_int, + /// Process jail ID. + pub ki_jid: ::c_int, + /// Number of threads in total. + pub ki_numthreads: ::c_int, + /// Thread ID. + pub ki_tid: ::lwpid_t, + /// Process priority. + pub ki_pri: ::priority, + /// Process rusage statistics. + pub ki_rusage: ::rusage, + /// rusage of children processes. + pub ki_rusage_ch: ::rusage, + // This is normally "struct pcb". + /// Kernel virtual addr of pcb. + pub ki_pcb: *mut ::c_void, + /// Kernel virtual addr of stack. + pub ki_kstack: *mut ::c_void, + /// User convenience pointer. + pub ki_udata: *mut ::c_void, + // This is normally "struct thread". + pub ki_tdaddr: *mut ::c_void, + // This is normally "struct pwddesc". + /// Pointer to process paths info. + pub ki_pd: *mut ::c_void, + pub ki_spareptrs: [*mut ::c_void; ::KI_NSPARE_PTR], + pub ki_sparelongs: [::c_long; ::KI_NSPARE_LONG], + /// PS_* flags. + pub ki_sflag: ::c_long, + /// kthread flag. + pub ki_tdflags: ::c_long, + } +} + +s_no_extra_traits! { + pub struct dirent { + pub d_fileno: ::ino_t, + pub d_off: ::off_t, + pub d_reclen: u16, + pub d_type: u8, + d_pad0: u8, + pub d_namlen: u16, + d_pad1: u16, + pub d_name: [::c_char; 256], + } + + pub struct statfs { + pub f_version: u32, + pub f_type: u32, + pub f_flags: u64, + pub f_bsize: u64, + pub f_iosize: u64, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: i64, + pub f_files: u64, + pub f_ffree: i64, + pub f_syncwrites: u64, + pub f_asyncwrites: u64, + pub f_syncreads: u64, + pub f_asyncreads: u64, + f_spare: [u64; 10], + pub f_namemax: u32, + pub f_owner: ::uid_t, + pub f_fsid: ::fsid_t, + f_charspare: [::c_char; 80], + pub f_fstypename: [::c_char; 16], + pub f_mntfromname: [::c_char; 1024], + pub f_mntonname: [::c_char; 1024], + } + + pub struct vnstat { + pub vn_fileid: u64, + pub vn_size: u64, + pub vn_dev: u64, + pub vn_fsid: u64, + pub vn_mntdir: *mut ::c_char, + pub vn_type: ::c_int, + pub vn_mode: u16, + pub vn_devname: [::c_char; ::SPECNAMELEN as usize + 1], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for statfs { + fn eq(&self, other: &statfs) -> bool { + self.f_version == other.f_version + && self.f_type == other.f_type + && self.f_flags == other.f_flags + && self.f_bsize == other.f_bsize + && self.f_iosize == other.f_iosize + && self.f_blocks == other.f_blocks + && self.f_bfree == other.f_bfree + && self.f_bavail == other.f_bavail + && self.f_files == other.f_files + && self.f_ffree == other.f_ffree + && self.f_syncwrites == other.f_syncwrites + && self.f_asyncwrites == other.f_asyncwrites + && self.f_syncreads == other.f_syncreads + && self.f_asyncreads == other.f_asyncreads + && self.f_namemax == other.f_namemax + && self.f_owner == other.f_owner + && self.f_fsid == other.f_fsid + && self.f_fstypename == other.f_fstypename + && self + .f_mntfromname + .iter() + .zip(other.f_mntfromname.iter()) + .all(|(a,b)| a == b) + && self + .f_mntonname + .iter() + .zip(other.f_mntonname.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for statfs {} + impl ::fmt::Debug for statfs { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("statfs") + .field("f_bsize", &self.f_bsize) + .field("f_iosize", &self.f_iosize) + .field("f_blocks", &self.f_blocks) + .field("f_bfree", &self.f_bfree) + .field("f_bavail", &self.f_bavail) + .field("f_files", &self.f_files) + .field("f_ffree", &self.f_ffree) + .field("f_syncwrites", &self.f_syncwrites) + .field("f_asyncwrites", &self.f_asyncwrites) + .field("f_syncreads", &self.f_syncreads) + .field("f_asyncreads", &self.f_asyncreads) + .field("f_namemax", &self.f_namemax) + .field("f_owner", &self.f_owner) + .field("f_fsid", &self.f_fsid) + .field("f_fstypename", &self.f_fstypename) + .field("f_mntfromname", &&self.f_mntfromname[..]) + .field("f_mntonname", &&self.f_mntonname[..]) + .finish() + } + } + impl ::hash::Hash for statfs { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + self.f_version.hash(state); + self.f_type.hash(state); + self.f_flags.hash(state); + self.f_bsize.hash(state); + self.f_iosize.hash(state); + self.f_blocks.hash(state); + self.f_bfree.hash(state); + self.f_bavail.hash(state); + self.f_files.hash(state); + self.f_ffree.hash(state); + self.f_syncwrites.hash(state); + self.f_asyncwrites.hash(state); + self.f_syncreads.hash(state); + self.f_asyncreads.hash(state); + self.f_namemax.hash(state); + self.f_owner.hash(state); + self.f_fsid.hash(state); + self.f_charspare.hash(state); + self.f_fstypename.hash(state); + self.f_mntfromname.hash(state); + self.f_mntonname.hash(state); + } + } + + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_fileno == other.d_fileno + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self.d_namlen == other.d_namlen + && self + .d_name[..self.d_namlen as _] + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for dirent {} + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent") + .field("d_fileno", &self.d_fileno) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + .field("d_namlen", &self.d_namlen) + .field("d_name", &&self.d_name[..self.d_namlen as _]) + .finish() + } + } + impl ::hash::Hash for dirent { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + self.d_fileno.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_namlen.hash(state); + self.d_name[..self.d_namlen as _].hash(state); + } + } + + impl PartialEq for vnstat { + fn eq(&self, other: &vnstat) -> bool { + let self_vn_devname: &[::c_char] = &self.vn_devname; + let other_vn_devname: &[::c_char] = &other.vn_devname; + + self.vn_fileid == other.vn_fileid && + self.vn_size == other.vn_size && + self.vn_dev == other.vn_dev && + self.vn_fsid == other.vn_fsid && + self.vn_mntdir == other.vn_mntdir && + self.vn_type == other.vn_type && + self.vn_mode == other.vn_mode && + self_vn_devname == other_vn_devname + } + } + impl Eq for vnstat {} + impl ::fmt::Debug for vnstat { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let self_vn_devname: &[::c_char] = &self.vn_devname; + + f.debug_struct("vnstat") + .field("vn_fileid", &self.vn_fileid) + .field("vn_size", &self.vn_size) + .field("vn_dev", &self.vn_dev) + .field("vn_fsid", &self.vn_fsid) + .field("vn_mntdir", &self.vn_mntdir) + .field("vn_type", &self.vn_type) + .field("vn_mode", &self.vn_mode) + .field("vn_devname", &self_vn_devname) + .finish() + } + } + impl ::hash::Hash for vnstat { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + let self_vn_devname: &[::c_char] = &self.vn_devname; + + self.vn_fileid.hash(state); + self.vn_size.hash(state); + self.vn_dev.hash(state); + self.vn_fsid.hash(state); + self.vn_mntdir.hash(state); + self.vn_type.hash(state); + self.vn_mode.hash(state); + self_vn_devname.hash(state); + } + } + } +} + +pub const RAND_MAX: ::c_int = 0x7fff_ffff; +pub const ELAST: ::c_int = 97; + +pub const KF_TYPE_EVENTFD: ::c_int = 13; + +/// max length of devicename +pub const SPECNAMELEN: ::c_int = 255; +pub const KI_NSPARE_PTR: usize = 5; + +/// domainset policies +pub const DOMAINSET_POLICY_INVALID: ::c_int = 0; +pub const DOMAINSET_POLICY_ROUNDROBIN: ::c_int = 1; +pub const DOMAINSET_POLICY_FIRSTTOUCH: ::c_int = 2; +pub const DOMAINSET_POLICY_PREFER: ::c_int = 3; +pub const DOMAINSET_POLICY_INTERLEAVE: ::c_int = 4; + +pub const MINCORE_SUPER: ::c_int = 0x60; + +extern "C" { + pub fn aio_readv(aiocbp: *mut ::aiocb) -> ::c_int; + pub fn aio_writev(aiocbp: *mut ::aiocb) -> ::c_int; + pub fn setgrent(); + pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; + pub fn freelocale(loc: ::locale_t); + pub fn msgrcv( + msqid: ::c_int, + msgp: *mut ::c_void, + msgsz: ::size_t, + msgtyp: ::c_long, + msgflg: ::c_int, + ) -> ::ssize_t; + pub fn clock_nanosleep( + clk_id: ::clockid_t, + flags: ::c_int, + rqtp: *const ::timespec, + rmtp: *mut ::timespec, + ) -> ::c_int; + + pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; + + pub fn fdatasync(fd: ::c_int) -> ::c_int; + + pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t; + pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; + pub fn elf_aux_info(aux: ::c_int, buf: *mut ::c_void, buflen: ::c_int) -> ::c_int; + pub fn setproctitle_fast(fmt: *const ::c_char, ...); + pub fn timingsafe_bcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int; + pub fn timingsafe_memcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int; + + pub fn cpuset_getdomain( + level: ::cpulevel_t, + which: ::cpuwhich_t, + id: ::id_t, + setsize: ::size_t, + mask: *mut ::domainset_t, + policy: *mut ::c_int, + ) -> ::c_int; + pub fn cpuset_setdomain( + level: ::cpulevel_t, + which: ::cpuwhich_t, + id: ::id_t, + setsize: ::size_t, + mask: *const ::domainset_t, + policy: ::c_int, + ) -> ::c_int; + + pub fn copy_file_range( + infd: ::c_int, + inoffp: *mut ::off_t, + outfd: ::c_int, + outoffp: *mut ::off_t, + len: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; +} + +#[link(name = "kvm")] +extern "C" { + pub fn kvm_kerndisp(kd: *mut ::kvm_t) -> ::kssize_t; +} + +cfg_if! { + if #[cfg(any(target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "riscv64"))] { + mod b64; + pub use self::b64::*; + } +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } +} diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs new file mode 100644 index 00000000..7bf25344 --- /dev/null +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs @@ -0,0 +1,5 @@ +pub const PROC_KPTI_CTL: ::c_int = ::PROC_PROCCTL_MD_MIN; +pub const PROC_KPTI_CTL_ENABLE_ON_EXEC: ::c_int = 1; +pub const PROC_KPTI_CTL_DISABLE_ON_EXEC: ::c_int = 2; +pub const PROC_KPTI_STATUS: ::c_int = ::PROC_PROCCTL_MD_MIN + 1; +pub const PROC_KPTI_STATUS_ACTIVE: ::c_int = 0x80000000; diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 99a7f2dc..9599e9cd 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1,10 +1,17 @@ pub type fflags_t = u32; pub type clock_t = i32; -pub type lwpid_t = i32; +pub type vm_prot_t = u_char; +pub type kvaddr_t = u64; +pub type segsz_t = isize; +pub type __fixpt_t = u32; +pub type fixpt_t = __fixpt_t; +pub type __lwpid_t = i32; +pub type lwpid_t = __lwpid_t; pub type blksize_t = i32; pub type clockid_t = ::c_int; pub type sem_t = _sem; +pub type timer_t = *mut __c_anonymous__timer; pub type fsblkcnt_t = u64; pub type fsfilcnt_t = u64; @@ -24,6 +31,209 @@ pub type pthread_spinlock_t = *mut __c_anonymous_pthread_spinlock; pub type pthread_barrierattr_t = *mut __c_anonymous_pthread_barrierattr; pub type pthread_barrier_t = *mut __c_anonymous_pthread_barrier; +pub type uuid_t = ::uuid; +pub type u_int = ::c_uint; +pub type u_char = ::c_uchar; +pub type u_long = ::c_ulong; +pub type u_short = ::c_ushort; + +pub type caddr_t = *mut ::c_char; + +pub type fhandle_t = fhandle; + +pub type au_id_t = ::uid_t; +pub type au_asid_t = ::pid_t; + +// It's an alias over "struct __kvm_t". However, its fields aren't supposed to be used directly, +// making the type definition system dependent. Better not bind it exactly. +pub type kvm_t = ::c_void; + +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] +#[repr(u32)] +pub enum devstat_support_flags { + DEVSTAT_ALL_SUPPORTED = 0x00, + DEVSTAT_NO_BLOCKSIZE = 0x01, + DEVSTAT_NO_ORDERED_TAGS = 0x02, + DEVSTAT_BS_UNAVAILABLE = 0x04, +} +impl ::Copy for devstat_support_flags {} +impl ::Clone for devstat_support_flags { + fn clone(&self) -> devstat_support_flags { + *self + } +} + +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] +#[repr(u32)] +pub enum devstat_trans_flags { + DEVSTAT_NO_DATA = 0x00, + DEVSTAT_READ = 0x01, + DEVSTAT_WRITE = 0x02, + DEVSTAT_FREE = 0x03, +} + +impl ::Copy for devstat_trans_flags {} +impl ::Clone for devstat_trans_flags { + fn clone(&self) -> devstat_trans_flags { + *self + } +} + +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] +#[repr(u32)] +pub enum devstat_tag_type { + DEVSTAT_TAG_SIMPLE = 0x00, + DEVSTAT_TAG_HEAD = 0x01, + DEVSTAT_TAG_ORDERED = 0x02, + DEVSTAT_TAG_NONE = 0x03, +} +impl ::Copy for devstat_tag_type {} +impl ::Clone for devstat_tag_type { + fn clone(&self) -> devstat_tag_type { + *self + } +} + +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] +#[repr(u32)] +pub enum devstat_match_flags { + DEVSTAT_MATCH_NONE = 0x00, + DEVSTAT_MATCH_TYPE = 0x01, + DEVSTAT_MATCH_IF = 0x02, + DEVSTAT_MATCH_PASS = 0x04, +} +impl ::Copy for devstat_match_flags {} +impl ::Clone for devstat_match_flags { + fn clone(&self) -> devstat_match_flags { + *self + } +} + +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] +#[repr(u32)] +pub enum devstat_priority { + DEVSTAT_PRIORITY_MIN = 0x000, + DEVSTAT_PRIORITY_OTHER = 0x020, + DEVSTAT_PRIORITY_PASS = 0x030, + DEVSTAT_PRIORITY_FD = 0x040, + DEVSTAT_PRIORITY_WFD = 0x050, + DEVSTAT_PRIORITY_TAPE = 0x060, + DEVSTAT_PRIORITY_CD = 0x090, + DEVSTAT_PRIORITY_DISK = 0x110, + DEVSTAT_PRIORITY_ARRAY = 0x120, + DEVSTAT_PRIORITY_MAX = 0xfff, +} +impl ::Copy for devstat_priority {} +impl ::Clone for devstat_priority { + fn clone(&self) -> devstat_priority { + *self + } +} + +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] +#[repr(u32)] +pub enum devstat_type_flags { + DEVSTAT_TYPE_DIRECT = 0x000, + DEVSTAT_TYPE_SEQUENTIAL = 0x001, + DEVSTAT_TYPE_PRINTER = 0x002, + DEVSTAT_TYPE_PROCESSOR = 0x003, + DEVSTAT_TYPE_WORM = 0x004, + DEVSTAT_TYPE_CDROM = 0x005, + DEVSTAT_TYPE_SCANNER = 0x006, + DEVSTAT_TYPE_OPTICAL = 0x007, + DEVSTAT_TYPE_CHANGER = 0x008, + DEVSTAT_TYPE_COMM = 0x009, + DEVSTAT_TYPE_ASC0 = 0x00a, + DEVSTAT_TYPE_ASC1 = 0x00b, + DEVSTAT_TYPE_STORARRAY = 0x00c, + DEVSTAT_TYPE_ENCLOSURE = 0x00d, + DEVSTAT_TYPE_FLOPPY = 0x00e, + DEVSTAT_TYPE_MASK = 0x00f, + DEVSTAT_TYPE_IF_SCSI = 0x010, + DEVSTAT_TYPE_IF_IDE = 0x020, + DEVSTAT_TYPE_IF_OTHER = 0x030, + DEVSTAT_TYPE_IF_MASK = 0x0f0, + DEVSTAT_TYPE_PASS = 0x100, +} +impl ::Copy for devstat_type_flags {} +impl ::Clone for devstat_type_flags { + fn clone(&self) -> devstat_type_flags { + *self + } +} + +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] +#[repr(u32)] +pub enum devstat_metric { + DSM_NONE, + DSM_TOTAL_BYTES, + DSM_TOTAL_BYTES_READ, + DSM_TOTAL_BYTES_WRITE, + DSM_TOTAL_TRANSFERS, + DSM_TOTAL_TRANSFERS_READ, + DSM_TOTAL_TRANSFERS_WRITE, + DSM_TOTAL_TRANSFERS_OTHER, + DSM_TOTAL_BLOCKS, + DSM_TOTAL_BLOCKS_READ, + DSM_TOTAL_BLOCKS_WRITE, + DSM_KB_PER_TRANSFER, + DSM_KB_PER_TRANSFER_READ, + DSM_KB_PER_TRANSFER_WRITE, + DSM_TRANSFERS_PER_SECOND, + DSM_TRANSFERS_PER_SECOND_READ, + DSM_TRANSFERS_PER_SECOND_WRITE, + DSM_TRANSFERS_PER_SECOND_OTHER, + DSM_MB_PER_SECOND, + DSM_MB_PER_SECOND_READ, + DSM_MB_PER_SECOND_WRITE, + DSM_BLOCKS_PER_SECOND, + DSM_BLOCKS_PER_SECOND_READ, + DSM_BLOCKS_PER_SECOND_WRITE, + DSM_MS_PER_TRANSACTION, + DSM_MS_PER_TRANSACTION_READ, + DSM_MS_PER_TRANSACTION_WRITE, + DSM_SKIP, + DSM_TOTAL_BYTES_FREE, + DSM_TOTAL_TRANSFERS_FREE, + DSM_TOTAL_BLOCKS_FREE, + DSM_KB_PER_TRANSFER_FREE, + DSM_MB_PER_SECOND_FREE, + DSM_TRANSFERS_PER_SECOND_FREE, + DSM_BLOCKS_PER_SECOND_FREE, + DSM_MS_PER_TRANSACTION_OTHER, + DSM_MS_PER_TRANSACTION_FREE, + DSM_BUSY_PCT, + DSM_QUEUE_LENGTH, + DSM_TOTAL_DURATION, + DSM_TOTAL_DURATION_READ, + DSM_TOTAL_DURATION_WRITE, + DSM_TOTAL_DURATION_FREE, + DSM_TOTAL_DURATION_OTHER, + DSM_TOTAL_BUSY_TIME, + DSM_MAX, +} +impl ::Copy for devstat_metric {} +impl ::Clone for devstat_metric { + fn clone(&self) -> devstat_metric { + *self + } +} + +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash, PartialEq, Eq))] +#[repr(u32)] +pub enum devstat_select_mode { + DS_SELECT_ADD, + DS_SELECT_ONLY, + DS_SELECT_REMOVE, + DS_SELECT_ADDONLY, +} +impl ::Copy for devstat_select_mode {} +impl ::Clone for devstat_select_mode { + fn clone(&self) -> devstat_select_mode { + *self + } +} + s! { pub struct aiocb { pub aio_fildes: ::c_int, @@ -70,6 +280,11 @@ s! { pub struct _sem { data: [u32; 4], } + pub struct sembuf { + pub sem_num: ::c_ushort, + pub sem_op: ::c_short, + pub sem_flg: ::c_short, + } pub struct msqid_ds { pub msg_perm: ::ipc_perm, @@ -105,11 +320,6 @@ s! { pub sc_groups: [::gid_t; 1], } - pub struct accept_filter_arg { - pub af_name: [::c_char; 16], - af_arg: [[::c_char; 10]; 24], - } - pub struct ptrace_vm_entry { pub pve_entry: ::c_int, pub pve_timestamp: ::c_int, @@ -123,6 +333,30 @@ s! { pub pve_path: *mut ::c_char, } + pub struct ptrace_lwpinfo { + pub pl_lwpid: lwpid_t, + pub pl_event: ::c_int, + pub pl_flags: ::c_int, + pub pl_sigmask: ::sigset_t, + pub pl_siglist: ::sigset_t, + pub pl_siginfo: ::siginfo_t, + pub pl_tdname: [::c_char; ::MAXCOMLEN as usize + 1], + pub pl_child_pid: ::pid_t, + pub pl_syscall_code: ::c_uint, + pub pl_syscall_narg: ::c_uint, + } + + pub struct ptrace_sc_ret { + pub sr_retval: [::register_t; 2], + pub sr_error: ::c_int, + } + + pub struct ptrace_coredump { + pub pc_fd: ::c_int, + pub pc_flags: u32, + pub pc_limit: ::off_t, + } + pub struct cpuset_t { #[cfg(target_pointer_width = "64")] __bits: [::c_long; 4], @@ -152,6 +386,15 @@ s! { c_spare: [u32; 1], } + pub struct uuid { + pub time_low: u32, + pub time_mid: u16, + pub time_hi_and_version: u16, + pub clock_seq_hi_and_reserved: u8, + pub clock_seq_low: u8, + pub node: [u8; _UUID_NODE_LEN], + } + pub struct __c_anonymous_pthread_spinlock { s_clock: umutex, } @@ -206,37 +449,544 @@ s! { pub kve_path: [[::c_char; 32]; 32], } - pub struct kinfo_proc { - __pad0: [[::uintptr_t; 17]; 8], + pub struct __c_anonymous_filestat { + pub stqe_next: *mut filestat, } pub struct filestat { - fs_type: ::c_int, - fs_flags: ::c_int, - fs_fflags: ::c_int, - fs_uflags: ::c_int, - fs_fd: ::c_int, - fs_ref_count: ::c_int, - fs_offset: ::off_t, - fs_typedep: *mut ::c_void, - fs_path: *mut ::c_char, - next: *mut filestat, - fs_cap_rights: cap_rights_t, + pub fs_type: ::c_int, + pub fs_flags: ::c_int, + pub fs_fflags: ::c_int, + pub fs_uflags: ::c_int, + pub fs_fd: ::c_int, + pub fs_ref_count: ::c_int, + pub fs_offset: ::off_t, + pub fs_typedep: *mut ::c_void, + pub fs_path: *mut ::c_char, + pub next: __c_anonymous_filestat, + pub fs_cap_rights: cap_rights_t, } pub struct filestat_list { - stqh_first: *mut filestat, - stqh_last: *mut *mut filestat, + pub stqh_first: *mut filestat, + pub stqh_last: *mut *mut filestat, } pub struct procstat { - tpe: ::c_int, - kd: ::uintptr_t, - vmentries: *mut ::c_void, - files: *mut ::c_void, - argv: *mut ::c_void, - envv: *mut ::c_void, - core: ::uintptr_t, + pub tpe: ::c_int, + pub kd: ::uintptr_t, + pub vmentries: *mut ::c_void, + pub files: *mut ::c_void, + pub argv: *mut ::c_void, + pub envv: *mut ::c_void, + pub core: ::uintptr_t, + } + + pub struct itimerspec { + pub it_interval: ::timespec, + pub it_value: ::timespec, + } + + pub struct __c_anonymous__timer { + _priv: [::c_int; 3], + } + + /// Used to hold a copy of the command line, if it had a sane length. + pub struct pargs { + /// Reference count. + pub ar_ref: u_int, + /// Length. + pub ar_length: u_int, + /// Arguments. + pub ar_args: [::c_uchar; 1], + } + + pub struct priority { + /// Scheduling class. + pub pri_class: u_char, + /// Normal priority level. + pub pri_level: u_char, + /// Priority before propagation. + pub pri_native: u_char, + /// User priority based on p_cpu and p_nice. + pub pri_user: u_char, + } + + pub struct kvm_swap { + pub ksw_devname: [::c_char; 32], + pub ksw_used: u_int, + pub ksw_total: u_int, + pub ksw_flags: ::c_int, + pub ksw_reserved1: u_int, + pub ksw_reserved2: u_int, + } + + pub struct nlist { + /// symbol name (in memory) + pub n_name: *const ::c_char, + /// type defines + pub n_type: ::c_uchar, + /// "type" and binding information + pub n_other: ::c_char, + /// used by stab entries + pub n_desc: ::c_short, + pub n_value: ::c_ulong, + } + + pub struct kvm_nlist { + pub n_name: *const ::c_char, + pub n_type: ::c_uchar, + pub n_value: ::kvaddr_t, + } + + pub struct __c_anonymous_sem { + _priv: ::uintptr_t, + } + + pub struct semid_ds { + pub sem_perm: ::ipc_perm, + pub __sem_base: *mut __c_anonymous_sem, + pub sem_nsems: ::c_ushort, + pub sem_otime: ::time_t, + pub sem_ctime: ::time_t, + } + + pub struct vmtotal { + pub t_vm: u64, + pub t_avm: u64, + pub t_rm: u64, + pub t_arm: u64, + pub t_vmshr: u64, + pub t_avmshr: u64, + pub t_rmshr: u64, + pub t_armshr: u64, + pub t_free: u64, + pub t_rq: i16, + pub t_dw: i16, + pub t_pw: i16, + pub t_sl: i16, + pub t_sw: i16, + pub t_pad: [u16; 3], + } + + pub struct sockstat { + pub inp_ppcb: u64, + pub so_addr: u64, + pub so_pcb: u64, + pub unp_conn: u64, + pub dom_family: ::c_int, + pub proto: ::c_int, + pub so_rcv_sb_state: ::c_int, + pub so_snd_sb_state: ::c_int, + /// Socket address. + pub sa_local: ::sockaddr_storage, + /// Peer address. + pub sa_peer: ::sockaddr_storage, + pub type_: ::c_int, + pub dname: [::c_char; 32], + #[cfg(any(freebsd12, freebsd13, freebsd14))] + pub sendq: ::c_uint, + #[cfg(any(freebsd12, freebsd13, freebsd14))] + pub recvq: ::c_uint, + } + + pub struct shmstat { + pub size: u64, + pub mode: u16, + } + + pub struct spacectl_range { + pub r_offset: ::off_t, + pub r_len: ::off_t + } + + pub struct rusage_ext { + pub rux_runtime: u64, + pub rux_uticks: u64, + pub rux_sticks: u64, + pub rux_iticks: u64, + pub rux_uu: u64, + pub rux_su: u64, + pub rux_tu: u64, + } + + pub struct if_clonereq { + pub ifcr_total: ::c_int, + pub ifcr_count: ::c_int, + pub ifcr_buffer: *mut ::c_char, + } + + pub struct if_msghdr { + /// to skip over non-understood messages + pub ifm_msglen: ::c_ushort, + /// future binary compatibility + pub ifm_version: ::c_uchar, + /// message type + pub ifm_type: ::c_uchar, + /// like rtm_addrs + pub ifm_addrs: ::c_int, + /// value of if_flags + pub ifm_flags: ::c_int, + /// index for associated ifp + pub ifm_index: ::c_ushort, + pub _ifm_spare1: ::c_ushort, + /// statistics and other data about if + pub ifm_data: if_data, + } + + pub struct if_msghdrl { + /// to skip over non-understood messages + pub ifm_msglen: ::c_ushort, + /// future binary compatibility + pub ifm_version: ::c_uchar, + /// message type + pub ifm_type: ::c_uchar, + /// like rtm_addrs + pub ifm_addrs: ::c_int, + /// value of if_flags + pub ifm_flags: ::c_int, + /// index for associated ifp + pub ifm_index: ::c_ushort, + /// spare space to grow if_index, see if_var.h + pub _ifm_spare1: ::c_ushort, + /// length of if_msghdrl incl. if_data + pub ifm_len: ::c_ushort, + /// offset of if_data from beginning + pub ifm_data_off: ::c_ushort, + pub _ifm_spare2: ::c_int, + /// statistics and other data about if + pub ifm_data: if_data, + } + + pub struct ifa_msghdr { + /// to skip over non-understood messages + pub ifam_msglen: ::c_ushort, + /// future binary compatibility + pub ifam_version: ::c_uchar, + /// message type + pub ifam_type: ::c_uchar, + /// like rtm_addrs + pub ifam_addrs: ::c_int, + /// value of ifa_flags + pub ifam_flags: ::c_int, + /// index for associated ifp + pub ifam_index: ::c_ushort, + pub _ifam_spare1: ::c_ushort, + /// value of ifa_ifp->if_metric + pub ifam_metric: ::c_int, + } + + pub struct ifa_msghdrl { + /// to skip over non-understood messages + pub ifam_msglen: ::c_ushort, + /// future binary compatibility + pub ifam_version: ::c_uchar, + /// message type + pub ifam_type: ::c_uchar, + /// like rtm_addrs + pub ifam_addrs: ::c_int, + /// value of ifa_flags + pub ifam_flags: ::c_int, + /// index for associated ifp + pub ifam_index: ::c_ushort, + /// spare space to grow if_index, see if_var.h + pub _ifam_spare1: ::c_ushort, + /// length of ifa_msghdrl incl. if_data + pub ifam_len: ::c_ushort, + /// offset of if_data from beginning + pub ifam_data_off: ::c_ushort, + /// value of ifa_ifp->if_metric + pub ifam_metric: ::c_int, + /// statistics and other data about if or address + pub ifam_data: if_data, + } + + pub struct ifma_msghdr { + /// to skip over non-understood messages + pub ifmam_msglen: ::c_ushort, + /// future binary compatibility + pub ifmam_version: ::c_uchar, + /// message type + pub ifmam_type: ::c_uchar, + /// like rtm_addrs + pub ifmam_addrs: ::c_int, + /// value of ifa_flags + pub ifmam_flags: ::c_int, + /// index for associated ifp + pub ifmam_index: ::c_ushort, + pub _ifmam_spare1: ::c_ushort, + } + + pub struct if_announcemsghdr { + /// to skip over non-understood messages + pub ifan_msglen: ::c_ushort, + /// future binary compatibility + pub ifan_version: ::c_uchar, + /// message type + pub ifan_type: ::c_uchar, + /// index for associated ifp + pub ifan_index: ::c_ushort, + /// if name, e.g. "en0" + pub ifan_name: [::c_char; ::IFNAMSIZ as usize], + /// what type of announcement + pub ifan_what: ::c_ushort, + } + + pub struct ifreq_buffer { + pub length: ::size_t, + pub buffer: *mut ::c_void, + } + + pub struct ifaliasreq { + /// if name, e.g. "en0" + pub ifra_name: [::c_char; ::IFNAMSIZ as usize], + pub ifra_addr: ::sockaddr, + pub ifra_broadaddr: ::sockaddr, + pub ifra_mask: ::sockaddr, + pub ifra_vhid: ::c_int, + } + + /// 9.x compat + pub struct oifaliasreq { + /// if name, e.g. "en0" + pub ifra_name: [::c_char; ::IFNAMSIZ as usize], + pub ifra_addr: ::sockaddr, + pub ifra_broadaddr: ::sockaddr, + pub ifra_mask: ::sockaddr, + } + + pub struct ifmediareq { + /// if name, e.g. "en0" + pub ifm_name: [::c_char; ::IFNAMSIZ as usize], + /// current media options + pub ifm_current: ::c_int, + /// don't care mask + pub ifm_mask: ::c_int, + /// media status + pub ifm_status: ::c_int, + /// active options + pub ifm_active: ::c_int, + /// # entries in ifm_ulist array + pub ifm_count: ::c_int, + /// media words + pub ifm_ulist: *mut ::c_int, + } + + pub struct ifdrv { + /// if name, e.g. "en0" + pub ifd_name: [::c_char; ::IFNAMSIZ as usize], + pub ifd_cmd: ::c_ulong, + pub ifd_len: ::size_t, + pub ifd_data: *mut ::c_void, + } + + pub struct ifi2creq { + /// i2c address (0xA0, 0xA2) + pub dev_addr: u8, + /// read offset + pub offset: u8, + /// read length + pub len: u8, + pub spare0: u8, + pub spare1: u32, + /// read buffer + pub data: [u8; 8], + } + + pub struct ifrsshash { + /// if name, e.g. "en0" + pub ifrh_name: [::c_char; ::IFNAMSIZ as usize], + /// RSS_FUNC_ + pub ifrh_func: u8, + pub ifrh_spare0: u8, + pub ifrh_spare1: u16, + /// RSS_TYPE_ + pub ifrh_types: u32, + } + + pub struct ifmibdata { + /// name of interface + pub ifmd_name: [::c_char; ::IFNAMSIZ as usize], + /// number of promiscuous listeners + pub ifmd_pcount: ::c_int, + /// interface flags + pub ifmd_flags: ::c_int, + /// instantaneous length of send queue + pub ifmd_snd_len: ::c_int, + /// maximum length of send queue + pub ifmd_snd_maxlen: ::c_int, + /// number of drops in send queue + pub ifmd_snd_drops: ::c_int, + /// for future expansion + pub ifmd_filler: [::c_int; 4], + /// generic information and statistics + pub ifmd_data: if_data, + } + + pub struct ifmib_iso_8802_3 { + pub dot3StatsAlignmentErrors: u32, + pub dot3StatsFCSErrors: u32, + pub dot3StatsSingleCollisionFrames: u32, + pub dot3StatsMultipleCollisionFrames: u32, + pub dot3StatsSQETestErrors: u32, + pub dot3StatsDeferredTransmissions: u32, + pub dot3StatsLateCollisions: u32, + pub dot3StatsExcessiveCollisions: u32, + pub dot3StatsInternalMacTransmitErrors: u32, + pub dot3StatsCarrierSenseErrors: u32, + pub dot3StatsFrameTooLongs: u32, + pub dot3StatsInternalMacReceiveErrors: u32, + pub dot3StatsEtherChipSet: u32, + pub dot3StatsMissedFrames: u32, + pub dot3StatsCollFrequencies: [u32; 16], + pub dot3Compliance: u32, + } + + pub struct __c_anonymous_ph { + pub ph1: u64, + pub ph2: u64, + } + + pub struct fid { + pub fid_len: ::c_ushort, + pub fid_data0: ::c_ushort, + pub fid_data: [::c_char; ::MAXFIDSZ as usize], + } + + pub struct fhandle { + pub fh_fsid: ::fsid_t, + pub fh_fid: fid, + } + + pub struct bintime { + pub sec: ::time_t, + pub frac: u64, + } + + pub struct clockinfo { + /// clock frequency + pub hz: ::c_int, + /// micro-seconds per hz tick + pub tick: ::c_int, + pub spare: ::c_int, + /// statistics clock frequency + pub stathz: ::c_int, + /// profiling clock frequency + pub profhz: ::c_int, + } + + pub struct __c_anonymous_stailq_entry_devstat { + pub stqe_next: *mut devstat, + } + + pub struct devstat { + /// Update sequence + pub sequence0: ::u_int, + /// Allocated entry + pub allocated: ::c_int, + /// started ops + pub start_count: ::u_int, + /// completed ops + pub end_count: ::u_int, + /// busy time unaccounted for since this time + pub busy_from: bintime, + pub dev_links: __c_anonymous_stailq_entry_devstat, + /// Devstat device number. + pub device_number: u32, + pub device_name: [::c_char; DEVSTAT_NAME_LEN as usize], + pub unit_number: ::c_int, + pub bytes: [u64; DEVSTAT_N_TRANS_FLAGS as usize], + pub operations: [u64; DEVSTAT_N_TRANS_FLAGS as usize], + pub duration: [bintime; DEVSTAT_N_TRANS_FLAGS as usize], + pub busy_time: bintime, + /// Time the device was created. + pub creation_time: bintime, + /// Block size, bytes + pub block_size: u32, + /// The number of simple, ordered, and head of queue tags sent. + pub tag_types: [u64; 3], + /// Which statistics are supported by a given device. + pub flags: devstat_support_flags, + /// Device type + pub device_type: devstat_type_flags, + /// Controls list pos. + pub priority: devstat_priority, + /// Identification for GEOM nodes + pub id: *const ::c_void, + /// Update sequence + pub sequence1: ::u_int, + } + + pub struct devstat_match { + pub match_fields: devstat_match_flags, + pub device_type: devstat_type_flags, + pub num_match_categories: ::c_int, + } + + pub struct devstat_match_table { + pub match_str: *const ::c_char, + pub type_: devstat_type_flags, + pub match_field: devstat_match_flags, + } + + pub struct device_selection { + pub device_number: u32, + pub device_name: [::c_char; DEVSTAT_NAME_LEN as usize], + pub unit_number: ::c_int, + pub selected: ::c_int, + pub bytes: u64, + pub position: ::c_int, + } + + pub struct devinfo { + pub devices: *mut devstat, + pub mem_ptr: *mut u8, + pub generation: ::c_long, + pub numdevs: ::c_int, + } + + pub struct sockcred2 { + pub sc_version: ::c_int, + pub sc_pid: ::pid_t, + pub sc_uid: ::uid_t, + pub sc_euid: ::uid_t, + pub sc_gid: ::gid_t, + pub sc_egid: ::gid_t, + pub sc_ngroups: ::c_int, + pub sc_groups: [::gid_t; 1], + } + + pub struct ifconf { + pub ifc_len: ::c_int, + #[cfg(libc_union)] + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + } + + pub struct au_mask_t { + pub am_success: ::c_uint, + pub am_failure: ::c_uint, + } + + pub struct au_tid_t { + pub port: u32, + pub machine: u32, + } + + pub struct auditinfo_t { + pub ai_auid: ::au_id_t, + pub ai_mask: ::au_mask_t, + pub ai_termid: au_tid_t, + pub ai_asid: ::au_asid_t, + } + + pub struct tcp_fastopen { + pub enable: ::c_int, + pub psk: [u8; ::TCP_FASTOPEN_PSK_LEN as usize], + } + + pub struct tcp_function_set { + pub function_set_name: [::c_char; ::TCP_FUNCTION_NAME_LEN_MAX as usize], + pub pcbcnt: u32, } } @@ -300,6 +1050,14 @@ s_no_extra_traits! { __unused2: [::c_long; 7] } + pub struct ptsstat { + #[cfg(any(freebsd12, freebsd13, freebsd14))] + pub dev: u64, + #[cfg(not(any(freebsd12, freebsd13, freebsd14)))] + pub dev: u32, + pub devname: [::c_char; SPECNAMELEN as usize + 1], + } + #[cfg(libc_union)] pub union __c_anonymous_elf32_auxv_union { pub a_val: ::c_int, @@ -310,6 +1068,136 @@ s_no_extra_traits! { #[cfg(libc_union)] pub a_un: __c_anonymous_elf32_auxv_union, } + + #[cfg(libc_union)] + pub union __c_anonymous_ifi_epoch { + pub tt: ::time_t, + pub ph: u64, + } + + #[cfg(libc_union)] + pub union __c_anonymous_ifi_lastchange { + pub tv: ::timeval, + pub ph: __c_anonymous_ph, + } + + pub struct if_data { + /// ethernet, tokenring, etc + pub ifi_type: u8, + /// e.g., AUI, Thinnet, 10base-T, etc + pub ifi_physical: u8, + /// media address length + pub ifi_addrlen: u8, + /// media header length + pub ifi_hdrlen: u8, + /// current link state + pub ifi_link_state: u8, + /// carp vhid + pub ifi_vhid: u8, + /// length of this data struct + pub ifi_datalen: u16, + /// maximum transmission unit + pub ifi_mtu: u32, + /// routing metric (external only) + pub ifi_metric: u32, + /// linespeed + pub ifi_baudrate: u64, + /// packets received on interface + pub ifi_ipackets: u64, + /// input errors on interface + pub ifi_ierrors: u64, + /// packets sent on interface + pub ifi_opackets: u64, + /// output errors on interface + pub ifi_oerrors: u64, + /// collisions on csma interfaces + pub ifi_collisions: u64, + /// total number of octets received + pub ifi_ibytes: u64, + /// total number of octets sent + pub ifi_obytes: u64, + /// packets received via multicast + pub ifi_imcasts: u64, + /// packets sent via multicast + pub ifi_omcasts: u64, + /// dropped on input + pub ifi_iqdrops: u64, + /// dropped on output + pub ifi_oqdrops: u64, + /// destined for unsupported protocol + pub ifi_noproto: u64, + /// HW offload capabilities, see IFCAP + pub ifi_hwassist: u64, + /// uptime at attach or stat reset + #[cfg(libc_union)] + pub __ifi_epoch: __c_anonymous_ifi_epoch, + /// uptime at attach or stat reset + #[cfg(not(libc_union))] + pub __ifi_epoch: u64, + /// time of last administrative change + #[cfg(libc_union)] + pub __ifi_lastchange: __c_anonymous_ifi_lastchange, + /// time of last administrative change + #[cfg(not(libc_union))] + pub __ifi_lastchange: ::timeval, + } + + #[cfg(libc_union)] + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: ::sockaddr, + pub ifru_dstaddr: ::sockaddr, + pub ifru_broadaddr: ::sockaddr, + pub ifru_buffer: ifreq_buffer, + pub ifru_flags: [::c_short; 2], + pub ifru_index: ::c_short, + pub ifru_jid: ::c_int, + pub ifru_metric: ::c_int, + pub ifru_mtu: ::c_int, + pub ifru_phys: ::c_int, + pub ifru_media: ::c_int, + pub ifru_data: ::caddr_t, + pub ifru_cap: [::c_int; 2], + pub ifru_fib: ::c_uint, + pub ifru_vlan_pcp: ::c_uchar, + } + + pub struct ifreq { + /// if name, e.g. "en0" + pub ifr_name: [::c_char; ::IFNAMSIZ], + #[cfg(libc_union)] + pub ifr_ifru: __c_anonymous_ifr_ifru, + #[cfg(not(libc_union))] + pub ifr_ifru: ::sockaddr, + } + + #[cfg(libc_union)] + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: ::caddr_t, + pub ifcu_req: *mut ifreq, + } + + pub struct ifstat { + /// if name, e.g. "en0" + pub ifs_name: [::c_char; ::IFNAMSIZ as usize], + pub ascii: [::c_char; ::IFSTATMAX as usize + 1], + } + + pub struct ifrsskey { + /// if name, e.g. "en0" + pub ifrk_name: [::c_char; ::IFNAMSIZ as usize], + /// RSS_FUNC_ + pub ifrk_func: u8, + pub ifrk_spare0: u8, + pub ifrk_keylen: u16, + pub ifrk_key: [u8; ::RSS_KEYLEN as usize], + } + + pub struct ifdownreason { + pub ifdr_name: [::c_char; ::IFNAMSIZ as usize], + pub ifdr_reason: u32, + pub ifdr_vendor: u32, + pub ifdr_msg: [::c_char; ::IFDR_MSG_SIZE as usize], + } } cfg_if! { @@ -530,6 +1418,35 @@ cfg_if! { self.sigev_notify_thread_id.hash(state); } } + + impl PartialEq for ptsstat { + fn eq(&self, other: &ptsstat) -> bool { + let self_devname: &[::c_char] = &self.devname; + let other_devname: &[::c_char] = &other.devname; + + self.dev == other.dev && self_devname == other_devname + } + } + impl Eq for ptsstat {} + impl ::fmt::Debug for ptsstat { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let self_devname: &[::c_char] = &self.devname; + + f.debug_struct("ptsstat") + .field("dev", &self.dev) + .field("devname", &self_devname) + .finish() + } + } + impl ::hash::Hash for ptsstat { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + let self_devname: &[::c_char] = &self.devname; + + self.dev.hash(state); + self_devname.hash(state); + } + } + #[cfg(libc_union)] impl PartialEq for __c_anonymous_elf32_auxv_union { fn eq(&self, other: &__c_anonymous_elf32_auxv_union) -> bool { @@ -577,9 +1494,395 @@ cfg_if! { .finish() } } + + #[cfg(libc_union)] + impl PartialEq for __c_anonymous_ifr_ifru { + fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { + unsafe { + self.ifru_addr == other.ifru_addr && + self.ifru_dstaddr == other.ifru_dstaddr && + self.ifru_broadaddr == other.ifru_broadaddr && + self.ifru_buffer == other.ifru_buffer && + self.ifru_flags == other.ifru_flags && + self.ifru_index == other.ifru_index && + self.ifru_jid == other.ifru_jid && + self.ifru_metric == other.ifru_metric && + self.ifru_mtu == other.ifru_mtu && + self.ifru_phys == other.ifru_phys && + self.ifru_media == other.ifru_media && + self.ifru_data == other.ifru_data && + self.ifru_cap == other.ifru_cap && + self.ifru_fib == other.ifru_fib && + self.ifru_vlan_pcp == other.ifru_vlan_pcp + } + } + } + #[cfg(libc_union)] + impl Eq for __c_anonymous_ifr_ifru {} + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ifr_ifru { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ifr_ifru") + .field("ifru_addr", unsafe { &self.ifru_addr }) + .field("ifru_dstaddr", unsafe { &self.ifru_dstaddr }) + .field("ifru_broadaddr", unsafe { &self.ifru_broadaddr }) + .field("ifru_buffer", unsafe { &self.ifru_buffer }) + .field("ifru_flags", unsafe { &self.ifru_flags }) + .field("ifru_index", unsafe { &self.ifru_index }) + .field("ifru_jid", unsafe { &self.ifru_jid }) + .field("ifru_metric", unsafe { &self.ifru_metric }) + .field("ifru_mtu", unsafe { &self.ifru_mtu }) + .field("ifru_phys", unsafe { &self.ifru_phys }) + .field("ifru_media", unsafe { &self.ifru_media }) + .field("ifru_data", unsafe { &self.ifru_data }) + .field("ifru_cap", unsafe { &self.ifru_cap }) + .field("ifru_fib", unsafe { &self.ifru_fib }) + .field("ifru_vlan_pcp", unsafe { &self.ifru_vlan_pcp }) + .finish() + } + } + #[cfg(libc_union)] + impl ::hash::Hash for __c_anonymous_ifr_ifru { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + unsafe { self.ifru_addr.hash(state) }; + unsafe { self.ifru_dstaddr.hash(state) }; + unsafe { self.ifru_broadaddr.hash(state) }; + unsafe { self.ifru_buffer.hash(state) }; + unsafe { self.ifru_flags.hash(state) }; + unsafe { self.ifru_index.hash(state) }; + unsafe { self.ifru_jid.hash(state) }; + unsafe { self.ifru_metric.hash(state) }; + unsafe { self.ifru_mtu.hash(state) }; + unsafe { self.ifru_phys.hash(state) }; + unsafe { self.ifru_media.hash(state) }; + unsafe { self.ifru_data.hash(state) }; + unsafe { self.ifru_cap.hash(state) }; + unsafe { self.ifru_fib.hash(state) }; + unsafe { self.ifru_vlan_pcp.hash(state) }; + } + } + + impl PartialEq for ifreq { + fn eq(&self, other: &ifreq) -> bool { + self.ifr_name == other.ifr_name && self.ifr_ifru == other.ifr_ifru + } + } + impl Eq for ifreq {} + impl ::fmt::Debug for ifreq { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ifreq") + .field("ifr_name", &self.ifr_name) + .field("ifr_ifru", &self.ifr_ifru) + .finish() + } + } + impl ::hash::Hash for ifreq { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + self.ifr_name.hash(state); + self.ifr_ifru.hash(state); + } + } + + #[cfg(libc_union)] + impl Eq for __c_anonymous_ifc_ifcu {} + + #[cfg(libc_union)] + impl PartialEq for __c_anonymous_ifc_ifcu { + fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool { + unsafe { + self.ifcu_buf == other.ifcu_buf && + self.ifcu_req == other.ifcu_req + } + } + } + + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ifc_ifcu { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ifc_ifcu") + .field("ifcu_buf", unsafe { &self.ifcu_buf }) + .field("ifcu_req", unsafe { &self.ifcu_req }) + .finish() + } + } + + #[cfg(libc_union)] + impl ::hash::Hash for __c_anonymous_ifc_ifcu { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + unsafe { self.ifcu_buf.hash(state) }; + unsafe { self.ifcu_req.hash(state) }; + } + } + + impl PartialEq for ifstat { + fn eq(&self, other: &ifstat) -> bool { + let self_ascii: &[::c_char] = &self.ascii; + let other_ascii: &[::c_char] = &other.ascii; + + self.ifs_name == other.ifs_name && self_ascii == other_ascii + } + } + impl Eq for ifstat {} + impl ::fmt::Debug for ifstat { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let ascii: &[::c_char] = &self.ascii; + + f.debug_struct("ifstat") + .field("ifs_name", &self.ifs_name) + .field("ascii", &ascii) + .finish() + } + } + impl ::hash::Hash for ifstat { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + self.ifs_name.hash(state); + self.ascii.hash(state); + } + } + + impl PartialEq for ifrsskey { + fn eq(&self, other: &ifrsskey) -> bool { + let self_ifrk_key: &[u8] = &self.ifrk_key; + let other_ifrk_key: &[u8] = &other.ifrk_key; + + self.ifrk_name == other.ifrk_name && + self.ifrk_func == other.ifrk_func && + self.ifrk_spare0 == other.ifrk_spare0 && + self.ifrk_keylen == other.ifrk_keylen && + self_ifrk_key == other_ifrk_key + } + } + impl Eq for ifrsskey {} + impl ::fmt::Debug for ifrsskey { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let ifrk_key: &[u8] = &self.ifrk_key; + + f.debug_struct("ifrsskey") + .field("ifrk_name", &self.ifrk_name) + .field("ifrk_func", &self.ifrk_func) + .field("ifrk_spare0", &self.ifrk_spare0) + .field("ifrk_keylen", &self.ifrk_keylen) + .field("ifrk_key", &ifrk_key) + .finish() + } + } + impl ::hash::Hash for ifrsskey { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + self.ifrk_name.hash(state); + self.ifrk_func.hash(state); + self.ifrk_spare0.hash(state); + self.ifrk_keylen.hash(state); + self.ifrk_key.hash(state); + } + } + + impl PartialEq for ifdownreason { + fn eq(&self, other: &ifdownreason) -> bool { + let self_ifdr_msg: &[::c_char] = &self.ifdr_msg; + let other_ifdr_msg: &[::c_char] = &other.ifdr_msg; + + self.ifdr_name == other.ifdr_name && + self.ifdr_reason == other.ifdr_reason && + self.ifdr_vendor == other.ifdr_vendor && + self_ifdr_msg == other_ifdr_msg + } + } + impl Eq for ifdownreason {} + impl ::fmt::Debug for ifdownreason { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let ifdr_msg: &[::c_char] = &self.ifdr_msg; + + f.debug_struct("ifdownreason") + .field("ifdr_name", &self.ifdr_name) + .field("ifdr_reason", &self.ifdr_reason) + .field("ifdr_vendor", &self.ifdr_vendor) + .field("ifdr_msg", &ifdr_msg) + .finish() + } + } + impl ::hash::Hash for ifdownreason { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + self.ifdr_name.hash(state); + self.ifdr_reason.hash(state); + self.ifdr_vendor.hash(state); + self.ifdr_msg.hash(state); + } + } + + #[cfg(libc_union)] + impl PartialEq for __c_anonymous_ifi_epoch { + fn eq(&self, other: &__c_anonymous_ifi_epoch) -> bool { + unsafe { + self.tt == other.tt && + self.ph == other.ph + } + } + } + #[cfg(libc_union)] + impl Eq for __c_anonymous_ifi_epoch {} + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ifi_epoch { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("__c_anonymous_ifi_epoch") + .field("tt", unsafe { &self.tt }) + .field("ph", unsafe { &self.ph }) + .finish() + } + } + #[cfg(libc_union)] + impl ::hash::Hash for __c_anonymous_ifi_epoch { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + unsafe { + self.tt.hash(state); + self.ph.hash(state); + } + } + } + + #[cfg(libc_union)] + impl PartialEq for __c_anonymous_ifi_lastchange { + fn eq(&self, other: &__c_anonymous_ifi_lastchange) -> bool { + unsafe { + self.tv == other.tv && + self.ph == other.ph + } + } + } + #[cfg(libc_union)] + impl Eq for __c_anonymous_ifi_lastchange {} + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ifi_lastchange { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("__c_anonymous_ifi_lastchange") + .field("tv", unsafe { &self.tv }) + .field("ph", unsafe { &self.ph }) + .finish() + } + } + #[cfg(libc_union)] + impl ::hash::Hash for __c_anonymous_ifi_lastchange { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + unsafe { + self.tv.hash(state); + self.ph.hash(state); + } + } + } + + impl PartialEq for if_data { + fn eq(&self, other: &if_data) -> bool { + self.ifi_type == other.ifi_type && + self.ifi_physical == other.ifi_physical && + self.ifi_addrlen == other.ifi_addrlen && + self.ifi_hdrlen == other.ifi_hdrlen && + self.ifi_link_state == other.ifi_link_state && + self.ifi_vhid == other.ifi_vhid && + self.ifi_datalen == other.ifi_datalen && + self.ifi_mtu == other.ifi_mtu && + self.ifi_metric == other.ifi_metric && + self.ifi_baudrate == other.ifi_baudrate && + self.ifi_ipackets == other.ifi_ipackets && + self.ifi_ierrors == other.ifi_ierrors && + self.ifi_opackets == other.ifi_opackets && + self.ifi_oerrors == other.ifi_oerrors && + self.ifi_collisions == other.ifi_collisions && + self.ifi_ibytes == other.ifi_ibytes && + self.ifi_obytes == other.ifi_obytes && + self.ifi_imcasts == other.ifi_imcasts && + self.ifi_omcasts == other.ifi_omcasts && + self.ifi_iqdrops == other.ifi_iqdrops && + self.ifi_oqdrops == other.ifi_oqdrops && + self.ifi_noproto == other.ifi_noproto && + self.ifi_hwassist == other.ifi_hwassist && + self.__ifi_epoch == other.__ifi_epoch && + self.__ifi_lastchange == other.__ifi_lastchange + } + } + impl Eq for if_data {} + impl ::fmt::Debug for if_data { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("if_data") + .field("ifi_type", &self.ifi_type) + .field("ifi_physical", &self.ifi_physical) + .field("ifi_addrlen", &self.ifi_addrlen) + .field("ifi_hdrlen", &self.ifi_hdrlen) + .field("ifi_link_state", &self.ifi_link_state) + .field("ifi_vhid", &self.ifi_vhid) + .field("ifi_datalen", &self.ifi_datalen) + .field("ifi_mtu", &self.ifi_mtu) + .field("ifi_metric", &self.ifi_metric) + .field("ifi_baudrate", &self.ifi_baudrate) + .field("ifi_ipackets", &self.ifi_ipackets) + .field("ifi_ierrors", &self.ifi_ierrors) + .field("ifi_opackets", &self.ifi_opackets) + .field("ifi_oerrors", &self.ifi_oerrors) + .field("ifi_collisions", &self.ifi_collisions) + .field("ifi_ibytes", &self.ifi_ibytes) + .field("ifi_obytes", &self.ifi_obytes) + .field("ifi_imcasts", &self.ifi_imcasts) + .field("ifi_omcasts", &self.ifi_omcasts) + .field("ifi_iqdrops", &self.ifi_iqdrops) + .field("ifi_oqdrops", &self.ifi_oqdrops) + .field("ifi_noproto", &self.ifi_noproto) + .field("ifi_hwassist", &self.ifi_hwassist) + .field("__ifi_epoch", &self.__ifi_epoch) + .field("__ifi_lastchange", &self.__ifi_lastchange) + .finish() + } + } + impl ::hash::Hash for if_data { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + self.ifi_type.hash(state); + self.ifi_physical.hash(state); + self.ifi_addrlen.hash(state); + self.ifi_hdrlen.hash(state); + self.ifi_link_state.hash(state); + self.ifi_vhid.hash(state); + self.ifi_datalen.hash(state); + self.ifi_mtu.hash(state); + self.ifi_metric.hash(state); + self.ifi_baudrate.hash(state); + self.ifi_ipackets.hash(state); + self.ifi_ierrors.hash(state); + self.ifi_opackets.hash(state); + self.ifi_oerrors.hash(state); + self.ifi_collisions.hash(state); + self.ifi_ibytes.hash(state); + self.ifi_obytes.hash(state); + self.ifi_imcasts.hash(state); + self.ifi_omcasts.hash(state); + self.ifi_iqdrops.hash(state); + self.ifi_oqdrops.hash(state); + self.ifi_noproto.hash(state); + self.ifi_hwassist.hash(state); + self.__ifi_epoch.hash(state); + self.__ifi_lastchange.hash(state); + } + } } } +#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[repr(u32)] +pub enum dot3Vendors { + dot3VendorAMD = 1, + dot3VendorIntel = 2, + dot3VendorNational = 4, + dot3VendorFujitsu = 5, + dot3VendorDigital = 6, + dot3VendorWesternDigital = 7, +} +impl ::Copy for dot3Vendors {} +impl ::Clone for dot3Vendors { + fn clone(&self) -> dot3Vendors { + *self + } +} + +// sys/devicestat.h +pub const DEVSTAT_N_TRANS_FLAGS: ::c_int = 4; +pub const DEVSTAT_NAME_LEN: ::c_int = 16; + pub const SIGEV_THREAD_ID: ::c_int = 4; pub const EXTATTR_NAMESPACE_EMPTY: ::c_int = 0; @@ -588,6 +1891,8 @@ pub const EXTATTR_NAMESPACE_SYSTEM: ::c_int = 2; pub const PTHREAD_STACK_MIN: ::size_t = MINSIGSTKSZ; pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 4; +pub const PTHREAD_MUTEX_STALLED: ::c_int = 0; +pub const PTHREAD_MUTEX_ROBUST: ::c_int = 1; pub const SIGSTKSZ: ::size_t = MINSIGSTKSZ + 32768; pub const SF_NODISKIO: ::c_int = 0x00000001; pub const SF_MNOWAIT: ::c_int = 0x00000002; @@ -605,12 +1910,22 @@ pub const ENOTCAPABLE: ::c_int = 93; pub const ECAPMODE: ::c_int = 94; pub const ENOTRECOVERABLE: ::c_int = 95; pub const EOWNERDEAD: ::c_int = 96; +pub const EINTEGRITY: ::c_int = 97; pub const RLIMIT_NPTS: ::c_int = 11; pub const RLIMIT_SWAP: ::c_int = 12; pub const RLIMIT_KQUEUES: ::c_int = 13; pub const RLIMIT_UMTXP: ::c_int = 14; #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] pub const RLIM_NLIMITS: ::rlim_t = 15; +pub const RLIM_SAVED_MAX: ::rlim_t = ::RLIM_INFINITY; +pub const RLIM_SAVED_CUR: ::rlim_t = ::RLIM_INFINITY; + +pub const CP_USER: ::c_int = 0; +pub const CP_NICE: ::c_int = 1; +pub const CP_SYS: ::c_int = 2; +pub const CP_INTR: ::c_int = 3; +pub const CP_IDLE: ::c_int = 4; +pub const CPUSTATES: ::c_int = 5; pub const NI_NOFQDN: ::c_int = 0x00000001; pub const NI_NUMERICHOST: ::c_int = 0x00000002; @@ -619,11 +1934,14 @@ pub const NI_NUMERICSERV: ::c_int = 0x00000008; pub const NI_DGRAM: ::c_int = 0x00000010; pub const NI_NUMERICSCOPE: ::c_int = 0x00000020; +pub const XU_NGROUPS: ::c_int = 16; + pub const Q_GETQUOTA: ::c_int = 0x700; pub const Q_SETQUOTA: ::c_int = 0x800; pub const MAP_GUARD: ::c_int = 0x00002000; pub const MAP_EXCL: ::c_int = 0x00004000; +pub const MAP_PREFAULT_READ: ::c_int = 0x00040000; pub const MAP_ALIGNED_SUPER: ::c_int = 1 << 24; pub const POSIX_FADV_NORMAL: ::c_int = 0; @@ -692,7 +2010,6 @@ pub const NOTE_USECONDS: u32 = 0x00000004; pub const NOTE_NSECONDS: u32 = 0x00000008; pub const MADV_PROTECT: ::c_int = 10; -pub const RUSAGE_THREAD: ::c_int = 1; #[doc(hidden)] #[deprecated( @@ -710,6 +2027,58 @@ pub const CTL_HW: ::c_int = 6; pub const CTL_MACHDEP: ::c_int = 7; pub const CTL_USER: ::c_int = 8; pub const CTL_P1003_1B: ::c_int = 9; + +// sys/sysctl.h +pub const CTL_MAXNAME: ::c_int = 24; + +pub const CTLTYPE: ::c_int = 0xf; +pub const CTLTYPE_NODE: ::c_int = 1; +pub const CTLTYPE_INT: ::c_int = 2; +pub const CTLTYPE_STRING: ::c_int = 3; +pub const CTLTYPE_S64: ::c_int = 4; +pub const CTLTYPE_OPAQUE: ::c_int = 5; +pub const CTLTYPE_STRUCT: ::c_int = CTLTYPE_OPAQUE; +pub const CTLTYPE_UINT: ::c_int = 6; +pub const CTLTYPE_LONG: ::c_int = 7; +pub const CTLTYPE_ULONG: ::c_int = 8; +pub const CTLTYPE_U64: ::c_int = 9; +pub const CTLTYPE_U8: ::c_int = 0xa; +pub const CTLTYPE_U16: ::c_int = 0xb; +pub const CTLTYPE_S8: ::c_int = 0xc; +pub const CTLTYPE_S16: ::c_int = 0xd; +pub const CTLTYPE_S32: ::c_int = 0xe; +pub const CTLTYPE_U32: ::c_int = 0xf; + +pub const CTLFLAG_RD: ::c_int = 0x80000000; +pub const CTLFLAG_WR: ::c_int = 0x40000000; +pub const CTLFLAG_RW: ::c_int = CTLFLAG_RD | CTLFLAG_WR; +pub const CTLFLAG_DORMANT: ::c_int = 0x20000000; +pub const CTLFLAG_ANYBODY: ::c_int = 0x10000000; +pub const CTLFLAG_SECURE: ::c_int = 0x08000000; +pub const CTLFLAG_PRISON: ::c_int = 0x04000000; +pub const CTLFLAG_DYN: ::c_int = 0x02000000; +pub const CTLFLAG_SKIP: ::c_int = 0x01000000; +pub const CTLMASK_SECURE: ::c_int = 0x00F00000; +pub const CTLFLAG_TUN: ::c_int = 0x00080000; +pub const CTLFLAG_RDTUN: ::c_int = CTLFLAG_RD | CTLFLAG_TUN; +pub const CTLFLAG_RWTUN: ::c_int = CTLFLAG_RW | CTLFLAG_TUN; +pub const CTLFLAG_MPSAFE: ::c_int = 0x00040000; +pub const CTLFLAG_VNET: ::c_int = 0x00020000; +pub const CTLFLAG_DYING: ::c_int = 0x00010000; +pub const CTLFLAG_CAPRD: ::c_int = 0x00008000; +pub const CTLFLAG_CAPWR: ::c_int = 0x00004000; +pub const CTLFLAG_STATS: ::c_int = 0x00002000; +pub const CTLFLAG_NOFETCH: ::c_int = 0x00001000; +pub const CTLFLAG_CAPRW: ::c_int = CTLFLAG_CAPRD | CTLFLAG_CAPWR; +pub const CTLFLAG_NEEDGIANT: ::c_int = 0x00000800; + +pub const CTLSHIFT_SECURE: ::c_int = 20; +pub const CTLFLAG_SECURE1: ::c_int = CTLFLAG_SECURE | (0 << CTLSHIFT_SECURE); +pub const CTLFLAG_SECURE2: ::c_int = CTLFLAG_SECURE | (1 << CTLSHIFT_SECURE); +pub const CTLFLAG_SECURE3: ::c_int = CTLFLAG_SECURE | (2 << CTLSHIFT_SECURE); + +pub const OID_AUTO: ::c_int = -1; + pub const CTL_SYSCTL_DEBUG: ::c_int = 0; pub const CTL_SYSCTL_NAME: ::c_int = 1; pub const CTL_SYSCTL_NEXT: ::c_int = 2; @@ -717,6 +2086,8 @@ pub const CTL_SYSCTL_NAME2OID: ::c_int = 3; pub const CTL_SYSCTL_OIDFMT: ::c_int = 4; pub const CTL_SYSCTL_OIDDESCR: ::c_int = 5; pub const CTL_SYSCTL_OIDLABEL: ::c_int = 6; +pub const CTL_SYSCTL_NEXTNOSKIP: ::c_int = 7; + pub const KERN_OSTYPE: ::c_int = 1; pub const KERN_OSRELEASE: ::c_int = 2; pub const KERN_OSREV: ::c_int = 3; @@ -754,6 +2125,8 @@ pub const KERN_LOGSIGEXIT: ::c_int = 34; pub const KERN_IOV_MAX: ::c_int = 35; pub const KERN_HOSTUUID: ::c_int = 36; pub const KERN_ARND: ::c_int = 37; +pub const KERN_MAXPHYS: ::c_int = 38; + pub const KERN_PROC_ALL: ::c_int = 0; pub const KERN_PROC_PID: ::c_int = 1; pub const KERN_PROC_PGRP: ::c_int = 2; @@ -781,6 +2154,10 @@ pub const KERN_PROC_PS_STRINGS: ::c_int = 38; pub const KERN_PROC_UMASK: ::c_int = 39; pub const KERN_PROC_OSREL: ::c_int = 40; pub const KERN_PROC_SIGTRAMP: ::c_int = 41; +pub const KERN_PROC_CWD: ::c_int = 42; +pub const KERN_PROC_NFDS: ::c_int = 43; +pub const KERN_PROC_SIGFASTBLK: ::c_int = 44; + pub const KIPC_MAXSOCKBUF: ::c_int = 1; pub const KIPC_SOCKBUF_WASTE: ::c_int = 2; pub const KIPC_SOMAXCONN: ::c_int = 3; @@ -788,6 +2165,7 @@ pub const KIPC_MAX_LINKHDR: ::c_int = 4; pub const KIPC_MAX_PROTOHDR: ::c_int = 5; pub const KIPC_MAX_HDR: ::c_int = 6; pub const KIPC_MAX_DATALEN: ::c_int = 7; + pub const HW_MACHINE: ::c_int = 1; pub const HW_MODEL: ::c_int = 2; pub const HW_NCPU: ::c_int = 3; @@ -800,6 +2178,7 @@ pub const HW_DISKSTATS: ::c_int = 9; pub const HW_FLOATINGPT: ::c_int = 10; pub const HW_MACHINE_ARCH: ::c_int = 11; pub const HW_REALMEM: ::c_int = 12; + pub const USER_CS_PATH: ::c_int = 1; pub const USER_BC_BASE_MAX: ::c_int = 2; pub const USER_BC_DIM_MAX: ::c_int = 3; @@ -820,6 +2199,8 @@ pub const USER_POSIX2_SW_DEV: ::c_int = 17; pub const USER_POSIX2_UPE: ::c_int = 18; pub const USER_STREAM_MAX: ::c_int = 19; pub const USER_TZNAME_MAX: ::c_int = 20; +pub const USER_LOCALBASE: ::c_int = 21; + pub const CTL_P1003_1B_ASYNCHRONOUS_IO: ::c_int = 1; pub const CTL_P1003_1B_MAPPED_FILES: ::c_int = 2; pub const CTL_P1003_1B_MEMLOCK: ::c_int = 3; @@ -845,14 +2226,18 @@ pub const CTL_P1003_1B_SEM_NSEMS_MAX: ::c_int = 22; pub const CTL_P1003_1B_SEM_VALUE_MAX: ::c_int = 23; pub const CTL_P1003_1B_SIGQUEUE_MAX: ::c_int = 24; pub const CTL_P1003_1B_TIMER_MAX: ::c_int = 25; -pub const TIOCGPTN: ::c_uint = 0x4004740f; -pub const TIOCPTMASTER: ::c_uint = 0x2000741c; -pub const TIOCSIG: ::c_uint = 0x2004745f; + +pub const TIOCGPTN: ::c_ulong = 0x4004740f; +pub const TIOCPTMASTER: ::c_ulong = 0x2000741c; +pub const TIOCSIG: ::c_ulong = 0x2004745f; pub const TIOCM_DCD: ::c_int = 0x40; pub const H4DISC: ::c_int = 0x7; +pub const VM_TOTAL: ::c_int = 1; + pub const BIOCSETFNR: ::c_ulong = 0x80104282; +pub const FIODGNAME: ::c_ulong = 0x80106678; pub const FIONWRITE: ::c_ulong = 0x40046677; pub const FIONSPACE: ::c_ulong = 0x40046676; pub const FIOSEEKDATA: ::c_ulong = 0xc0086661; @@ -879,6 +2264,8 @@ pub const MNT_UNION: ::c_int = 0x00000020; pub const MNT_EXPUBLIC: ::c_int = 0x20000000; pub const MNT_NONBUSY: ::c_int = 0x04000000; +pub const SCM_CREDS2: ::c_int = 0x08; + pub const SO_BINTIME: ::c_int = 0x2000; pub const SO_NO_OFFLOAD: ::c_int = 0x4000; pub const SO_NO_DDP: ::c_int = 0x8000; @@ -892,12 +2279,29 @@ pub const SO_SETFIB: ::c_int = 0x1014; pub const SO_USER_COOKIE: ::c_int = 0x1015; pub const SO_PROTOCOL: ::c_int = 0x1016; pub const SO_PROTOTYPE: ::c_int = SO_PROTOCOL; +pub const SO_DOMAIN: ::c_int = 0x1019; pub const SO_VENDOR: ::c_int = 0x80000000; pub const LOCAL_CREDS: ::c_int = 2; +pub const LOCAL_CREDS_PERSISTENT: ::c_int = 3; pub const LOCAL_CONNWAIT: ::c_int = 4; pub const LOCAL_VENDOR: ::c_int = SO_VENDOR; +pub const PL_EVENT_NONE: ::c_int = 0; +pub const PL_EVENT_SIGNAL: ::c_int = 1; +pub const PL_FLAG_SA: ::c_int = 0x01; +pub const PL_FLAG_BOUND: ::c_int = 0x02; +pub const PL_FLAG_SCE: ::c_int = 0x04; +pub const PL_FLAG_SCX: ::c_int = 0x08; +pub const PL_FLAG_EXEC: ::c_int = 0x10; +pub const PL_FLAG_SI: ::c_int = 0x20; +pub const PL_FLAG_FORKED: ::c_int = 0x40; +pub const PL_FLAG_CHILD: ::c_int = 0x80; +pub const PL_FLAG_BORN: ::c_int = 0x100; +pub const PL_FLAG_EXITED: ::c_int = 0x200; +pub const PL_FLAG_VFORKED: ::c_int = 0x400; +pub const PL_FLAG_VFORK_DONE: ::c_int = 0x800; + pub const PT_LWPINFO: ::c_int = 13; pub const PT_GETNUMLWPS: ::c_int = 14; pub const PT_GETLWPLIST: ::c_int = 15; @@ -912,6 +2316,9 @@ pub const PT_FOLLOW_FORK: ::c_int = 23; pub const PT_LWP_EVENTS: ::c_int = 24; pub const PT_GET_EVENT_MASK: ::c_int = 25; pub const PT_SET_EVENT_MASK: ::c_int = 26; +pub const PT_GET_SC_ARGS: ::c_int = 27; +pub const PT_GET_SC_RET: ::c_int = 28; +pub const PT_COREDUMP: ::c_int = 29; pub const PT_GETREGS: ::c_int = 33; pub const PT_SETREGS: ::c_int = 34; pub const PT_GETFPREGS: ::c_int = 35; @@ -920,6 +2327,8 @@ pub const PT_GETDBREGS: ::c_int = 37; pub const PT_SETDBREGS: ::c_int = 38; pub const PT_VM_TIMESTAMP: ::c_int = 40; pub const PT_VM_ENTRY: ::c_int = 41; +pub const PT_GETREGSET: ::c_int = 42; +pub const PT_SETREGSET: ::c_int = 43; pub const PT_FIRSTMACH: ::c_int = 64; pub const PTRACE_EXEC: ::c_int = 0x0001; @@ -931,6 +2340,9 @@ pub const PTRACE_LWP: ::c_int = 0x0010; pub const PTRACE_VFORK: ::c_int = 0x0020; pub const PTRACE_DEFAULT: ::c_int = PTRACE_EXEC; +pub const PC_COMPRESS: u32 = 0x00000001; +pub const PC_ALL: u32 = 0x00000002; + pub const PROC_SPROTECT: ::c_int = 1; pub const PROC_REAP_ACQUIRE: ::c_int = 2; pub const PROC_REAP_RELEASE: ::c_int = 3; @@ -943,8 +2355,40 @@ pub const PROC_TRAPCAP_CTL: ::c_int = 9; pub const PROC_TRAPCAP_STATUS: ::c_int = 10; pub const PROC_PDEATHSIG_CTL: ::c_int = 11; pub const PROC_PDEATHSIG_STATUS: ::c_int = 12; +pub const PROC_ASLR_CTL: ::c_int = 13; +pub const PROC_ASLR_STATUS: ::c_int = 14; +pub const PROC_PROTMAX_CTL: ::c_int = 15; +pub const PROC_PROTMAX_STATUS: ::c_int = 16; pub const PROC_STACKGAP_CTL: ::c_int = 17; pub const PROC_STACKGAP_STATUS: ::c_int = 18; +pub const PROC_PROCCTL_MD_MIN: ::c_int = 0x10000000; + +pub const PPROT_SET: ::c_int = 1; +pub const PPROT_CLEAR: ::c_int = 2; +pub const PPROT_DESCEND: ::c_int = 0x10; +pub const PPROT_INHERIT: ::c_int = 0x20; + +pub const PROC_TRACE_CTL_ENABLE: ::c_int = 1; +pub const PROC_TRACE_CTL_DISABLE: ::c_int = 2; +pub const PROC_TRACE_CTL_DISABLE_EXEC: ::c_int = 3; + +pub const PROC_TRAPCAP_CTL_ENABLE: ::c_int = 1; +pub const PROC_TRAPCAP_CTL_DISABLE: ::c_int = 2; + +pub const PROC_ASLR_FORCE_ENABLE: ::c_int = 1; +pub const PROC_ASLR_FORCE_DISABLE: ::c_int = 2; +pub const PROC_ASLR_NOFORCE: ::c_int = 3; +pub const PROC_ASLR_ACTIVE: ::c_int = 0x80000000; + +pub const PROC_PROTMAX_FORCE_ENABLE: ::c_int = 1; +pub const PROC_PROTMAX_FORCE_DISABLE: ::c_int = 2; +pub const PROC_PROTMAX_NOFORCE: ::c_int = 3; +pub const PROC_PROTMAX_ACTIVE: ::c_int = 0x80000000; + +pub const PROC_STACKGAP_ENABLE: ::c_int = 0x0001; +pub const PROC_STACKGAP_DISABLE: ::c_int = 0x0002; +pub const PROC_STACKGAP_ENABLE_EXEC: ::c_int = 0x0004; +pub const PROC_STACKGAP_DISABLE_EXEC: ::c_int = 0x0008; pub const AF_SLOW: ::c_int = 33; pub const AF_SCLUSTER: ::c_int = 34; @@ -954,40 +2398,218 @@ pub const AF_IEEE80211: ::c_int = 37; pub const AF_INET_SDP: ::c_int = 40; pub const AF_INET6_SDP: ::c_int = 42; -// https://github.com/freebsd/freebsd/blob/master/sys/net/if.h#L140 -pub const IFF_UP: ::c_int = 0x1; // (n) interface is up -pub const IFF_BROADCAST: ::c_int = 0x2; // (i) broadcast address valid -pub const IFF_DEBUG: ::c_int = 0x4; // (n) turn on debugging -pub const IFF_LOOPBACK: ::c_int = 0x8; // (i) is a loopback net -pub const IFF_POINTOPOINT: ::c_int = 0x10; // (i) is a point-to-point link - // 0x20 was IFF_SMART -pub const IFF_RUNNING: ::c_int = 0x40; // (d) resources allocated +// sys/net/if.h +pub const IF_MAXUNIT: ::c_int = 0x7fff; +/// (n) interface is up +pub const IFF_UP: ::c_int = 0x1; +/// (i) broadcast address valid +pub const IFF_BROADCAST: ::c_int = 0x2; +/// (n) turn on debugging +pub const IFF_DEBUG: ::c_int = 0x4; +/// (i) is a loopback net +pub const IFF_LOOPBACK: ::c_int = 0x8; +/// (i) is a point-to-point link +pub const IFF_POINTOPOINT: ::c_int = 0x10; +/// (i) calls if_input in net epoch +pub const IFF_KNOWSEPOCH: ::c_int = 0x20; +/// (d) resources allocated +pub const IFF_RUNNING: ::c_int = 0x40; #[doc(hidden)] #[deprecated( since = "0.2.54", note = "IFF_DRV_RUNNING is deprecated. Use the portable IFF_RUNNING instead" )] +/// (d) resources allocate pub const IFF_DRV_RUNNING: ::c_int = 0x40; -pub const IFF_NOARP: ::c_int = 0x80; // (n) no address resolution protocol -pub const IFF_PROMISC: ::c_int = 0x100; // (n) receive all packets -pub const IFF_ALLMULTI: ::c_int = 0x200; // (n) receive all multicast packets -pub const IFF_OACTIVE: ::c_int = 0x400; // (d) tx hardware queue is full +/// (n) no address resolution protocol +pub const IFF_NOARP: ::c_int = 0x80; +/// (n) receive all packets +pub const IFF_PROMISC: ::c_int = 0x100; +/// (n) receive all multicast packets +pub const IFF_ALLMULTI: ::c_int = 0x200; +/// (d) tx hardware queue is full +pub const IFF_OACTIVE: ::c_int = 0x400; #[doc(hidden)] #[deprecated(since = "0.2.54", note = "Use the portable `IFF_OACTIVE` instead")] +/// (d) tx hardware queue is full pub const IFF_DRV_OACTIVE: ::c_int = 0x400; -pub const IFF_SIMPLEX: ::c_int = 0x800; // (i) can't hear own transmissions -pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit -pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit -pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit -pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection -pub const IFF_MULTICAST: ::c_int = 0x8000; // (i) supports multicast - // (i) unconfigurable using ioctl(2) +/// (i) can't hear own transmissions +pub const IFF_SIMPLEX: ::c_int = 0x800; +/// per link layer defined bit +pub const IFF_LINK0: ::c_int = 0x1000; +/// per link layer defined bit +pub const IFF_LINK1: ::c_int = 0x2000; +/// per link layer defined bit +pub const IFF_LINK2: ::c_int = 0x4000; +/// use alternate physical connection +pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; +/// (i) supports multicast +pub const IFF_MULTICAST: ::c_int = 0x8000; +/// (i) unconfigurable using ioctl(2) pub const IFF_CANTCONFIG: ::c_int = 0x10000; -pub const IFF_PPROMISC: ::c_int = 0x20000; // (n) user-requested promisc mode -pub const IFF_MONITOR: ::c_int = 0x40000; // (n) user-requested monitor mode -pub const IFF_STATICARP: ::c_int = 0x80000; // (n) static ARP -pub const IFF_DYING: ::c_int = 0x200000; // (n) interface is winding down -pub const IFF_RENAMING: ::c_int = 0x400000; // (n) interface is being renamed +/// (n) user-requested promisc mode +pub const IFF_PPROMISC: ::c_int = 0x20000; +/// (n) user-requested monitor mode +pub const IFF_MONITOR: ::c_int = 0x40000; +/// (n) static ARP +pub const IFF_STATICARP: ::c_int = 0x80000; +/// (n) interface is winding down +pub const IFF_DYING: ::c_int = 0x200000; +/// (n) interface is being renamed +pub const IFF_RENAMING: ::c_int = 0x400000; +/// interface is not part of any groups +pub const IFF_NOGROUP: ::c_int = 0x800000; + +/// link invalid/unknown +pub const LINK_STATE_UNKNOWN: ::c_int = 0; +/// link is down +pub const LINK_STATE_DOWN: ::c_int = 1; +/// link is up +pub const LINK_STATE_UP: ::c_int = 2; + +/// can offload checksum on RX +pub const IFCAP_RXCSUM: ::c_int = 0x00001; +/// can offload checksum on TX +pub const IFCAP_TXCSUM: ::c_int = 0x00002; +/// can be a network console +pub const IFCAP_NETCONS: ::c_int = 0x00004; +/// VLAN-compatible MTU +pub const IFCAP_VLAN_MTU: ::c_int = 0x00008; +/// hardware VLAN tag support +pub const IFCAP_VLAN_HWTAGGING: ::c_int = 0x00010; +/// 9000 byte MTU supported +pub const IFCAP_JUMBO_MTU: ::c_int = 0x00020; +/// driver supports polling +pub const IFCAP_POLLING: ::c_int = 0x00040; +/// can do IFCAP_HWCSUM on VLANs +pub const IFCAP_VLAN_HWCSUM: ::c_int = 0x00080; +/// can do TCP Segmentation Offload +pub const IFCAP_TSO4: ::c_int = 0x00100; +/// can do TCP6 Segmentation Offload +pub const IFCAP_TSO6: ::c_int = 0x00200; +/// can do Large Receive Offload +pub const IFCAP_LRO: ::c_int = 0x00400; +/// wake on any unicast frame +pub const IFCAP_WOL_UCAST: ::c_int = 0x00800; +/// wake on any multicast frame +pub const IFCAP_WOL_MCAST: ::c_int = 0x01000; +/// wake on any Magic Packet +pub const IFCAP_WOL_MAGIC: ::c_int = 0x02000; +/// interface can offload TCP +pub const IFCAP_TOE4: ::c_int = 0x04000; +/// interface can offload TCP6 +pub const IFCAP_TOE6: ::c_int = 0x08000; +/// interface hw can filter vlan tag +pub const IFCAP_VLAN_HWFILTER: ::c_int = 0x10000; +/// can do IFCAP_TSO on VLANs +pub const IFCAP_VLAN_HWTSO: ::c_int = 0x40000; +/// the runtime link state is dynamic +pub const IFCAP_LINKSTATE: ::c_int = 0x80000; +/// netmap mode supported/enabled +pub const IFCAP_NETMAP: ::c_int = 0x100000; +/// can offload checksum on IPv6 RX +pub const IFCAP_RXCSUM_IPV6: ::c_int = 0x200000; +/// can offload checksum on IPv6 TX +pub const IFCAP_TXCSUM_IPV6: ::c_int = 0x400000; +/// manages counters internally +pub const IFCAP_HWSTATS: ::c_int = 0x800000; +/// hardware supports TX rate limiting +pub const IFCAP_TXRTLMT: ::c_int = 0x1000000; +/// hardware rx timestamping +pub const IFCAP_HWRXTSTMP: ::c_int = 0x2000000; +/// understands M_EXTPG mbufs +pub const IFCAP_MEXTPG: ::c_int = 0x4000000; +/// can do TLS encryption and segmentation for TCP +pub const IFCAP_TXTLS4: ::c_int = 0x8000000; +/// can do TLS encryption and segmentation for TCP6 +pub const IFCAP_TXTLS6: ::c_int = 0x10000000; +/// can do IFCAN_HWCSUM on VXLANs +pub const IFCAP_VXLAN_HWCSUM: ::c_int = 0x20000000; +/// can do IFCAP_TSO on VXLANs +pub const IFCAP_VXLAN_HWTSO: ::c_int = 0x40000000; +/// can do TLS with rate limiting +pub const IFCAP_TXTLS_RTLMT: ::c_int = 0x80000000; + +pub const IFCAP_HWCSUM_IPV6: ::c_int = IFCAP_RXCSUM_IPV6 | IFCAP_TXCSUM_IPV6; +pub const IFCAP_HWCSUM: ::c_int = IFCAP_RXCSUM | IFCAP_TXCSUM; +pub const IFCAP_TSO: ::c_int = IFCAP_TSO4 | IFCAP_TSO6; +pub const IFCAP_WOL: ::c_int = IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC; +pub const IFCAP_TOE: ::c_int = IFCAP_TOE4 | IFCAP_TOE6; +pub const IFCAP_TXTLS: ::c_int = IFCAP_TXTLS4 | IFCAP_TXTLS6; +pub const IFCAP_CANTCHANGE: ::c_int = IFCAP_NETMAP; + +pub const IFQ_MAXLEN: ::c_int = 50; +pub const IFNET_SLOWHZ: ::c_int = 1; + +pub const IFAN_ARRIVAL: ::c_int = 0; +pub const IFAN_DEPARTURE: ::c_int = 1; + +pub const IFSTATMAX: ::c_int = 800; + +pub const RSS_FUNC_NONE: ::c_int = 0; +pub const RSS_FUNC_PRIVATE: ::c_int = 1; +pub const RSS_FUNC_TOEPLITZ: ::c_int = 2; + +pub const RSS_TYPE_IPV4: ::c_int = 0x00000001; +pub const RSS_TYPE_TCP_IPV4: ::c_int = 0x00000002; +pub const RSS_TYPE_IPV6: ::c_int = 0x00000004; +pub const RSS_TYPE_IPV6_EX: ::c_int = 0x00000008; +pub const RSS_TYPE_TCP_IPV6: ::c_int = 0x00000010; +pub const RSS_TYPE_TCP_IPV6_EX: ::c_int = 0x00000020; +pub const RSS_TYPE_UDP_IPV4: ::c_int = 0x00000040; +pub const RSS_TYPE_UDP_IPV6: ::c_int = 0x00000080; +pub const RSS_TYPE_UDP_IPV6_EX: ::c_int = 0x00000100; +pub const RSS_KEYLEN: ::c_int = 128; + +pub const IFNET_PCP_NONE: ::c_int = 0xff; +pub const IFDR_MSG_SIZE: ::c_int = 64; +pub const IFDR_REASON_MSG: ::c_int = 1; +pub const IFDR_REASON_VENDOR: ::c_int = 2; + +// sys/net/if_mib.h + +/// non-interface-specific +pub const IFMIB_SYSTEM: ::c_int = 1; +/// per-interface data table +pub const IFMIB_IFDATA: ::c_int = 2; + +/// generic stats for all kinds of ifaces +pub const IFDATA_GENERAL: ::c_int = 1; +/// specific to the type of interface +pub const IFDATA_LINKSPECIFIC: ::c_int = 2; +/// driver name and unit +pub const IFDATA_DRIVERNAME: ::c_int = 3; + +/// number of interfaces configured +pub const IFMIB_IFCOUNT: ::c_int = 1; + +/// functions not specific to a type of iface +pub const NETLINK_GENERIC: ::c_int = 0; + +pub const DOT3COMPLIANCE_STATS: ::c_int = 1; +pub const DOT3COMPLIANCE_COLLS: ::c_int = 2; + +pub const dot3ChipSetAMD7990: ::c_int = 1; +pub const dot3ChipSetAMD79900: ::c_int = 2; +pub const dot3ChipSetAMD79C940: ::c_int = 3; + +pub const dot3ChipSetIntel82586: ::c_int = 1; +pub const dot3ChipSetIntel82596: ::c_int = 2; +pub const dot3ChipSetIntel82557: ::c_int = 3; + +pub const dot3ChipSetNational8390: ::c_int = 1; +pub const dot3ChipSetNationalSonic: ::c_int = 2; + +pub const dot3ChipSetFujitsu86950: ::c_int = 1; + +pub const dot3ChipSetDigitalDC21040: ::c_int = 1; +pub const dot3ChipSetDigitalDC21140: ::c_int = 2; +pub const dot3ChipSetDigitalDC21041: ::c_int = 3; +pub const dot3ChipSetDigitalDC21140A: ::c_int = 4; +pub const dot3ChipSetDigitalDC21142: ::c_int = 5; + +pub const dot3ChipSetWesternDigital83C690: ::c_int = 1; +pub const dot3ChipSetWesternDigital83C790: ::c_int = 2; // sys/netinet/in.h // Protocols (RFC 1700) @@ -1239,10 +2861,24 @@ pub const TCP_MD5SIG: ::c_int = 16; pub const TCP_INFO: ::c_int = 32; pub const TCP_CONGESTION: ::c_int = 64; pub const TCP_CCALGOOPT: ::c_int = 65; +pub const TCP_MAXUNACKTIME: ::c_int = 68; +pub const TCP_MAXPEAKRATE: ::c_int = 69; +pub const TCP_IDLE_REDUCE: ::c_int = 70; +pub const TCP_REMOTE_UDP_ENCAPS_PORT: ::c_int = 71; +pub const TCP_DELACK: ::c_int = 72; +pub const TCP_FIN_IS_RST: ::c_int = 73; +pub const TCP_LOG_LIMIT: ::c_int = 74; +pub const TCP_SHARED_CWND_ALLOWED: ::c_int = 75; +pub const TCP_PROC_ACCOUNTING: ::c_int = 76; +pub const TCP_USE_CMP_ACKS: ::c_int = 77; +pub const TCP_PERF_INFO: ::c_int = 78; +pub const TCP_LRD: ::c_int = 79; pub const TCP_KEEPINIT: ::c_int = 128; pub const TCP_FASTOPEN: ::c_int = 1025; pub const TCP_PCAP_OUT: ::c_int = 2048; pub const TCP_PCAP_IN: ::c_int = 4096; +pub const TCP_FASTOPEN_PSK_LEN: ::c_int = 16; +pub const TCP_FUNCTION_NAME_LEN_MAX: ::c_int = 32; pub const IP_BINDANY: ::c_int = 24; pub const IP_BINDMULTI: ::c_int = 25; @@ -1382,6 +3018,8 @@ pub const _PC_ACL_NFS4: ::c_int = 64; pub const _SC_CPUSET_SIZE: ::c_int = 122; +pub const _UUID_NODE_LEN: usize = 6; + // Flags which can be passed to pdfork(2) pub const PD_DAEMON: ::c_int = 0x00000001; pub const PD_CLOEXEC: ::c_int = 0x00000002; @@ -1409,14 +3047,30 @@ pub const UF_READONLY: ::c_ulong = 0x00001000; pub const UF_HIDDEN: ::c_ulong = 0x00008000; pub const SF_SNAPSHOT: ::c_ulong = 0x00200000; +// fcntl commands +pub const F_ADD_SEALS: ::c_int = 19; +pub const F_GET_SEALS: ::c_int = 20; pub const F_OGETLK: ::c_int = 7; pub const F_OSETLK: ::c_int = 8; pub const F_OSETLKW: ::c_int = 9; -pub const F_DUP2FD: ::c_int = 10; -pub const F_SETLK_REMOTE: ::c_int = 14; -pub const F_READAHEAD: ::c_int = 15; pub const F_RDAHEAD: ::c_int = 16; -pub const F_DUP2FD_CLOEXEC: ::c_int = 18; +pub const F_READAHEAD: ::c_int = 15; +pub const F_SETLK_REMOTE: ::c_int = 14; +pub const F_KINFO: ::c_int = 22; + +// for use with F_ADD_SEALS +pub const F_SEAL_GROW: ::c_int = 4; +pub const F_SEAL_SEAL: ::c_int = 1; +pub const F_SEAL_SHRINK: ::c_int = 2; +pub const F_SEAL_WRITE: ::c_int = 8; + +// for use with fspacectl +pub const SPACECTL_DEALLOC: ::c_int = 1; + +// For getrandom() +pub const GRND_NONBLOCK: ::c_uint = 0x1; +pub const GRND_RANDOM: ::c_uint = 0x2; +pub const GRND_INSECURE: ::c_uint = 0x4; // For realhostname* api pub const HOSTNAME_FOUND: ::c_int = 0; @@ -1435,8 +3089,573 @@ pub const RFLINUXTHPN: ::c_int = 65536; pub const RFTSIGZMB: ::c_int = 524288; pub const RFSPAWN: ::c_int = 2147483648; +// For eventfd +pub const EFD_SEMAPHORE: ::c_int = 0x1; +pub const EFD_NONBLOCK: ::c_int = 0x4; +pub const EFD_CLOEXEC: ::c_int = 0x100000; + pub const MALLOCX_ZERO: ::c_int = 0x40; +/// size of returned wchan message +pub const WMESGLEN: usize = 8; +/// size of returned lock name +pub const LOCKNAMELEN: usize = 8; +/// size of returned thread name +pub const TDNAMLEN: usize = 16; +/// size of returned ki_comm name +pub const COMMLEN: usize = 19; +/// size of returned ki_emul +pub const KI_EMULNAMELEN: usize = 16; +/// number of groups in ki_groups +pub const KI_NGROUPS: usize = 16; +cfg_if! { + if #[cfg(freebsd11)] { + pub const KI_NSPARE_INT: usize = 4; + } else { + pub const KI_NSPARE_INT: usize = 2; + } +} +pub const KI_NSPARE_LONG: usize = 12; +/// Flags for the process credential. +pub const KI_CRF_CAPABILITY_MODE: usize = 0x00000001; +/// Steal a bit from ki_cr_flags to indicate that the cred had more than +/// KI_NGROUPS groups. +pub const KI_CRF_GRP_OVERFLOW: usize = 0x80000000; +/// controlling tty vnode active +pub const KI_CTTY: usize = 0x00000001; +/// session leader +pub const KI_SLEADER: usize = 0x00000002; +/// proc blocked on lock ki_lockname +pub const KI_LOCKBLOCK: usize = 0x00000004; +/// size of returned ki_login +pub const LOGNAMELEN: usize = 17; +/// size of returned ki_loginclass +pub const LOGINCLASSLEN: usize = 17; + +pub const KF_ATTR_VALID: ::c_int = 0x0001; +pub const KF_TYPE_NONE: ::c_int = 0; +pub const KF_TYPE_VNODE: ::c_int = 1; +pub const KF_TYPE_SOCKET: ::c_int = 2; +pub const KF_TYPE_PIPE: ::c_int = 3; +pub const KF_TYPE_FIFO: ::c_int = 4; +pub const KF_TYPE_KQUEUE: ::c_int = 5; +pub const KF_TYPE_MQUEUE: ::c_int = 7; +pub const KF_TYPE_SHM: ::c_int = 8; +pub const KF_TYPE_SEM: ::c_int = 9; +pub const KF_TYPE_PTS: ::c_int = 10; +pub const KF_TYPE_PROCDESC: ::c_int = 11; +pub const KF_TYPE_DEV: ::c_int = 12; +pub const KF_TYPE_UNKNOWN: ::c_int = 255; + +pub const KF_VTYPE_VNON: ::c_int = 0; +pub const KF_VTYPE_VREG: ::c_int = 1; +pub const KF_VTYPE_VDIR: ::c_int = 2; +pub const KF_VTYPE_VBLK: ::c_int = 3; +pub const KF_VTYPE_VCHR: ::c_int = 4; +pub const KF_VTYPE_VLNK: ::c_int = 5; +pub const KF_VTYPE_VSOCK: ::c_int = 6; +pub const KF_VTYPE_VFIFO: ::c_int = 7; +pub const KF_VTYPE_VBAD: ::c_int = 8; +pub const KF_VTYPE_UNKNOWN: ::c_int = 255; + +/// Current working directory +pub const KF_FD_TYPE_CWD: ::c_int = -1; +/// Root directory +pub const KF_FD_TYPE_ROOT: ::c_int = -2; +/// Jail directory +pub const KF_FD_TYPE_JAIL: ::c_int = -3; +/// Ktrace vnode +pub const KF_FD_TYPE_TRACE: ::c_int = -4; +pub const KF_FD_TYPE_TEXT: ::c_int = -5; +/// Controlling terminal +pub const KF_FD_TYPE_CTTY: ::c_int = -6; +pub const KF_FLAG_READ: ::c_int = 0x00000001; +pub const KF_FLAG_WRITE: ::c_int = 0x00000002; +pub const KF_FLAG_APPEND: ::c_int = 0x00000004; +pub const KF_FLAG_ASYNC: ::c_int = 0x00000008; +pub const KF_FLAG_FSYNC: ::c_int = 0x00000010; +pub const KF_FLAG_NONBLOCK: ::c_int = 0x00000020; +pub const KF_FLAG_DIRECT: ::c_int = 0x00000040; +pub const KF_FLAG_HASLOCK: ::c_int = 0x00000080; +pub const KF_FLAG_SHLOCK: ::c_int = 0x00000100; +pub const KF_FLAG_EXLOCK: ::c_int = 0x00000200; +pub const KF_FLAG_NOFOLLOW: ::c_int = 0x00000400; +pub const KF_FLAG_CREAT: ::c_int = 0x00000800; +pub const KF_FLAG_TRUNC: ::c_int = 0x00001000; +pub const KF_FLAG_EXCL: ::c_int = 0x00002000; +pub const KF_FLAG_EXEC: ::c_int = 0x00004000; + +pub const KVME_TYPE_NONE: ::c_int = 0; +pub const KVME_TYPE_DEFAULT: ::c_int = 1; +pub const KVME_TYPE_VNODE: ::c_int = 2; +pub const KVME_TYPE_SWAP: ::c_int = 3; +pub const KVME_TYPE_DEVICE: ::c_int = 4; +pub const KVME_TYPE_PHYS: ::c_int = 5; +pub const KVME_TYPE_DEAD: ::c_int = 6; +pub const KVME_TYPE_SG: ::c_int = 7; +pub const KVME_TYPE_MGTDEVICE: ::c_int = 8; +// Present in `sys/user.h` but is undefined for whatever reason... +// pub const KVME_TYPE_GUARD: ::c_int = 9; +pub const KVME_TYPE_UNKNOWN: ::c_int = 255; +pub const KVME_PROT_READ: ::c_int = 0x00000001; +pub const KVME_PROT_WRITE: ::c_int = 0x00000002; +pub const KVME_PROT_EXEC: ::c_int = 0x00000004; +pub const KVME_FLAG_COW: ::c_int = 0x00000001; +pub const KVME_FLAG_NEEDS_COPY: ::c_int = 0x00000002; +pub const KVME_FLAG_NOCOREDUMP: ::c_int = 0x00000004; +pub const KVME_FLAG_SUPER: ::c_int = 0x00000008; +pub const KVME_FLAG_GROWS_UP: ::c_int = 0x00000010; +pub const KVME_FLAG_GROWS_DOWN: ::c_int = 0x00000020; +pub const KVME_FLAG_USER_WIRED: ::c_int = 0x00000040; + +pub const KKST_MAXLEN: ::c_int = 1024; +/// Stack is valid. +pub const KKST_STATE_STACKOK: ::c_int = 0; +/// Stack swapped out. +pub const KKST_STATE_SWAPPED: ::c_int = 1; +pub const KKST_STATE_RUNNING: ::c_int = 2; + +// Constants about priority. +pub const PRI_MIN: ::c_int = 0; +pub const PRI_MAX: ::c_int = 255; +pub const PRI_MIN_ITHD: ::c_int = PRI_MIN; +pub const PRI_MAX_ITHD: ::c_int = PRI_MIN_REALTIME - 1; +pub const PI_REALTIME: ::c_int = PRI_MIN_ITHD + 0; +pub const PI_AV: ::c_int = PRI_MIN_ITHD + 4; +pub const PI_NET: ::c_int = PRI_MIN_ITHD + 8; +pub const PI_DISK: ::c_int = PRI_MIN_ITHD + 12; +pub const PI_TTY: ::c_int = PRI_MIN_ITHD + 16; +pub const PI_DULL: ::c_int = PRI_MIN_ITHD + 20; +pub const PI_SOFT: ::c_int = PRI_MIN_ITHD + 24; +pub const PRI_MIN_REALTIME: ::c_int = 48; +pub const PRI_MAX_REALTIME: ::c_int = PRI_MIN_KERN - 1; +pub const PRI_MIN_KERN: ::c_int = 80; +pub const PRI_MAX_KERN: ::c_int = PRI_MIN_TIMESHARE - 1; +pub const PSWP: ::c_int = PRI_MIN_KERN + 0; +pub const PVM: ::c_int = PRI_MIN_KERN + 4; +pub const PINOD: ::c_int = PRI_MIN_KERN + 8; +pub const PRIBIO: ::c_int = PRI_MIN_KERN + 12; +pub const PVFS: ::c_int = PRI_MIN_KERN + 16; +pub const PZERO: ::c_int = PRI_MIN_KERN + 20; +pub const PSOCK: ::c_int = PRI_MIN_KERN + 24; +pub const PWAIT: ::c_int = PRI_MIN_KERN + 28; +pub const PLOCK: ::c_int = PRI_MIN_KERN + 32; +pub const PPAUSE: ::c_int = PRI_MIN_KERN + 36; +pub const PRI_MIN_TIMESHARE: ::c_int = 120; +pub const PRI_MAX_TIMESHARE: ::c_int = PRI_MIN_IDLE - 1; +pub const PUSER: ::c_int = PRI_MIN_TIMESHARE; +pub const PRI_MIN_IDLE: ::c_int = 224; +pub const PRI_MAX_IDLE: ::c_int = PRI_MAX; + +pub const NZERO: ::c_int = 0; + +// Resource utilization information. +pub const RUSAGE_THREAD: ::c_int = 1; + +cfg_if! { + if #[cfg(any(freebsd11, target_pointer_width = "32"))] { + pub const ARG_MAX: ::c_int = 256 * 1024; + } else { + pub const ARG_MAX: ::c_int = 2 * 256 * 1024; + } +} +pub const CHILD_MAX: ::c_int = 40; +/// max command name remembered +pub const MAXCOMLEN: usize = 19; +/// max interpreter file name length +pub const MAXINTERP: ::c_int = ::PATH_MAX; +/// max login name length (incl. NUL) +pub const MAXLOGNAME: ::c_int = 33; +/// max simultaneous processes +pub const MAXUPRC: ::c_int = CHILD_MAX; +/// max bytes for an exec function +pub const NCARGS: ::c_int = ARG_MAX; +/// /* max number groups +pub const NGROUPS: ::c_int = NGROUPS_MAX + 1; +/// max open files per process +pub const NOFILE: ::c_int = OPEN_MAX; +/// marker for empty group set member +pub const NOGROUP: ::c_int = 65535; +/// max hostname size +pub const MAXHOSTNAMELEN: ::c_int = 256; +/// max bytes in term canon input line +pub const MAX_CANON: ::c_int = 255; +/// max bytes in terminal input +pub const MAX_INPUT: ::c_int = 255; +/// max bytes in a file name +pub const NAME_MAX: ::c_int = 255; +pub const MAXSYMLINKS: ::c_int = 32; +/// max supplemental group id's +pub const NGROUPS_MAX: ::c_int = 1023; +/// max open files per process +pub const OPEN_MAX: ::c_int = 64; + +pub const _POSIX_ARG_MAX: ::c_int = 4096; +pub const _POSIX_LINK_MAX: ::c_int = 8; +pub const _POSIX_MAX_CANON: ::c_int = 255; +pub const _POSIX_MAX_INPUT: ::c_int = 255; +pub const _POSIX_NAME_MAX: ::c_int = 14; +pub const _POSIX_PIPE_BUF: ::c_int = 512; +pub const _POSIX_SSIZE_MAX: ::c_int = 32767; +pub const _POSIX_STREAM_MAX: ::c_int = 8; + +/// max ibase/obase values in bc(1) +pub const BC_BASE_MAX: ::c_int = 99; +/// max array elements in bc(1) +pub const BC_DIM_MAX: ::c_int = 2048; +/// max scale value in bc(1) +pub const BC_SCALE_MAX: ::c_int = 99; +/// max const string length in bc(1) +pub const BC_STRING_MAX: ::c_int = 1000; +/// max character class name size +pub const CHARCLASS_NAME_MAX: ::c_int = 14; +/// max weights for order keyword +pub const COLL_WEIGHTS_MAX: ::c_int = 10; +/// max expressions nested in expr(1) +pub const EXPR_NEST_MAX: ::c_int = 32; +/// max bytes in an input line +pub const LINE_MAX: ::c_int = 2048; +/// max RE's in interval notation +pub const RE_DUP_MAX: ::c_int = 255; + +pub const _POSIX2_BC_BASE_MAX: ::c_int = 99; +pub const _POSIX2_BC_DIM_MAX: ::c_int = 2048; +pub const _POSIX2_BC_SCALE_MAX: ::c_int = 99; +pub const _POSIX2_BC_STRING_MAX: ::c_int = 1000; +pub const _POSIX2_CHARCLASS_NAME_MAX: ::c_int = 14; +pub const _POSIX2_COLL_WEIGHTS_MAX: ::c_int = 2; +pub const _POSIX2_EQUIV_CLASS_MAX: ::c_int = 2; +pub const _POSIX2_EXPR_NEST_MAX: ::c_int = 32; +pub const _POSIX2_LINE_MAX: ::c_int = 2048; +pub const _POSIX2_RE_DUP_MAX: ::c_int = 255; + +// sys/proc.h +pub const TDF_BORROWING: ::c_int = 0x00000001; +pub const TDF_INPANIC: ::c_int = 0x00000002; +pub const TDF_INMEM: ::c_int = 0x00000004; +pub const TDF_SINTR: ::c_int = 0x00000008; +pub const TDF_TIMEOUT: ::c_int = 0x00000010; +pub const TDF_IDLETD: ::c_int = 0x00000020; +pub const TDF_CANSWAP: ::c_int = 0x00000040; +pub const TDF_KTH_SUSP: ::c_int = 0x00000100; +pub const TDF_ALLPROCSUSP: ::c_int = 0x00000200; +pub const TDF_BOUNDARY: ::c_int = 0x00000400; +pub const TDF_ASTPENDING: ::c_int = 0x00000800; +pub const TDF_SBDRY: ::c_int = 0x00002000; +pub const TDF_UPIBLOCKED: ::c_int = 0x00004000; +pub const TDF_NEEDSUSPCHK: ::c_int = 0x00008000; +pub const TDF_NEEDRESCHED: ::c_int = 0x00010000; +pub const TDF_NEEDSIGCHK: ::c_int = 0x00020000; +pub const TDF_NOLOAD: ::c_int = 0x00040000; +pub const TDF_SERESTART: ::c_int = 0x00080000; +pub const TDF_THRWAKEUP: ::c_int = 0x00100000; +pub const TDF_SEINTR: ::c_int = 0x00200000; +pub const TDF_SWAPINREQ: ::c_int = 0x00400000; +pub const TDF_UNUSED23: ::c_int = 0x00800000; +pub const TDF_SCHED0: ::c_int = 0x01000000; +pub const TDF_SCHED1: ::c_int = 0x02000000; +pub const TDF_SCHED2: ::c_int = 0x04000000; +pub const TDF_SCHED3: ::c_int = 0x08000000; +pub const TDF_ALRMPEND: ::c_int = 0x10000000; +pub const TDF_PROFPEND: ::c_int = 0x20000000; +pub const TDF_MACPEND: ::c_int = 0x40000000; + +pub const TDB_SUSPEND: ::c_int = 0x00000001; +pub const TDB_XSIG: ::c_int = 0x00000002; +pub const TDB_USERWR: ::c_int = 0x00000004; +pub const TDB_SCE: ::c_int = 0x00000008; +pub const TDB_SCX: ::c_int = 0x00000010; +pub const TDB_EXEC: ::c_int = 0x00000020; +pub const TDB_FORK: ::c_int = 0x00000040; +pub const TDB_STOPATFORK: ::c_int = 0x00000080; +pub const TDB_CHILD: ::c_int = 0x00000100; +pub const TDB_BORN: ::c_int = 0x00000200; +pub const TDB_EXIT: ::c_int = 0x00000400; +pub const TDB_VFORK: ::c_int = 0x00000800; +pub const TDB_FSTP: ::c_int = 0x00001000; +pub const TDB_STEP: ::c_int = 0x00002000; + +pub const TDP_OLDMASK: ::c_int = 0x00000001; +pub const TDP_INKTR: ::c_int = 0x00000002; +pub const TDP_INKTRACE: ::c_int = 0x00000004; +pub const TDP_BUFNEED: ::c_int = 0x00000008; +pub const TDP_COWINPROGRESS: ::c_int = 0x00000010; +pub const TDP_ALTSTACK: ::c_int = 0x00000020; +pub const TDP_DEADLKTREAT: ::c_int = 0x00000040; +pub const TDP_NOFAULTING: ::c_int = 0x00000080; +pub const TDP_OWEUPC: ::c_int = 0x00000200; +pub const TDP_ITHREAD: ::c_int = 0x00000400; +pub const TDP_SYNCIO: ::c_int = 0x00000800; +pub const TDP_SCHED1: ::c_int = 0x00001000; +pub const TDP_SCHED2: ::c_int = 0x00002000; +pub const TDP_SCHED3: ::c_int = 0x00004000; +pub const TDP_SCHED4: ::c_int = 0x00008000; +pub const TDP_GEOM: ::c_int = 0x00010000; +pub const TDP_SOFTDEP: ::c_int = 0x00020000; +pub const TDP_NORUNNINGBUF: ::c_int = 0x00040000; +pub const TDP_WAKEUP: ::c_int = 0x00080000; +pub const TDP_INBDFLUSH: ::c_int = 0x00100000; +pub const TDP_KTHREAD: ::c_int = 0x00200000; +pub const TDP_CALLCHAIN: ::c_int = 0x00400000; +pub const TDP_IGNSUSP: ::c_int = 0x00800000; +pub const TDP_AUDITREC: ::c_int = 0x01000000; +pub const TDP_RFPPWAIT: ::c_int = 0x02000000; +pub const TDP_RESETSPUR: ::c_int = 0x04000000; +pub const TDP_NERRNO: ::c_int = 0x08000000; +pub const TDP_EXECVMSPC: ::c_int = 0x40000000; + +pub const TDI_SUSPENDED: ::c_int = 0x0001; +pub const TDI_SLEEPING: ::c_int = 0x0002; +pub const TDI_SWAPPED: ::c_int = 0x0004; +pub const TDI_LOCK: ::c_int = 0x0008; +pub const TDI_IWAIT: ::c_int = 0x0010; + +pub const P_ADVLOCK: ::c_int = 0x00000001; +pub const P_CONTROLT: ::c_int = 0x00000002; +pub const P_KPROC: ::c_int = 0x00000004; +pub const P_UNUSED3: ::c_int = 0x00000008; +pub const P_PPWAIT: ::c_int = 0x00000010; +pub const P_PROFIL: ::c_int = 0x00000020; +pub const P_STOPPROF: ::c_int = 0x00000040; +pub const P_HADTHREADS: ::c_int = 0x00000080; +pub const P_SUGID: ::c_int = 0x00000100; +pub const P_SYSTEM: ::c_int = 0x00000200; +pub const P_SINGLE_EXIT: ::c_int = 0x00000400; +pub const P_TRACED: ::c_int = 0x00000800; +pub const P_WAITED: ::c_int = 0x00001000; +pub const P_WEXIT: ::c_int = 0x00002000; +pub const P_EXEC: ::c_int = 0x00004000; +pub const P_WKILLED: ::c_int = 0x00008000; +pub const P_CONTINUED: ::c_int = 0x00010000; +pub const P_STOPPED_SIG: ::c_int = 0x00020000; +pub const P_STOPPED_TRACE: ::c_int = 0x00040000; +pub const P_STOPPED_SINGLE: ::c_int = 0x00080000; +pub const P_PROTECTED: ::c_int = 0x00100000; +pub const P_SIGEVENT: ::c_int = 0x00200000; +pub const P_SINGLE_BOUNDARY: ::c_int = 0x00400000; +pub const P_HWPMC: ::c_int = 0x00800000; +pub const P_JAILED: ::c_int = 0x01000000; +pub const P_TOTAL_STOP: ::c_int = 0x02000000; +pub const P_INEXEC: ::c_int = 0x04000000; +pub const P_STATCHILD: ::c_int = 0x08000000; +pub const P_INMEM: ::c_int = 0x10000000; +pub const P_SWAPPINGOUT: ::c_int = 0x20000000; +pub const P_SWAPPINGIN: ::c_int = 0x40000000; +pub const P_PPTRACE: ::c_int = 0x80000000; +pub const P_STOPPED: ::c_int = P_STOPPED_SIG | P_STOPPED_SINGLE | P_STOPPED_TRACE; + +pub const P2_INHERIT_PROTECTED: ::c_int = 0x00000001; +pub const P2_NOTRACE: ::c_int = 0x00000002; +pub const P2_NOTRACE_EXEC: ::c_int = 0x00000004; +pub const P2_AST_SU: ::c_int = 0x00000008; +pub const P2_PTRACE_FSTP: ::c_int = 0x00000010; +pub const P2_TRAPCAP: ::c_int = 0x00000020; +pub const P2_STKGAP_DISABLE: ::c_int = 0x00000800; +pub const P2_STKGAP_DISABLE_EXEC: ::c_int = 0x00001000; + +pub const P_TREE_ORPHANED: ::c_int = 0x00000001; +pub const P_TREE_FIRST_ORPHAN: ::c_int = 0x00000002; +pub const P_TREE_REAPER: ::c_int = 0x00000004; + +pub const SIDL: ::c_char = 1; +pub const SRUN: ::c_char = 2; +pub const SSLEEP: ::c_char = 3; +pub const SSTOP: ::c_char = 4; +pub const SZOMB: ::c_char = 5; +pub const SWAIT: ::c_char = 6; +pub const SLOCK: ::c_char = 7; + +pub const P_MAGIC: ::c_int = 0xbeefface; + +pub const TDP_SIGFASTBLOCK: ::c_int = 0x00000100; +pub const TDP_UIOHELD: ::c_int = 0x10000000; +pub const TDP_SIGFASTPENDING: ::c_int = 0x80000000; +pub const TDP2_COMPAT32RB: ::c_int = 0x00000002; +pub const P2_PROTMAX_ENABLE: ::c_int = 0x00000200; +pub const P2_PROTMAX_DISABLE: ::c_int = 0x00000400; +pub const TDP2_SBPAGES: ::c_int = 0x00000001; +pub const P2_ASLR_ENABLE: ::c_int = 0x00000040; +pub const P2_ASLR_DISABLE: ::c_int = 0x00000080; +pub const P2_ASLR_IGNSTART: ::c_int = 0x00000100; +pub const P_TREE_GRPEXITED: ::c_int = 0x00000008; + +// libprocstat.h +pub const PS_FST_VTYPE_VNON: ::c_int = 1; +pub const PS_FST_VTYPE_VREG: ::c_int = 2; +pub const PS_FST_VTYPE_VDIR: ::c_int = 3; +pub const PS_FST_VTYPE_VBLK: ::c_int = 4; +pub const PS_FST_VTYPE_VCHR: ::c_int = 5; +pub const PS_FST_VTYPE_VLNK: ::c_int = 6; +pub const PS_FST_VTYPE_VSOCK: ::c_int = 7; +pub const PS_FST_VTYPE_VFIFO: ::c_int = 8; +pub const PS_FST_VTYPE_VBAD: ::c_int = 9; +pub const PS_FST_VTYPE_UNKNOWN: ::c_int = 255; + +pub const PS_FST_TYPE_VNODE: ::c_int = 1; +pub const PS_FST_TYPE_FIFO: ::c_int = 2; +pub const PS_FST_TYPE_SOCKET: ::c_int = 3; +pub const PS_FST_TYPE_PIPE: ::c_int = 4; +pub const PS_FST_TYPE_PTS: ::c_int = 5; +pub const PS_FST_TYPE_KQUEUE: ::c_int = 6; +pub const PS_FST_TYPE_MQUEUE: ::c_int = 8; +pub const PS_FST_TYPE_SHM: ::c_int = 9; +pub const PS_FST_TYPE_SEM: ::c_int = 10; +pub const PS_FST_TYPE_UNKNOWN: ::c_int = 11; +pub const PS_FST_TYPE_NONE: ::c_int = 12; +pub const PS_FST_TYPE_PROCDESC: ::c_int = 13; +pub const PS_FST_TYPE_DEV: ::c_int = 14; +pub const PS_FST_TYPE_EVENTFD: ::c_int = 15; + +pub const PS_FST_UFLAG_RDIR: ::c_int = 0x0001; +pub const PS_FST_UFLAG_CDIR: ::c_int = 0x0002; +pub const PS_FST_UFLAG_JAIL: ::c_int = 0x0004; +pub const PS_FST_UFLAG_TRACE: ::c_int = 0x0008; +pub const PS_FST_UFLAG_TEXT: ::c_int = 0x0010; +pub const PS_FST_UFLAG_MMAP: ::c_int = 0x0020; +pub const PS_FST_UFLAG_CTTY: ::c_int = 0x0040; + +pub const PS_FST_FFLAG_READ: ::c_int = 0x0001; +pub const PS_FST_FFLAG_WRITE: ::c_int = 0x0002; +pub const PS_FST_FFLAG_NONBLOCK: ::c_int = 0x0004; +pub const PS_FST_FFLAG_APPEND: ::c_int = 0x0008; +pub const PS_FST_FFLAG_SHLOCK: ::c_int = 0x0010; +pub const PS_FST_FFLAG_EXLOCK: ::c_int = 0x0020; +pub const PS_FST_FFLAG_ASYNC: ::c_int = 0x0040; +pub const PS_FST_FFLAG_SYNC: ::c_int = 0x0080; +pub const PS_FST_FFLAG_NOFOLLOW: ::c_int = 0x0100; +pub const PS_FST_FFLAG_CREAT: ::c_int = 0x0200; +pub const PS_FST_FFLAG_TRUNC: ::c_int = 0x0400; +pub const PS_FST_FFLAG_EXCL: ::c_int = 0x0800; +pub const PS_FST_FFLAG_DIRECT: ::c_int = 0x1000; +pub const PS_FST_FFLAG_EXEC: ::c_int = 0x2000; +pub const PS_FST_FFLAG_HASLOCK: ::c_int = 0x4000; + +// sys/mount.h + +/// File identifier. +/// These are unique per filesystem on a single machine. +/// +/// Note that the offset of fid_data is 4 bytes, so care must be taken to avoid +/// undefined behavior accessing unaligned fields within an embedded struct. +pub const MAXFIDSZ: ::c_int = 16; +/// Length of type name including null. +pub const MFSNAMELEN: ::c_int = 16; +cfg_if! { + if #[cfg(any(freebsd10, freebsd11))] { + /// Size of on/from name bufs. + pub const MNAMELEN: ::c_int = 88; + } else { + /// Size of on/from name bufs. + pub const MNAMELEN: ::c_int = 1024; + } +} + +/// Using journaled soft updates. +pub const MNT_SUJ: u64 = 0x100000000; +/// Mounted by automountd(8). +pub const MNT_AUTOMOUNTED: u64 = 0x200000000; +/// Filesys metadata untrusted. +pub const MNT_UNTRUSTED: u64 = 0x800000000; + +/// Require TLS. +pub const MNT_EXTLS: u64 = 0x4000000000; +/// Require TLS with client cert. +pub const MNT_EXTLSCERT: u64 = 0x8000000000; +/// Require TLS with user cert. +pub const MNT_EXTLSCERTUSER: u64 = 0x10000000000; + +/// Filesystem is stored locally. +pub const MNT_LOCAL: u64 = 0x000001000; +/// Quotas are enabled on fs. +pub const MNT_QUOTA: u64 = 0x000002000; +/// Identifies the root fs. +pub const MNT_ROOTFS: u64 = 0x000004000; +/// Mounted by a user. +pub const MNT_USER: u64 = 0x000008000; +/// Do not show entry in df. +pub const MNT_IGNORE: u64 = 0x000800000; +/// Filesystem is verified. +pub const MNT_VERIFIED: u64 = 0x400000000; + +/// Do not cover a mount point. +pub const MNT_NOCOVER: u64 = 0x001000000000; +/// Only mount on empty dir. +pub const MNT_EMPTYDIR: u64 = 0x002000000000; +/// Recursively unmount uppers. +pub const MNT_RECURSE: u64 = 0x100000000000; +/// Unmount in async context. +pub const MNT_DEFERRED: u64 = 0x200000000000; + +/// Get configured filesystems. +pub const VFS_VFSCONF: ::c_int = 0; +/// Generic filesystem information. +pub const VFS_GENERIC: ::c_int = 0; + +/// int: highest defined filesystem type. +pub const VFS_MAXTYPENUM: ::c_int = 1; +/// struct: vfsconf for filesystem given as next argument. +pub const VFS_CONF: ::c_int = 2; + +/// Synchronously wait for I/O to complete. +pub const MNT_WAIT: ::c_int = 1; +/// Start all I/O, but do not wait for it. +pub const MNT_NOWAIT: ::c_int = 2; +/// Push data not written by filesystem syncer. +pub const MNT_LAZY: ::c_int = 3; +/// Suspend file system after sync. +pub const MNT_SUSPEND: ::c_int = 4; + +pub const MAXSECFLAVORS: ::c_int = 5; + +/// Statically compiled into kernel. +pub const VFCF_STATIC: ::c_int = 0x00010000; +/// May get data over the network. +pub const VFCF_NETWORK: ::c_int = 0x00020000; +/// Writes are not implemented. +pub const VFCF_READONLY: ::c_int = 0x00040000; +/// Data does not represent real files. +pub const VFCF_SYNTHETIC: ::c_int = 0x00080000; +/// Aliases some other mounted FS. +pub const VFCF_LOOPBACK: ::c_int = 0x00100000; +/// Stores file names as Unicode. +pub const VFCF_UNICODE: ::c_int = 0x00200000; +/// Can be mounted from within a jail. +pub const VFCF_JAIL: ::c_int = 0x00400000; +/// Supports delegated administration. +pub const VFCF_DELEGADMIN: ::c_int = 0x00800000; +/// Stop at Boundary: defer stop requests to kernel->user (AST) transition. +pub const VFCF_SBDRY: ::c_int = 0x01000000; + +// time.h + +/// not on dst +pub const DST_NONE: ::c_int = 0; +/// USA style dst +pub const DST_USA: ::c_int = 1; +/// Australian style dst +pub const DST_AUST: ::c_int = 2; +/// Western European dst +pub const DST_WET: ::c_int = 3; +/// Middle European dst +pub const DST_MET: ::c_int = 4; +/// Eastern European dst +pub const DST_EET: ::c_int = 5; +/// Canada +pub const DST_CAN: ::c_int = 6; + +pub const CPUCLOCK_WHICH_PID: ::c_int = 0; +pub const CPUCLOCK_WHICH_TID: ::c_int = 1; + +pub const MFD_CLOEXEC: ::c_uint = 0x00000001; +pub const MFD_ALLOW_SEALING: ::c_uint = 0x00000002; +pub const MFD_HUGETLB: ::c_uint = 0x00000004; + +pub const SHM_LARGEPAGE_ALLOC_DEFAULT: ::c_int = 0; +pub const SHM_LARGEPAGE_ALLOC_NOWAIT: ::c_int = 1; +pub const SHM_LARGEPAGE_ALLOC_HARD: ::c_int = 2; +pub const SHM_RENAME_NOREPLACE: ::c_int = 1 << 0; +pub const SHM_RENAME_EXCHANGE: ::c_int = 1 << 1; + const_fn! { {const} fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES @@ -1527,11 +3746,31 @@ f! { () } - pub fn CPU_ISSET(cpu: usize, cpuset: &mut cpuset_t) -> bool { + pub fn CPU_ISSET(cpu: usize, cpuset: &cpuset_t) -> bool { let bitset_bits = ::mem::size_of::<::c_long>(); let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); 0 != cpuset.__bits[idx] & (1 << offset) } + + pub fn CPU_COUNT(cpuset: &cpuset_t) -> ::c_int { + let mut s: u32 = 0; + let cpuset_size = ::mem::size_of::<cpuset_t>(); + let bitset_bits = ::mem::size_of::<::c_long>(); + + for i in cpuset.__bits[..(cpuset_size / bitset_bits)].iter() { + s += i.count_ones(); + }; + s as ::c_int + } + + pub fn SOCKCRED2SIZE(ngrps: usize) -> usize { + let ngrps = if ngrps > 0 { + ngrps - 1 + } else { + 0 + }; + ::mem::size_of::<sockcred2>() + ::mem::size_of::<::gid_t>() * ngrps + } } safe_f! { @@ -1540,6 +3779,26 @@ safe_f! { } } +cfg_if! { + if #[cfg(not(any(freebsd10, freebsd11)))] { + extern "C" { + pub fn fhlink(fhp: *mut fhandle_t, to: *const ::c_char) -> ::c_int; + pub fn fhlinkat(fhp: *mut fhandle_t, tofd: ::c_int, to: *const ::c_char) -> ::c_int; + pub fn fhreadlink( + fhp: *mut fhandle_t, + buf: *mut ::c_char, + bufsize: ::size_t, + ) -> ::c_int; + pub fn getfhat( + fd: ::c_int, + path: *mut ::c_char, + fhp: *mut fhandle, + flag: ::c_int, + ) -> ::c_int; + } + } +} + extern "C" { pub fn __error() -> *mut ::c_int; @@ -1555,6 +3814,13 @@ extern "C" { ) -> ::c_int; pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int; + pub fn devname_r( + dev: ::dev_t, + mode: ::mode_t, + buf: *mut ::c_char, + len: ::c_int, + ) -> *mut ::c_char; + pub fn extattr_delete_fd( fd: ::c_int, attrnamespace: ::c_int, @@ -1631,6 +3897,14 @@ extern "C" { nbytes: ::size_t, ) -> ::ssize_t; + pub fn fspacectl( + fd: ::c_int, + cmd: ::c_int, + rqsr: *const spacectl_range, + flags: ::c_int, + rmsr: *mut spacectl_range, + ) -> ::c_int; + pub fn jail(jail: *mut ::jail) -> ::c_int; pub fn jail_attach(jid: ::c_int) -> ::c_int; pub fn jail_remove(jid: ::c_int) -> ::c_int; @@ -1644,8 +3918,6 @@ extern "C" { sevp: *mut sigevent, ) -> ::c_int; - pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int; - pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, advise: ::c_int) -> ::c_int; pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int; pub fn mkostemps(template: *mut ::c_char, suffixlen: ::c_int, flags: ::c_int) -> ::c_int; @@ -1667,6 +3939,9 @@ extern "C" { pub fn shmat(shmid: ::c_int, shmaddr: *const ::c_void, shmflg: ::c_int) -> *mut ::c_void; pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int; pub fn shmctl(shmid: ::c_int, cmd: ::c_int, buf: *mut ::shmid_ds) -> ::c_int; + pub fn semget(key: ::key_t, nsems: ::c_int, semflg: ::c_int) -> ::c_int; + pub fn semctl(semid: ::c_int, semnum: ::c_int, cmd: ::c_int, ...) -> ::c_int; + pub fn semop(semid: ::c_int, sops: *mut sembuf, nsops: ::size_t) -> ::c_int; pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut ::msqid_ds) -> ::c_int; pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int; pub fn msgsnd( @@ -1676,11 +3951,6 @@ extern "C" { msgflg: ::c_int, ) -> ::c_int; pub fn cfmakesane(termios: *mut ::termios); - pub fn fexecve( - fd: ::c_int, - argv: *const *const ::c_char, - envp: *const *const ::c_char, - ) -> ::c_int; pub fn pdfork(fdp: *mut ::c_int, flags: ::c_int) -> ::pid_t; pub fn pdgetpid(fd: ::c_int, pidp: *mut ::pid_t) -> ::c_int; @@ -1765,6 +4035,11 @@ extern "C" { newfd: ::c_int, ) -> ::c_int; + pub fn uuidgen(store: *mut uuid, count: ::c_int) -> ::c_int; + + pub fn thr_kill(id: ::c_long, sig: ::c_int) -> ::c_int; + pub fn thr_kill2(pid: ::pid_t, id: ::c_long, sig: ::c_int) -> ::c_int; + pub fn thr_self(tid: *mut ::c_long) -> ::c_int; pub fn pthread_getthreadid_np() -> ::c_int; pub fn pthread_getaffinity_np( td: ::pthread_t, @@ -1777,6 +4052,26 @@ extern "C" { cpusetp: *const cpuset_t, ) -> ::c_int; + // sched.h linux compatibility api + pub fn sched_getaffinity(pid: ::pid_t, cpusetsz: ::size_t, cpuset: *mut ::cpuset_t) -> ::c_int; + pub fn sched_setaffinity( + pid: ::pid_t, + cpusetsz: ::size_t, + cpuset: *const ::cpuset_t, + ) -> ::c_int; + pub fn sched_getcpu() -> ::c_int; + + pub fn pthread_mutex_consistent(mutex: *mut ::pthread_mutex_t) -> ::c_int; + + pub fn pthread_mutexattr_getrobust( + attr: *mut ::pthread_mutexattr_t, + robust: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_mutexattr_setrobust( + attr: *mut ::pthread_mutexattr_t, + robust: ::c_int, + ) -> ::c_int; + pub fn pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: ::c_int) -> ::c_int; pub fn pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> ::c_int; pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> ::c_int; @@ -1811,7 +4106,25 @@ extern "C" { needlelen: ::size_t, ) -> *mut ::c_void; + pub fn fhopen(fhp: *const fhandle_t, flags: ::c_int) -> ::c_int; + pub fn fhstat(fhp: *const fhandle, buf: *mut ::stat) -> ::c_int; + pub fn fhstatfs(fhp: *const fhandle_t, buf: *mut ::statfs) -> ::c_int; + pub fn getfh(path: *const ::c_char, fhp: *mut fhandle_t) -> ::c_int; + pub fn lgetfh(path: *const ::c_char, fhp: *mut fhandle_t) -> ::c_int; + pub fn getfsstat(buf: *mut ::statfs, bufsize: ::c_long, mode: ::c_int) -> ::c_int; + #[cfg_attr( + all(target_os = "freebsd", freebsd11), + link_name = "getmntinfo@FBSD_1.0" + )] + pub fn getmntinfo(mntbufp: *mut *mut ::statfs, mode: ::c_int) -> ::c_int; + pub fn mount( + type_: *const ::c_char, + dir: *const ::c_char, + flags: ::c_int, + data: *mut ::c_void, + ) -> ::c_int; pub fn nmount(iov: *mut ::iovec, niov: ::c_uint, flags: ::c_int) -> ::c_int; + pub fn setproctitle(fmt: *const ::c_char, ...); pub fn rfork(flags: ::c_int) -> ::c_int; pub fn cpuset_getaffinity( @@ -1886,6 +4199,96 @@ extern "C" { pub fn nallocx(size: ::size_t, flags: ::c_int) -> ::size_t; pub fn procctl(idtype: ::idtype_t, id: ::id_t, cmd: ::c_int, data: *mut ::c_void) -> ::c_int; + + pub fn getpagesize() -> ::c_int; + pub fn getpagesizes(pagesize: *mut ::size_t, nelem: ::c_int) -> ::c_int; + + pub fn adjtime(arg1: *const ::timeval, arg2: *mut ::timeval) -> ::c_int; + pub fn clock_getcpuclockid2(arg1: ::id_t, arg2: ::c_int, arg3: *mut clockid_t) -> ::c_int; + + pub fn shm_create_largepage( + path: *const ::c_char, + flags: ::c_int, + psind: ::c_int, + alloc_policy: ::c_int, + mode: ::mode_t, + ) -> ::c_int; + pub fn shm_rename( + path_from: *const ::c_char, + path_to: *const ::c_char, + flags: ::c_int, + ) -> ::c_int; + pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int; + pub fn setaudit(auditinfo: *const auditinfo_t) -> ::c_int; +} + +#[link(name = "kvm")] +extern "C" { + pub fn kvm_open( + execfile: *const ::c_char, + corefile: *const ::c_char, + swapfile: *const ::c_char, + flags: ::c_int, + errstr: *const ::c_char, + ) -> *mut kvm_t; + pub fn kvm_close(kd: *mut kvm_t) -> ::c_int; + pub fn kvm_dpcpu_setcpu(kd: *mut kvm_t, cpu: ::c_uint) -> ::c_int; + pub fn kvm_getargv(kd: *mut kvm_t, p: *const kinfo_proc, nchr: ::c_int) -> *mut *mut ::c_char; + pub fn kvm_getcptime(kd: *mut kvm_t, cp_time: *mut ::c_long) -> ::c_int; + pub fn kvm_getenvv(kd: *mut kvm_t, p: *const kinfo_proc, nchr: ::c_int) -> *mut *mut ::c_char; + pub fn kvm_geterr(kd: *mut kvm_t) -> *mut ::c_char; + pub fn kvm_getloadavg(kd: *mut kvm_t, loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int; + pub fn kvm_getmaxcpu(kd: *mut kvm_t) -> ::c_int; + pub fn kvm_getncpus(kd: *mut kvm_t) -> ::c_int; + pub fn kvm_getpcpu(kd: *mut kvm_t, cpu: ::c_int) -> *mut ::c_void; + pub fn kvm_counter_u64_fetch(kd: *mut kvm_t, base: ::c_ulong) -> u64; + pub fn kvm_getprocs( + kd: *mut kvm_t, + op: ::c_int, + arg: ::c_int, + cnt: *mut ::c_int, + ) -> *mut kinfo_proc; + pub fn kvm_getswapinfo( + kd: *mut kvm_t, + info: *mut kvm_swap, + maxswap: ::c_int, + flags: ::c_int, + ) -> ::c_int; + pub fn kvm_native(kd: *mut kvm_t) -> ::c_int; + pub fn kvm_nlist(kd: *mut kvm_t, nl: *mut nlist) -> ::c_int; + pub fn kvm_nlist2(kd: *mut kvm_t, nl: *mut kvm_nlist) -> ::c_int; + pub fn kvm_openfiles( + execfile: *const ::c_char, + corefile: *const ::c_char, + swapfile: *const ::c_char, + flags: ::c_int, + errbuf: *mut ::c_char, + ) -> *mut kvm_t; + pub fn kvm_read( + kd: *mut kvm_t, + addr: ::c_ulong, + buf: *mut ::c_void, + nbytes: ::size_t, + ) -> ::ssize_t; + pub fn kvm_read_zpcpu( + kd: *mut kvm_t, + base: ::c_ulong, + buf: *mut ::c_void, + size: ::size_t, + cpu: ::c_int, + ) -> ::ssize_t; + pub fn kvm_read2( + kd: *mut kvm_t, + addr: kvaddr_t, + buf: *mut ::c_void, + nbytes: ::size_t, + ) -> ::ssize_t; + pub fn kvm_write( + kd: *mut kvm_t, + addr: ::c_ulong, + buf: *const ::c_void, + nbytes: ::size_t, + ) -> ::ssize_t; } #[link(name = "util")] @@ -1910,6 +4313,19 @@ extern "C" { pub fn kld_load(name: *const ::c_char) -> ::c_int; pub fn kinfo_getvmmap(pid: ::pid_t, cntp: *mut ::c_int) -> *mut kinfo_vmentry; + + pub fn hexdump(ptr: *const ::c_void, length: ::c_int, hdr: *const ::c_char, flags: ::c_int); + pub fn humanize_number( + buf: *mut ::c_char, + len: ::size_t, + number: i64, + suffix: *const ::c_char, + scale: ::c_int, + flags: ::c_int, + ) -> ::c_int; + + pub fn flopen(path: *const ::c_char, flags: ::c_int, ...) -> ::c_int; + pub fn flopenat(fd: ::c_int, path: *const ::c_char, flags: ::c_int, ...) -> ::c_int; } #[link(name = "procstat")] @@ -1935,10 +4351,123 @@ extern "C" { ) -> *mut kinfo_vmentry; pub fn procstat_freevmmap(procstat: *mut procstat, vmmap: *mut kinfo_vmentry); pub fn procstat_close(procstat: *mut procstat); + pub fn procstat_freeargv(procstat: *mut procstat); + pub fn procstat_freeenvv(procstat: *mut procstat); + pub fn procstat_freegroups(procstat: *mut procstat, groups: *mut ::gid_t); + pub fn procstat_freeptlwpinfo(procstat: *mut procstat, pl: *mut ptrace_lwpinfo); + pub fn procstat_getargv( + procstat: *mut procstat, + kp: *mut kinfo_proc, + nchr: ::size_t, + ) -> *mut *mut ::c_char; + pub fn procstat_getenvv( + procstat: *mut procstat, + kp: *mut kinfo_proc, + nchr: ::size_t, + ) -> *mut *mut ::c_char; + pub fn procstat_getgroups( + procstat: *mut procstat, + kp: *mut kinfo_proc, + count: *mut ::c_uint, + ) -> *mut ::gid_t; + pub fn procstat_getosrel( + procstat: *mut procstat, + kp: *mut kinfo_proc, + osrelp: *mut ::c_int, + ) -> ::c_int; + pub fn procstat_getpathname( + procstat: *mut procstat, + kp: *mut kinfo_proc, + pathname: *mut ::c_char, + maxlen: ::size_t, + ) -> ::c_int; + pub fn procstat_getrlimit( + procstat: *mut procstat, + kp: *mut kinfo_proc, + which: ::c_int, + rlimit: *mut ::rlimit, + ) -> ::c_int; + pub fn procstat_getumask( + procstat: *mut procstat, + kp: *mut kinfo_proc, + maskp: *mut ::c_ushort, + ) -> ::c_int; + pub fn procstat_open_core(filename: *const ::c_char) -> *mut procstat; + pub fn procstat_open_kvm(nlistf: *const ::c_char, memf: *const ::c_char) -> *mut procstat; + pub fn procstat_get_socket_info( + proc_: *mut procstat, + fst: *mut filestat, + sock: *mut sockstat, + errbuf: *mut ::c_char, + ) -> ::c_int; + pub fn procstat_get_vnode_info( + proc_: *mut procstat, + fst: *mut filestat, + vn: *mut vnstat, + errbuf: *mut ::c_char, + ) -> ::c_int; + pub fn procstat_get_pts_info( + proc_: *mut procstat, + fst: *mut filestat, + pts: *mut ptsstat, + errbuf: *mut ::c_char, + ) -> ::c_int; + pub fn procstat_get_shm_info( + proc_: *mut procstat, + fst: *mut filestat, + shm: *mut shmstat, + errbuf: *mut ::c_char, + ) -> ::c_int; +} + +#[link(name = "rt")] +extern "C" { + pub fn timer_create(clock_id: clockid_t, evp: *mut sigevent, timerid: *mut timer_t) -> ::c_int; + pub fn timer_delete(timerid: timer_t) -> ::c_int; + pub fn timer_getoverrun(timerid: timer_t) -> ::c_int; + pub fn timer_gettime(timerid: timer_t, value: *mut itimerspec) -> ::c_int; + pub fn timer_settime( + timerid: timer_t, + flags: ::c_int, + value: *const itimerspec, + ovalue: *mut itimerspec, + ) -> ::c_int; +} + +#[link(name = "devstat")] +extern "C" { + pub fn devstat_getnumdevs(kd: *mut kvm_t) -> ::c_int; + pub fn devstat_getgeneration(kd: *mut kvm_t) -> ::c_long; + pub fn devstat_getversion(kd: *mut kvm_t) -> ::c_int; + pub fn devstat_checkversion(kd: *mut kvm_t) -> ::c_int; + pub fn devstat_selectdevs( + dev_select: *mut *mut device_selection, + num_selected: *mut ::c_int, + num_selections: *mut ::c_int, + select_generation: *mut ::c_long, + current_generation: ::c_long, + devices: *mut devstat, + numdevs: ::c_int, + matches: *mut devstat_match, + num_matches: ::c_int, + dev_selections: *mut *mut ::c_char, + num_dev_selections: ::c_int, + select_mode: devstat_select_mode, + maxshowdevs: ::c_int, + perf_select: ::c_int, + ) -> ::c_int; + pub fn devstat_buildmatch( + match_str: *mut ::c_char, + matches: *mut *mut devstat_match, + num_matches: *mut ::c_int, + ) -> ::c_int; } cfg_if! { - if #[cfg(freebsd13)] { + if #[cfg(freebsd14)] { + mod freebsd14; + pub use self::freebsd14::*; + } else if #[cfg(freebsd13)] { mod freebsd13; pub use self::freebsd13::*; } else if #[cfg(freebsd12)] { @@ -1971,6 +4500,9 @@ cfg_if! { } else if #[cfg(target_arch = "powerpc")] { mod powerpc; pub use self::powerpc::*; + } else if #[cfg(target_arch = "riscv64")] { + mod riscv64; + pub use self::riscv64::*; } else { // Unknown target_arch } diff --git a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs new file mode 100644 index 00000000..c91a8dfb --- /dev/null +++ b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs @@ -0,0 +1,154 @@ +pub type c_char = u8; +pub type c_long = i64; +pub type c_ulong = u64; +pub type wchar_t = ::c_int; +pub type time_t = i64; +pub type suseconds_t = ::c_long; +pub type register_t = i64; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + +s_no_extra_traits! { + pub struct gpregs { + pub gp_ra: ::register_t, + pub gp_sp: ::register_t, + pub gp_gp: ::register_t, + pub gp_tp: ::register_t, + pub gp_t: [::register_t; 7], + pub gp_s: [::register_t; 12], + pub gp_a: [::register_t; 8], + pub gp_sepc: ::register_t, + pub gp_sstatus: ::register_t, + } + + pub struct fpregs { + pub fp_x: [[::register_t; 2]; 32], + pub fp_fcsr: ::register_t, + pub fp_flags: ::c_int, + pub fp_pad: ::c_int, + } + + pub struct mcontext_t { + pub mc_gpregs: gpregs, + pub mc_fpregs: fpregs, + pub mc_flags: ::c_int, + pub mc_pad: ::c_int, + pub mc_spare: [u64; 8], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for gpregs { + fn eq(&self, other: &gpregs) -> bool { + self.gp_ra == other.gp_ra && + self.gp_sp == other.gp_sp && + self.gp_gp == other.gp_gp && + self.gp_tp == other.gp_tp && + self.gp_t.iter().zip(other.gp_t.iter()).all(|(a, b)| a == b) && + self.gp_s.iter().zip(other.gp_s.iter()).all(|(a, b)| a == b) && + self.gp_a.iter().zip(other.gp_a.iter()).all(|(a, b)| a == b) && + self.gp_sepc == other.gp_sepc && + self.gp_sstatus == other.gp_sstatus + } + } + impl Eq for gpregs {} + impl ::fmt::Debug for gpregs { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("gpregs") + .field("gp_ra", &self.gp_ra) + .field("gp_sp", &self.gp_sp) + .field("gp_gp", &self.gp_gp) + .field("gp_tp", &self.gp_tp) + .field("gp_t", &self.gp_t) + .field("gp_s", &self.gp_s) + .field("gp_a", &self.gp_a) + .field("gp_sepc", &self.gp_sepc) + .field("gp_sstatus", &self.gp_sstatus) + .finish() + } + } + impl ::hash::Hash for gpregs { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + self.gp_ra.hash(state); + self.gp_sp.hash(state); + self.gp_gp.hash(state); + self.gp_tp.hash(state); + self.gp_t.hash(state); + self.gp_s.hash(state); + self.gp_a.hash(state); + self.gp_sepc.hash(state); + self.gp_sstatus.hash(state); + } + } + impl PartialEq for fpregs { + fn eq(&self, other: &fpregs) -> bool { + self.fp_x == other.fp_x && + self.fp_fcsr == other.fp_fcsr && + self.fp_flags == other.fp_flags && + self.fp_pad == other.fp_pad + } + } + impl Eq for fpregs {} + impl ::fmt::Debug for fpregs { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("fpregs") + .field("fp_x", &self.fp_x) + .field("fp_fcsr", &self.fp_fcsr) + .field("fp_flags", &self.fp_flags) + .field("fp_pad", &self.fp_pad) + .finish() + } + } + impl ::hash::Hash for fpregs { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + self.fp_x.hash(state); + self.fp_fcsr.hash(state); + self.fp_flags.hash(state); + self.fp_pad.hash(state); + } + } + impl PartialEq for mcontext_t { + fn eq(&self, other: &mcontext_t) -> bool { + self.mc_gpregs == other.mc_gpregs && + self.mc_fpregs == other.mc_fpregs && + self.mc_flags == other.mc_flags && + self.mc_pad == other.mc_pad && + self.mc_spare.iter().zip(other.mc_spare.iter()).all(|(a, b)| a == b) + } + } + impl Eq for mcontext_t {} + impl ::fmt::Debug for mcontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mcontext_t") + .field("mc_gpregs", &self.mc_gpregs) + .field("mc_fpregs", &self.mc_fpregs) + .field("mc_flags", &self.mc_flags) + .field("mc_pad", &self.mc_pad) + .field("mc_spare", &self.mc_spare) + .finish() + } + } + impl ::hash::Hash for mcontext_t { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + self.mc_gpregs.hash(state); + self.mc_fpregs.hash(state); + self.mc_flags.hash(state); + self.mc_pad.hash(state); + self.mc_spare.hash(state); + } + } + } +} + +pub const MAP_32BIT: ::c_int = 0x00080000; +pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index f403f98c..ae1fcf78 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -93,6 +93,23 @@ s_no_extra_traits! { #[cfg(libc_union)] pub a_un: __c_anonymous_elf64_auxv_union, } + + pub struct kinfo_file { + pub kf_structsize: ::c_int, + pub kf_type: ::c_int, + pub kf_fd: ::c_int, + pub kf_ref_count: ::c_int, + pub kf_flags: ::c_int, + _kf_pad0: ::c_int, + pub kf_offset: i64, + _priv: [::uintptr_t; 38], // FIXME if needed + pub kf_status: u16, + _kf_pad1: u16, + _kf_ispare0: ::c_int, + pub kf_cap_rights: ::cap_rights_t, + _kf_cap_spare: u64, + pub kf_path: [::c_char; ::PATH_MAX as usize], + } } cfg_if! { @@ -236,6 +253,52 @@ cfg_if! { .finish() } } + + impl PartialEq for kinfo_file { + fn eq(&self, other: &kinfo_file) -> bool { + self.kf_structsize == other.kf_structsize && + self.kf_type == other.kf_type && + self.kf_fd == other.kf_fd && + self.kf_ref_count == other.kf_ref_count && + self.kf_flags == other.kf_flags && + self.kf_offset == other.kf_offset && + self.kf_status == other.kf_status && + self.kf_cap_rights == other.kf_cap_rights && + self.kf_path + .iter() + .zip(other.kf_path.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for kinfo_file {} + impl ::fmt::Debug for kinfo_file { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("kinfo_file") + .field("kf_structsize", &self.kf_structsize) + .field("kf_type", &self.kf_type) + .field("kf_fd", &self.kf_fd) + .field("kf_ref_count", &self.kf_ref_count) + .field("kf_flags", &self.kf_flags) + .field("kf_offset", &self.kf_offset) + .field("kf_status", &self.kf_status) + .field("kf_cap_rights", &self.kf_cap_rights) + .field("kf_path", &&self.kf_path[..]) + .finish() + } + } + impl ::hash::Hash for kinfo_file { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + self.kf_structsize.hash(state); + self.kf_type.hash(state); + self.kf_fd.hash(state); + self.kf_ref_count.hash(state); + self.kf_flags.hash(state); + self.kf_offset.hash(state); + self.kf_status.hash(state); + self.kf_cap_rights.hash(state); + self.kf_path.hash(state); + } + } } } diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 05648c9a..d9380bdc 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -90,6 +90,12 @@ s! { pub imr_interface: in_addr, } + pub struct ip_mreqn { + pub imr_multiaddr: in_addr, + pub imr_address: in_addr, + pub imr_ifindex: ::c_int, + } + pub struct glob_t { pub gl_pathc: ::size_t, pub gl_matchc: ::size_t, @@ -266,6 +272,11 @@ s! { pub time_state: ::c_int, } + pub struct accept_filter_arg { + pub af_name: [::c_char; 16], + af_arg: [[::c_char; 10]; 24], + } + pub struct ptrace_io_desc { pub piod_op: ::c_int, pub piod_offs: *mut ::c_void, @@ -573,6 +584,8 @@ pub const F_TEST: ::c_int = 3; pub const F_TLOCK: ::c_int = 2; pub const F_ULOCK: ::c_int = 0; pub const F_DUPFD_CLOEXEC: ::c_int = 17; +pub const F_DUP2FD: ::c_int = 10; +pub const F_DUP2FD_CLOEXEC: ::c_int = 18; pub const SIGHUP: ::c_int = 1; pub const SIGINT: ::c_int = 2; pub const SIGQUIT: ::c_int = 3; @@ -724,6 +737,14 @@ pub const POLLSTANDARD: ::c_short = ::POLLIN | ::POLLHUP | ::POLLNVAL; +pub const AI_PASSIVE: ::c_int = 0x00000001; +pub const AI_CANONNAME: ::c_int = 0x00000002; +pub const AI_NUMERICHOST: ::c_int = 0x00000004; +pub const AI_NUMERICSERV: ::c_int = 0x00000008; +pub const AI_ALL: ::c_int = 0x00000100; +pub const AI_ADDRCONFIG: ::c_int = 0x00000400; +pub const AI_V4MAPPED: ::c_int = 0x00000800; + pub const EAI_AGAIN: ::c_int = 2; pub const EAI_BADFLAGS: ::c_int = 3; pub const EAI_FAIL: ::c_int = 4; @@ -814,7 +835,6 @@ pub const MINCORE_REFERENCED: ::c_int = 0x2; pub const MINCORE_MODIFIED: ::c_int = 0x4; pub const MINCORE_REFERENCED_OTHER: ::c_int = 0x8; pub const MINCORE_MODIFIED_OTHER: ::c_int = 0x10; -pub const MINCORE_SUPER: ::c_int = 0x20; pub const AF_UNSPEC: ::c_int = 0; pub const AF_LOCAL: ::c_int = 1; @@ -1167,7 +1187,6 @@ pub const ST_NOSUID: ::c_ulong = 2; pub const NI_MAXHOST: ::size_t = 1025; -pub const XU_NGROUPS: ::c_int = 16; pub const XUCRED_VERSION: ::c_uint = 0; pub const RTLD_LOCAL: ::c_int = 0; @@ -1180,30 +1199,30 @@ pub const LOG_SECURITY: ::c_int = 13 << 3; pub const LOG_CONSOLE: ::c_int = 14 << 3; pub const LOG_NFACILITIES: ::c_int = 24; -pub const TIOCEXCL: ::c_uint = 0x2000740d; -pub const TIOCNXCL: ::c_uint = 0x2000740e; +pub const TIOCEXCL: ::c_ulong = 0x2000740d; +pub const TIOCNXCL: ::c_ulong = 0x2000740e; pub const TIOCFLUSH: ::c_ulong = 0x80047410; -pub const TIOCGETA: ::c_uint = 0x402c7413; +pub const TIOCGETA: ::c_ulong = 0x402c7413; pub const TIOCSETA: ::c_ulong = 0x802c7414; pub const TIOCSETAW: ::c_ulong = 0x802c7415; pub const TIOCSETAF: ::c_ulong = 0x802c7416; -pub const TIOCGETD: ::c_uint = 0x4004741a; +pub const TIOCGETD: ::c_ulong = 0x4004741a; pub const TIOCSETD: ::c_ulong = 0x8004741b; -pub const TIOCGDRAINWAIT: ::c_uint = 0x40047456; +pub const TIOCGDRAINWAIT: ::c_ulong = 0x40047456; pub const TIOCSDRAINWAIT: ::c_ulong = 0x80047457; -pub const TIOCTIMESTAMP: ::c_uint = 0x40107459; -pub const TIOCMGDTRWAIT: ::c_uint = 0x4004745a; +pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; +pub const TIOCMGDTRWAIT: ::c_ulong = 0x4004745a; pub const TIOCMSDTRWAIT: ::c_ulong = 0x8004745b; -pub const TIOCDRAIN: ::c_uint = 0x2000745e; +pub const TIOCDRAIN: ::c_ulong = 0x2000745e; pub const TIOCEXT: ::c_ulong = 0x80047460; -pub const TIOCSCTTY: ::c_uint = 0x20007461; +pub const TIOCSCTTY: ::c_ulong = 0x20007461; pub const TIOCCONS: ::c_ulong = 0x80047462; -pub const TIOCGSID: ::c_uint = 0x40047463; -pub const TIOCSTAT: ::c_uint = 0x20007465; +pub const TIOCGSID: ::c_ulong = 0x40047463; +pub const TIOCSTAT: ::c_ulong = 0x20007465; pub const TIOCUCNTL: ::c_ulong = 0x80047466; pub const TIOCSWINSZ: ::c_ulong = 0x80087467; -pub const TIOCGWINSZ: ::c_uint = 0x40087468; -pub const TIOCMGET: ::c_uint = 0x4004746a; +pub const TIOCGWINSZ: ::c_ulong = 0x40087468; +pub const TIOCMGET: ::c_ulong = 0x4004746a; pub const TIOCM_LE: ::c_int = 0x1; pub const TIOCM_DTR: ::c_int = 0x2; pub const TIOCM_RTS: ::c_int = 0x4; @@ -1218,8 +1237,8 @@ pub const TIOCM_RNG: ::c_int = 0x80; pub const TIOCMBIC: ::c_ulong = 0x8004746b; pub const TIOCMBIS: ::c_ulong = 0x8004746c; pub const TIOCMSET: ::c_ulong = 0x8004746d; -pub const TIOCSTART: ::c_uint = 0x2000746e; -pub const TIOCSTOP: ::c_uint = 0x2000746f; +pub const TIOCSTART: ::c_ulong = 0x2000746e; +pub const TIOCSTOP: ::c_ulong = 0x2000746f; pub const TIOCPKT: ::c_ulong = 0x80047470; pub const TIOCPKT_DATA: ::c_int = 0x0; pub const TIOCPKT_FLUSHREAD: ::c_int = 0x1; @@ -1229,13 +1248,13 @@ pub const TIOCPKT_START: ::c_int = 0x8; pub const TIOCPKT_NOSTOP: ::c_int = 0x10; pub const TIOCPKT_DOSTOP: ::c_int = 0x20; pub const TIOCPKT_IOCTL: ::c_int = 0x40; -pub const TIOCNOTTY: ::c_uint = 0x20007471; +pub const TIOCNOTTY: ::c_ulong = 0x20007471; pub const TIOCSTI: ::c_ulong = 0x80017472; -pub const TIOCOUTQ: ::c_uint = 0x40047473; +pub const TIOCOUTQ: ::c_ulong = 0x40047473; pub const TIOCSPGRP: ::c_ulong = 0x80047476; -pub const TIOCGPGRP: ::c_uint = 0x40047477; -pub const TIOCCDTR: ::c_uint = 0x20007478; -pub const TIOCSDTR: ::c_uint = 0x20007479; +pub const TIOCGPGRP: ::c_ulong = 0x40047477; +pub const TIOCCDTR: ::c_ulong = 0x20007478; +pub const TIOCSDTR: ::c_ulong = 0x20007479; pub const TTYDISC: ::c_int = 0x0; pub const SLIPDISC: ::c_int = 0x4; pub const PPPDISC: ::c_int = 0x5; @@ -1253,7 +1272,6 @@ pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e; pub const FIODTYPE: ::c_ulong = 0x4004667a; pub const FIOGETLBA: ::c_ulong = 0x40046679; -pub const FIODGNAME: ::c_ulong = 0x80106678; pub const B0: speed_t = 0; pub const B50: speed_t = 50; @@ -1436,6 +1454,11 @@ extern "C" { pub fn duplocale(base: ::locale_t) -> ::locale_t; pub fn endutxent(); pub fn fchflags(fd: ::c_int, flags: ::c_ulong) -> ::c_int; + pub fn fexecve( + fd: ::c_int, + argv: *const *const ::c_char, + envp: *const *const ::c_char, + ) -> ::c_int; pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; pub fn getdomainname(name: *mut ::c_char, len: ::c_int) -> ::c_int; pub fn getgrent_r( @@ -1466,6 +1489,8 @@ extern "C" { flags: ::c_int, ) -> ::c_int; pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int; + pub fn getresgid(rgid: *mut ::gid_t, egid: *mut ::gid_t, sgid: *mut ::gid_t) -> ::c_int; + pub fn getresuid(ruid: *mut ::uid_t, euid: *mut ::uid_t, suid: *mut ::uid_t) -> ::c_int; pub fn getutxent() -> *mut utmpx; pub fn getutxid(ut: *const utmpx) -> *mut utmpx; pub fn getutxline(ut: *const utmpx) -> *mut utmpx; @@ -1500,6 +1525,8 @@ extern "C" { pub fn newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t; pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char; pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; + pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int; + pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, advise: ::c_int) -> ::c_int; pub fn ppoll( fds: *mut ::pollfd, nfds: ::nfds_t, @@ -1565,13 +1592,16 @@ extern "C" { ) -> ::c_int; pub fn pthread_barrier_destroy(barrier: *mut pthread_barrier_t) -> ::c_int; pub fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> ::c_int; + pub fn pthread_get_name_np(tid: ::pthread_t, name: *mut ::c_char, len: ::size_t); pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: *mut ::c_char, data: ::c_int) -> ::c_int; + pub fn utrace(addr: *const ::c_void, len: ::size_t) -> ::c_int; pub fn pututxline(ut: *const utmpx) -> *mut utmpx; pub fn pwritev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t; pub fn querylocale(mask: ::c_int, loc: ::locale_t) -> *const ::c_char; pub fn rtprio(function: ::c_int, pid: ::pid_t, rtp: *mut rtprio) -> ::c_int; + pub fn sched_rr_get_interval(pid: ::pid_t, t: *mut ::timespec) -> ::c_int; pub fn sched_getparam(pid: ::pid_t, param: *mut sched_param) -> ::c_int; pub fn sched_setparam(pid: ::pid_t, param: *const sched_param) -> ::c_int; pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; @@ -1719,6 +1749,13 @@ extern "C" { winp: *mut ::winsize, ) -> ::pid_t; pub fn login_tty(fd: ::c_int) -> ::c_int; + pub fn fparseln( + stream: *mut ::FILE, + len: *mut ::size_t, + lineno: *mut ::size_t, + delim: *const ::c_char, + flags: ::c_int, + ) -> *mut ::c_char; } #[link(name = "execinfo")] diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index a08506d1..a0729ee5 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -867,6 +867,16 @@ extern "C" { pub fn arc4random() -> u32; pub fn arc4random_buf(buf: *mut ::c_void, size: ::size_t); pub fn arc4random_uniform(l: u32) -> u32; + + pub fn drand48() -> ::c_double; + pub fn erand48(xseed: *mut ::c_ushort) -> ::c_double; + pub fn lrand48() -> ::c_long; + pub fn nrand48(xseed: *mut ::c_ushort) -> ::c_long; + pub fn mrand48() -> ::c_long; + pub fn jrand48(xseed: *mut ::c_ushort) -> ::c_long; + pub fn srand48(seed: ::c_long); + pub fn seed48(xseed: *mut ::c_ushort) -> *mut ::c_ushort; + pub fn lcong48(p: *mut ::c_ushort); } cfg_if! { diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 4e9cd1bc..7356e7ae 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -747,6 +747,7 @@ extern "C" { pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void; pub fn gethostid() -> ::c_long; pub fn sethostid(hostid: ::c_long) -> ::c_int; + pub fn ftok(path: *const ::c_char, id: ::c_int) -> ::key_t; } cfg_if! { diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index cf383798..ef587788 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -13,6 +13,7 @@ pub type shmatt_t = ::c_uint; pub type cpuid_t = u64; pub type cpuset_t = _cpuset; pub type pthread_spin_t = ::c_uchar; +pub type timer_t = ::c_int; // elf.h @@ -34,6 +35,14 @@ pub type Elf64_Xword = u64; pub type iconv_t = *mut ::c_void; +e! { + pub enum fae_action { + FAE_OPEN, + FAE_DUP2, + FAE_CLOSE, + } +} + cfg_if! { if #[cfg(target_pointer_width = "64")] { type Elf_Addr = Elf64_Addr; @@ -120,6 +129,11 @@ s! { pub mq_curmsgs: ::c_long, } + pub struct itimerspec { + pub it_interval: ::timespec, + pub it_value: ::timespec, + } + pub struct sigset_t { __bits: [u32; 4], } @@ -329,6 +343,14 @@ s! { pub sc_groups: [::gid_t; 1], } + pub struct uucred { + pub cr_unused: ::c_ushort, + pub cr_uid: ::uid_t, + pub cr_gid: ::gid_t, + pub cr_ngroups: ::c_int, + pub cr_groups: [::gid_t; NGROUPS_MAX as usize], + } + pub struct unpcbid { pub unp_pid: ::pid_t, pub unp_euid: ::uid_t, @@ -491,6 +513,78 @@ s! { pub kve_vn_mode: u32, pub kve_path: [[::c_char; 32]; 32], } + + pub struct __c_anonymous_posix_spawn_fae_open { + pub path: *mut ::c_char, + pub oflag: ::c_int, + pub mode: ::mode_t, + } + + pub struct __c_anonymous_posix_spawn_fae_dup2 { + pub newfildes: ::c_int, + } + + pub struct posix_spawnattr_t { + pub sa_flags: ::c_short, + pub sa_pgroup: ::pid_t, + pub sa_schedparam: sched_param, + pub sa_schedpolicy: ::c_int, + pub sa_sigdefault: sigset_t, + pub sa_sigmask: sigset_t, + } + + pub struct posix_spawn_file_actions_entry_t { + pub fae_action: fae_action, + pub fae_fildes: ::c_int, + #[cfg(libc_union)] + pub fae_data: __c_anonymous_posix_spawn_fae, + } + + pub struct posix_spawn_file_actions_t { + pub size: ::c_uint, + pub len: ::c_uint, + #[cfg(libc_union)] + pub fae: *mut posix_spawn_file_actions_entry_t, + } + + pub struct ptrace_lwpinfo { + pub pl_lwpid: lwpid_t, + pub pl_event: ::c_int, + } + + pub struct ptrace_lwpstatus { + pub pl_lwpid: lwpid_t, + pub pl_sigpend: sigset_t, + pub pl_sigmask: sigset_t, + pub pl_name: [::c_char; 20], + pub pl_private: *mut ::c_void, + } + + pub struct ptrace_siginfo { + pub psi_siginfo: siginfo_t, + pub psi_lwpid: lwpid_t, + } + + pub struct ptrace_event { + pub pe_set_event: ::c_int, + } + + pub struct sysctldesc { + pub descr_num: i32, + pub descr_ver: u32, + pub descr_len: u32, + pub descr_str: [::c_char; 1], + } + + pub struct ifreq { + pub _priv: [[::c_char; 6]; 24], + } + + pub struct ifconf { + pub ifc_len: ::c_int, + #[cfg(libc_union)] + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + } } s_no_extra_traits! { @@ -603,6 +697,18 @@ s_no_extra_traits! { __unused1: *mut ::c_void, //actually a function pointer pub sigev_notify_attributes: *mut ::c_void } + + #[cfg(libc_union)] + pub union __c_anonymous_posix_spawn_fae { + pub open: __c_anonymous_posix_spawn_fae_open, + pub dup2: __c_anonymous_posix_spawn_fae_dup2, + } + + #[cfg(libc_union)] + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: *mut ::c_void, + pub ifcu_req: *mut ifreq, + } } cfg_if! { @@ -1030,6 +1136,76 @@ cfg_if! { self.sigev_notify_attributes.hash(state); } } + + #[cfg(libc_union)] + impl Eq for __c_anonymous_posix_spawn_fae {} + + #[cfg(libc_union)] + impl PartialEq for __c_anonymous_posix_spawn_fae { + fn eq(&self, other: &__c_anonymous_posix_spawn_fae) -> bool { + unsafe { + self.open == other.open + || self.dup2 == other.dup2 + } + } + } + + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_posix_spawn_fae { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + unsafe { + f.debug_struct("__c_anonymous_posix_fae") + .field("open", &self.open) + .field("dup2", &self.dup2) + .finish() + } + } + } + + #[cfg(libc_union)] + impl ::hash::Hash for __c_anonymous_posix_spawn_fae { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + unsafe { + self.open.hash(state); + self.dup2.hash(state); + } + } + } + + #[cfg(libc_union)] + impl Eq for __c_anonymous_ifc_ifcu {} + + #[cfg(libc_union)] + impl PartialEq for __c_anonymous_ifc_ifcu { + fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool { + unsafe { + self.ifcu_buf == other.ifcu_buf + || self.ifcu_req == other.ifcu_req + } + } + } + + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ifc_ifcu { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + unsafe { + f.debug_struct("__c_anonymous_ifc_ifcu") + .field("ifcu_buf", &self.ifcu_buf) + .field("ifcu_req", &self.ifcu_req) + .finish() + } + } + } + + #[cfg(libc_union)] + impl ::hash::Hash for __c_anonymous_ifc_ifcu { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + unsafe { + self.ifcu_buf.hash(state); + self.ifcu_req.hash(state); + } + } + } } } @@ -1128,6 +1304,7 @@ pub const F_CLOSEM: ::c_int = 10; pub const F_GETNOSIGPIPE: ::c_int = 13; pub const F_SETNOSIGPIPE: ::c_int = 14; pub const F_MAXFD: ::c_int = 11; +pub const F_GETPATH: ::c_int = 15; pub const IP_RECVDSTADDR: ::c_int = 7; pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR; @@ -1297,6 +1474,15 @@ pub const MAP_NORESERVE: ::c_int = 0x40; pub const MAP_HASSEMAPHORE: ::c_int = 0x200; pub const MAP_WIRED: ::c_int = 0x800; pub const MAP_STACK: ::c_int = 0x2000; +// map alignment aliases for MAP_ALIGNED +pub const MAP_ALIGNMENT_SHIFT: ::c_int = 24; +pub const MAP_ALIGNMENT_MASK: ::c_int = 0xff << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNMENT_64KB: ::c_int = 16 << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNMENT_16MB: ::c_int = 24 << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNMENT_4GB: ::c_int = 32 << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNMENT_1TB: ::c_int = 40 << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNMENT_256TB: ::c_int = 48 << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNMENT_64PB: ::c_int = 56 << MAP_ALIGNMENT_SHIFT; // mremap flag pub const MAP_REMAPDUP: ::c_int = 0x004; @@ -1510,6 +1696,10 @@ pub const TIME_ERROR: ::c_int = 5; pub const LITTLE_ENDIAN: ::c_int = 1234; pub const BIG_ENDIAN: ::c_int = 4321; +pub const PL_EVENT_NONE: ::c_int = 0; +pub const PL_EVENT_SIGNAL: ::c_int = 1; +pub const PL_EVENT_SUSPENDED: ::c_int = 2; + cfg_if! { if #[cfg(any(target_arch = "sparc", target_arch = "sparc64", target_arch = "x86", target_arch = "x86_64"))] { @@ -1608,6 +1798,13 @@ pub const NOTE_CHILD: u32 = 0x00000004; pub const TMP_MAX: ::c_uint = 308915776; +pub const AI_PASSIVE: ::c_int = 0x00000001; +pub const AI_CANONNAME: ::c_int = 0x00000002; +pub const AI_NUMERICHOST: ::c_int = 0x00000004; +pub const AI_NUMERICSERV: ::c_int = 0x00000008; +pub const AI_ADDRCONFIG: ::c_int = 0x00000400; +pub const AI_SRV: ::c_int = 0x00000800; + pub const NI_MAXHOST: ::socklen_t = 1025; pub const NI_MAXSERV: ::socklen_t = 32; @@ -1867,8 +2064,25 @@ pub const PT_SYSCALLEMU: ::c_int = 15; pub const PT_SET_EVENT_MASK: ::c_int = 16; pub const PT_GET_EVENT_MASK: ::c_int = 17; pub const PT_GET_PROCESS_STATE: ::c_int = 18; +pub const PT_SET_SIGINFO: ::c_int = 19; +pub const PT_GET_SIGINFO: ::c_int = 20; +pub const PT_RESUME: ::c_int = 21; +pub const PT_SUSPEND: ::c_int = 23; +pub const PT_STOP: ::c_int = 23; +pub const PT_LWPSTATUS: ::c_int = 24; +pub const PT_LWPNEXT: ::c_int = 25; +pub const PT_SET_SIGPASS: ::c_int = 26; +pub const PT_GET_SIGPASS: ::c_int = 27; pub const PT_FIRSTMACH: ::c_int = 32; +pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01; +pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02; +pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_int = 0x04; +pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x08; +pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x10; +pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x20; +pub const POSIX_SPAWN_RETURNERROR: ::c_int = 0x40; + // Flags for chflags(2) pub const SF_SNAPSHOT: ::c_ulong = 0x00200000; pub const SF_LOG: ::c_ulong = 0x00400000; @@ -1886,6 +2100,8 @@ pub const KVME_FLAG_PAGEABLE: ::c_int = 0x000000008; pub const KVME_FLAG_GROWS_UP: ::c_int = 0x000000010; pub const KVME_FLAG_GROWS_DOWN: ::c_int = 0x000000020; +pub const NGROUPS_MAX: ::c_int = 16; + const_fn! { {const} fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES @@ -1940,6 +2156,14 @@ f! { }; ::mem::size_of::<sockcred>() + ::mem::size_of::<::gid_t>() * ngrps } + + pub fn PROT_MPROTECT(x: ::c_int) -> ::c_int { + x << 3 + } + + pub fn PROT_MPROTECT_EXTRACT(x: ::c_int) -> ::c_int { + (x >> 3) & 0x7 + } } safe_f! { @@ -2000,6 +2224,12 @@ extern "C" { pub fn fchflags(fd: ::c_int, flags: ::c_ulong) -> ::c_int; pub fn lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int; + pub fn execvpe( + file: *const ::c_char, + argv: *const *const ::c_char, + envp: *const *const ::c_char, + ) -> ::c_int; + pub fn extattr_delete_fd( fd: ::c_int, attrnamespace: ::c_int, @@ -2147,6 +2377,8 @@ extern "C" { ) -> ::c_int; pub fn mq_unlink(name: *const ::c_char) -> ::c_int; pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: *mut ::c_void, data: ::c_int) -> ::c_int; + pub fn utrace(label: *const ::c_char, addr: *mut ::c_void, len: ::size_t) -> ::c_int; + pub fn pthread_getname_np(t: ::pthread_t, name: *mut ::c_char, len: ::size_t) -> ::c_int; pub fn pthread_setname_np( t: ::pthread_t, name: *const ::c_char, @@ -2255,6 +2487,21 @@ extern "C" { ) -> ::size_t; pub fn iconv_close(cd: iconv_t) -> ::c_int; + pub fn timer_create( + clockid: ::clockid_t, + sevp: *mut ::sigevent, + timerid: *mut ::timer_t, + ) -> ::c_int; + pub fn timer_delete(timerid: ::timer_t) -> ::c_int; + pub fn timer_getoverrun(timerid: ::timer_t) -> ::c_int; + pub fn timer_gettime(timerid: ::timer_t, curr_value: *mut ::itimerspec) -> ::c_int; + pub fn timer_settime( + timerid: ::timer_t, + flags: ::c_int, + new_value: *const ::itimerspec, + old_value: *mut ::itimerspec, + ) -> ::c_int; + // Added in `NetBSD` 7.0 pub fn explicit_memset(b: *mut ::c_void, c: ::c_int, len: ::size_t); pub fn consttime_memequal(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int; @@ -2268,6 +2515,7 @@ extern "C" { flags: ::c_int, ) -> *mut ::c_void; + pub fn sched_rr_get_interval(pid: ::pid_t, t: *mut ::timespec) -> ::c_int; pub fn sched_setparam(pid: ::pid_t, param: *const sched_param) -> ::c_int; pub fn sched_getparam(pid: ::pid_t, param: *mut sched_param) -> ::c_int; pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; @@ -2276,6 +2524,91 @@ extern "C" { policy: ::c_int, param: *const ::sched_param, ) -> ::c_int; + + #[link_name = "__pollts50"] + pub fn pollts( + fds: *mut ::pollfd, + nfds: ::nfds_t, + ts: *const ::timespec, + sigmask: *const ::sigset_t, + ) -> ::c_int; + + pub fn posix_spawn( + pid: *mut ::pid_t, + path: *const ::c_char, + file_actions: *const ::posix_spawn_file_actions_t, + attrp: *const ::posix_spawnattr_t, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char, + ) -> ::c_int; + pub fn posix_spawnp( + pid: *mut ::pid_t, + file: *const ::c_char, + file_actions: *const ::posix_spawn_file_actions_t, + attrp: *const ::posix_spawnattr_t, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char, + ) -> ::c_int; + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> ::c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> ::c_int; + pub fn posix_spawnattr_getsigdefault( + attr: *const posix_spawnattr_t, + default: *mut ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_setsigdefault( + attr: *mut posix_spawnattr_t, + default: *const ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_getsigmask( + attr: *const posix_spawnattr_t, + default: *mut ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_setsigmask( + attr: *mut posix_spawnattr_t, + default: *const ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_getflags( + attr: *const posix_spawnattr_t, + flags: *mut ::c_short, + ) -> ::c_int; + pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: ::c_short) -> ::c_int; + pub fn posix_spawnattr_getpgroup( + attr: *const posix_spawnattr_t, + flags: *mut ::pid_t, + ) -> ::c_int; + pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: ::pid_t) -> ::c_int; + pub fn posix_spawnattr_getschedpolicy( + attr: *const posix_spawnattr_t, + flags: *mut ::c_int, + ) -> ::c_int; + pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: ::c_int) -> ::c_int; + pub fn posix_spawnattr_getschedparam( + attr: *const posix_spawnattr_t, + param: *mut ::sched_param, + ) -> ::c_int; + pub fn posix_spawnattr_setschedparam( + attr: *mut posix_spawnattr_t, + param: *const ::sched_param, + ) -> ::c_int; + + pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> ::c_int; + pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> ::c_int; + pub fn posix_spawn_file_actions_addopen( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + path: *const ::c_char, + oflag: ::c_int, + mode: ::mode_t, + ) -> ::c_int; + pub fn posix_spawn_file_actions_addclose( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + ) -> ::c_int; + pub fn posix_spawn_file_actions_adddup2( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + newfd: ::c_int, + ) -> ::c_int; } #[link(name = "util")] @@ -2317,10 +2650,23 @@ extern "C" { pub fn emalloc(n: ::size_t) -> *mut ::c_void; pub fn ecalloc(n: ::size_t, c: ::size_t) -> *mut ::c_void; pub fn erealloc(p: *mut ::c_void, n: ::size_t) -> *mut ::c_void; + pub fn ereallocarr(p: *mut ::c_void, n: ::size_t, s: ::size_t); pub fn estrdup(s: *const ::c_char) -> *mut ::c_char; pub fn estrndup(s: *const ::c_char, len: ::size_t) -> *mut ::c_char; pub fn estrlcpy(dst: *mut ::c_char, src: *const ::c_char, len: ::size_t) -> ::size_t; pub fn estrlcat(dst: *mut ::c_char, src: *const ::c_char, len: ::size_t) -> ::size_t; + pub fn estrtoi( + nptr: *const ::c_char, + base: ::c_int, + lo: ::intmax_t, + hi: ::intmax_t, + ) -> ::intmax_t; + pub fn estrtou( + nptr: *const ::c_char, + base: ::c_int, + lo: ::uintmax_t, + hi: ::uintmax_t, + ) -> ::uintmax_t; pub fn easprintf(string: *mut *mut ::c_char, fmt: *const ::c_char, ...) -> ::c_int; pub fn evasprintf(string: *mut *mut ::c_char, fmt: *const ::c_char, ...) -> ::c_int; pub fn esetfunc( @@ -2388,6 +2734,57 @@ extern "C" { tpe: ::c_int, ); + pub fn getxattr( + path: *const ::c_char, + name: *const ::c_char, + value: *mut ::c_void, + size: ::size_t, + ) -> ::ssize_t; + pub fn lgetxattr( + path: *const ::c_char, + name: *const ::c_char, + value: *mut ::c_void, + size: ::size_t, + ) -> ::ssize_t; + pub fn fgetxattr( + filedes: ::c_int, + name: *const ::c_char, + value: *mut ::c_void, + size: ::size_t, + ) -> ::ssize_t; + pub fn setxattr( + path: *const ::c_char, + name: *const ::c_char, + value: *const ::c_void, + size: ::size_t, + ) -> ::c_int; + pub fn lsetxattr( + path: *const ::c_char, + name: *const ::c_char, + value: *const ::c_void, + size: ::size_t, + ) -> ::c_int; + pub fn fsetxattr( + filedes: ::c_int, + name: *const ::c_char, + value: *const ::c_void, + size: ::size_t, + flags: ::c_int, + ) -> ::c_int; + pub fn listxattr(path: *const ::c_char, list: *mut ::c_char, size: ::size_t) -> ::ssize_t; + pub fn llistxattr(path: *const ::c_char, list: *mut ::c_char, size: ::size_t) -> ::ssize_t; + pub fn flistxattr(filedes: ::c_int, list: *mut ::c_char, size: ::size_t) -> ::ssize_t; + pub fn removexattr(path: *const ::c_char, name: *const ::c_char) -> ::c_int; + pub fn lremovexattr(path: *const ::c_char, name: *const ::c_char) -> ::c_int; + pub fn fremovexattr(fd: ::c_int, path: *const ::c_char, name: *const ::c_char) -> ::c_int; + + pub fn string_to_flags( + string_p: *mut *mut ::c_char, + setp: *mut ::c_ulong, + clrp: *mut ::c_ulong, + ) -> ::c_int; + pub fn flags_to_string(flags: ::c_ulong, def: *const ::c_char) -> ::c_int; + pub fn kinfo_getvmmap(pid: ::pid_t, cntp: *mut ::size_t) -> *mut kinfo_vmentry; } diff --git a/src/unix/bsd/netbsdlike/openbsd/arm.rs b/src/unix/bsd/netbsdlike/openbsd/arm.rs new file mode 100644 index 00000000..f1ab365d --- /dev/null +++ b/src/unix/bsd/netbsdlike/openbsd/arm.rs @@ -0,0 +1,16 @@ +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_char = u8; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_double>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + +pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/mips64.rs b/src/unix/bsd/netbsdlike/openbsd/mips64.rs new file mode 100644 index 00000000..15803ced --- /dev/null +++ b/src/unix/bsd/netbsdlike/openbsd/mips64.rs @@ -0,0 +1,8 @@ +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = i8; + +#[doc(hidden)] +pub const _ALIGNBYTES: usize = 7; + +pub const _MAX_PAGE_SHIFT: u32 = 14; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 4812db6f..9cab0b1a 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -48,6 +48,12 @@ cfg_if! { } s! { + pub struct ip_mreqn { + pub imr_multiaddr: in_addr, + pub imr_address: in_addr, + pub imr_ifindex: ::c_int, + } + pub struct glob_t { pub gl_pathc: ::size_t, pub gl_matchc: ::size_t, @@ -209,6 +215,12 @@ s! { pub sin_zero: [i8; 8], } + pub struct splice { + pub sp_fd: ::c_int, + pub sp_max: ::off_t, + pub sp_idle: ::timeval, + } + pub struct kevent { pub ident: ::uintptr_t, pub filter: ::c_short, @@ -401,6 +413,16 @@ s! { pub kve_inheritance: ::c_int, pub kve_flags: u8, } + + pub struct ptrace_state { + pub pe_report_event: ::c_int, + pub pe_other_pid: ::pid_t, + pub pe_tid: ::pid_t, + } + + pub struct ptrace_thread_state { + pub pts_tid: ::pid_t, + } } impl siginfo_t { @@ -1163,7 +1185,9 @@ pub const EV_DISPATCH: u16 = 0x80; pub const EV_FLAG1: u16 = 0x2000; pub const EV_ERROR: u16 = 0x4000; pub const EV_EOF: u16 = 0x8000; -pub const EV_SYSFLAGS: u16 = 0xf000; + +#[deprecated(since = "0.2.113", note = "Not stable across OS versions")] +pub const EV_SYSFLAGS: u16 = 0xf800; pub const NOTE_LOWAT: u32 = 0x00000001; pub const NOTE_EOF: u32 = 0x00000002; @@ -1186,6 +1210,14 @@ pub const NOTE_CHILD: u32 = 0x00000004; pub const TMP_MAX: ::c_uint = 0x7fffffff; +pub const AI_PASSIVE: ::c_int = 1; +pub const AI_CANONNAME: ::c_int = 2; +pub const AI_NUMERICHOST: ::c_int = 4; +pub const AI_EXT: ::c_int = 8; +pub const AI_NUMERICSERV: ::c_int = 16; +pub const AI_FQDN: ::c_int = 32; +pub const AI_ADDRCONFIG: ::c_int = 64; + pub const NI_NUMERICHOST: ::c_int = 1; pub const NI_NUMERICSERV: ::c_int = 2; pub const NI_NOFQDN: ::c_int = 4; @@ -1420,6 +1452,11 @@ pub const PTHREAD_STACK_MIN: ::size_t = 1_usize << _MAX_PAGE_SHIFT; pub const MINSIGSTKSZ: ::size_t = 3_usize << _MAX_PAGE_SHIFT; pub const SIGSTKSZ: ::size_t = MINSIGSTKSZ + (1_usize << _MAX_PAGE_SHIFT) * 4; +pub const PT_SET_EVENT_MASK: ::c_int = 12; +pub const PT_GET_EVENT_MASK: ::c_int = 13; +pub const PT_GET_PROCESS_STATE: ::c_int = 14; +pub const PT_GET_THREAD_FIRST: ::c_int = 15; +pub const PT_GET_THREAD_NEXT: ::c_int = 16; pub const PT_FIRSTMACH: ::c_int = 32; pub const SOCK_CLOEXEC: ::c_int = 0x8000; @@ -1527,6 +1564,8 @@ extern "C" { servlen: ::size_t, flags: ::c_int, ) -> ::c_int; + pub fn getresgid(rgid: *mut ::gid_t, egid: *mut ::gid_t, sgid: *mut ::gid_t) -> ::c_int; + pub fn getresuid(ruid: *mut ::uid_t, euid: *mut ::uid_t, suid: *mut ::uid_t) -> ::c_int; pub fn kevent( kq: ::c_int, changelist: *const ::kevent, @@ -1536,6 +1575,7 @@ extern "C" { timeout: *const ::timespec, ) -> ::c_int; pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; + pub fn getthrid() -> ::pid_t; pub fn pthread_attr_getguardsize( attr: *const ::pthread_attr_t, guardsize: *mut ::size_t, @@ -1546,6 +1586,7 @@ extern "C" { stacksize: *mut ::size_t, ) -> ::c_int; pub fn pthread_main_np() -> ::c_int; + pub fn pthread_get_name_np(tid: ::pthread_t, name: *mut ::c_char, len: ::size_t); pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); pub fn pthread_stackseg_np(thread: ::pthread_t, sinfo: *mut ::stack_t) -> ::c_int; @@ -1561,6 +1602,7 @@ extern "C" { pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int; pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int; pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: caddr_t, data: ::c_int) -> ::c_int; + pub fn utrace(label: *const ::c_char, addr: *const ::c_void, len: ::size_t) -> ::c_int; pub fn memmem( haystack: *const ::c_void, haystacklen: ::size_t, @@ -1591,6 +1633,26 @@ extern "C" { pub fn freezero(ptr: *mut ::c_void, size: ::size_t); pub fn malloc_conceal(size: ::size_t) -> *mut ::c_void; pub fn calloc_conceal(nmemb: ::size_t, size: ::size_t) -> *mut ::c_void; + + pub fn srand48_deterministic(seed: ::c_long); + pub fn seed48_deterministic(xseed: *mut ::c_ushort) -> *mut ::c_ushort; + pub fn lcong48_deterministic(p: *mut ::c_ushort); +} + +#[link(name = "execinfo")] +extern "C" { + pub fn backtrace(addrlist: *mut *mut ::c_void, len: ::size_t) -> ::size_t; + pub fn backtrace_symbols(addrlist: *const *mut ::c_void, len: ::size_t) -> *mut *mut ::c_char; + pub fn backtrace_symbols_fd( + addrlist: *const *mut ::c_void, + len: ::size_t, + fd: ::c_int, + ) -> ::c_int; + pub fn backtrace_symbols_fmt( + addrlist: *const *mut ::c_void, + len: ::size_t, + fmt: *const ::c_char, + ) -> *mut *mut ::c_char; } cfg_if! { @@ -1604,18 +1666,33 @@ cfg_if! { } cfg_if! { - if #[cfg(target_arch = "x86")] { - mod x86; - pub use self::x86::*; - } else if #[cfg(target_arch = "x86_64")] { - mod x86_64; - pub use self::x86_64::*; - } else if #[cfg(target_arch = "aarch64")] { + if #[cfg(target_arch = "aarch64")] { mod aarch64; pub use self::aarch64::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else if #[cfg(target_arch = "mips64")] { + mod mips64; + pub use self::mips64::*; + } else if #[cfg(target_arch = "powerpc")] { + mod powerpc; + pub use self::powerpc::*; + } else if #[cfg(target_arch = "powerpc64")] { + mod powerpc64; + pub use self::powerpc64::*; + } else if #[cfg(target_arch = "riscv64")] { + mod riscv64; + pub use self::riscv64::*; } else if #[cfg(target_arch = "sparc64")] { mod sparc64; pub use self::sparc64::*; + } else if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; } else { // Unknown target_arch } diff --git a/src/unix/bsd/netbsdlike/openbsd/powerpc.rs b/src/unix/bsd/netbsdlike/openbsd/powerpc.rs new file mode 100644 index 00000000..f1ab365d --- /dev/null +++ b/src/unix/bsd/netbsdlike/openbsd/powerpc.rs @@ -0,0 +1,16 @@ +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_char = u8; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_double>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + +pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs b/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs new file mode 100644 index 00000000..99350ec8 --- /dev/null +++ b/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs @@ -0,0 +1,16 @@ +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = u8; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + +pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/riscv64.rs b/src/unix/bsd/netbsdlike/openbsd/riscv64.rs new file mode 100644 index 00000000..99350ec8 --- /dev/null +++ b/src/unix/bsd/netbsdlike/openbsd/riscv64.rs @@ -0,0 +1,16 @@ +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = u8; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + +pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/haiku/b32.rs b/src/unix/haiku/b32.rs index cce88648..073ae9d4 100644 --- a/src/unix/haiku/b32.rs +++ b/src/unix/haiku/b32.rs @@ -1,3 +1,20 @@ pub type c_long = i32; pub type c_ulong = u32; pub type time_t = i32; + +pub type Elf_Addr = ::Elf32_Addr; +pub type Elf_Half = ::Elf32_Half; +pub type Elf_Phdr = ::Elf32_Phdr; + +s! { + pub struct Elf32_Phdr { + pub p_type: ::Elf32_Word, + pub p_offset: ::Elf32_Off, + pub p_vaddr: ::Elf32_Addr, + pub p_paddr: ::Elf32_Addr, + pub p_filesz: ::Elf32_Word, + pub p_memsz: ::Elf32_Word, + pub p_flags: ::Elf32_Word, + pub p_align: ::Elf32_Word, + } +} diff --git a/src/unix/haiku/b64.rs b/src/unix/haiku/b64.rs index 3e66f14c..45691805 100644 --- a/src/unix/haiku/b64.rs +++ b/src/unix/haiku/b64.rs @@ -1,3 +1,20 @@ pub type c_ulong = u64; pub type c_long = i64; pub type time_t = i64; + +pub type Elf_Addr = ::Elf64_Addr; +pub type Elf_Half = ::Elf64_Half; +pub type Elf_Phdr = ::Elf64_Phdr; + +s! { + pub struct Elf64_Phdr { + pub p_type: ::Elf64_Word, + pub p_flags: ::Elf64_Word, + pub p_offset: ::Elf64_Off, + pub p_vaddr: ::Elf64_Addr, + pub p_paddr: ::Elf64_Addr, + pub p_filesz: ::Elf64_Xword, + pub p_memsz: ::Elf64_Xword, + pub p_align: ::Elf64_Xword, + } +} diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index ee2af390..0182dee1 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -31,6 +31,22 @@ pub type id_t = i32; pub type idtype_t = ::c_uint; pub type fd_mask = u32; +pub type Elf32_Addr = u32; +pub type Elf32_Half = u16; +pub type Elf32_Lword = u64; +pub type Elf32_Off = u32; +pub type Elf32_Sword = i32; +pub type Elf32_Word = u32; + +pub type Elf64_Addr = u64; +pub type Elf64_Half = u16; +pub type Elf64_Lword = u64; +pub type Elf64_Off = u64; +pub type Elf64_Sword = i32; +pub type Elf64_Sxword = i64; +pub type Elf64_Word = u32; +pub type Elf64_Xword = u64; + #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} impl ::Copy for timezone {} @@ -102,6 +118,16 @@ s! { pub ai_next: *mut addrinfo, } + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut ::c_char, + pub ifa_flags: ::c_uint, + pub ifa_addr: *mut ::sockaddr, + pub ifa_netmask: *mut ::sockaddr, + pub ifa_dstaddr: *mut ::sockaddr, + pub ida_data: *mut ::c_void, + } + pub struct fd_set { // size for 1024 bits, and a fd_mask with size u32 fds_bits: [fd_mask; 32], @@ -333,6 +359,17 @@ s! { pub sdl_slen: u8, pub sdl_data: [u8; 46], } + + pub struct dl_phdr_info { + pub dlpi_addr: Elf_Addr, + pub dlpi_name: *const ::c_char, + pub dlpi_phdr: *const Elf_Phdr, + pub dlpi_phnum: Elf_Half, + pub dlpi_adds: ::c_ulonglong, + pub dlpi_subs: ::c_ulonglong, + pub dlpi_tls_modid: usize, + pub dlpi_tls_data: *mut ::c_void, + } } s_no_extra_traits! { @@ -364,10 +401,63 @@ s_no_extra_traits! { __unused1: *mut ::c_void, // actually a function pointer pub sigev_notify_attributes: *mut ::pthread_attr_t, } + + pub struct utmpx { + pub ut_type: ::c_short, + pub ut_tv: ::timeval, + pub ut_id: [::c_char; 8], + pub ut_pid: ::pid_t, + pub ut_user: [::c_char; 32], + pub ut_line: [::c_char; 16], + pub ut_host: [::c_char; 128], + __ut_reserved: [::c_char; 64], + } } cfg_if! { if #[cfg(feature = "extra_traits")] { + impl PartialEq for utmpx { + fn eq(&self, other: &utmpx) -> bool { + self.ut_type == other.ut_type + && self.ut_tv == other.ut_tv + && self.ut_id == other.ut_id + && self.ut_pid == other.ut_pid + && self.ut_user == other.ut_user + && self.ut_line == other.ut_line + && self.ut_host.iter().zip(other.ut_host.iter()).all(|(a,b)| a == b) + && self.__ut_reserved == other.__ut_reserved + } + } + + impl Eq for utmpx {} + + impl ::fmt::Debug for utmpx { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("utmpx") + .field("ut_type", &self.ut_type) + .field("ut_tv", &self.ut_tv) + .field("ut_id", &self.ut_id) + .field("ut_pid", &self.ut_pid) + .field("ut_user", &self.ut_user) + .field("ut_line", &self.ut_line) + .field("ut_host", &self.ut_host) + .field("__ut_reserved", &self.__ut_reserved) + .finish() + } + } + + impl ::hash::Hash for utmpx { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + self.ut_type.hash(state); + self.ut_tv.hash(state); + self.ut_id.hash(state); + self.ut_pid.hash(state); + self.ut_user.hash(state); + self.ut_line.hash(state); + self.ut_host.hash(state); + self.__ut_reserved.hash(state); + } + } impl PartialEq for sockaddr_un { fn eq(&self, other: &sockaddr_un) -> bool { self.sun_len == other.sun_len @@ -1265,6 +1355,16 @@ pub const PRIO_PROCESS: ::c_int = 0; pub const PRIO_PGRP: ::c_int = 1; pub const PRIO_USER: ::c_int = 2; +// utmpx entry types +pub const EMPTY: ::c_short = 0; +pub const BOOT_TIME: ::c_short = 1; +pub const OLD_TIME: ::c_short = 2; +pub const NEW_TIME: ::c_short = 3; +pub const USER_PROCESS: ::c_short = 4; +pub const INIT_PROCESS: ::c_short = 5; +pub const LOGIN_PROCESS: ::c_short = 6; +pub const DEAD_PROCESS: ::c_short = 7; + pub const LOG_PID: ::c_int = 1 << 12; pub const LOG_CONS: ::c_int = 2 << 12; pub const LOG_ODELAY: ::c_int = 4 << 12; @@ -1387,6 +1487,12 @@ extern "C" { pub fn getpriority(which: ::c_int, who: id_t) -> ::c_int; pub fn setpriority(which: ::c_int, who: id_t, priority: ::c_int) -> ::c_int; + pub fn endusershell(); + pub fn getpass(prompt: *const ::c_char) -> *mut ::c_char; + pub fn getusershell() -> *mut ::c_char; + pub fn issetugid() -> ::c_int; + pub fn setusershell(); + pub fn utimensat( fd: ::c_int, path: *const ::c_char, @@ -1402,6 +1508,14 @@ extern "C" { pub fn labs(i: ::c_long) -> ::c_long; pub fn rand() -> ::c_int; pub fn srand(seed: ::c_uint); + pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; + pub fn freeifaddrs(ifa: *mut ::ifaddrs); + pub fn ppoll( + fds: *mut ::pollfd, + numfds: ::nfds_t, + timeout: *const ::timespec, + sigMask: *const sigset_t, + ) -> ::c_int; } #[link(name = "bsd")] @@ -1510,6 +1624,12 @@ extern "C" { buflen: ::size_t, result: *mut *mut ::group, ) -> ::c_int; + pub fn getgrouplist( + user: *const ::c_char, + basegroup: ::gid_t, + grouplist: *mut ::gid_t, + groupcount: *mut ::c_int, + ) -> ::c_int; pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int; pub fn sem_close(sem: *mut sem_t) -> ::c_int; pub fn getdtablesize() -> ::c_int; @@ -1563,6 +1683,29 @@ extern "C" { ) -> ::pid_t; pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; pub fn uname(buf: *mut ::utsname) -> ::c_int; + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + pub fn setutxent(); + pub fn endutxent(); + + pub fn dl_iterate_phdr( + callback: ::Option< + unsafe extern "C" fn( + info: *mut dl_phdr_info, + size: usize, + data: *mut ::c_void, + ) -> ::c_int, + >, + data: *mut ::c_void, + ) -> ::c_int; + + pub fn strsep(string: *mut *mut ::c_char, delimiters: *const ::c_char) -> *mut ::c_char; + pub fn explicit_bzero(buf: *mut ::c_void, len: ::size_t); + + pub fn login_tty(_fd: ::c_int) -> ::c_int; + pub fn fgetln(stream: *mut ::FILE, _length: *mut ::size_t) -> *mut ::c_char; } cfg_if! { diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index 162752ad..35c9914f 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -48,6 +48,13 @@ s! { __unused4: ::c_uint, __unused5: ::c_uint, } + + pub struct user_regs_struct { + pub regs: [u64; 31], + pub sp: u64, + pub pc: u64, + pub pstate: u64, + } } pub const O_DIRECT: ::c_int = 0x10000; diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index f530e4fa..236f57a4 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -349,6 +349,12 @@ s! { pub instruction_pointer: ::__u64, pub args: [::__u64; 6], } + + pub struct ptrace_peeksiginfo_args { + pub off: ::__u64, + pub flags: ::__u32, + pub nr: ::__s32, + } } s_no_extra_traits! { @@ -792,9 +798,6 @@ pub const EPROTO: ::c_int = 71; pub const EDOTDOT: ::c_int = 73; pub const EPOLL_CLOEXEC: ::c_int = 0x80000; -pub const EPOLLONESHOT: ::c_int = 0x40000000; -pub const EPOLLRDHUP: ::c_int = 0x00002000; -pub const EPOLLWAKEUP: ::c_int = 0x20000000; // sys/eventfd.h pub const EFD_SEMAPHORE: ::c_int = 0x1; @@ -809,6 +812,8 @@ pub const TFD_TIMER_CANCEL_ON_SET: ::c_int = 2; pub const USER_PROCESS: ::c_short = 7; +pub const _POSIX_VDISABLE: ::cc_t = 0; + // linux/falloc.h pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01; pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02; @@ -989,6 +994,10 @@ pub const F_ULOCK: ::c_int = 0; pub const F_SEAL_FUTURE_WRITE: ::c_int = 0x0010; +pub const IFF_LOWER_UP: ::c_int = 0x10000; +pub const IFF_DORMANT: ::c_int = 0x20000; +pub const IFF_ECHO: ::c_int = 0x40000; + pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; @@ -1207,6 +1216,9 @@ pub const SO_SNDLOWAT: ::c_int = 19; pub const SO_RCVTIMEO: ::c_int = 20; pub const SO_SNDTIMEO: ::c_int = 21; pub const SO_BINDTODEVICE: ::c_int = 25; +pub const SO_ATTACH_FILTER: ::c_int = 26; +pub const SO_DETACH_FILTER: ::c_int = 27; +pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER; pub const SO_TIMESTAMP: ::c_int = 29; pub const SO_ACCEPTCONN: ::c_int = 30; pub const SO_PEERSEC: ::c_int = 31; @@ -1257,33 +1269,6 @@ pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; pub const EXTPROC: ::tcflag_t = 0o200000; -pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; -pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; -pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; -pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; -pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; -pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; -pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; -pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; -pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; -pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; -pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; -pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; -pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; -pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; -pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; -pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; -pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; -pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; -pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; -pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; -pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; -pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; -pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; -pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; -pub const TMPFS_MAGIC: ::c_long = 0x01021994; -pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; - pub const MAP_HUGETLB: ::c_int = 0x040000; pub const PTRACE_TRACEME: ::c_int = 0; @@ -1343,6 +1328,10 @@ pub const TCGETS: ::c_int = 0x5401; pub const TCSETS: ::c_int = 0x5402; pub const TCSETSW: ::c_int = 0x5403; pub const TCSETSF: ::c_int = 0x5404; +pub const TCGETS2: ::c_int = 0x802c542a; +pub const TCSETS2: ::c_int = 0x402c542b; +pub const TCSETSW2: ::c_int = 0x402c542c; +pub const TCSETSF2: ::c_int = 0x402c542d; pub const TCGETA: ::c_int = 0x5405; pub const TCSETA: ::c_int = 0x5406; pub const TCSETAW: ::c_int = 0x5407; @@ -1536,6 +1525,10 @@ pub const B2500000: ::speed_t = 0o010014; pub const B3000000: ::speed_t = 0o010015; pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; +pub const IBSHIFT: ::tcflag_t = 16; + +pub const BLKSSZGET: ::c_int = 0x1268; +pub const BLKPBSZGET: ::c_int = 0x127B; pub const EAI_AGAIN: ::c_int = 2; pub const EAI_BADFLAGS: ::c_int = 3; @@ -1789,6 +1782,11 @@ pub const NETLINK_BROADCAST_ERROR: ::c_int = 4; pub const NETLINK_NO_ENOBUFS: ::c_int = 5; pub const NETLINK_RX_RING: ::c_int = 6; pub const NETLINK_TX_RING: ::c_int = 7; +pub const NETLINK_LISTEN_ALL_NSID: ::c_int = 8; +pub const NETLINK_LIST_MEMBERSHIPS: ::c_int = 9; +pub const NETLINK_CAP_ACK: ::c_int = 10; +pub const NETLINK_EXT_ACK: ::c_int = 11; +pub const NETLINK_GET_STRICT_CHK: ::c_int = 12; pub const GRND_NONBLOCK: ::c_uint = 0x0001; pub const GRND_RANDOM: ::c_uint = 0x0002; @@ -1868,6 +1866,39 @@ pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; pub const MFD_CLOEXEC: ::c_uint = 0x0001; pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002; pub const MFD_HUGETLB: ::c_uint = 0x0004; +pub const MFD_HUGE_64KB: ::c_uint = 0x40000000; +pub const MFD_HUGE_512KB: ::c_uint = 0x4c000000; +pub const MFD_HUGE_1MB: ::c_uint = 0x50000000; +pub const MFD_HUGE_2MB: ::c_uint = 0x54000000; +pub const MFD_HUGE_8MB: ::c_uint = 0x5c000000; +pub const MFD_HUGE_16MB: ::c_uint = 0x60000000; +pub const MFD_HUGE_32MB: ::c_uint = 0x64000000; +pub const MFD_HUGE_256MB: ::c_uint = 0x70000000; +pub const MFD_HUGE_512MB: ::c_uint = 0x74000000; +pub const MFD_HUGE_1GB: ::c_uint = 0x78000000; +pub const MFD_HUGE_2GB: ::c_uint = 0x7c000000; +pub const MFD_HUGE_16GB: ::c_uint = 0x88000000; +pub const MFD_HUGE_MASK: ::c_uint = 63; +pub const MFD_HUGE_SHIFT: ::c_uint = 26; + +// these are used in the p_type field of Elf32_Phdr and Elf64_Phdr, which has +// the type Elf32Word and Elf64Word respectively. Luckily, both of those are u32 +// so we can use that type here to avoid having to cast. +pub const PT_NULL: u32 = 0; +pub const PT_LOAD: u32 = 1; +pub const PT_DYNAMIC: u32 = 2; +pub const PT_INTERP: u32 = 3; +pub const PT_NOTE: u32 = 4; +pub const PT_SHLIB: u32 = 5; +pub const PT_PHDR: u32 = 6; +pub const PT_TLS: u32 = 7; +pub const PT_LOOS: u32 = 0x60000000; +pub const PT_GNU_EH_FRAME: u32 = 0x6474e550; +pub const PT_GNU_STACK: u32 = 0x6474e551; +pub const PT_GNU_RELRO: u32 = 0x6474e552; +pub const PT_HIOS: u32 = 0x6fffffff; +pub const PT_LOPROC: u32 = 0x70000000; +pub const PT_HIPROC: u32 = 0x7fffffff; // linux/netfilter.h pub const NF_DROP: ::c_int = 0; @@ -2301,6 +2332,9 @@ pub const ALG_SET_AEAD_AUTHSIZE: ::c_int = 5; pub const ALG_OP_DECRYPT: ::c_int = 0; pub const ALG_OP_ENCRYPT: ::c_int = 1; +// sys/mman.h +pub const MLOCK_ONFAULT: ::c_int = 0x01; + // uapi/linux/vm_sockets.h pub const VMADDR_CID_ANY: ::c_uint = 0xFFFFFFFF; pub const VMADDR_CID_HYPERVISOR: ::c_uint = 0; @@ -2428,6 +2462,15 @@ pub const SCHED_DEADLINE: ::c_int = 6; pub const SCHED_RESET_ON_FORK: ::c_int = 0x40000000; +pub const CLONE_PIDFD: ::c_int = 0x1000; + +// linux/mempolicy.h +pub const MPOL_DEFAULT: ::c_int = 0; +pub const MPOL_PREFERRED: ::c_int = 1; +pub const MPOL_BIND: ::c_int = 2; +pub const MPOL_INTERLEAVE: ::c_int = 3; +pub const MPOL_LOCAL: ::c_int = 4; + // bits/seek_constants.h pub const SEEK_DATA: ::c_int = 3; pub const SEEK_HOLE: ::c_int = 4; @@ -2467,6 +2510,12 @@ f! { } } + pub fn CPU_ALLOC_SIZE(count: ::c_int) -> ::size_t { + let _dummy: cpu_set_t = ::mem::zeroed(); + let size_in_bits = 8 * ::mem::size_of_val(&_dummy.__bits[0]); + ((count as ::size_t + size_in_bits - 1) / 8) as ::size_t + } + pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { for slot in cpuset.__bits.iter_mut() { *slot = 0; @@ -2474,28 +2523,44 @@ f! { } pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in___bits = 8 * ::mem::size_of_val(&cpuset.__bits[0]); - let (idx, offset) = (cpu / size_in___bits, cpu % size_in___bits); + let size_in_bits + = 8 * ::mem::size_of_val(&cpuset.__bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.__bits[idx] |= 1 << offset; () } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in___bits = 8 * ::mem::size_of_val(&cpuset.__bits[0]); - let (idx, offset) = (cpu / size_in___bits, cpu % size_in___bits); + let size_in_bits + = 8 * ::mem::size_of_val(&cpuset.__bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.__bits[idx] &= !(1 << offset); () } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { - let size_in___bits = 8 * ::mem::size_of_val(&cpuset.__bits[0]); - let (idx, offset) = (cpu / size_in___bits, cpu % size_in___bits); + let size_in_bits = 8 * ::mem::size_of_val(&cpuset.__bits[0]); + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); 0 != (cpuset.__bits[idx] & (1 << offset)) } + pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> ::c_int { + let mut s: u32 = 0; + let size_of_mask = ::mem::size_of_val(&cpuset.__bits[0]); + for i in cpuset.__bits[..(size / size_of_mask)].iter() { + s += i.count_ones(); + }; + s as ::c_int + } + + pub fn CPU_COUNT(cpuset: &cpu_set_t) -> ::c_int { + CPU_COUNT_S(::mem::size_of::<cpu_set_t>(), cpuset) + } + pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { set1.__bits == set2.__bits } + pub fn major(dev: ::dev_t) -> ::c_int { ((dev >> 8) & 0xfff) as ::c_int } @@ -2537,6 +2602,7 @@ extern "C" { pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int; pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int; + pub fn mlock2(addr: *const ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index b83415a3..5494aad3 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -965,10 +965,6 @@ pub const SHM_UNLOCK: ::c_int = 12; pub const SHM_HUGETLB: ::c_int = 0o4000; pub const SHM_NORESERVE: ::c_int = 0o10000; -pub const EPOLLRDHUP: ::c_int = 0x2000; -pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000; -pub const EPOLLONESHOT: ::c_int = 0x40000000; - pub const QFMT_VFS_OLD: ::c_int = 1; pub const QFMT_VFS_V0: ::c_int = 2; @@ -1372,8 +1368,6 @@ pub const PTRACE_INTERRUPT: ::c_int = 0x4207; pub const PTRACE_LISTEN: ::c_int = 0x4208; pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209; -pub const EPOLLWAKEUP: ::c_int = 0x20000000; - pub const PTRACE_GETFPREGS: ::c_uint = 14; pub const PTRACE_SETFPREGS: ::c_uint = 15; pub const PTRACE_GETFPXREGS: ::c_uint = 18; diff --git a/src/unix/linux_like/linux/align.rs b/src/unix/linux_like/linux/align.rs index 11f5504a..a4e656c6 100644 --- a/src/unix/linux_like/linux/align.rs +++ b/src/unix/linux_like/linux/align.rs @@ -76,6 +76,7 @@ macro_rules! expand_align { any(target_arch = "mips", target_arch = "arm", target_arch = "hexagon", + target_arch = "m68k", target_arch = "powerpc", target_arch = "sparc", target_arch = "x86_64", @@ -85,6 +86,7 @@ macro_rules! expand_align { not(any(target_arch = "mips", target_arch = "arm", target_arch = "hexagon", + target_arch = "m68k", target_arch = "powerpc", target_arch = "sparc", target_arch = "x86_64", @@ -99,6 +101,7 @@ macro_rules! expand_align { any(target_arch = "mips", target_arch = "arm", target_arch = "hexagon", + target_arch = "m68k", target_arch = "powerpc", target_arch = "sparc", target_arch = "x86_64", @@ -108,6 +111,7 @@ macro_rules! expand_align { not(any(target_arch = "mips", target_arch = "arm", target_arch = "hexagon", + target_arch = "m68k", target_arch = "powerpc", target_arch = "sparc", target_arch = "x86_64", diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs index e3401d4b..223928cc 100644 --- a/src/unix/linux_like/linux/arch/generic/mod.rs +++ b/src/unix/linux_like/linux/arch/generic/mod.rs @@ -1,3 +1,16 @@ +s! { + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 19], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } +} + // include/uapi/asm-generic/socket.h // arch/alpha/include/uapi/asm/socket.h // tools/include/uapi/asm-generic/socket.h @@ -98,3 +111,124 @@ cfg_if! { // pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP; pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; + +// Ioctl Constants + +cfg_if! { + if #[cfg(not(any(target_arch = "mips", + target_arch = "mips64", + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "sparc", + target_arch = "sparc64")))] { + + pub const TCGETS: ::Ioctl = 0x5401; + pub const TCSETS: ::Ioctl = 0x5402; + pub const TCSETSW: ::Ioctl = 0x5403; + pub const TCSETSF: ::Ioctl = 0x5404; + pub const TCGETA: ::Ioctl = 0x5405; + pub const TCSETA: ::Ioctl = 0x5406; + pub const TCSETAW: ::Ioctl = 0x5407; + pub const TCSETAF: ::Ioctl = 0x5408; + pub const TCSBRK: ::Ioctl = 0x5409; + pub const TCXONC: ::Ioctl = 0x540A; + pub const TCFLSH: ::Ioctl = 0x540B; + pub const TIOCEXCL: ::Ioctl = 0x540C; + pub const TIOCNXCL: ::Ioctl = 0x540D; + pub const TIOCSCTTY: ::Ioctl = 0x540E; + pub const TIOCGPGRP: ::Ioctl = 0x540F; + pub const TIOCSPGRP: ::Ioctl = 0x5410; + pub const TIOCOUTQ: ::Ioctl = 0x5411; + pub const TIOCSTI: ::Ioctl = 0x5412; + pub const TIOCGWINSZ: ::Ioctl = 0x5413; + pub const TIOCSWINSZ: ::Ioctl = 0x5414; + pub const TIOCMGET: ::Ioctl = 0x5415; + pub const TIOCMBIS: ::Ioctl = 0x5416; + pub const TIOCMBIC: ::Ioctl = 0x5417; + pub const TIOCMSET: ::Ioctl = 0x5418; + pub const TIOCGSOFTCAR: ::Ioctl = 0x5419; + pub const TIOCSSOFTCAR: ::Ioctl = 0x541A; + pub const FIONREAD: ::Ioctl = 0x541B; + pub const TIOCINQ: ::Ioctl = FIONREAD; + pub const TIOCLINUX: ::Ioctl = 0x541C; + pub const TIOCCONS: ::Ioctl = 0x541D; + pub const TIOCGSERIAL: ::Ioctl = 0x541E; + pub const TIOCSSERIAL: ::Ioctl = 0x541F; + pub const TIOCPKT: ::Ioctl = 0x5420; + pub const FIONBIO: ::Ioctl = 0x5421; + pub const TIOCNOTTY: ::Ioctl = 0x5422; + pub const TIOCSETD: ::Ioctl = 0x5423; + pub const TIOCGETD: ::Ioctl = 0x5424; + pub const TCSBRKP: ::Ioctl = 0x5425; + pub const TIOCSBRK: ::Ioctl = 0x5427; + pub const TIOCCBRK: ::Ioctl = 0x5428; + pub const TIOCGSID: ::Ioctl = 0x5429; + pub const TCGETS2: ::Ioctl = 0x802c542a; + pub const TCSETS2: ::Ioctl = 0x402c542b; + pub const TCSETSW2: ::Ioctl = 0x402c542c; + pub const TCSETSF2: ::Ioctl = 0x402c542d; + pub const TIOCGRS485: ::Ioctl = 0x542E; + pub const TIOCSRS485: ::Ioctl = 0x542F; + pub const TIOCGPTN: ::Ioctl = 0x80045430; + pub const TIOCSPTLCK: ::Ioctl = 0x40045431; + pub const TIOCGDEV: ::Ioctl = 0x80045432; + pub const TCGETX: ::Ioctl = 0x5432; + pub const TCSETX: ::Ioctl = 0x5433; + pub const TCSETXF: ::Ioctl = 0x5434; + pub const TCSETXW: ::Ioctl = 0x5435; + pub const TIOCSIG: ::Ioctl = 0x40045436; + pub const TIOCVHANGUP: ::Ioctl = 0x5437; + pub const TIOCGPKT: ::Ioctl = 0x80045438; + pub const TIOCGPTLCK: ::Ioctl = 0x80045439; + pub const TIOCGEXCL: ::Ioctl = 0x80045440; + pub const TIOCGPTPEER: ::Ioctl = 0x5441; +// pub const TIOCGISO7816: ::Ioctl = 0x80285442; +// pub const TIOCSISO7816: ::Ioctl = 0xc0285443; + pub const FIONCLEX: ::Ioctl = 0x5450; + pub const FIOCLEX: ::Ioctl = 0x5451; + pub const FIOASYNC: ::Ioctl = 0x5452; + pub const TIOCSERCONFIG: ::Ioctl = 0x5453; + pub const TIOCSERGWILD: ::Ioctl = 0x5454; + pub const TIOCSERSWILD: ::Ioctl = 0x5455; + pub const TIOCGLCKTRMIOS: ::Ioctl = 0x5456; + pub const TIOCSLCKTRMIOS: ::Ioctl = 0x5457; + pub const TIOCSERGSTRUCT: ::Ioctl = 0x5458; + pub const TIOCSERGETLSR: ::Ioctl = 0x5459; + pub const TIOCSERGETMULTI: ::Ioctl = 0x545A; + pub const TIOCSERSETMULTI: ::Ioctl = 0x545B; + pub const TIOCMIWAIT: ::Ioctl = 0x545C; + pub const TIOCGICOUNT: ::Ioctl = 0x545D; + } +} + +cfg_if! { + if #[cfg(any(target_arch = "arm", + target_arch = "s390x"))] { + pub const FIOQSIZE: ::Ioctl = 0x545E; + } else if #[cfg(not(any(target_arch = "mips", + target_arch = "mips64", + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "sparc", + target_arch = "sparc64")))] { + pub const FIOQSIZE: ::Ioctl = 0x5460; + } +} + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; +pub const TIOCM_DSR: ::c_int = 0x100; + +pub const BOTHER: ::speed_t = 0o010000; +pub const IBSHIFT: ::tcflag_t = 16; + +pub const BLKSSZGET: ::Ioctl = 0x1268; +pub const BLKPBSZGET: ::Ioctl = 0x127B; diff --git a/src/unix/linux_like/linux/arch/mips/mod.rs b/src/unix/linux_like/linux/arch/mips/mod.rs index cdbdca2b..b67b7347 100644 --- a/src/unix/linux_like/linux/arch/mips/mod.rs +++ b/src/unix/linux_like/linux/arch/mips/mod.rs @@ -1,3 +1,16 @@ +s! { + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 23], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } +} + // arch/mips/include/uapi/asm/socket.h pub const SOL_SOCKET: ::c_int = 0xffff; @@ -94,3 +107,106 @@ pub const SO_TIMESTAMPING: ::c_int = 37; // pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP; pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; + +// Ioctl Constants + +pub const TCGETS: ::Ioctl = 0x540d; +pub const TCSETS: ::Ioctl = 0x540e; +pub const TCSETSW: ::Ioctl = 0x540f; +pub const TCSETSF: ::Ioctl = 0x5410; +pub const TCGETA: ::Ioctl = 0x5401; +pub const TCSETA: ::Ioctl = 0x5402; +pub const TCSETAW: ::Ioctl = 0x5403; +pub const TCSETAF: ::Ioctl = 0x5404; +pub const TCSBRK: ::Ioctl = 0x5405; +pub const TCXONC: ::Ioctl = 0x5406; +pub const TCFLSH: ::Ioctl = 0x5407; +pub const TIOCEXCL: ::Ioctl = 0x740d; +pub const TIOCNXCL: ::Ioctl = 0x740e; +pub const TIOCSCTTY: ::Ioctl = 0x5480; +pub const TIOCGPGRP: ::Ioctl = 0x40047477; +pub const TIOCSPGRP: ::Ioctl = 0x80047476; +pub const TIOCOUTQ: ::Ioctl = 0x7472; +pub const TIOCSTI: ::Ioctl = 0x5472; +pub const TIOCGWINSZ: ::Ioctl = 0x40087468; +pub const TIOCSWINSZ: ::Ioctl = 0x80087467; +pub const TIOCMGET: ::Ioctl = 0x741d; +pub const TIOCMBIS: ::Ioctl = 0x741b; +pub const TIOCMBIC: ::Ioctl = 0x741c; +pub const TIOCMSET: ::Ioctl = 0x741a; +pub const TIOCGSOFTCAR: ::Ioctl = 0x5481; +pub const TIOCSSOFTCAR: ::Ioctl = 0x5482; +pub const FIONREAD: ::Ioctl = 0x467f; +pub const TIOCINQ: ::Ioctl = FIONREAD; +pub const TIOCLINUX: ::Ioctl = 0x5483; +pub const TIOCCONS: ::Ioctl = 0x80047478; +pub const TIOCGSERIAL: ::Ioctl = 0x5484; +pub const TIOCSSERIAL: ::Ioctl = 0x5485; +pub const TIOCPKT: ::Ioctl = 0x5470; +pub const FIONBIO: ::Ioctl = 0x667e; +pub const TIOCNOTTY: ::Ioctl = 0x5471; +pub const TIOCSETD: ::Ioctl = 0x7401; +pub const TIOCGETD: ::Ioctl = 0x7400; +pub const TCSBRKP: ::Ioctl = 0x5486; +pub const TIOCSBRK: ::Ioctl = 0x5427; +pub const TIOCCBRK: ::Ioctl = 0x5428; +pub const TIOCGSID: ::Ioctl = 0x7416; +pub const TCGETS2: ::Ioctl = 0x4030542a; +pub const TCSETS2: ::Ioctl = 0x8030542b; +pub const TCSETSW2: ::Ioctl = 0x8030542c; +pub const TCSETSF2: ::Ioctl = 0x8030542d; +pub const TIOCGPTN: ::Ioctl = 0x40045430; +pub const TIOCSPTLCK: ::Ioctl = 0x80045431; +pub const TIOCGDEV: ::Ioctl = 0x40045432; +pub const TIOCSIG: ::Ioctl = 0x80045436; +pub const TIOCVHANGUP: ::Ioctl = 0x5437; +pub const TIOCGPKT: ::Ioctl = 0x40045438; +pub const TIOCGPTLCK: ::Ioctl = 0x40045439; +pub const TIOCGEXCL: ::Ioctl = 0x40045440; +pub const TIOCGPTPEER: ::Ioctl = 0x20005441; +//pub const TIOCGISO7816: ::Ioctl = 0x40285442; +//pub const TIOCSISO7816: ::Ioctl = 0xc0285443; +pub const FIONCLEX: ::Ioctl = 0x6602; +pub const FIOCLEX: ::Ioctl = 0x6601; +pub const FIOASYNC: ::Ioctl = 0x667d; +pub const TIOCSERCONFIG: ::Ioctl = 0x5488; +pub const TIOCSERGWILD: ::Ioctl = 0x5489; +pub const TIOCSERSWILD: ::Ioctl = 0x548a; +pub const TIOCGLCKTRMIOS: ::Ioctl = 0x548b; +pub const TIOCSLCKTRMIOS: ::Ioctl = 0x548c; +pub const TIOCSERGSTRUCT: ::Ioctl = 0x548d; +pub const TIOCSERGETLSR: ::Ioctl = 0x548e; +pub const TIOCSERGETMULTI: ::Ioctl = 0x548f; +pub const TIOCSERSETMULTI: ::Ioctl = 0x5490; +pub const TIOCMIWAIT: ::Ioctl = 0x5491; +pub const TIOCGICOUNT: ::Ioctl = 0x5492; +pub const FIOQSIZE: ::Ioctl = 0x667f; +pub const TIOCSLTC: ::Ioctl = 0x7475; +pub const TIOCGETP: ::Ioctl = 0x7408; +pub const TIOCSETP: ::Ioctl = 0x7409; +pub const TIOCSETN: ::Ioctl = 0x740a; + +cfg_if! { + if #[cfg(target_env = "musl")] { + pub const TIOCGRS485: ::Ioctl = 0x4020542e; + pub const TIOCSRS485: ::Ioctl = 0xc020542f; + } +} + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x010; +pub const TIOCM_SR: ::c_int = 0x020; +pub const TIOCM_CTS: ::c_int = 0x040; +pub const TIOCM_CAR: ::c_int = 0x100; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RNG: ::c_int = 0x200; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; +pub const TIOCM_DSR: ::c_int = 0x400; + +pub const BOTHER: ::speed_t = 0o010000; +pub const IBSHIFT: ::tcflag_t = 16; + +pub const BLKSSZGET: ::Ioctl = 0x20001268; +pub const BLKPBSZGET: ::Ioctl = 0x2000127B; diff --git a/src/unix/linux_like/linux/arch/powerpc/mod.rs b/src/unix/linux_like/linux/arch/powerpc/mod.rs index 89cc09e3..d2824d13 100644 --- a/src/unix/linux_like/linux/arch/powerpc/mod.rs +++ b/src/unix/linux_like/linux/arch/powerpc/mod.rs @@ -89,3 +89,103 @@ pub const SO_BINDTOIFINDEX: ::c_int = 62; // pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP; pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; + +// Ioctl Constants + +cfg_if! { + if #[cfg(target_env = "musl")] { + pub const TCGETS: ::Ioctl = 0x402c7413; + pub const TCSETS: ::Ioctl = 0x802c7414; + pub const TCSETSW: ::Ioctl = 0x802c7415; + pub const TCSETSF: ::Ioctl = 0x802c7416; + } else { + pub const TCGETS: ::Ioctl = 0x403c7413; + pub const TCSETS: ::Ioctl = 0x803c7414; + pub const TCSETSW: ::Ioctl = 0x803c7415; + pub const TCSETSF: ::Ioctl = 0x803c7416; + } +} + +pub const TCGETA: ::Ioctl = 0x40147417; +pub const TCSETA: ::Ioctl = 0x80147418; +pub const TCSETAW: ::Ioctl = 0x80147419; +pub const TCSETAF: ::Ioctl = 0x8014741C; +pub const TCSBRK: ::Ioctl = 0x2000741D; +pub const TCXONC: ::Ioctl = 0x2000741E; +pub const TCFLSH: ::Ioctl = 0x2000741F; +pub const TIOCEXCL: ::Ioctl = 0x540C; +pub const TIOCNXCL: ::Ioctl = 0x540D; +pub const TIOCSCTTY: ::Ioctl = 0x540E; +pub const TIOCGPGRP: ::Ioctl = 0x40047477; +pub const TIOCSPGRP: ::Ioctl = 0x80047476; +pub const TIOCOUTQ: ::Ioctl = 0x40047473; +pub const TIOCSTI: ::Ioctl = 0x5412; +pub const TIOCGWINSZ: ::Ioctl = 0x40087468; +pub const TIOCSWINSZ: ::Ioctl = 0x80087467; +pub const TIOCMGET: ::Ioctl = 0x5415; +pub const TIOCMBIS: ::Ioctl = 0x5416; +pub const TIOCMBIC: ::Ioctl = 0x5417; +pub const TIOCMSET: ::Ioctl = 0x5418; +pub const TIOCGSOFTCAR: ::Ioctl = 0x5419; +pub const TIOCSSOFTCAR: ::Ioctl = 0x541A; +pub const FIONREAD: ::Ioctl = 0x4004667F; +pub const TIOCINQ: ::Ioctl = FIONREAD; +pub const TIOCLINUX: ::Ioctl = 0x541C; +pub const TIOCCONS: ::Ioctl = 0x541D; +pub const TIOCGSERIAL: ::Ioctl = 0x541E; +pub const TIOCSSERIAL: ::Ioctl = 0x541F; +pub const TIOCPKT: ::Ioctl = 0x5420; +pub const FIONBIO: ::Ioctl = 0x8004667e; +pub const TIOCNOTTY: ::Ioctl = 0x5422; +pub const TIOCSETD: ::Ioctl = 0x5423; +pub const TIOCGETD: ::Ioctl = 0x5424; +pub const TCSBRKP: ::Ioctl = 0x5425; +pub const TIOCSBRK: ::Ioctl = 0x5427; +pub const TIOCCBRK: ::Ioctl = 0x5428; +pub const TIOCGSID: ::Ioctl = 0x5429; +pub const TIOCGRS485: ::Ioctl = 0x542e; +pub const TIOCSRS485: ::Ioctl = 0x542f; +pub const TIOCGPTN: ::Ioctl = 0x40045430; +pub const TIOCSPTLCK: ::Ioctl = 0x80045431; +pub const TIOCGDEV: ::Ioctl = 0x40045432; +pub const TIOCSIG: ::Ioctl = 0x80045436; +pub const TIOCVHANGUP: ::Ioctl = 0x5437; +pub const TIOCGPKT: ::Ioctl = 0x40045438; +pub const TIOCGPTLCK: ::Ioctl = 0x40045439; +pub const TIOCGEXCL: ::Ioctl = 0x40045440; +pub const TIOCGPTPEER: ::Ioctl = 0x20005441; +//pub const TIOCGISO7816: ::Ioctl = 0x40285442; +//pub const TIOCSISO7816: ::Ioctl = 0xc0285443; +pub const FIONCLEX: ::Ioctl = 0x20006602; +pub const FIOCLEX: ::Ioctl = 0x20006601; +pub const FIOASYNC: ::Ioctl = 0x8004667d; +pub const TIOCSERCONFIG: ::Ioctl = 0x5453; +pub const TIOCSERGWILD: ::Ioctl = 0x5454; +pub const TIOCSERSWILD: ::Ioctl = 0x5455; +pub const TIOCGLCKTRMIOS: ::Ioctl = 0x5456; +pub const TIOCSLCKTRMIOS: ::Ioctl = 0x5457; +pub const TIOCSERGSTRUCT: ::Ioctl = 0x5458; +pub const TIOCSERGETLSR: ::Ioctl = 0x5459; +pub const TIOCSERGETMULTI: ::Ioctl = 0x545A; +pub const TIOCSERSETMULTI: ::Ioctl = 0x545B; +pub const TIOCMIWAIT: ::Ioctl = 0x545C; +pub const TIOCGICOUNT: ::Ioctl = 0x545D; +//pub const FIOQSIZE: ::Ioctl = 0x40086680; + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; +pub const TIOCM_DSR: ::c_int = 0x100; + +pub const BOTHER: ::speed_t = 0o0037; +pub const IBSHIFT: ::tcflag_t = 16; + +pub const BLKSSZGET: ::Ioctl = 0x20001268; +pub const BLKPBSZGET: ::Ioctl = 0x2000127B; diff --git a/src/unix/linux_like/linux/arch/sparc/mod.rs b/src/unix/linux_like/linux/arch/sparc/mod.rs index d4f9bb0e..a06fdce4 100644 --- a/src/unix/linux_like/linux/arch/sparc/mod.rs +++ b/src/unix/linux_like/linux/arch/sparc/mod.rs @@ -1,3 +1,16 @@ +s! { + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 19], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } +} + // arch/sparc/include/uapi/asm/socket.h pub const SOL_SOCKET: ::c_int = 0xffff; @@ -86,3 +99,100 @@ pub const SO_TIMESTAMPING: ::c_int = 0x0023; // pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP; pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; + +// Ioctl Constants + +pub const TCGETS: ::Ioctl = 0x40245408; +pub const TCSETS: ::Ioctl = 0x80245409; +pub const TCSETSW: ::Ioctl = 0x8024540a; +pub const TCSETSF: ::Ioctl = 0x8024540b; +pub const TCGETA: ::Ioctl = 0x40125401; +pub const TCSETA: ::Ioctl = 0x80125402; +pub const TCSETAW: ::Ioctl = 0x80125403; +pub const TCSETAF: ::Ioctl = 0x80125404; +pub const TCSBRK: ::Ioctl = 0x20005405; +pub const TCXONC: ::Ioctl = 0x20005406; +pub const TCFLSH: ::Ioctl = 0x20005407; +pub const TIOCEXCL: ::Ioctl = 0x2000740d; +pub const TIOCNXCL: ::Ioctl = 0x2000740e; +pub const TIOCSCTTY: ::Ioctl = 0x20007484; +pub const TIOCGPGRP: ::Ioctl = 0x40047483; +pub const TIOCSPGRP: ::Ioctl = 0x80047482; +pub const TIOCOUTQ: ::Ioctl = 0x40047473; +pub const TIOCSTI: ::Ioctl = 0x80017472; +pub const TIOCGWINSZ: ::Ioctl = 0x40087468; +pub const TIOCSWINSZ: ::Ioctl = 0x80087467; +pub const TIOCMGET: ::Ioctl = 0x4004746a; +pub const TIOCMBIS: ::Ioctl = 0x8004746c; +pub const TIOCMBIC: ::Ioctl = 0x8004746b; +pub const TIOCMSET: ::Ioctl = 0x8004746d; +pub const TIOCGSOFTCAR: ::Ioctl = 0x40047464; +pub const TIOCSSOFTCAR: ::Ioctl = 0x80047465; +pub const FIONREAD: ::Ioctl = 0x4004667f; +pub const TIOCINQ: ::Ioctl = FIONREAD; +pub const TIOCLINUX: ::Ioctl = 0x541C; +pub const TIOCCONS: ::Ioctl = 0x20007424; +pub const TIOCGSERIAL: ::Ioctl = 0x541E; +pub const TIOCSSERIAL: ::Ioctl = 0x541F; +pub const TIOCPKT: ::Ioctl = 0x80047470; +pub const FIONBIO: ::Ioctl = 0x8004667e; +pub const TIOCNOTTY: ::Ioctl = 0x20007471; +pub const TIOCSETD: ::Ioctl = 0x80047401; +pub const TIOCGETD: ::Ioctl = 0x40047400; +pub const TCSBRKP: ::Ioctl = 0x5425; +pub const TIOCSBRK: ::Ioctl = 0x2000747b; +pub const TIOCCBRK: ::Ioctl = 0x2000747a; +pub const TIOCGSID: ::Ioctl = 0x40047485; +pub const TCGETS2: ::Ioctl = 0x402c540c; +pub const TCSETS2: ::Ioctl = 0x802c540d; +pub const TCSETSW2: ::Ioctl = 0x802c540e; +pub const TCSETSF2: ::Ioctl = 0x802c540f; +pub const TIOCGPTN: ::Ioctl = 0x40047486; +pub const TIOCSPTLCK: ::Ioctl = 0x80047487; +pub const TIOCGDEV: ::Ioctl = 0x40045432; +pub const TIOCSIG: ::Ioctl = 0x80047488; +pub const TIOCVHANGUP: ::Ioctl = 0x20005437; +pub const TIOCGPKT: ::Ioctl = 0x40045438; +pub const TIOCGPTLCK: ::Ioctl = 0x40045439; +pub const TIOCGEXCL: ::Ioctl = 0x40045440; +pub const TIOCGPTPEER: ::Ioctl = 0x20007489; +pub const FIONCLEX: ::Ioctl = 0x20006602; +pub const FIOCLEX: ::Ioctl = 0x20006601; +pub const TIOCSERCONFIG: ::Ioctl = 0x5453; +pub const TIOCSERGWILD: ::Ioctl = 0x5454; +pub const TIOCSERSWILD: ::Ioctl = 0x5455; +pub const TIOCGLCKTRMIOS: ::Ioctl = 0x5456; +pub const TIOCSLCKTRMIOS: ::Ioctl = 0x5457; +pub const TIOCSERGSTRUCT: ::Ioctl = 0x5458; +pub const TIOCSERGETLSR: ::Ioctl = 0x5459; +pub const TIOCSERGETMULTI: ::Ioctl = 0x545A; +pub const TIOCSERSETMULTI: ::Ioctl = 0x545B; +pub const TIOCMIWAIT: ::Ioctl = 0x545C; +pub const TIOCGICOUNT: ::Ioctl = 0x545D; +pub const TIOCSTART: ::Ioctl = 0x2000746e; +pub const TIOCSTOP: ::Ioctl = 0x2000746f; + +//pub const FIOASYNC: ::Ioctl = 0x4004667d; +//pub const FIOQSIZE: ::Ioctl = ; +//pub const TIOCGISO7816: ::Ioctl = 0x40285443; +//pub const TIOCSISO7816: ::Ioctl = 0xc0285444; +//pub const TIOCGRS485: ::Ioctl = 0x40205441; +//pub const TIOCSRS485: ::Ioctl = 0xc0205442; + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; +pub const TIOCM_DSR: ::c_int = 0x100; + +pub const BOTHER: ::speed_t = 0x1000; +pub const IBSHIFT: ::tcflag_t = 16; + +pub const BLKSSZGET: ::Ioctl = 0x20001268; +pub const BLKPBSZGET: ::Ioctl = 0x2000127B; diff --git a/src/unix/linux_like/linux/gnu/b32/arm/align.rs b/src/unix/linux_like/linux/gnu/b32/arm/align.rs index 825546be..2645ec4c 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/align.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/align.rs @@ -4,4 +4,50 @@ s_no_extra_traits! { pub struct max_align_t { priv_: [i64; 2] } + + #[allow(missing_debug_implementations)] + #[repr(align(8))] + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_mcontext: ::mcontext_t, + pub uc_sigmask: ::sigset_t, + pub uc_regspace: [::c_ulong; 128], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for ucontext_t { + fn eq(&self, other: &ucontext_t) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask == other.uc_sigmask + } + } + impl Eq for ucontext_t {} + impl ::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_link) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_sigmask", &self.uc_sigmask) + .finish() + } + } + impl ::hash::Hash for ucontext_t { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask.hash(state); + } + } + } } diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs index 0e7fb70f..9ad1051c 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -141,17 +141,6 @@ s! { __glibc_reserved5: ::c_ulong, } - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } - pub struct siginfo_t { pub si_signo: ::c_int, pub si_errno: ::c_int, @@ -172,6 +161,36 @@ s! { pub ss_flags: ::c_int, pub ss_size: ::size_t } + + pub struct seccomp_notif_sizes { + pub seccomp_notif: ::__u16, + pub seccomp_notif_resp: ::__u16, + pub seccomp_data: ::__u16, + } + + pub struct mcontext_t { + pub trap_no: ::c_ulong, + pub error_code: ::c_ulong, + pub oldmask: ::c_ulong, + pub arm_r0: ::c_ulong, + pub arm_r1: ::c_ulong, + pub arm_r2: ::c_ulong, + pub arm_r3: ::c_ulong, + pub arm_r4: ::c_ulong, + pub arm_r5: ::c_ulong, + pub arm_r6: ::c_ulong, + pub arm_r7: ::c_ulong, + pub arm_r8: ::c_ulong, + pub arm_r9: ::c_ulong, + pub arm_r10: ::c_ulong, + pub arm_fp: ::c_ulong, + pub arm_ip: ::c_ulong, + pub arm_sp: ::c_ulong, + pub arm_lr: ::c_ulong, + pub arm_pc: ::c_ulong, + pub arm_cpsr: ::c_ulong, + pub fault_address: ::c_ulong, + } } pub const RLIM_INFINITY: ::rlim_t = !0; @@ -305,10 +324,6 @@ pub const SA_NOCLDWAIT: ::c_int = 0x00000002; pub const SOCK_STREAM: ::c_int = 1; pub const SOCK_DGRAM: ::c_int = 2; -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONCLEX: ::c_ulong = 0x5450; -pub const FIONBIO: ::c_ulong = 0x5421; - pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; @@ -419,7 +434,6 @@ pub const B19200: ::speed_t = 0o000016; pub const B38400: ::speed_t = 0o000017; pub const EXTA: ::speed_t = B19200; pub const EXTB: ::speed_t = B38400; -pub const BOTHER: ::speed_t = 0o010000; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; @@ -436,6 +450,11 @@ pub const B3000000: ::speed_t = 0o010015; pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; +pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; +pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; +pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; +pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; + pub const VEOL: usize = 11; pub const VEOL2: usize = 16; pub const VMIN: usize = 6; @@ -443,52 +462,11 @@ pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; pub const EXTPROC: ::tcflag_t = 0x00010000; -pub const TCGETS: ::c_ulong = 0x5401; -pub const TCSETS: ::c_ulong = 0x5402; -pub const TCSETSW: ::c_ulong = 0x5403; -pub const TCSETSF: ::c_ulong = 0x5404; -pub const TCGETA: ::c_ulong = 0x5405; -pub const TCSETA: ::c_ulong = 0x5406; -pub const TCSETAW: ::c_ulong = 0x5407; -pub const TCSETAF: ::c_ulong = 0x5408; -pub const TCSBRK: ::c_ulong = 0x5409; -pub const TCXONC: ::c_ulong = 0x540A; -pub const TCFLSH: ::c_ulong = 0x540B; -pub const TIOCINQ: ::c_ulong = 0x541B; -pub const TIOCGPGRP: ::c_ulong = 0x540F; -pub const TIOCSPGRP: ::c_ulong = 0x5410; -pub const TIOCOUTQ: ::c_ulong = 0x5411; -pub const TIOCGWINSZ: ::c_ulong = 0x5413; -pub const TIOCSWINSZ: ::c_ulong = 0x5414; -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; -pub const FIONREAD: ::c_ulong = 0x541B; - -pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; -pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; -pub const TIOCEXCL: ::c_ulong = 0x540C; -pub const TIOCNXCL: ::c_ulong = 0x540D; -pub const TIOCSCTTY: ::c_ulong = 0x540E; -pub const TIOCSTI: ::c_ulong = 0x5412; -pub const TIOCMGET: ::c_ulong = 0x5415; -pub const TIOCMBIS: ::c_ulong = 0x5416; -pub const TIOCMBIC: ::c_ulong = 0x5417; -pub const TIOCMSET: ::c_ulong = 0x5418; -pub const TIOCCONS: ::c_ulong = 0x541D; pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - // Syscall table pub const SYS_restart_syscall: ::c_long = 0; pub const SYS_exit: ::c_long = 1; diff --git a/src/unix/linux_like/linux/gnu/b32/m68k/align.rs b/src/unix/linux_like/linux/gnu/b32/m68k/align.rs new file mode 100644 index 00000000..639394a3 --- /dev/null +++ b/src/unix/linux_like/linux/gnu/b32/m68k/align.rs @@ -0,0 +1,7 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[repr(align(2))] + pub struct max_align_t { + priv_: [i8; 20] + } +} diff --git a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs new file mode 100644 index 00000000..0302dd7f --- /dev/null +++ b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -0,0 +1,855 @@ +pub type c_char = i8; +pub type wchar_t = i32; + +s! { + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_ulong, + pub sa_restorer: ::Option<extern fn()>, + } + + pub struct statfs { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + pub f_flags: ::__fsword_t, + f_spare: [::__fsword_t; 4], + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } + + pub struct ipc_perm { + __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::mode_t, + __seq: ::c_ushort, + __pad1: ::c_ushort, + __glibc_reserved1: ::c_ulong, + __glibc_reserved2: ::c_ulong, + } + + pub struct stat64 { + pub st_dev: ::dev_t, + __pad1: ::c_ushort, + pub __st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + __pad2: ::c_ushort, + pub st_size: ::off64_t, + pub st_blksize: ::blksize_t, + pub st_blocks: ::blkcnt64_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_ulong, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_ulong, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_ulong, + pub st_ino: ::ino64_t, + } + + pub struct statfs64 { + pub f_type: ::__fsword_t, + pub f_bsize: ::__fsword_t, + pub f_blocks: ::fsblkcnt64_t, + pub f_bfree: ::fsblkcnt64_t, + pub f_bavail: ::fsblkcnt64_t, + pub f_files: ::fsblkcnt64_t, + pub f_ffree: ::fsblkcnt64_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::__fsword_t, + pub f_frsize: ::__fsword_t, + pub f_flags: ::__fsword_t, + pub f_spare: [::__fsword_t; 4], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt64_t, + pub f_bfree: ::fsblkcnt64_t, + pub f_bavail: ::fsblkcnt64_t, + pub f_files: ::fsblkcnt64_t, + pub f_ffree: ::fsblkcnt64_t, + pub f_favail: ::fsblkcnt64_t, + pub f_fsid: ::c_ulong, + __f_unused: ::c_int, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + __f_spare: [::c_int; 6], + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + __glibc_reserved1: ::c_long, + pub shm_dtime: ::time_t, + __glibc_reserved2: ::c_long, + pub shm_ctime: ::time_t, + __glibc_reserved3: ::c_long, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __glibc_reserved5: ::c_ulong, + __glibc_reserved6: ::c_ulong, + } + + pub struct msqid_ds { + pub msg_perm: ::ipc_perm, + pub msg_stime: ::time_t, + __glibc_reserved1: ::c_uint, + pub msg_rtime: ::time_t, + __glibc_reserved2: ::c_uint, + pub msg_ctime: ::time_t, + __glibc_reserved3: ::c_uint, + __msg_cbytes: ::c_ulong, + pub msg_qnum: ::msgqnum_t, + pub msg_qbytes: ::msglen_t, + pub msg_lspid: ::pid_t, + pub msg_lrpid: ::pid_t, + __glibc_reserved4: ::c_ulong, + __glibc_reserved5: ::c_ulong, + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_code: ::c_int, + pub si_errno: ::c_int, + _pad: [::c_int; 29], + _align: [usize; 0], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } +} + +pub const RLIM_INFINITY: ::rlim_t = !0; +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: ::c_int = 0x8; +pub const RTLD_GLOBAL: ::c_int = 0x100; +pub const RTLD_NOLOAD: ::c_int = 0x4; +pub const O_DIRECT: ::c_int = 0x10000; +pub const O_DIRECTORY: ::c_int = 0x4000; +pub const O_NOFOLLOW: ::c_int = 0x8000; +pub const O_LARGEFILE: ::c_int = 0x20000; +pub const O_APPEND: ::c_int = 1024; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; +pub const O_FSYNC: ::c_int = 0x101000; +pub const O_ASYNC: ::c_int = 0x2000; +pub const O_NDELAY: ::c_int = 0x800; +pub const RLIMIT_NOFILE: ::__rlimit_resource_t = 7; +pub const RLIMIT_NPROC: ::__rlimit_resource_t = 6; +pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; +pub const RLIMIT_AS: ::__rlimit_resource_t = 9; +pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_32BIT: ::c_int = 0x0040; +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_ANONYMOUS: ::c_int = 0x0020; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; +pub const MAP_HUGETLB: ::c_int = 0x040000; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_SYNC: ::c_int = 0x080000; + +pub const EDEADLOCK: ::c_int = 35; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDEADLK: ::c_int = 35; +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EMULTIHOP: ::c_int = 72; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EBADMSG: ::c_int = 74; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const EHWPOISON: ::c_int = 133; +pub const ERFKILL: ::c_int = 132; + +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; + +pub const F_GETLK: ::c_int = 5; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETOWN: ::c_int = 8; + +pub const PTRACE_GETFPXREGS: ::c_uint = 18; +pub const PTRACE_SETFPXREGS: ::c_uint = 19; +pub const PTRACE_SYSEMU: ::c_uint = 31; +pub const PTRACE_SYSEMU_SINGLESTEP: ::c_uint = 32; + +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const EFD_NONBLOCK: ::c_int = 0x800; +pub const SFD_NONBLOCK: ::c_int = 0x0800; + +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: ::c_int = 31; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const FF1: ::tcflag_t = 0x00008000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VT1: ::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; + +pub const B0: ::speed_t = 0o000000; +pub const B50: ::speed_t = 0o000001; +pub const B75: ::speed_t = 0o000002; +pub const B110: ::speed_t = 0o000003; +pub const B134: ::speed_t = 0o000004; +pub const B150: ::speed_t = 0o000005; +pub const B200: ::speed_t = 0o000006; +pub const B300: ::speed_t = 0o000007; +pub const B600: ::speed_t = 0o000010; +pub const B1200: ::speed_t = 0o000011; +pub const B1800: ::speed_t = 0o000012; +pub const B2400: ::speed_t = 0o000013; +pub const B4800: ::speed_t = 0o000014; +pub const B9600: ::speed_t = 0o000015; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; +pub const EXTA: ::speed_t = B19200; +pub const EXTB: ::speed_t = B38400; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: ::tcflag_t = 0x00008000; +pub const TOSTOP: ::tcflag_t = 0x00000100; +pub const FLUSHO: ::tcflag_t = 0x00001000; +pub const EXTPROC: ::tcflag_t = 0x00010000; + +pub const TCSANOW: ::c_int = 0; +pub const TCSADRAIN: ::c_int = 1; +pub const TCSAFLUSH: ::c_int = 2; + +pub const SYS_restart_syscall: ::c_long = 0; +pub const SYS_exit: ::c_long = 1; +pub const SYS_fork: ::c_long = 2; +pub const SYS_read: ::c_long = 3; +pub const SYS_write: ::c_long = 4; +pub const SYS_open: ::c_long = 5; +pub const SYS_close: ::c_long = 6; +pub const SYS_waitpid: ::c_long = 7; +pub const SYS_creat: ::c_long = 8; +pub const SYS_link: ::c_long = 9; +pub const SYS_unlink: ::c_long = 10; +pub const SYS_execve: ::c_long = 11; +pub const SYS_chdir: ::c_long = 12; +pub const SYS_time32: ::c_long = 13; +pub const SYS_mknod: ::c_long = 14; +pub const SYS_chmod: ::c_long = 15; +pub const SYS_chown16: ::c_long = 16; +pub const SYS_stat: ::c_long = 18; +pub const SYS_lseek: ::c_long = 19; +pub const SYS_getpid: ::c_long = 20; +pub const SYS_mount: ::c_long = 21; +pub const SYS_oldumount: ::c_long = 22; +pub const SYS_setuid16: ::c_long = 23; +pub const SYS_getuid16: ::c_long = 24; +pub const SYS_stime32: ::c_long = 25; +pub const SYS_ptrace: ::c_long = 26; +pub const SYS_alarm: ::c_long = 27; +pub const SYS_fstat: ::c_long = 28; +pub const SYS_pause: ::c_long = 29; +pub const SYS_utime32: ::c_long = 30; +pub const SYS_access: ::c_long = 33; +pub const SYS_nice: ::c_long = 34; +pub const SYS_sync: ::c_long = 36; +pub const SYS_kill: ::c_long = 37; +pub const SYS_rename: ::c_long = 38; +pub const SYS_mkdir: ::c_long = 39; +pub const SYS_rmdir: ::c_long = 40; +pub const SYS_dup: ::c_long = 41; +pub const SYS_pipe: ::c_long = 42; +pub const SYS_times: ::c_long = 43; +pub const SYS_brk: ::c_long = 45; +pub const SYS_setgid16: ::c_long = 46; +pub const SYS_getgid16: ::c_long = 47; +pub const SYS_signal: ::c_long = 48; +pub const SYS_geteuid16: ::c_long = 49; +pub const SYS_getegid16: ::c_long = 50; +pub const SYS_acct: ::c_long = 51; +pub const SYS_umount: ::c_long = 52; +pub const SYS_ioctl: ::c_long = 54; +pub const SYS_fcntl: ::c_long = 55; +pub const SYS_setpgid: ::c_long = 57; +pub const SYS_umask: ::c_long = 60; +pub const SYS_chroot: ::c_long = 61; +pub const SYS_ustat: ::c_long = 62; +pub const SYS_dup2: ::c_long = 63; +pub const SYS_getppid: ::c_long = 64; +pub const SYS_getpgrp: ::c_long = 65; +pub const SYS_setsid: ::c_long = 66; +pub const SYS_sigaction: ::c_long = 67; +pub const SYS_sgetmask: ::c_long = 68; +pub const SYS_ssetmask: ::c_long = 69; +pub const SYS_setreuid16: ::c_long = 70; +pub const SYS_setregid16: ::c_long = 71; +pub const SYS_sigsuspend: ::c_long = 72; +pub const SYS_sigpending: ::c_long = 73; +pub const SYS_sethostname: ::c_long = 74; +pub const SYS_setrlimit: ::c_long = 75; +pub const SYS_old_getrlimit: ::c_long = 76; +pub const SYS_getrusage: ::c_long = 77; +pub const SYS_gettimeofday: ::c_long = 78; +pub const SYS_settimeofday: ::c_long = 79; +pub const SYS_getgroups16: ::c_long = 80; +pub const SYS_setgroups16: ::c_long = 81; +pub const SYS_old_select: ::c_long = 82; +pub const SYS_symlink: ::c_long = 83; +pub const SYS_lstat: ::c_long = 84; +pub const SYS_readlink: ::c_long = 85; +pub const SYS_uselib: ::c_long = 86; +pub const SYS_swapon: ::c_long = 87; +pub const SYS_reboot: ::c_long = 88; +pub const SYS_old_readdir: ::c_long = 89; +pub const SYS_old_mmap: ::c_long = 90; +pub const SYS_munmap: ::c_long = 91; +pub const SYS_truncate: ::c_long = 92; +pub const SYS_ftruncate: ::c_long = 93; +pub const SYS_fchmod: ::c_long = 94; +pub const SYS_fchown16: ::c_long = 95; +pub const SYS_getpriority: ::c_long = 96; +pub const SYS_setpriority: ::c_long = 97; +pub const SYS_statfs: ::c_long = 99; +pub const SYS_fstatfs: ::c_long = 100; +pub const SYS_socketcall: ::c_long = 102; +pub const SYS_syslog: ::c_long = 103; +pub const SYS_setitimer: ::c_long = 104; +pub const SYS_getitimer: ::c_long = 105; +pub const SYS_newstat: ::c_long = 106; +pub const SYS_newlstat: ::c_long = 107; +pub const SYS_newfstat: ::c_long = 108; +pub const SYS_vhangup: ::c_long = 111; +pub const SYS_wait4: ::c_long = 114; +pub const SYS_swapoff: ::c_long = 115; +pub const SYS_sysinfo: ::c_long = 116; +pub const SYS_ipc: ::c_long = 117; +pub const SYS_fsync: ::c_long = 118; +pub const SYS_sigreturn: ::c_long = 119; +pub const SYS_clone: ::c_long = 120; +pub const SYS_setdomainname: ::c_long = 121; +pub const SYS_newuname: ::c_long = 122; +pub const SYS_cacheflush: ::c_long = 123; +pub const SYS_adjtimex_time32: ::c_long = 124; +pub const SYS_mprotect: ::c_long = 125; +pub const SYS_sigprocmask: ::c_long = 126; +pub const SYS_create_module: ::c_long = 127; +pub const SYS_init_module: ::c_long = 128; +pub const SYS_delete_module: ::c_long = 129; +pub const SYS_get_kernel_syms: ::c_long = 130; +pub const SYS_quotactl: ::c_long = 131; +pub const SYS_getpgid: ::c_long = 132; +pub const SYS_fchdir: ::c_long = 133; +pub const SYS_bdflush: ::c_long = 134; +pub const SYS_sysfs: ::c_long = 135; +pub const SYS_personality: ::c_long = 136; +pub const SYS_setfsuid16: ::c_long = 138; +pub const SYS_setfsgid16: ::c_long = 139; +pub const SYS_llseek: ::c_long = 140; +pub const SYS_getdents: ::c_long = 141; +pub const SYS_select: ::c_long = 142; +pub const SYS_flock: ::c_long = 143; +pub const SYS_msync: ::c_long = 144; +pub const SYS_readv: ::c_long = 145; +pub const SYS_writev: ::c_long = 146; +pub const SYS_getsid: ::c_long = 147; +pub const SYS_fdatasync: ::c_long = 148; +pub const SYS__sysctl: ::c_long = 149; +pub const SYS_mlock: ::c_long = 150; +pub const SYS_munlock: ::c_long = 151; +pub const SYS_mlockall: ::c_long = 152; +pub const SYS_munlockall: ::c_long = 153; +pub const SYS_sched_setparam: ::c_long = 154; +pub const SYS_sched_getparam: ::c_long = 155; +pub const SYS_sched_setscheduler: ::c_long = 156; +pub const SYS_sched_getscheduler: ::c_long = 157; +pub const SYS_sched_yield: ::c_long = 158; +pub const SYS_sched_get_priority_max: ::c_long = 159; +pub const SYS_sched_get_priority_min: ::c_long = 160; +pub const SYS_sched_rr_get_interval_time32: ::c_long = 161; +pub const SYS_nanosleep_time32: ::c_long = 162; +pub const SYS_mremap: ::c_long = 163; +pub const SYS_setresuid16: ::c_long = 164; +pub const SYS_getresuid16: ::c_long = 165; +pub const SYS_getpagesize: ::c_long = 166; +pub const SYS_query_module: ::c_long = 167; +pub const SYS_poll: ::c_long = 168; +pub const SYS_nfsservctl: ::c_long = 169; +pub const SYS_setresgid16: ::c_long = 170; +pub const SYS_getresgid16: ::c_long = 171; +pub const SYS_prctl: ::c_long = 172; +pub const SYS_rt_sigreturn: ::c_long = 173; +pub const SYS_rt_sigaction: ::c_long = 174; +pub const SYS_rt_sigprocmask: ::c_long = 175; +pub const SYS_rt_sigpending: ::c_long = 176; +pub const SYS_rt_sigtimedwait_time32: ::c_long = 177; +pub const SYS_rt_sigqueueinfo: ::c_long = 178; +pub const SYS_rt_sigsuspend: ::c_long = 179; +pub const SYS_pread64: ::c_long = 180; +pub const SYS_pwrite64: ::c_long = 181; +pub const SYS_lchown16: ::c_long = 182; +pub const SYS_getcwd: ::c_long = 183; +pub const SYS_capget: ::c_long = 184; +pub const SYS_capset: ::c_long = 185; +pub const SYS_sigaltstack: ::c_long = 186; +pub const SYS_sendfile: ::c_long = 187; +pub const SYS_getpmsg: ::c_long = 188; +pub const SYS_putpmsg: ::c_long = 189; +pub const SYS_vfork: ::c_long = 190; +pub const SYS_getrlimit: ::c_long = 191; +pub const SYS_mmap2: ::c_long = 192; +pub const SYS_truncate64: ::c_long = 193; +pub const SYS_ftruncate64: ::c_long = 194; +pub const SYS_stat64: ::c_long = 195; +pub const SYS_lstat64: ::c_long = 196; +pub const SYS_fstat64: ::c_long = 197; +pub const SYS_chown: ::c_long = 198; +pub const SYS_getuid: ::c_long = 199; +pub const SYS_getgid: ::c_long = 200; +pub const SYS_geteuid: ::c_long = 201; +pub const SYS_getegid: ::c_long = 202; +pub const SYS_setreuid: ::c_long = 203; +pub const SYS_setregid: ::c_long = 204; +pub const SYS_getgroups: ::c_long = 205; +pub const SYS_setgroups: ::c_long = 206; +pub const SYS_fchown: ::c_long = 207; +pub const SYS_setresuid: ::c_long = 208; +pub const SYS_getresuid: ::c_long = 209; +pub const SYS_setresgid: ::c_long = 210; +pub const SYS_getresgid: ::c_long = 211; +pub const SYS_lchown: ::c_long = 212; +pub const SYS_setuid: ::c_long = 213; +pub const SYS_setgid: ::c_long = 214; +pub const SYS_setfsuid: ::c_long = 215; +pub const SYS_setfsgid: ::c_long = 216; +pub const SYS_pivot_root: ::c_long = 217; +pub const SYS_getdents64: ::c_long = 220; +pub const SYS_gettid: ::c_long = 221; +pub const SYS_tkill: ::c_long = 222; +pub const SYS_setxattr: ::c_long = 223; +pub const SYS_lsetxattr: ::c_long = 224; +pub const SYS_fsetxattr: ::c_long = 225; +pub const SYS_getxattr: ::c_long = 226; +pub const SYS_lgetxattr: ::c_long = 227; +pub const SYS_fgetxattr: ::c_long = 228; +pub const SYS_listxattr: ::c_long = 229; +pub const SYS_llistxattr: ::c_long = 230; +pub const SYS_flistxattr: ::c_long = 231; +pub const SYS_removexattr: ::c_long = 232; +pub const SYS_lremovexattr: ::c_long = 233; +pub const SYS_fremovexattr: ::c_long = 234; +pub const SYS_futex_time32: ::c_long = 235; +pub const SYS_sendfile64: ::c_long = 236; +pub const SYS_mincore: ::c_long = 237; +pub const SYS_madvise: ::c_long = 238; +pub const SYS_fcntl64: ::c_long = 239; +pub const SYS_readahead: ::c_long = 240; +pub const SYS_io_setup: ::c_long = 241; +pub const SYS_io_destroy: ::c_long = 242; +pub const SYS_io_getevents_time32: ::c_long = 243; +pub const SYS_io_submit: ::c_long = 244; +pub const SYS_io_cancel: ::c_long = 245; +pub const SYS_fadvise64: ::c_long = 246; +pub const SYS_exit_group: ::c_long = 247; +pub const SYS_lookup_dcookie: ::c_long = 248; +pub const SYS_epoll_create: ::c_long = 249; +pub const SYS_epoll_ctl: ::c_long = 250; +pub const SYS_epoll_wait: ::c_long = 251; +pub const SYS_remap_file_pages: ::c_long = 252; +pub const SYS_set_tid_address: ::c_long = 253; +pub const SYS_timer_create: ::c_long = 254; +pub const SYS_timer_settime32: ::c_long = 255; +pub const SYS_timer_gettime32: ::c_long = 256; +pub const SYS_timer_getoverrun: ::c_long = 257; +pub const SYS_timer_delete: ::c_long = 258; +pub const SYS_clock_settime32: ::c_long = 259; +pub const SYS_clock_gettime32: ::c_long = 260; +pub const SYS_clock_getres_time32: ::c_long = 261; +pub const SYS_clock_nanosleep_time32: ::c_long = 262; +pub const SYS_statfs64: ::c_long = 263; +pub const SYS_fstatfs64: ::c_long = 264; +pub const SYS_tgkill: ::c_long = 265; +pub const SYS_utimes_time32: ::c_long = 266; +pub const SYS_fadvise64_64: ::c_long = 267; +pub const SYS_mbind: ::c_long = 268; +pub const SYS_get_mempolicy: ::c_long = 269; +pub const SYS_set_mempolicy: ::c_long = 270; +pub const SYS_mq_open: ::c_long = 271; +pub const SYS_mq_unlink: ::c_long = 272; +pub const SYS_mq_timedsend_time32: ::c_long = 273; +pub const SYS_mq_timedreceive_time32: ::c_long = 274; +pub const SYS_mq_notify: ::c_long = 275; +pub const SYS_mq_getsetattr: ::c_long = 276; +pub const SYS_waitid: ::c_long = 277; +pub const SYS_add_key: ::c_long = 279; +pub const SYS_request_key: ::c_long = 280; +pub const SYS_keyctl: ::c_long = 281; +pub const SYS_ioprio_set: ::c_long = 282; +pub const SYS_ioprio_get: ::c_long = 283; +pub const SYS_inotify_init: ::c_long = 284; +pub const SYS_inotify_add_watch: ::c_long = 285; +pub const SYS_inotify_rm_watch: ::c_long = 286; +pub const SYS_migrate_pages: ::c_long = 287; +pub const SYS_openat: ::c_long = 288; +pub const SYS_mkdirat: ::c_long = 289; +pub const SYS_mknodat: ::c_long = 290; +pub const SYS_fchownat: ::c_long = 291; +pub const SYS_futimesat_time32: ::c_long = 292; +pub const SYS_fstatat64: ::c_long = 293; +pub const SYS_unlinkat: ::c_long = 294; +pub const SYS_renameat: ::c_long = 295; +pub const SYS_linkat: ::c_long = 296; +pub const SYS_symlinkat: ::c_long = 297; +pub const SYS_readlinkat: ::c_long = 298; +pub const SYS_fchmodat: ::c_long = 299; +pub const SYS_faccessat: ::c_long = 300; +pub const SYS_pselect6_time32: ::c_long = 301; +pub const SYS_ppoll_time32: ::c_long = 302; +pub const SYS_unshare: ::c_long = 303; +pub const SYS_set_robust_list: ::c_long = 304; +pub const SYS_get_robust_list: ::c_long = 305; +pub const SYS_splice: ::c_long = 306; +pub const SYS_sync_file_range: ::c_long = 307; +pub const SYS_tee: ::c_long = 308; +pub const SYS_vmsplice: ::c_long = 309; +pub const SYS_move_pages: ::c_long = 310; +pub const SYS_sched_setaffinity: ::c_long = 311; +pub const SYS_sched_getaffinity: ::c_long = 312; +pub const SYS_kexec_load: ::c_long = 313; +pub const SYS_getcpu: ::c_long = 314; +pub const SYS_epoll_pwait: ::c_long = 315; +pub const SYS_utimensat_time32: ::c_long = 316; +pub const SYS_signalfd: ::c_long = 317; +pub const SYS_timerfd_create: ::c_long = 318; +pub const SYS_eventfd: ::c_long = 319; +pub const SYS_fallocate: ::c_long = 320; +pub const SYS_timerfd_settime32: ::c_long = 321; +pub const SYS_timerfd_gettime32: ::c_long = 322; +pub const SYS_signalfd4: ::c_long = 323; +pub const SYS_eventfd2: ::c_long = 324; +pub const SYS_epoll_create1: ::c_long = 325; +pub const SYS_dup3: ::c_long = 326; +pub const SYS_pipe2: ::c_long = 327; +pub const SYS_inotify_init1: ::c_long = 328; +pub const SYS_preadv: ::c_long = 329; +pub const SYS_pwritev: ::c_long = 330; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 331; +pub const SYS_perf_event_open: ::c_long = 332; +pub const SYS_get_thread_area: ::c_long = 333; +pub const SYS_set_thread_area: ::c_long = 334; +pub const SYS_atomic_cmpxchg_32: ::c_long = 335; +pub const SYS_atomic_barrier: ::c_long = 336; +pub const SYS_fanotify_init: ::c_long = 337; +pub const SYS_fanotify_mark: ::c_long = 338; +pub const SYS_prlimit64: ::c_long = 339; +pub const SYS_name_to_handle_at: ::c_long = 340; +pub const SYS_open_by_handle_at: ::c_long = 341; +pub const SYS_clock_adjtime32: ::c_long = 342; +pub const SYS_syncfs: ::c_long = 343; +pub const SYS_setns: ::c_long = 344; +pub const SYS_process_vm_readv: ::c_long = 345; +pub const SYS_process_vm_writev: ::c_long = 346; +pub const SYS_kcmp: ::c_long = 347; +pub const SYS_finit_module: ::c_long = 348; +pub const SYS_sched_setattr: ::c_long = 349; +pub const SYS_sched_getattr: ::c_long = 350; +pub const SYS_renameat2: ::c_long = 351; +pub const SYS_getrandom: ::c_long = 352; +pub const SYS_memfd_create: ::c_long = 353; +pub const SYS_bpf: ::c_long = 354; +pub const SYS_execveat: ::c_long = 355; +pub const SYS_socket: ::c_long = 356; +pub const SYS_socketpair: ::c_long = 357; +pub const SYS_bind: ::c_long = 358; +pub const SYS_connect: ::c_long = 359; +pub const SYS_listen: ::c_long = 360; +pub const SYS_accept4: ::c_long = 361; +pub const SYS_getsockopt: ::c_long = 362; +pub const SYS_setsockopt: ::c_long = 363; +pub const SYS_getsockname: ::c_long = 364; +pub const SYS_getpeername: ::c_long = 365; +pub const SYS_sendto: ::c_long = 366; +pub const SYS_sendmsg: ::c_long = 367; +pub const SYS_recvfrom: ::c_long = 368; +pub const SYS_recvmsg: ::c_long = 369; +pub const SYS_shutdown: ::c_long = 370; +pub const SYS_recvmmsg_time32: ::c_long = 371; +pub const SYS_sendmmsg: ::c_long = 372; +pub const SYS_userfaultfd: ::c_long = 373; +pub const SYS_membarrier: ::c_long = 374; +pub const SYS_mlock2: ::c_long = 375; +pub const SYS_copy_file_range: ::c_long = 376; +pub const SYS_preadv2: ::c_long = 377; +pub const SYS_pwritev2: ::c_long = 378; +pub const SYS_statx: ::c_long = 379; +pub const SYS_seccomp: ::c_long = 380; +pub const SYS_pkey_mprotect: ::c_long = 381; +pub const SYS_pkey_alloc: ::c_long = 382; +pub const SYS_pkey_free: ::c_long = 383; +pub const SYS_rseq: ::c_long = 384; +pub const SYS_semget: ::c_long = 393; +pub const SYS_semctl: ::c_long = 394; +pub const SYS_shmget: ::c_long = 395; +pub const SYS_shmctl: ::c_long = 396; +pub const SYS_shmat: ::c_long = 397; +pub const SYS_shmdt: ::c_long = 398; +pub const SYS_msgget: ::c_long = 399; +pub const SYS_msgsnd: ::c_long = 400; +pub const SYS_msgrcv: ::c_long = 401; +pub const SYS_msgctl: ::c_long = 402; +pub const SYS_clock_gettime: ::c_long = 403; +pub const SYS_clock_settime: ::c_long = 404; +pub const SYS_clock_adjtime: ::c_long = 405; +pub const SYS_clock_getres: ::c_long = 406; +pub const SYS_clock_nanosleep: ::c_long = 407; +pub const SYS_timer_gettime: ::c_long = 408; +pub const SYS_timer_settime: ::c_long = 409; +pub const SYS_timerfd_gettime: ::c_long = 410; +pub const SYS_timerfd_settime: ::c_long = 411; +pub const SYS_utimensat: ::c_long = 412; +pub const SYS_pselect6: ::c_long = 413; +pub const SYS_ppoll: ::c_long = 414; +pub const SYS_io_pgetevents: ::c_long = 416; +pub const SYS_recvmmsg: ::c_long = 417; +pub const SYS_mq_timedsend: ::c_long = 418; +pub const SYS_mq_timedreceive: ::c_long = 419; +pub const SYS_semtimedop: ::c_long = 420; +pub const SYS_rt_sigtimedwait: ::c_long = 421; +pub const SYS_futex: ::c_long = 422; +pub const SYS_sched_rr_get_interval: ::c_long = 423; +pub const SYS_pidfd_send_signal: ::c_long = 424; +pub const SYS_io_uring_setup: ::c_long = 425; +pub const SYS_io_uring_enter: ::c_long = 426; +pub const SYS_io_uring_register: ::c_long = 427; +pub const SYS_open_tree: ::c_long = 428; +pub const SYS_move_mount: ::c_long = 429; +pub const SYS_fsopen: ::c_long = 430; +pub const SYS_fsconfig: ::c_long = 431; +pub const SYS_fsmount: ::c_long = 432; +pub const SYS_fspick: ::c_long = 433; +pub const SYS_pidfd_open: ::c_long = 434; +pub const SYS_clone3: ::c_long = 435; +pub const SYS_close_range: ::c_long = 436; +pub const SYS_openat2: ::c_long = 437; +pub const SYS_pidfd_getfd: ::c_long = 438; +pub const SYS_faccessat2: ::c_long = 439; +pub const SYS_process_madvise: ::c_long = 440; +pub const SYS_epoll_pwait2: ::c_long = 441; +pub const SYS_mount_setattr: ::c_long = 442; +pub const SYS_quotactl_fd: ::c_long = 443; +pub const SYS_landlock_create_ruleset: ::c_long = 444; +pub const SYS_landlock_add_rule: ::c_long = 445; +pub const SYS_landlock_restrict_self: ::c_long = 446; +pub const SYS_process_mrelease: ::c_long = 448; +pub const SYS_futex_waitv: ::c_long = 449; +pub const SYS_set_mempolicy_home_node: ::c_long = 450; diff --git a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs index 4ded201f..9106f70e 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -153,17 +153,6 @@ s! { pub l_pid: ::pid_t, pad: [::c_long; 4], } - - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 23], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } } pub const O_LARGEFILE: ::c_int = 0x2000; @@ -668,10 +657,6 @@ pub const MAP_STACK: ::c_int = 0x40000; pub const SOCK_STREAM: ::c_int = 2; pub const SOCK_DGRAM: ::c_int = 1; -pub const FIOCLEX: ::c_ulong = 0x6601; -pub const FIONCLEX: ::c_ulong = 0x6602; -pub const FIONBIO: ::c_ulong = 0x667e; - pub const SA_SIGINFO: ::c_int = 0x00000008; pub const SA_NOCLDWAIT: ::c_int = 0x00010000; @@ -726,38 +711,6 @@ pub const F_SETOWN: ::c_int = 24; pub const SFD_NONBLOCK: ::c_int = 0x80; -pub const TCGETS: ::c_ulong = 0x540d; -pub const TCSETS: ::c_ulong = 0x540e; -pub const TCSETSW: ::c_ulong = 0x540f; -pub const TCSETSF: ::c_ulong = 0x5410; -pub const TCGETA: ::c_ulong = 0x5401; -pub const TCSETA: ::c_ulong = 0x5402; -pub const TCSETAW: ::c_ulong = 0x5403; -pub const TCSETAF: ::c_ulong = 0x5404; -pub const TCSBRK: ::c_ulong = 0x5405; -pub const TCXONC: ::c_ulong = 0x5406; -pub const TCFLSH: ::c_ulong = 0x5407; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5481; -pub const TIOCSSOFTCAR: ::c_ulong = 0x5482; -pub const TIOCINQ: ::c_ulong = 0x467f; -pub const TIOCLINUX: ::c_ulong = 0x5483; -pub const TIOCGSERIAL: ::c_ulong = 0x5484; -pub const TIOCEXCL: ::c_ulong = 0x740d; -pub const TIOCNXCL: ::c_ulong = 0x740e; -pub const TIOCSCTTY: ::c_ulong = 0x5480; -pub const TIOCGPGRP: ::c_ulong = 0x40047477; -pub const TIOCSPGRP: ::c_ulong = 0x80047476; -pub const TIOCOUTQ: ::c_ulong = 0x7472; -pub const TIOCSTI: ::c_ulong = 0x5472; -pub const TIOCGWINSZ: ::c_ulong = 0x40087468; -pub const TIOCSWINSZ: ::c_ulong = 0x80087467; -pub const TIOCMGET: ::c_ulong = 0x741d; -pub const TIOCMBIS: ::c_ulong = 0x741b; -pub const TIOCMBIC: ::c_ulong = 0x741c; -pub const TIOCMSET: ::c_ulong = 0x741a; -pub const FIONREAD: ::c_ulong = 0x467f; -pub const TIOCCONS: ::c_ulong = 0x80047478; - pub const RTLD_DEEPBIND: ::c_int = 0x10; pub const RTLD_GLOBAL: ::c_int = 0x4; pub const RTLD_NOLOAD: ::c_int = 0x8; @@ -837,7 +790,6 @@ pub const B19200: ::speed_t = 0o000016; pub const B38400: ::speed_t = 0o000017; pub const EXTA: ::speed_t = B19200; pub const EXTB: ::speed_t = B38400; -pub const BOTHER: ::speed_t = 0o010000; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; @@ -854,13 +806,6 @@ pub const B3000000: ::speed_t = 0o010015; pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; -pub const TIOCM_ST: ::c_int = 0x010; -pub const TIOCM_SR: ::c_int = 0x020; -pub const TIOCM_CTS: ::c_int = 0x040; -pub const TIOCM_CAR: ::c_int = 0x100; -pub const TIOCM_RNG: ::c_int = 0x200; -pub const TIOCM_DSR: ::c_int = 0x400; - pub const EHWPOISON: ::c_int = 168; cfg_if! { diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index 418c6380..ad0d64c5 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -11,6 +11,7 @@ pub type msgqnum_t = ::c_ulong; pub type msglen_t = ::c_ulong; pub type nlink_t = u32; pub type __u64 = ::c_ulonglong; +pub type __s64 = ::c_longlong; pub type __fsword_t = i32; pub type fsblkcnt64_t = u64; pub type fsfilcnt64_t = u64; @@ -134,12 +135,6 @@ s! { pub _f: [::c_char; 8], } - pub struct ip_mreqn { - pub imr_multiaddr: ::in_addr, - pub imr_address: ::in_addr, - pub imr_ifindex: ::c_int, - } - pub struct semid_ds { pub sem_perm: ipc_perm, #[cfg(target_arch = "powerpc")] @@ -322,9 +317,6 @@ pub const PTRACE_SETFPREGS: ::c_uint = 15; pub const PTRACE_GETREGS: ::c_uint = 12; pub const PTRACE_SETREGS: ::c_uint = 13; -pub const TIOCSBRK: ::c_int = 0x5427; -pub const TIOCCBRK: ::c_int = 0x5428; - extern "C" { pub fn sysctl( name: *mut ::c_int, @@ -346,6 +338,9 @@ cfg_if! { } else if #[cfg(target_arch = "mips")] { mod mips; pub use self::mips::*; + } else if #[cfg(target_arch = "m68k")] { + mod m68k; + pub use self::m68k::*; } else if #[cfg(target_arch = "powerpc")] { mod powerpc; pub use self::powerpc::*; diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index 59c1e1c8..a615e52c 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -192,15 +192,6 @@ pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - pub const MADV_SOFT_OFFLINE: ::c_int = 101; pub const MAP_LOCKED: ::c_int = 0x00080; pub const MAP_NORESERVE: ::c_int = 0x00040; @@ -306,10 +297,6 @@ pub const SA_NOCLDWAIT: ::c_int = 0x00000002; pub const SOCK_STREAM: ::c_int = 1; pub const SOCK_DGRAM: ::c_int = 2; -pub const FIOCLEX: ::c_ulong = 0x20006601; -pub const FIONCLEX: ::c_ulong = 0x20006602; -pub const FIONBIO: ::c_ulong = 0x8004667e; - pub const MCL_CURRENT: ::c_int = 0x2000; pub const MCL_FUTURE: ::c_int = 0x4000; @@ -323,18 +310,6 @@ pub const F_SETOWN: ::c_int = 8; pub const EFD_NONBLOCK: ::c_int = 0x800; pub const SFD_NONBLOCK: ::c_int = 0x0800; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; -pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; -pub const TIOCEXCL: ::c_ulong = 0x540C; -pub const TIOCNXCL: ::c_ulong = 0x540D; -pub const TIOCSCTTY: ::c_ulong = 0x540E; -pub const TIOCSTI: ::c_ulong = 0x5412; -pub const TIOCMGET: ::c_ulong = 0x5415; -pub const TIOCMBIS: ::c_ulong = 0x5416; -pub const TIOCMBIC: ::c_ulong = 0x5417; -pub const TIOCMSET: ::c_ulong = 0x5418; -pub const TIOCCONS: ::c_ulong = 0x541D; - pub const SIGCHLD: ::c_int = 17; pub const SIGBUS: ::c_int = 7; pub const SIGUSR1: ::c_int = 10; @@ -446,7 +421,6 @@ pub const B2500000: ::speed_t = 0o0033; pub const B3000000: ::speed_t = 0o0034; pub const B3500000: ::speed_t = 0o0035; pub const B4000000: ::speed_t = 0o0036; -pub const BOTHER: ::speed_t = 0o0037; pub const VEOL: usize = 6; pub const VEOL2: usize = 8; @@ -455,26 +429,6 @@ pub const IEXTEN: ::tcflag_t = 0x400; pub const TOSTOP: ::tcflag_t = 0x400000; pub const FLUSHO: ::tcflag_t = 0x800000; pub const EXTPROC: ::tcflag_t = 0x10000000; -pub const TCGETS: ::c_ulong = 0x403c7413; -pub const TCSETS: ::c_ulong = 0x803c7414; -pub const TCSETSW: ::c_ulong = 0x803c7415; -pub const TCSETSF: ::c_ulong = 0x803c7416; -pub const TCGETA: ::c_ulong = 0x40147417; -pub const TCSETA: ::c_ulong = 0x80147418; -pub const TCSETAW: ::c_ulong = 0x80147419; -pub const TCSETAF: ::c_ulong = 0x8014741c; -pub const TCSBRK: ::c_ulong = 0x2000741d; -pub const TCXONC: ::c_ulong = 0x2000741e; -pub const TCFLSH: ::c_ulong = 0x2000741f; -pub const TIOCINQ: ::c_ulong = 0x4004667f; -pub const TIOCGPGRP: ::c_ulong = 0x40047477; -pub const TIOCSPGRP: ::c_ulong = 0x80047476; -pub const TIOCOUTQ: ::c_ulong = 0x40047473; -pub const TIOCGWINSZ: ::c_ulong = 0x40087468; -pub const TIOCSWINSZ: ::c_ulong = 0x80087467; -pub const TIOCGRS485: ::c_int = 0x542e; -pub const TIOCSRS485: ::c_int = 0x542f; -pub const FIONREAD: ::c_ulong = 0x4004667f; pub const SYS_restart_syscall: ::c_long = 0; pub const SYS_exit: ::c_long = 1; diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/align.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/align.rs new file mode 100644 index 00000000..48d152a5 --- /dev/null +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/align.rs @@ -0,0 +1,44 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct ucontext_t { + pub __uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_sigmask: ::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct mcontext_t { + pub __gregs: [::c_ulong; 32], + pub __fpregs: __riscv_mc_fp_state, + } + + #[allow(missing_debug_implementations)] + pub union __riscv_mc_fp_state { + pub __f: __riscv_mc_f_ext_state, + pub __d: __riscv_mc_d_ext_state, + pub __q: __riscv_mc_q_ext_state, + } + + #[allow(missing_debug_implementations)] + pub struct __riscv_mc_f_ext_state { + pub __f: [::c_uint; 32], + pub __fcsr: ::c_uint, + } + + #[allow(missing_debug_implementations)] + pub struct __riscv_mc_d_ext_state { + pub __f: [::c_ulonglong; 32], + pub __fcsr: ::c_uint, + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct __riscv_mc_q_ext_state { + pub __f: [::c_ulonglong; 64], + pub __fcsr: ::c_uint, + pub __glibc_reserved: [::c_uint; 3], + } +} diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs index 09061f38..9d77c0ba 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -203,10 +203,6 @@ pub const VEOF: usize = 4; pub const RTLD_DEEPBIND: ::c_int = 0x8; pub const RTLD_GLOBAL: ::c_int = 0x100; pub const RTLD_NOLOAD: ::c_int = 0x4; -pub const TIOCGSOFTCAR: ::c_ulong = 21529; -pub const TIOCSSOFTCAR: ::c_ulong = 21530; -pub const TIOCGRS485: ::c_int = 21550; -pub const TIOCSRS485: ::c_int = 21551; pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; pub const RLIMIT_AS: ::__rlimit_resource_t = 9; pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; @@ -341,23 +337,6 @@ pub const SFD_NONBLOCK: ::c_int = 2048; pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 21532; -pub const TIOCGSERIAL: ::c_ulong = 21534; -pub const TIOCEXCL: ::c_ulong = 21516; -pub const TIOCNXCL: ::c_ulong = 21517; -pub const TIOCSCTTY: ::c_ulong = 21518; -pub const TIOCSTI: ::c_ulong = 21522; -pub const TIOCMGET: ::c_ulong = 21525; -pub const TIOCMBIS: ::c_ulong = 21526; -pub const TIOCMBIC: ::c_ulong = 21527; -pub const TIOCMSET: ::c_ulong = 21528; -pub const TIOCCONS: ::c_ulong = 21533; -pub const TIOCM_ST: ::c_int = 8; -pub const TIOCM_SR: ::c_int = 16; -pub const TIOCM_CTS: ::c_int = 32; -pub const TIOCM_CAR: ::c_int = 64; -pub const TIOCM_RNG: ::c_int = 128; -pub const TIOCM_DSR: ::c_int = 256; pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; @@ -381,9 +360,6 @@ pub const ENOTNAM: ::c_int = 118; pub const ENAVAIL: ::c_int = 119; pub const EISNAM: ::c_int = 120; pub const EREMOTEIO: ::c_int = 121; -pub const FIOCLEX: ::c_ulong = 21585; -pub const FIONCLEX: ::c_ulong = 21584; -pub const FIONBIO: ::c_ulong = 21537; pub const MCL_CURRENT: ::c_int = 1; pub const MCL_FUTURE: ::c_int = 2; pub const SIGSTKSZ: ::size_t = 8192; @@ -479,26 +455,18 @@ pub const IEXTEN: ::tcflag_t = 32768; pub const TOSTOP: ::tcflag_t = 256; pub const FLUSHO: ::tcflag_t = 4096; pub const EXTPROC: ::tcflag_t = 65536; -pub const TCGETS: ::c_ulong = 21505; -pub const TCSETS: ::c_ulong = 21506; -pub const TCSETSW: ::c_ulong = 21507; -pub const TCSETSF: ::c_ulong = 21508; -pub const TCGETA: ::c_ulong = 21509; -pub const TCSETA: ::c_ulong = 21510; -pub const TCSETAW: ::c_ulong = 21511; -pub const TCSETAF: ::c_ulong = 21512; -pub const TCSBRK: ::c_ulong = 21513; -pub const TCXONC: ::c_ulong = 21514; -pub const TCFLSH: ::c_ulong = 21515; -pub const TIOCINQ: ::c_ulong = 21531; -pub const TIOCGPGRP: ::c_ulong = 21519; -pub const TIOCSPGRP: ::c_ulong = 21520; -pub const TIOCOUTQ: ::c_ulong = 21521; -pub const TIOCGWINSZ: ::c_ulong = 21523; -pub const TIOCSWINSZ: ::c_ulong = 21524; -pub const FIONREAD: ::c_ulong = 21531; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const NGREG: usize = 32; +pub const REG_PC: usize = 0; +pub const REG_RA: usize = 1; +pub const REG_SP: usize = 2; +pub const REG_TP: usize = 4; +pub const REG_S0: usize = 8; +pub const REG_S1: usize = 9; +pub const REG_A0: usize = 10; +pub const REG_S2: usize = 18; +pub const REG_NARGS: usize = 8; pub const SYS_read: ::c_long = 63; pub const SYS_write: ::c_long = 64; @@ -794,3 +762,10 @@ pub const SYS_faccessat2: ::c_long = 439; pub const SYS_process_madvise: ::c_long = 440; pub const SYS_epoll_pwait2: ::c_long = 441; pub const SYS_mount_setattr: ::c_long = 442; + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index 43648140..90a57bd8 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -191,17 +191,6 @@ s! { __glibc_reserved1: ::c_ulong, __glibc_reserved2: ::c_ulong, } - - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } } pub const RLIM_INFINITY: ::rlim_t = !0; @@ -210,9 +199,6 @@ pub const RTLD_DEEPBIND: ::c_int = 0x8; pub const RTLD_GLOBAL: ::c_int = 0x100; pub const RTLD_NOLOAD: ::c_int = 0x4; -pub const TIOCGSOFTCAR: ::c_ulong = 0x40047464; -pub const TIOCSSOFTCAR: ::c_ulong = 0x80047465; - pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; pub const RLIMIT_AS: ::__rlimit_resource_t = 9; pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; @@ -367,25 +353,6 @@ pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; -pub const TIOCEXCL: ::c_ulong = 0x2000740d; -pub const TIOCNXCL: ::c_ulong = 0x2000740e; -pub const TIOCSCTTY: ::c_ulong = 0x20007484; -pub const TIOCSTI: ::c_ulong = 0x80017472; -pub const TIOCMGET: ::c_ulong = 0x4004746a; -pub const TIOCMBIS: ::c_ulong = 0x8004746c; -pub const TIOCMBIC: ::c_ulong = 0x8004746b; -pub const TIOCMSET: ::c_ulong = 0x8004746d; -pub const TIOCCONS: ::c_ulong = 0x20007424; - -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - pub const O_DIRECTORY: ::c_int = 0o200000; pub const O_NOFOLLOW: ::c_int = 0o400000; pub const O_LARGEFILE: ::c_int = 0x40000; @@ -401,10 +368,6 @@ pub const ENAVAIL: ::c_int = 119; pub const EISNAM: ::c_int = 120; pub const EREMOTEIO: ::c_int = 121; -pub const FIOCLEX: ::c_ulong = 0x20006601; -pub const FIONCLEX: ::c_ulong = 0x20006602; -pub const FIONBIO: ::c_ulong = 0x8004667e; - pub const MCL_CURRENT: ::c_int = 0x2000; pub const MCL_FUTURE: ::c_int = 0x4000; @@ -480,7 +443,6 @@ pub const B19200: ::speed_t = 0o000016; pub const B38400: ::speed_t = 0o000017; pub const EXTA: ::speed_t = B19200; pub const EXTB: ::speed_t = B38400; -pub const BOTHER: ::speed_t = 0x1000; pub const B57600: ::speed_t = 0x1001; pub const B115200: ::speed_t = 0x1002; pub const B230400: ::speed_t = 0x1003; @@ -504,24 +466,6 @@ pub const IEXTEN: ::tcflag_t = 0x8000; pub const TOSTOP: ::tcflag_t = 0x100; pub const FLUSHO: ::tcflag_t = 0x1000; pub const EXTPROC: ::tcflag_t = 0x10000; -pub const TCGETS: ::c_ulong = 0x40245408; -pub const TCSETS: ::c_ulong = 0x80245409; -pub const TCSETSW: ::c_ulong = 0x8024540a; -pub const TCSETSF: ::c_ulong = 0x8024540b; -pub const TCGETA: ::c_ulong = 0x40125401; -pub const TCSETA: ::c_ulong = 0x80125402; -pub const TCSETAW: ::c_ulong = 0x80125403; -pub const TCSETAF: ::c_ulong = 0x80125404; -pub const TCSBRK: ::c_ulong = 0x20005405; -pub const TCXONC: ::c_ulong = 0x20005406; -pub const TCFLSH: ::c_ulong = 0x20005407; -pub const TIOCINQ: ::c_ulong = 0x4004667f; -pub const TIOCGPGRP: ::c_ulong = 0x40047483; -pub const TIOCSPGRP: ::c_ulong = 0x80047482; -pub const TIOCOUTQ: ::c_ulong = 0x40047473; -pub const TIOCGWINSZ: ::c_ulong = 0x40087468; -pub const TIOCSWINSZ: ::c_ulong = 0x80087467; -pub const FIONREAD: ::c_ulong = 0x4004667f; pub const SYS_restart_syscall: ::c_long = 0; pub const SYS_exit: ::c_long = 1; diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index 75edd278..705f5660 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -215,17 +215,6 @@ s! { __glibc_reserved5: ::c_ulong, } - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } - pub struct siginfo_t { pub si_signo: ::c_int, pub si_errno: ::c_int, @@ -246,6 +235,12 @@ s! { pub ss_flags: ::c_int, pub ss_size: ::size_t } + + pub struct seccomp_notif_sizes { + pub seccomp_notif: ::__u16, + pub seccomp_notif_resp: ::__u16, + pub seccomp_data: ::__u16, + } } s_no_extra_traits! { @@ -511,10 +506,6 @@ pub const F_GETLK: ::c_int = 5; pub const F_GETOWN: ::c_int = 9; pub const F_SETOWN: ::c_int = 8; -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONCLEX: ::c_ulong = 0x5450; -pub const FIONBIO: ::c_ulong = 0x5421; - pub const PTRACE_GETFPXREGS: ::c_uint = 18; pub const PTRACE_SETFPXREGS: ::c_uint = 19; pub const PTRACE_SYSEMU: ::c_uint = 31; @@ -608,18 +599,6 @@ pub const FFDLY: ::tcflag_t = 0o100000; pub const VTDLY: ::tcflag_t = 0o040000; pub const XTABS: ::tcflag_t = 0o014000; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; -pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; -pub const TIOCEXCL: ::c_ulong = 0x540C; -pub const TIOCNXCL: ::c_ulong = 0x540D; -pub const TIOCSCTTY: ::c_ulong = 0x540E; -pub const TIOCSTI: ::c_ulong = 0x5412; -pub const TIOCMGET: ::c_ulong = 0x5415; -pub const TIOCMBIS: ::c_ulong = 0x5416; -pub const TIOCMBIC: ::c_ulong = 0x5417; -pub const TIOCMSET: ::c_ulong = 0x5418; -pub const TIOCCONS: ::c_ulong = 0x541D; - pub const B0: ::speed_t = 0o000000; pub const B50: ::speed_t = 0o000001; pub const B75: ::speed_t = 0o000002; @@ -638,7 +617,6 @@ pub const B19200: ::speed_t = 0o000016; pub const B38400: ::speed_t = 0o000017; pub const EXTA: ::speed_t = B19200; pub const EXTB: ::speed_t = B38400; -pub const BOTHER: ::speed_t = 0o010000; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; @@ -662,40 +640,11 @@ pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; pub const EXTPROC: ::tcflag_t = 0x00010000; -pub const TCGETS: ::c_ulong = 0x5401; -pub const TCSETS: ::c_ulong = 0x5402; -pub const TCSETSW: ::c_ulong = 0x5403; -pub const TCSETSF: ::c_ulong = 0x5404; -pub const TCGETA: ::c_ulong = 0x5405; -pub const TCSETA: ::c_ulong = 0x5406; -pub const TCSETAW: ::c_ulong = 0x5407; -pub const TCSETAF: ::c_ulong = 0x5408; -pub const TCSBRK: ::c_ulong = 0x5409; -pub const TCXONC: ::c_ulong = 0x540A; -pub const TCFLSH: ::c_ulong = 0x540B; -pub const TIOCINQ: ::c_ulong = 0x541B; -pub const TIOCGPGRP: ::c_ulong = 0x540F; -pub const TIOCSPGRP: ::c_ulong = 0x5410; -pub const TIOCOUTQ: ::c_ulong = 0x5411; -pub const TIOCGWINSZ: ::c_ulong = 0x5413; -pub const TIOCSWINSZ: ::c_ulong = 0x5414; -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; -pub const FIONREAD: ::c_ulong = 0x541B; pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - // Syscall table pub const SYS_restart_syscall: ::c_long = 0; pub const SYS_exit: ::c_long = 1; @@ -1137,6 +1086,11 @@ pub const REG_EFL: ::c_int = 16; pub const REG_UESP: ::c_int = 17; pub const REG_SS: ::c_int = 18; +pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; +pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; +pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; +pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; + extern "C" { pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int; pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index 35fe3061..dd7c058b 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -6,6 +6,7 @@ pub type nlink_t = u32; pub type blksize_t = i32; pub type suseconds_t = i64; pub type __u64 = ::c_ulonglong; +pub type __s64 = ::c_longlong; s! { pub struct sigaction { @@ -142,6 +143,13 @@ s! { __size: [usize; 8] } + pub struct user_regs_struct { + pub regs: [::c_ulonglong; 31], + pub sp: ::c_ulonglong, + pub pc: ::c_ulonglong, + pub pstate: ::c_ulonglong, + } + pub struct ipc_perm { pub __key: ::key_t, pub uid: ::uid_t, @@ -168,17 +176,6 @@ s! { __unused5: ::c_ulong } - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } - pub struct siginfo_t { pub si_signo: ::c_int, pub si_errno: ::c_int, @@ -200,10 +197,10 @@ s! { pub ss_size: ::size_t } - pub struct ip_mreqn { - pub imr_multiaddr: ::in_addr, - pub imr_address: ::in_addr, - pub imr_ifindex: ::c_int, + pub struct seccomp_notif_sizes { + pub seccomp_notif: ::__u16, + pub seccomp_notif_resp: ::__u16, + pub seccomp_data: ::__u16, } } @@ -380,29 +377,6 @@ pub const F_UNLCK: ::c_int = 2; pub const SFD_NONBLOCK: ::c_int = 0x0800; -pub const TIOCEXCL: ::c_ulong = 0x540C; -pub const TIOCNXCL: ::c_ulong = 0x540D; -pub const TIOCSCTTY: ::c_ulong = 0x540E; -pub const TIOCSTI: ::c_ulong = 0x5412; -pub const TIOCMGET: ::c_ulong = 0x5415; -pub const TIOCMBIS: ::c_ulong = 0x5416; -pub const TIOCMBIC: ::c_ulong = 0x5417; -pub const TIOCMSET: ::c_ulong = 0x5418; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; -pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; -pub const TIOCCONS: ::c_ulong = 0x541D; -pub const TIOCSBRK: ::c_ulong = 0x5427; -pub const TIOCCBRK: ::c_ulong = 0x5428; -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; - -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - pub const SFD_CLOEXEC: ::c_int = 0x080000; pub const NCCS: usize = 32; @@ -453,10 +427,6 @@ pub const MAP_SYNC: ::c_int = 0x080000; pub const EDEADLOCK: ::c_int = 35; -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONCLEX: ::c_ulong = 0x5450; -pub const FIONBIO: ::c_ulong = 0x5421; - pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; @@ -532,7 +502,6 @@ pub const B19200: ::speed_t = 0o000016; pub const B38400: ::speed_t = 0o000017; pub const EXTA: ::speed_t = B19200; pub const EXTB: ::speed_t = B38400; -pub const BOTHER: ::speed_t = 0o010000; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; @@ -549,6 +518,11 @@ pub const B3000000: ::speed_t = 0o010015; pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; +pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; +pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; +pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; +pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; + pub const VEOL: usize = 11; pub const VEOL2: usize = 16; pub const VMIN: usize = 6; @@ -556,32 +530,11 @@ pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; pub const EXTPROC: ::tcflag_t = 0x00010000; -pub const TCGETS: ::c_ulong = 0x5401; -pub const TCSETS: ::c_ulong = 0x5402; -pub const TCSETSW: ::c_ulong = 0x5403; -pub const TCSETSF: ::c_ulong = 0x5404; -pub const TCGETA: ::c_ulong = 0x5405; -pub const TCSETA: ::c_ulong = 0x5406; -pub const TCSETAW: ::c_ulong = 0x5407; -pub const TCSETAF: ::c_ulong = 0x5408; -pub const TCSBRK: ::c_ulong = 0x5409; -pub const TCXONC: ::c_ulong = 0x540A; -pub const TCFLSH: ::c_ulong = 0x540B; -pub const TIOCINQ: ::c_ulong = 0x541B; -pub const TIOCGPGRP: ::c_ulong = 0x540F; -pub const TIOCSPGRP: ::c_ulong = 0x5410; -pub const TIOCOUTQ: ::c_ulong = 0x5411; -pub const TIOCGWINSZ: ::c_ulong = 0x5413; -pub const TIOCSWINSZ: ::c_ulong = 0x5414; -pub const FIONREAD: ::c_ulong = 0x541B; pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; - // sys/auxv.h pub const HWCAP_FP: ::c_ulong = 1 << 0; pub const HWCAP_ASIMD: ::c_ulong = 1 << 1; diff --git a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs index 87939566..0d7fb221 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -8,6 +8,7 @@ pub type nlink_t = u64; pub type suseconds_t = i64; pub type wchar_t = i32; pub type __u64 = ::c_ulong; +pub type __s64 = ::c_long; s! { pub struct stat { @@ -183,17 +184,6 @@ s! { __unused4: ::c_ulong, __unused5: ::c_ulong } - - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 23], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } } pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; @@ -756,10 +746,6 @@ pub const MAP_HUGETLB: ::c_int = 0x080000; pub const SOCK_STREAM: ::c_int = 2; pub const SOCK_DGRAM: ::c_int = 1; -pub const FIOCLEX: ::c_ulong = 0x6601; -pub const FIONCLEX: ::c_ulong = 0x6602; -pub const FIONBIO: ::c_ulong = 0x667e; - pub const SA_ONSTACK: ::c_int = 0x08000000; pub const SA_SIGINFO: ::c_int = 0x00000008; pub const SA_NOCLDWAIT: ::c_int = 0x00010000; @@ -826,40 +812,6 @@ pub const F_OFD_SETLKW: ::c_int = 38; pub const SFD_NONBLOCK: ::c_int = 0x80; -pub const TCGETS: ::c_ulong = 0x540d; -pub const TCSETS: ::c_ulong = 0x540e; -pub const TCSETSW: ::c_ulong = 0x540f; -pub const TCSETSF: ::c_ulong = 0x5410; -pub const TCGETA: ::c_ulong = 0x5401; -pub const TCSETA: ::c_ulong = 0x5402; -pub const TCSETAW: ::c_ulong = 0x5403; -pub const TCSETAF: ::c_ulong = 0x5404; -pub const TCSBRK: ::c_ulong = 0x5405; -pub const TCXONC: ::c_ulong = 0x5406; -pub const TCFLSH: ::c_ulong = 0x5407; -pub const TIOCSBRK: ::c_ulong = 0x5427; -pub const TIOCCBRK: ::c_ulong = 0x5428; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5481; -pub const TIOCSSOFTCAR: ::c_ulong = 0x5482; -pub const TIOCINQ: ::c_ulong = 0x467f; -pub const TIOCLINUX: ::c_ulong = 0x5483; -pub const TIOCGSERIAL: ::c_ulong = 0x5484; -pub const TIOCEXCL: ::c_ulong = 0x740d; -pub const TIOCNXCL: ::c_ulong = 0x740e; -pub const TIOCSCTTY: ::c_ulong = 0x5480; -pub const TIOCGPGRP: ::c_ulong = 0x40047477; -pub const TIOCSPGRP: ::c_ulong = 0x80047476; -pub const TIOCOUTQ: ::c_ulong = 0x7472; -pub const TIOCSTI: ::c_ulong = 0x5472; -pub const TIOCGWINSZ: ::c_ulong = 0x40087468; -pub const TIOCSWINSZ: ::c_ulong = 0x80087467; -pub const TIOCMGET: ::c_ulong = 0x741d; -pub const TIOCMBIS: ::c_ulong = 0x741b; -pub const TIOCMBIC: ::c_ulong = 0x741c; -pub const TIOCMSET: ::c_ulong = 0x741a; -pub const FIONREAD: ::c_ulong = 0x467f; -pub const TIOCCONS: ::c_ulong = 0x80047478; - pub const RTLD_DEEPBIND: ::c_int = 0x10; pub const RTLD_GLOBAL: ::c_int = 0x4; pub const RTLD_NOLOAD: ::c_int = 0x8; @@ -939,7 +891,6 @@ pub const B19200: ::speed_t = 0o000016; pub const B38400: ::speed_t = 0o000017; pub const EXTA: ::speed_t = B19200; pub const EXTB: ::speed_t = B38400; -pub const BOTHER: ::speed_t = 0o010000; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; @@ -956,13 +907,6 @@ pub const B3000000: ::speed_t = 0o010015; pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; -pub const TIOCM_ST: ::c_int = 0x010; -pub const TIOCM_SR: ::c_int = 0x020; -pub const TIOCM_CTS: ::c_int = 0x040; -pub const TIOCM_CAR: ::c_int = 0x100; -pub const TIOCM_RNG: ::c_int = 0x200; -pub const TIOCM_DSR: ::c_int = 0x400; - pub const EHWPOISON: ::c_int = 168; extern "C" { diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs index dcaeaf52..0a71e224 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -10,6 +10,7 @@ pub type nlink_t = u64; pub type blksize_t = i64; pub type suseconds_t = i64; pub type __u64 = ::c_ulong; +pub type __s64 = ::c_long; s! { pub struct sigaction { @@ -190,12 +191,6 @@ s! { pub ss_flags: ::c_int, pub ss_size: ::size_t } - - pub struct ip_mreqn { - pub imr_multiaddr: ::in_addr, - pub imr_address: ::in_addr, - pub imr_ifindex: ::c_int, - } } pub const POSIX_FADV_DONTNEED: ::c_int = 4; @@ -207,9 +202,6 @@ pub const RTLD_NOLOAD: ::c_int = 0x4; pub const VEOF: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; -pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; - pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; pub const RLIMIT_AS: ::__rlimit_resource_t = 9; pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; @@ -381,29 +373,6 @@ pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; -pub const TIOCEXCL: ::c_ulong = 0x540C; -pub const TIOCNXCL: ::c_ulong = 0x540D; -pub const TIOCSCTTY: ::c_ulong = 0x540E; -pub const TIOCSTI: ::c_ulong = 0x5412; -pub const TIOCMGET: ::c_ulong = 0x5415; -pub const TIOCMBIS: ::c_ulong = 0x5416; -pub const TIOCMBIC: ::c_ulong = 0x5417; -pub const TIOCMSET: ::c_ulong = 0x5418; -pub const TIOCCONS: ::c_ulong = 0x541D; -pub const TIOCSBRK: ::c_ulong = 0x5427; -pub const TIOCCBRK: ::c_ulong = 0x5428; -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; - -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - pub const SFD_CLOEXEC: ::c_int = 0x080000; pub const NCCS: usize = 32; @@ -506,10 +475,6 @@ pub const ENAVAIL: ::c_int = 119; pub const EISNAM: ::c_int = 120; pub const EREMOTEIO: ::c_int = 121; -pub const FIOCLEX: ::c_ulong = 0x20006601; -pub const FIONCLEX: ::c_ulong = 0x20006602; -pub const FIONBIO: ::c_ulong = 0x8004667e; - pub const MCL_CURRENT: ::c_int = 0x2000; pub const MCL_FUTURE: ::c_int = 0x4000; @@ -599,7 +564,6 @@ pub const B2500000: ::speed_t = 0o0033; pub const B3000000: ::speed_t = 0o0034; pub const B3500000: ::speed_t = 0o0035; pub const B4000000: ::speed_t = 0o0036; -pub const BOTHER: ::speed_t = 0o0037; pub const VEOL: usize = 6; pub const VEOL2: usize = 8; @@ -608,24 +572,6 @@ pub const IEXTEN: ::tcflag_t = 0x400; pub const TOSTOP: ::tcflag_t = 0x400000; pub const FLUSHO: ::tcflag_t = 0x800000; pub const EXTPROC: ::tcflag_t = 0x10000000; -pub const TCGETS: ::c_ulong = 0x403c7413; -pub const TCSETS: ::c_ulong = 0x803c7414; -pub const TCSETSW: ::c_ulong = 0x803c7415; -pub const TCSETSF: ::c_ulong = 0x803c7416; -pub const TCGETA: ::c_ulong = 0x40147417; -pub const TCSETA: ::c_ulong = 0x80147418; -pub const TCSETAW: ::c_ulong = 0x80147419; -pub const TCSETAF: ::c_ulong = 0x8014741c; -pub const TCSBRK: ::c_ulong = 0x2000741d; -pub const TCXONC: ::c_ulong = 0x2000741e; -pub const TCFLSH: ::c_ulong = 0x2000741f; -pub const TIOCINQ: ::c_ulong = 0x4004667f; -pub const TIOCGPGRP: ::c_ulong = 0x40047477; -pub const TIOCSPGRP: ::c_ulong = 0x80047476; -pub const TIOCOUTQ: ::c_ulong = 0x40047473; -pub const TIOCGWINSZ: ::c_ulong = 0x40087468; -pub const TIOCSWINSZ: ::c_ulong = 0x80087467; -pub const FIONREAD: ::c_ulong = 0x4004667f; // Syscall table pub const SYS_restart_syscall: ::c_long = 0; diff --git a/src/unix/linux_like/linux/gnu/b64/riscv64/align.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/align.rs new file mode 100644 index 00000000..48d152a5 --- /dev/null +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/align.rs @@ -0,0 +1,44 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct ucontext_t { + pub __uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_sigmask: ::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct mcontext_t { + pub __gregs: [::c_ulong; 32], + pub __fpregs: __riscv_mc_fp_state, + } + + #[allow(missing_debug_implementations)] + pub union __riscv_mc_fp_state { + pub __f: __riscv_mc_f_ext_state, + pub __d: __riscv_mc_d_ext_state, + pub __q: __riscv_mc_q_ext_state, + } + + #[allow(missing_debug_implementations)] + pub struct __riscv_mc_f_ext_state { + pub __f: [::c_uint; 32], + pub __fcsr: ::c_uint, + } + + #[allow(missing_debug_implementations)] + pub struct __riscv_mc_d_ext_state { + pub __f: [::c_ulonglong; 32], + pub __fcsr: ::c_uint, + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct __riscv_mc_q_ext_state { + pub __f: [::c_ulonglong; 64], + pub __fcsr: ::c_uint, + pub __glibc_reserved: [::c_uint; 3], + } +} diff --git a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs index 982277d8..e2abb37e 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -11,6 +11,7 @@ pub type fsblkcnt64_t = ::c_ulong; pub type fsfilcnt64_t = ::c_ulong; pub type suseconds_t = i64; pub type __u64 = ::c_ulonglong; +pub type __s64 = ::c_longlong; s! { pub struct pthread_attr_t { @@ -191,12 +192,6 @@ s! { pub l_len: ::off64_t, pub l_pid: ::pid_t, } - - pub struct ip_mreqn { - pub imr_multiaddr: ::in_addr, - pub imr_address: ::in_addr, - pub imr_ifindex: ::c_int, - } } pub const POSIX_FADV_DONTNEED: ::c_int = 4; @@ -205,10 +200,6 @@ pub const VEOF: usize = 4; pub const RTLD_DEEPBIND: ::c_int = 0x8; pub const RTLD_GLOBAL: ::c_int = 0x100; pub const RTLD_NOLOAD: ::c_int = 0x4; -pub const TIOCGSOFTCAR: ::c_ulong = 21529; -pub const TIOCSSOFTCAR: ::c_ulong = 21530; -pub const TIOCGRS485: ::c_int = 21550; -pub const TIOCSRS485: ::c_int = 21551; pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; pub const RLIMIT_AS: ::__rlimit_resource_t = 9; pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; @@ -356,23 +347,6 @@ pub const SFD_NONBLOCK: ::c_int = 2048; pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 21532; -pub const TIOCGSERIAL: ::c_ulong = 21534; -pub const TIOCEXCL: ::c_ulong = 21516; -pub const TIOCNXCL: ::c_ulong = 21517; -pub const TIOCSCTTY: ::c_ulong = 21518; -pub const TIOCSTI: ::c_ulong = 21522; -pub const TIOCMGET: ::c_ulong = 21525; -pub const TIOCMBIS: ::c_ulong = 21526; -pub const TIOCMBIC: ::c_ulong = 21527; -pub const TIOCMSET: ::c_ulong = 21528; -pub const TIOCCONS: ::c_ulong = 21533; -pub const TIOCM_ST: ::c_int = 8; -pub const TIOCM_SR: ::c_int = 16; -pub const TIOCM_CTS: ::c_int = 32; -pub const TIOCM_CAR: ::c_int = 64; -pub const TIOCM_RNG: ::c_int = 128; -pub const TIOCM_DSR: ::c_int = 256; pub const SFD_CLOEXEC: ::c_int = 524288; pub const NCCS: usize = 32; pub const O_TRUNC: ::c_int = 512; @@ -419,9 +393,12 @@ pub const ENOTNAM: ::c_int = 118; pub const ENAVAIL: ::c_int = 119; pub const EISNAM: ::c_int = 120; pub const EREMOTEIO: ::c_int = 121; -pub const FIOCLEX: ::c_ulong = 21585; -pub const FIONCLEX: ::c_ulong = 21584; -pub const FIONBIO: ::c_ulong = 21537; +pub const PTRACE_GETFPREGS: ::c_uint = 14; +pub const PTRACE_SETFPREGS: ::c_uint = 15; +pub const PTRACE_GETFPXREGS: ::c_uint = 18; +pub const PTRACE_SETFPXREGS: ::c_uint = 19; +pub const PTRACE_GETREGS: ::c_uint = 12; +pub const PTRACE_SETREGS: ::c_uint = 13; pub const MCL_CURRENT: ::c_int = 1; pub const MCL_FUTURE: ::c_int = 2; pub const SIGSTKSZ: ::size_t = 8192; @@ -517,26 +494,19 @@ pub const IEXTEN: ::tcflag_t = 32768; pub const TOSTOP: ::tcflag_t = 256; pub const FLUSHO: ::tcflag_t = 4096; pub const EXTPROC: ::tcflag_t = 65536; -pub const TCGETS: ::c_ulong = 21505; -pub const TCSETS: ::c_ulong = 21506; -pub const TCSETSW: ::c_ulong = 21507; -pub const TCSETSF: ::c_ulong = 21508; -pub const TCGETA: ::c_ulong = 21509; -pub const TCSETA: ::c_ulong = 21510; -pub const TCSETAW: ::c_ulong = 21511; -pub const TCSETAF: ::c_ulong = 21512; -pub const TCSBRK: ::c_ulong = 21513; -pub const TCXONC: ::c_ulong = 21514; -pub const TCFLSH: ::c_ulong = 21515; -pub const TIOCINQ: ::c_ulong = 21531; -pub const TIOCGPGRP: ::c_ulong = 21519; -pub const TIOCSPGRP: ::c_ulong = 21520; -pub const TIOCOUTQ: ::c_ulong = 21521; -pub const TIOCGWINSZ: ::c_ulong = 21523; -pub const TIOCSWINSZ: ::c_ulong = 21524; -pub const FIONREAD: ::c_ulong = 21531; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const NGREG: usize = 32; +pub const REG_PC: usize = 0; +pub const REG_RA: usize = 1; +pub const REG_SP: usize = 2; +pub const REG_TP: usize = 4; +pub const REG_S0: usize = 8; +pub const REG_S1: usize = 9; +pub const REG_A0: usize = 10; +pub const REG_S2: usize = 18; +pub const REG_NARGS: usize = 8; + pub const SYS_read: ::c_long = 63; pub const SYS_write: ::c_long = 64; pub const SYS_close: ::c_long = 57; @@ -831,3 +801,10 @@ pub const SYS_faccessat2: ::c_long = 439; pub const SYS_process_madvise: ::c_long = 440; pub const SYS_epoll_pwait2: ::c_long = 441; pub const SYS_mount_setattr: ::c_long = 442; + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index 833997a6..c906aeb8 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -11,6 +11,7 @@ pub type suseconds_t = i64; pub type wchar_t = i32; pub type greg_t = u64; pub type __u64 = u64; +pub type __s64 = i64; s! { pub struct sigaction { @@ -153,17 +154,6 @@ s! { __f_spare: [::c_int; 6], } - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } - pub struct __psw_t { pub mask: u64, pub addr: u64, @@ -340,9 +330,6 @@ pub const EDEADLK: ::c_int = 35; pub const ENOSYS: ::c_int = 38; pub const ENOTCONN: ::c_int = 107; pub const ETIMEDOUT: ::c_int = 110; -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONCLEX: ::c_ulong = 0x5450; -pub const FIONBIO: ::c_ulong = 0x5421; pub const O_APPEND: ::c_int = 1024; pub const O_CREAT: ::c_int = 64; pub const O_EXCL: ::c_int = 128; @@ -515,51 +502,10 @@ pub const F_OFD_SETLKW: ::c_int = 38; pub const SFD_NONBLOCK: ::c_int = 0x0800; -pub const TCGETS: ::c_ulong = 0x5401; -pub const TCSETS: ::c_ulong = 0x5402; -pub const TCSETSW: ::c_ulong = 0x5403; -pub const TCSETSF: ::c_ulong = 0x5404; -pub const TCGETA: ::c_ulong = 0x5405; -pub const TCSETA: ::c_ulong = 0x5406; -pub const TCSETAW: ::c_ulong = 0x5407; -pub const TCSETAF: ::c_ulong = 0x5408; -pub const TCSBRK: ::c_ulong = 0x5409; -pub const TCXONC: ::c_ulong = 0x540A; -pub const TCFLSH: ::c_ulong = 0x540B; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; -pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; -pub const TIOCINQ: ::c_ulong = 0x541B; -pub const TIOCEXCL: ::c_ulong = 0x540C; -pub const TIOCNXCL: ::c_ulong = 0x540D; -pub const TIOCSCTTY: ::c_ulong = 0x540E; -pub const TIOCGPGRP: ::c_ulong = 0x540F; -pub const TIOCSPGRP: ::c_ulong = 0x5410; -pub const TIOCOUTQ: ::c_ulong = 0x5411; -pub const TIOCSTI: ::c_ulong = 0x5412; -pub const TIOCGWINSZ: ::c_ulong = 0x5413; -pub const TIOCSWINSZ: ::c_ulong = 0x5414; -pub const TIOCMGET: ::c_ulong = 0x5415; -pub const TIOCMBIS: ::c_ulong = 0x5416; -pub const TIOCMBIC: ::c_ulong = 0x5417; -pub const TIOCMSET: ::c_ulong = 0x5418; -pub const FIONREAD: ::c_ulong = 0x541B; -pub const TIOCCONS: ::c_ulong = 0x541D; -pub const TIOCSBRK: ::c_ulong = 0x5427; -pub const TIOCCBRK: ::c_ulong = 0x5428; - pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - pub const VTIME: usize = 5; pub const VSWTC: usize = 7; pub const VSTART: usize = 8; @@ -617,7 +563,6 @@ pub const PARODD: ::tcflag_t = 0o001000; pub const HUPCL: ::tcflag_t = 0o002000; pub const CLOCAL: ::tcflag_t = 0o004000; pub const CBAUDEX: ::tcflag_t = 0o010000; -pub const BOTHER: ::speed_t = 0o010000; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; diff --git a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs index 5ed83ab8..89ac913a 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -10,6 +10,7 @@ pub type nlink_t = u32; pub type blksize_t = i64; pub type suseconds_t = i32; pub type __u64 = ::c_ulonglong; +pub type __s64 = ::c_longlong; s! { pub struct sigaction { @@ -193,17 +194,6 @@ s! { __reserved1: ::c_ulong, __reserved2: ::c_ulong } - - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } } pub const POSIX_FADV_DONTNEED: ::c_int = 4; @@ -215,9 +205,6 @@ pub const RTLD_GLOBAL: ::c_int = 0x100; pub const RTLD_NOLOAD: ::c_int = 0x4; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; -pub const TIOCGSOFTCAR: ::c_ulong = 0x40047464; -pub const TIOCSSOFTCAR: ::c_ulong = 0x80047465; - pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; pub const RLIMIT_AS: ::__rlimit_resource_t = 9; pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; @@ -364,7 +351,7 @@ pub const POLLWRBAND: ::c_short = 0x100; pub const O_ASYNC: ::c_int = 0x40; pub const O_NDELAY: ::c_int = 0x4004; -pub const PTRACE_DETACH: ::c_uint = 11; +pub const PTRACE_DETACH: ::c_uint = 17; pub const EFD_NONBLOCK: ::c_int = 0x4000; @@ -387,27 +374,6 @@ pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; -pub const TIOCEXCL: ::c_ulong = 0x2000740d; -pub const TIOCNXCL: ::c_ulong = 0x2000740e; -pub const TIOCCONS: ::c_ulong = 0x20007424; -pub const TIOCMGET: ::c_ulong = 0x4004746a; -pub const TIOCMBIC: ::c_ulong = 0x8004746b; -pub const TIOCMBIS: ::c_ulong = 0x8004746c; -pub const TIOCMSET: ::c_ulong = 0x8004746d; -pub const TIOCSTI: ::c_ulong = 0x80017472; -pub const TIOCCBRK: ::c_ulong = 0x2000747a; -pub const TIOCSBRK: ::c_ulong = 0x2000747b; -pub const TIOCSCTTY: ::c_ulong = 0x20007484; - -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - pub const SFD_CLOEXEC: ::c_int = 0x400000; pub const NCCS: usize = 17; @@ -480,10 +446,6 @@ pub const ENAVAIL: ::c_int = 119; pub const EISNAM: ::c_int = 120; pub const EREMOTEIO: ::c_int = 121; -pub const FIOCLEX: ::c_ulong = 0x20006601; -pub const FIONCLEX: ::c_ulong = 0x20006602; -pub const FIONBIO: ::c_ulong = 0x8004667e; - pub const MCL_CURRENT: ::c_int = 0x2000; pub const MCL_FUTURE: ::c_int = 0x4000; @@ -559,7 +521,6 @@ pub const B19200: ::speed_t = 0o000016; pub const B38400: ::speed_t = 0o000017; pub const EXTA: ::speed_t = B19200; pub const EXTB: ::speed_t = B38400; -pub const BOTHER: ::speed_t = 0x1000; pub const B57600: ::speed_t = 0x1001; pub const B115200: ::speed_t = 0x1002; pub const B230400: ::speed_t = 0x1003; @@ -583,24 +544,6 @@ pub const IEXTEN: ::tcflag_t = 0x8000; pub const TOSTOP: ::tcflag_t = 0x100; pub const FLUSHO: ::tcflag_t = 0x1000; pub const EXTPROC: ::tcflag_t = 0x10000; -pub const TCGETS: ::c_ulong = 0x40245408; -pub const TCSETS: ::c_ulong = 0x80245409; -pub const TCSETSW: ::c_ulong = 0x8024540a; -pub const TCSETSF: ::c_ulong = 0x8024540b; -pub const TCGETA: ::c_ulong = 0x40125401; -pub const TCSETA: ::c_ulong = 0x80125402; -pub const TCSETAW: ::c_ulong = 0x80125403; -pub const TCSETAF: ::c_ulong = 0x80125404; -pub const TCSBRK: ::c_ulong = 0x20005405; -pub const TCXONC: ::c_ulong = 0x20005406; -pub const TCFLSH: ::c_ulong = 0x20005407; -pub const TIOCINQ: ::c_ulong = 0x4004667f; -pub const TIOCGPGRP: ::c_ulong = 0x40047483; -pub const TIOCSPGRP: ::c_ulong = 0x80047482; -pub const TIOCOUTQ: ::c_ulong = 0x40047473; -pub const TIOCGWINSZ: ::c_ulong = 0x40087468; -pub const TIOCSWINSZ: ::c_ulong = 0x80087467; -pub const FIONREAD: ::c_ulong = 0x4004667f; pub const SYS_restart_syscall: ::c_long = 0; pub const SYS_exit: ::c_long = 1; diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs index 99937dfa..281f23e8 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -7,6 +7,7 @@ pub type blksize_t = i64; pub type greg_t = i64; pub type suseconds_t = i64; pub type __u64 = ::c_ulonglong; +pub type __s64 = ::c_longlong; s! { pub struct sigaction { @@ -259,21 +260,10 @@ s! { __unused5: u64 } - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } - - pub struct ip_mreqn { - pub imr_multiaddr: ::in_addr, - pub imr_address: ::in_addr, - pub imr_ifindex: ::c_int, + pub struct seccomp_notif_sizes { + pub seccomp_notif: ::__u16, + pub seccomp_notif_resp: ::__u16, + pub seccomp_data: ::__u16, } } @@ -409,10 +399,6 @@ pub const VEOF: usize = 4; pub const RTLD_DEEPBIND: ::c_int = 0x8; pub const RTLD_GLOBAL: ::c_int = 0x100; pub const RTLD_NOLOAD: ::c_int = 0x4; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; -pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; pub const RLIMIT_AS: ::__rlimit_resource_t = 9; @@ -577,25 +563,6 @@ pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; -pub const TIOCEXCL: ::c_ulong = 0x540C; -pub const TIOCNXCL: ::c_ulong = 0x540D; -pub const TIOCSCTTY: ::c_ulong = 0x540E; -pub const TIOCSTI: ::c_ulong = 0x5412; -pub const TIOCMGET: ::c_ulong = 0x5415; -pub const TIOCMBIS: ::c_ulong = 0x5416; -pub const TIOCMBIC: ::c_ulong = 0x5417; -pub const TIOCMSET: ::c_ulong = 0x5418; -pub const TIOCCONS: ::c_ulong = 0x541D; - -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - pub const SFD_CLOEXEC: ::c_int = 0x080000; pub const NCCS: usize = 32; @@ -655,10 +622,6 @@ pub const ENAVAIL: ::c_int = 119; pub const EISNAM: ::c_int = 120; pub const EREMOTEIO: ::c_int = 121; -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONCLEX: ::c_ulong = 0x5450; -pub const FIONBIO: ::c_ulong = 0x5421; - pub const PTRACE_GETFPREGS: ::c_uint = 14; pub const PTRACE_SETFPREGS: ::c_uint = 15; pub const PTRACE_GETFPXREGS: ::c_uint = 18; @@ -744,7 +707,6 @@ pub const B19200: ::speed_t = 0o000016; pub const B38400: ::speed_t = 0o000017; pub const EXTA: ::speed_t = B19200; pub const EXTB: ::speed_t = B38400; -pub const BOTHER: ::speed_t = 0o010000; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; @@ -768,26 +730,6 @@ pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; pub const EXTPROC: ::tcflag_t = 0x00010000; -pub const TCGETS: ::c_ulong = 0x5401; -pub const TCSETS: ::c_ulong = 0x5402; -pub const TCSETSW: ::c_ulong = 0x5403; -pub const TCSETSF: ::c_ulong = 0x5404; -pub const TCGETA: ::c_ulong = 0x5405; -pub const TCSETA: ::c_ulong = 0x5406; -pub const TCSETAW: ::c_ulong = 0x5407; -pub const TCSETAF: ::c_ulong = 0x5408; -pub const TCSBRK: ::c_ulong = 0x5409; -pub const TCXONC: ::c_ulong = 0x540A; -pub const TCFLSH: ::c_ulong = 0x540B; -pub const TIOCINQ: ::c_ulong = 0x541B; -pub const TIOCGPGRP: ::c_ulong = 0x540F; -pub const TIOCSPGRP: ::c_ulong = 0x5410; -pub const TIOCOUTQ: ::c_ulong = 0x5411; -pub const TIOCGWINSZ: ::c_ulong = 0x5413; -pub const TIOCSWINSZ: ::c_ulong = 0x5414; -pub const FIONREAD: ::c_ulong = 0x541B; -pub const TIOCSBRK: ::c_ulong = 0x5427; -pub const TIOCCBRK: ::c_ulong = 0x5428; // offsets in user_regs_structs, from sys/reg.h pub const R15: ::c_int = 0; @@ -843,6 +785,11 @@ pub const REG_TRAPNO: ::c_int = 20; pub const REG_OLDMASK: ::c_int = 21; pub const REG_CR2: ::c_int = 22; +pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; +pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; +pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; +pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; + extern "C" { pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int; pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index d55973a7..058f2f72 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -4,6 +4,16 @@ pub type __rlimit_resource_t = ::c_uint; pub type Lmid_t = ::c_long; pub type regoff_t = ::c_int; +cfg_if! { + if #[cfg(doc)] { + // Used in `linux::arch` to define ioctl constants. + pub(crate) type Ioctl = ::c_ulong; + } else { + #[doc(hidden)] + pub type Ioctl = ::c_ulong; + } +} + s! { pub struct statx { pub stx_mask: u32, @@ -141,19 +151,6 @@ s! { pub keepcost: ::size_t, } - pub struct nlmsghdr { - pub nlmsg_len: u32, - pub nlmsg_type: u16, - pub nlmsg_flags: u16, - pub nlmsg_seq: u32, - pub nlmsg_pid: u32, - } - - pub struct nlmsgerr { - pub error: ::c_int, - pub msg: nlmsghdr, - } - pub struct nl_pktinfo { pub group: u32, } @@ -174,11 +171,6 @@ s! { pub nm_gid: u32, } - pub struct nlattr { - pub nla_len: u16, - pub nla_type: u16, - } - pub struct rtentry { pub rt_pad1: ::c_ulong, pub rt_dst: ::sockaddr, @@ -326,6 +318,38 @@ s! { pub semvmx: ::c_int, pub semaem: ::c_int, } + + pub struct ptrace_peeksiginfo_args { + pub off: ::__u64, + pub flags: ::__u32, + pub nr: ::__s32, + } + + pub struct __c_anonymous_ptrace_syscall_info_entry { + pub nr: ::__u64, + pub args: [::__u64; 6], + } + + pub struct __c_anonymous_ptrace_syscall_info_exit { + pub sval: ::__s64, + pub is_error: ::__u8, + } + + pub struct __c_anonymous_ptrace_syscall_info_seccomp { + pub nr: ::__u64, + pub args: [::__u64; 6], + pub ret_data: ::__u32, + } + + pub struct ptrace_syscall_info { + pub op: ::__u8, + pub pad: [::__u8; 3], + pub arch: ::__u32, + pub instruction_pointer: ::__u64, + pub stack_pointer: ::__u64, + #[cfg(libc_union)] + pub u: __c_anonymous_ptrace_syscall_info_data, + } } impl siginfo_t { @@ -413,6 +437,18 @@ cfg_if! { self.sifields().sigchld.si_stime } } + + pub union __c_anonymous_ptrace_syscall_info_data { + pub entry: __c_anonymous_ptrace_syscall_info_entry, + pub exit: __c_anonymous_ptrace_syscall_info_exit, + pub seccomp: __c_anonymous_ptrace_syscall_info_seccomp, + } + impl ::Copy for __c_anonymous_ptrace_syscall_info_data {} + impl ::Clone for __c_anonymous_ptrace_syscall_info_data { + fn clone(&self) -> __c_anonymous_ptrace_syscall_info_data { + *self + } + } } } @@ -511,6 +547,44 @@ cfg_if! { self.__glibc_reserved.hash(state); } } + + #[cfg(libc_union)] + impl PartialEq for __c_anonymous_ptrace_syscall_info_data { + fn eq(&self, other: &__c_anonymous_ptrace_syscall_info_data) -> bool { + unsafe { + self.entry == other.entry || + self.exit == other.exit || + self.seccomp == other.seccomp + } + } + } + + #[cfg(libc_union)] + impl Eq for __c_anonymous_ptrace_syscall_info_data {} + + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ptrace_syscall_info_data { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + unsafe { + f.debug_struct("__c_anonymous_ptrace_syscall_info_data") + .field("entry", &self.entry) + .field("exit", &self.exit) + .field("seccomp", &self.seccomp) + .finish() + } + } + } + + #[cfg(libc_union)] + impl ::hash::Hash for __c_anonymous_ptrace_syscall_info_data { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + unsafe { + self.entry.hash(state); + self.exit.hash(state); + self.seccomp.hash(state); + } + } + } } } @@ -605,6 +679,7 @@ pub const RTLD_DI_TLS_MODID: ::c_int = 9; pub const RTLD_DI_TLS_DATA: ::c_int = 10; pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK; +pub const PIDFD_NONBLOCK: ::c_uint = O_NONBLOCK as ::c_uint; pub const SOL_RXRPC: ::c_int = 272; pub const SOL_PPPOL2TP: ::c_int = 273; @@ -771,114 +846,15 @@ pub const O_ACCMODE: ::c_int = 3; pub const ST_RELATIME: ::c_ulong = 4096; pub const NI_MAXHOST: ::socklen_t = 1025; +// Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the +// following are only available on newer Linux versions than the versions +// currently used in CI in some configurations, so we define them here. cfg_if! { if #[cfg(not(target_arch = "s390x"))] { - pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; - pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; - pub const AFS_SUPER_MAGIC: ::c_long = 0x5346414f; - pub const AUTOFS_SUPER_MAGIC: ::c_long = 0x0187; pub const BINDERFS_SUPER_MAGIC: ::c_long = 0x6c6f6f70; - pub const BPF_FS_MAGIC: ::c_long = 0xcafe4a11; - pub const BTRFS_SUPER_MAGIC: ::c_long = 0x9123683e; - pub const CGROUP2_SUPER_MAGIC: ::c_long = 0x63677270; - pub const CGROUP_SUPER_MAGIC: ::c_long = 0x27e0eb; - pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; - pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; - pub const DEBUGFS_MAGIC: ::c_long = 0x64626720; - pub const DEVPTS_SUPER_MAGIC: ::c_long = 0x1cd1; - pub const ECRYPTFS_SUPER_MAGIC: ::c_long = 0xf15f; - pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; - pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; - pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; - pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; - pub const F2FS_SUPER_MAGIC: ::c_long = 0xf2f52010; - pub const FUTEXFS_SUPER_MAGIC: ::c_long = 0xbad1dea; - pub const HOSTFS_SUPER_MAGIC: ::c_long = 0x00c0ffee; - pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; - pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; - pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; - pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; - pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; - pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; - pub const MINIX3_SUPER_MAGIC: ::c_long = 0x4d5a; - pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; - pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; - pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; - pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; - pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; - pub const NILFS_SUPER_MAGIC: ::c_long = 0x3434; - pub const OCFS2_SUPER_MAGIC: ::c_long = 0x7461636f; - pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; - pub const OVERLAYFS_SUPER_MAGIC: ::c_long = 0x794c7630; - pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; - pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; - pub const QNX6_SUPER_MAGIC: ::c_long = 0x68191122; - pub const RDTGROUP_SUPER_MAGIC: ::c_long = 0x7655821; - pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; - pub const SECURITYFS_MAGIC: ::c_long = 0x73636673; - pub const SELINUX_MAGIC: ::c_long = 0xf97cff8c; - pub const SMACK_MAGIC: ::c_long = 0x43415d53; - pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; - pub const SYSFS_MAGIC: ::c_long = 0x62656572; - pub const TMPFS_MAGIC: ::c_long = 0x01021994; - pub const TRACEFS_MAGIC: ::c_long = 0x74726163; - pub const UDF_SUPER_MAGIC: ::c_long = 0x15013346; - pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; - pub const XENFS_SUPER_MAGIC: ::c_long = 0xabba1974; pub const XFS_SUPER_MAGIC: ::c_long = 0x58465342; } else if #[cfg(target_arch = "s390x")] { - pub const ADFS_SUPER_MAGIC: ::c_uint = 0x0000adf5; - pub const AFFS_SUPER_MAGIC: ::c_uint = 0x0000adff; - pub const AFS_SUPER_MAGIC: ::c_uint = 0x5346414f; - pub const AUTOFS_SUPER_MAGIC: ::c_uint = 0x0187; pub const BINDERFS_SUPER_MAGIC: ::c_uint = 0x6c6f6f70; - pub const BPF_FS_MAGIC: ::c_uint = 0xcafe4a11; - pub const BTRFS_SUPER_MAGIC: ::c_uint = 0x9123683e; - pub const CGROUP2_SUPER_MAGIC: ::c_uint = 0x63677270; - pub const CGROUP_SUPER_MAGIC: ::c_uint = 0x27e0eb; - pub const CODA_SUPER_MAGIC: ::c_uint = 0x73757245; - pub const CRAMFS_MAGIC: ::c_uint = 0x28cd3d45; - pub const DEBUGFS_MAGIC: ::c_uint = 0x64626720; - pub const DEVPTS_SUPER_MAGIC: ::c_uint = 0x1cd1; - pub const ECRYPTFS_SUPER_MAGIC: ::c_uint = 0xf15f; - pub const EFS_SUPER_MAGIC: ::c_uint = 0x00414a53; - pub const EXT2_SUPER_MAGIC: ::c_uint = 0x0000ef53; - pub const EXT3_SUPER_MAGIC: ::c_uint = 0x0000ef53; - pub const EXT4_SUPER_MAGIC: ::c_uint = 0x0000ef53; - pub const F2FS_SUPER_MAGIC: ::c_uint = 0xf2f52010; - pub const FUTEXFS_SUPER_MAGIC: ::c_uint = 0xbad1dea; - pub const HOSTFS_SUPER_MAGIC: ::c_uint = 0x00c0ffee; - pub const HPFS_SUPER_MAGIC: ::c_uint = 0xf995e849; - pub const HUGETLBFS_MAGIC: ::c_uint = 0x958458f6; - pub const ISOFS_SUPER_MAGIC: ::c_uint = 0x00009660; - pub const JFFS2_SUPER_MAGIC: ::c_uint = 0x000072b6; - pub const MINIX2_SUPER_MAGIC2: ::c_uint = 0x00002478; - pub const MINIX2_SUPER_MAGIC: ::c_uint = 0x00002468; - pub const MINIX3_SUPER_MAGIC: ::c_uint = 0x4d5a; - pub const MINIX_SUPER_MAGIC2: ::c_uint = 0x0000138f; - pub const MINIX_SUPER_MAGIC: ::c_uint = 0x0000137f; - pub const MSDOS_SUPER_MAGIC: ::c_uint = 0x00004d44; - pub const NCP_SUPER_MAGIC: ::c_uint = 0x0000564c; - pub const NFS_SUPER_MAGIC: ::c_uint = 0x00006969; - pub const NILFS_SUPER_MAGIC: ::c_uint = 0x3434; - pub const OCFS2_SUPER_MAGIC: ::c_uint = 0x7461636f; - pub const OPENPROM_SUPER_MAGIC: ::c_uint = 0x00009fa1; - pub const OVERLAYFS_SUPER_MAGIC: ::c_uint = 0x794c7630; - pub const PROC_SUPER_MAGIC: ::c_uint = 0x00009fa0; - pub const QNX4_SUPER_MAGIC: ::c_uint = 0x0000002f; - pub const QNX6_SUPER_MAGIC: ::c_uint = 0x68191122; - pub const RDTGROUP_SUPER_MAGIC: ::c_uint = 0x7655821; - pub const REISERFS_SUPER_MAGIC: ::c_uint = 0x52654973; - pub const SECURITYFS_MAGIC: ::c_uint = 0x73636673; - pub const SELINUX_MAGIC: ::c_uint = 0xf97cff8c; - pub const SMACK_MAGIC: ::c_uint = 0x43415d53; - pub const SMB_SUPER_MAGIC: ::c_uint = 0x0000517b; - pub const SYSFS_MAGIC: ::c_uint = 0x62656572; - pub const TMPFS_MAGIC: ::c_uint = 0x01021994; - pub const TRACEFS_MAGIC: ::c_uint = 0x74726163; - pub const UDF_SUPER_MAGIC: ::c_uint = 0x15013346; - pub const USBDEVICE_SUPER_MAGIC: ::c_uint = 0x00009fa2; - pub const XENFS_SUPER_MAGIC: ::c_uint = 0xabba1974; pub const XFS_SUPER_MAGIC: ::c_uint = 0x58465342; } } @@ -907,6 +883,7 @@ pub const PTRACE_SEIZE: ::c_uint = 0x4206; pub const PTRACE_INTERRUPT: ::c_uint = 0x4207; pub const PTRACE_LISTEN: ::c_uint = 0x4208; pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209; +pub const PTRACE_GET_SYSCALL_INFO: ::c_uint = 0x420e; // linux/fs.h @@ -968,11 +945,24 @@ pub const GENL_UNS_ADMIN_PERM: ::c_int = 0x10; pub const GENL_ID_VFS_DQUOT: ::c_int = ::NLMSG_MIN_TYPE + 1; pub const GENL_ID_PMCRAID: ::c_int = ::NLMSG_MIN_TYPE + 2; -pub const TIOCM_LE: ::c_int = 0x001; -pub const TIOCM_DTR: ::c_int = 0x002; -pub const TIOCM_RTS: ::c_int = 0x004; -pub const TIOCM_CD: ::c_int = TIOCM_CAR; -pub const TIOCM_RI: ::c_int = TIOCM_RNG; +// elf.h +pub const NT_PRSTATUS: ::c_int = 1; +pub const NT_PRFPREG: ::c_int = 2; +pub const NT_FPREGSET: ::c_int = 2; +pub const NT_PRPSINFO: ::c_int = 3; +pub const NT_PRXREG: ::c_int = 4; +pub const NT_TASKSTRUCT: ::c_int = 4; +pub const NT_PLATFORM: ::c_int = 5; +pub const NT_AUXV: ::c_int = 6; +pub const NT_GWINDOWS: ::c_int = 7; +pub const NT_ASRS: ::c_int = 8; +pub const NT_PSTATUS: ::c_int = 10; +pub const NT_PSINFO: ::c_int = 13; +pub const NT_PRCRED: ::c_int = 14; +pub const NT_UTSNAME: ::c_int = 15; +pub const NT_LWPSTATUS: ::c_int = 16; +pub const NT_LWPSINFO: ::c_int = 17; +pub const NT_PRFPXREG: ::c_int = 20; // linux/keyctl.h pub const KEYCTL_DH_COMPUTE: u32 = 23; @@ -1210,13 +1200,6 @@ extern "C" { statxbuf: *mut statx, ) -> ::c_int; pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t; - - pub fn memmem( - haystack: *const ::c_void, - haystacklen: ::size_t, - needle: *const ::c_void, - needlelen: ::size_t, - ) -> *mut ::c_void; pub fn getauxval(type_: ::c_ulong) -> ::c_ulong; pub fn adjtimex(buf: *mut timex) -> ::c_int; @@ -1280,6 +1263,8 @@ extern "C" { pub fn explicit_bzero(s: *mut ::c_void, len: ::size_t); // Added in `glibc` 2.29 pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void; + + pub fn ctermid(s: *mut ::c_char) -> *mut ::c_char; } extern "C" { @@ -1305,16 +1290,6 @@ extern "C" { ) -> ::c_int; pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int; pub fn setpriority(which: ::__priority_which_t, who: ::id_t, prio: ::c_int) -> ::c_int; - pub fn pthread_getaffinity_np( - thread: ::pthread_t, - cpusetsize: ::size_t, - cpuset: *mut ::cpu_set_t, - ) -> ::c_int; - pub fn pthread_setaffinity_np( - thread: ::pthread_t, - cpusetsize: ::size_t, - cpuset: *const ::cpu_set_t, - ) -> ::c_int; pub fn pthread_rwlockattr_getkind_np( attr: *const ::pthread_rwlockattr_t, val: *mut ::c_int, @@ -1323,7 +1298,6 @@ extern "C" { attr: *mut ::pthread_rwlockattr_t, val: ::c_int, ) -> ::c_int; - pub fn sched_getcpu() -> ::c_int; pub fn mallinfo() -> ::mallinfo; pub fn mallinfo2() -> ::mallinfo2; pub fn malloc_info(options: ::c_int, stream: *mut ::FILE) -> ::c_int; @@ -1344,6 +1318,9 @@ extern "C" { pub fn pthread_setname_np(thread: ::pthread_t, name: *const ::c_char) -> ::c_int; pub fn sethostid(hostid: ::c_long) -> ::c_int; + + pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int; + pub fn mlock2(addr: *const ::c_void, len: ::size_t, flags: ::c_uint) -> ::c_int; } extern "C" { @@ -1355,11 +1332,13 @@ extern "C" { extra_info: *mut *mut ::c_void, flags: ::c_int, ) -> ::c_int; + pub fn malloc_trim(__pad: ::size_t) -> ::c_int; } cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "arm", + target_arch = "m68k", target_arch = "mips", target_arch = "powerpc", target_arch = "sparc", diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 20cb9ae6..cbde59f0 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -563,6 +563,24 @@ s! { pub instruction_pointer: ::__u64, pub args: [::__u64; 6], } + + pub struct nlmsghdr { + pub nlmsg_len: u32, + pub nlmsg_type: u16, + pub nlmsg_flags: u16, + pub nlmsg_seq: u32, + pub nlmsg_pid: u32, + } + + pub struct nlmsgerr { + pub error: ::c_int, + pub msg: nlmsghdr, + } + + pub struct nlattr { + pub nla_len: u16, + pub nla_type: u16, + } } s_no_extra_traits! { @@ -653,6 +671,19 @@ s_no_extra_traits! { } cfg_if! { + if #[cfg(not(all(target_env = "musl", target_arch = "mips")))] { + s_no_extra_traits! { + // linux/net_tstamp.h + #[allow(missing_debug_implementations)] + pub struct sock_txtime { + pub clockid: ::clockid_t, + pub flags: ::__u32, + } + } + } +} + +cfg_if! { if #[cfg(libc_union)] { s_no_extra_traits! { // linux/can.h @@ -1299,6 +1330,7 @@ pub const POSIX_MADV_NORMAL: ::c_int = 0; pub const POSIX_MADV_RANDOM: ::c_int = 1; pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; pub const POSIX_MADV_WILLNEED: ::c_int = 3; +pub const POSIX_SPAWN_USEVFORK: ::c_int = 64; pub const S_IEXEC: mode_t = 64; pub const S_IWRITE: mode_t = 128; @@ -1445,6 +1477,13 @@ pub const RTLD_NOW: ::c_int = 0x2; pub const AT_EACCESS: ::c_int = 0x200; +// linux/mempolicy.h +pub const MPOL_DEFAULT: ::c_int = 0; +pub const MPOL_PREFERRED: ::c_int = 1; +pub const MPOL_BIND: ::c_int = 2; +pub const MPOL_INTERLEAVE: ::c_int = 3; +pub const MPOL_LOCAL: ::c_int = 4; + align_const! { pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { size: [0; __SIZEOF_PTHREAD_MUTEX_T], @@ -1460,6 +1499,8 @@ pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL; +pub const PTHREAD_MUTEX_STALLED: ::c_int = 0; +pub const PTHREAD_MUTEX_ROBUST: ::c_int = 1; pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 0; pub const PTHREAD_PROCESS_SHARED: ::c_int = 1; pub const __SIZEOF_PTHREAD_COND_T: usize = 48; @@ -1476,6 +1517,8 @@ pub const SCHED_IDLE: ::c_int = 5; pub const SCHED_RESET_ON_FORK: ::c_int = 0x40000000; +pub const CLONE_PIDFD: ::c_int = 0x1000; + // netinet/in.h // NOTE: These are in addition to the constants defined in src/unix/mod.rs @@ -1520,11 +1563,6 @@ pub const SHM_HUGETLB: ::c_int = 0o4000; #[cfg(not(all(target_env = "uclibc", target_arch = "mips")))] pub const SHM_NORESERVE: ::c_int = 0o10000; -pub const EPOLLRDHUP: ::c_int = 0x2000; -pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000; -pub const EPOLLWAKEUP: ::c_int = 0x20000000; -pub const EPOLLONESHOT: ::c_int = 0x40000000; - pub const QFMT_VFS_OLD: ::c_int = 1; pub const QFMT_VFS_V0: ::c_int = 2; pub const QFMT_VFS_V1: ::c_int = 4; @@ -1789,6 +1827,95 @@ pub const CMSPAR: ::tcflag_t = 0o10000000000; pub const MFD_CLOEXEC: ::c_uint = 0x0001; pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002; pub const MFD_HUGETLB: ::c_uint = 0x0004; +pub const MFD_HUGE_64KB: ::c_uint = 0x40000000; +pub const MFD_HUGE_512KB: ::c_uint = 0x4c000000; +pub const MFD_HUGE_1MB: ::c_uint = 0x50000000; +pub const MFD_HUGE_2MB: ::c_uint = 0x54000000; +pub const MFD_HUGE_8MB: ::c_uint = 0x5c000000; +pub const MFD_HUGE_16MB: ::c_uint = 0x60000000; +pub const MFD_HUGE_32MB: ::c_uint = 0x64000000; +pub const MFD_HUGE_256MB: ::c_uint = 0x70000000; +pub const MFD_HUGE_512MB: ::c_uint = 0x74000000; +pub const MFD_HUGE_1GB: ::c_uint = 0x78000000; +pub const MFD_HUGE_2GB: ::c_uint = 0x7c000000; +pub const MFD_HUGE_16GB: ::c_uint = 0x88000000; +pub const MFD_HUGE_MASK: ::c_uint = 63; +pub const MFD_HUGE_SHIFT: ::c_uint = 26; + +// linux/close_range.h +pub const CLOSE_RANGE_UNSHARE: ::c_uint = 1 << 1; +pub const CLOSE_RANGE_CLOEXEC: ::c_uint = 1 << 2; + +// linux/filter.h +pub const SKF_AD_OFF: ::c_int = -0x1000; +pub const SKF_AD_PROTOCOL: ::c_int = 0; +pub const SKF_AD_PKTTYPE: ::c_int = 4; +pub const SKF_AD_IFINDEX: ::c_int = 8; +pub const SKF_AD_NLATTR: ::c_int = 12; +pub const SKF_AD_NLATTR_NEST: ::c_int = 16; +pub const SKF_AD_MARK: ::c_int = 20; +pub const SKF_AD_QUEUE: ::c_int = 24; +pub const SKF_AD_HATYPE: ::c_int = 28; +pub const SKF_AD_RXHASH: ::c_int = 32; +pub const SKF_AD_CPU: ::c_int = 36; +pub const SKF_AD_ALU_XOR_X: ::c_int = 40; +pub const SKF_AD_VLAN_TAG: ::c_int = 44; +pub const SKF_AD_VLAN_TAG_PRESENT: ::c_int = 48; +pub const SKF_AD_PAY_OFFSET: ::c_int = 52; +pub const SKF_AD_RANDOM: ::c_int = 56; +pub const SKF_AD_VLAN_TPID: ::c_int = 60; +pub const SKF_AD_MAX: ::c_int = 64; +pub const SKF_NET_OFF: ::c_int = -0x100000; +pub const SKF_LL_OFF: ::c_int = -0x200000; +pub const BPF_NET_OFF: ::c_int = SKF_NET_OFF; +pub const BPF_LL_OFF: ::c_int = SKF_LL_OFF; +pub const BPF_MEMWORDS: ::c_int = 16; +pub const BPF_MAXINSNS: ::c_int = 4096; + +// linux/bpf_common.h +pub const BPF_LD: ::__u32 = 0x00; +pub const BPF_LDX: ::__u32 = 0x01; +pub const BPF_ST: ::__u32 = 0x02; +pub const BPF_STX: ::__u32 = 0x03; +pub const BPF_ALU: ::__u32 = 0x04; +pub const BPF_JMP: ::__u32 = 0x05; +pub const BPF_RET: ::__u32 = 0x06; +pub const BPF_MISC: ::__u32 = 0x07; +pub const BPF_W: ::__u32 = 0x00; +pub const BPF_H: ::__u32 = 0x08; +pub const BPF_B: ::__u32 = 0x10; +pub const BPF_IMM: ::__u32 = 0x00; +pub const BPF_ABS: ::__u32 = 0x20; +pub const BPF_IND: ::__u32 = 0x40; +pub const BPF_MEM: ::__u32 = 0x60; +pub const BPF_LEN: ::__u32 = 0x80; +pub const BPF_MSH: ::__u32 = 0xa0; +pub const BPF_ADD: ::__u32 = 0x00; +pub const BPF_SUB: ::__u32 = 0x10; +pub const BPF_MUL: ::__u32 = 0x20; +pub const BPF_DIV: ::__u32 = 0x30; +pub const BPF_OR: ::__u32 = 0x40; +pub const BPF_AND: ::__u32 = 0x50; +pub const BPF_LSH: ::__u32 = 0x60; +pub const BPF_RSH: ::__u32 = 0x70; +pub const BPF_NEG: ::__u32 = 0x80; +pub const BPF_MOD: ::__u32 = 0x90; +pub const BPF_XOR: ::__u32 = 0xa0; +pub const BPF_JA: ::__u32 = 0x00; +pub const BPF_JEQ: ::__u32 = 0x10; +pub const BPF_JGT: ::__u32 = 0x20; +pub const BPF_JGE: ::__u32 = 0x30; +pub const BPF_JSET: ::__u32 = 0x40; +pub const BPF_K: ::__u32 = 0x00; +pub const BPF_X: ::__u32 = 0x08; + +// linux/openat2.h +pub const RESOLVE_NO_XDEV: ::__u64 = 0x01; +pub const RESOLVE_NO_MAGICLINKS: ::__u64 = 0x02; +pub const RESOLVE_NO_SYMLINKS: ::__u64 = 0x04; +pub const RESOLVE_BENEATH: ::__u64 = 0x08; +pub const RESOLVE_IN_ROOT: ::__u64 = 0x10; +pub const RESOLVE_CACHED: ::__u64 = 0x20; // these are used in the p_type field of Elf32_Phdr and Elf64_Phdr, which has // the type Elf32Word and Elf64Word respectively. Luckily, both of those are u32 @@ -2362,6 +2489,8 @@ pub const NETLINK_TX_RING: ::c_int = 7; pub const NETLINK_LISTEN_ALL_NSID: ::c_int = 8; pub const NETLINK_LIST_MEMBERSHIPS: ::c_int = 9; pub const NETLINK_CAP_ACK: ::c_int = 10; +pub const NETLINK_EXT_ACK: ::c_int = 11; +pub const NETLINK_GET_STRICT_CHK: ::c_int = 12; pub const NLA_F_NESTED: ::c_int = 1 << 15; pub const NLA_F_NET_BYTEORDER: ::c_int = 1 << 14; @@ -2510,6 +2639,12 @@ pub const SOF_TIMESTAMPING_RX_SOFTWARE: ::c_uint = 1 << 3; pub const SOF_TIMESTAMPING_SOFTWARE: ::c_uint = 1 << 4; pub const SOF_TIMESTAMPING_SYS_HARDWARE: ::c_uint = 1 << 5; pub const SOF_TIMESTAMPING_RAW_HARDWARE: ::c_uint = 1 << 6; +cfg_if! { + if #[cfg(not(all(target_env = "musl", target_arch = "mips")))] { + pub const SOF_TXTIME_DEADLINE_MODE: u32 = 1 << 0; + pub const SOF_TXTIME_REPORT_ERRORS: u32 = 1 << 1; + } +} // linux/if_alg.h pub const ALG_SET_KEY: ::c_int = 1; @@ -2532,6 +2667,7 @@ pub const MAP_SHARED_VALIDATE: ::c_int = 0x3; // include/uapi/asm-generic/mman-common.h pub const MAP_FIXED_NOREPLACE: ::c_int = 0x100000; +pub const MLOCK_ONFAULT: ::c_uint = 0x01; // uapi/linux/vm_sockets.h pub const VMADDR_CID_ANY: ::c_uint = 0xFFFFFFFF; @@ -3037,18 +3173,14 @@ pub const SOL_CAN_BASE: ::c_int = 100; pub const CAN_INV_FILTER: canid_t = 0x20000000; pub const CAN_RAW_FILTER_MAX: ::c_int = 512; -#[deprecated( - since = "0.2.102", - note = "Errnoeously uses c_int; should use c_short." -)] -#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64")))] -pub const POLLRDHUP: ::c_int = 0x2000; -#[deprecated( - since = "0.2.102", - note = "Errnoeously uses c_int; should use c_short." -)] -#[cfg(any(target_arch = "sparc", target_arch = "sparc64"))] -pub const POLLRDHUP: ::c_int = 0x800; +// linux/can/raw.h +pub const SOL_CAN_RAW: ::c_int = SOL_CAN_BASE + CAN_RAW; +pub const CAN_RAW_FILTER: ::c_int = 1; +pub const CAN_RAW_ERR_FILTER: ::c_int = 2; +pub const CAN_RAW_LOOPBACK: ::c_int = 3; +pub const CAN_RAW_RECV_OWN_MSGS: ::c_int = 4; +pub const CAN_RAW_FD_FRAMES: ::c_int = 5; +pub const CAN_RAW_JOIN_FILTERS: ::c_int = 6; f! { pub fn NLA_ALIGN(len: ::c_int) -> ::c_int { @@ -3173,6 +3305,22 @@ f! { pub fn SO_EE_OFFENDER(ee: *const ::sock_extended_err) -> *mut ::sockaddr { ee.offset(1) as *mut ::sockaddr } + + pub fn BPF_RVAL(code: ::__u32) -> ::__u32 { + code & 0x18 + } + + pub fn BPF_MISCOP(code: ::__u32) -> ::__u32 { + code & 0xf8 + } + + pub fn BPF_STMT(code: ::__u16, k: ::__u32) -> sock_filter { + sock_filter{code: code, jt: 0, jf: 0, k: k} + } + + pub fn BPF_JUMP(code: ::__u16, k: ::__u32, jt: ::__u8, jf: ::__u8) -> sock_filter { + sock_filter{code: code, jt: jt, jf: jf, k: k} + } } cfg_if! { @@ -3438,6 +3586,16 @@ extern "C" { len: *mut ::socklen_t, flg: ::c_int, ) -> ::c_int; + pub fn pthread_getaffinity_np( + thread: ::pthread_t, + cpusetsize: ::size_t, + cpuset: *mut ::cpu_set_t, + ) -> ::c_int; + pub fn pthread_setaffinity_np( + thread: ::pthread_t, + cpusetsize: ::size_t, + cpuset: *const ::cpu_set_t, + ) -> ::c_int; pub fn pthread_setschedprio(native: ::pthread_t, priority: ::c_int) -> ::c_int; pub fn reboot(how_to: ::c_int) -> ::c_int; pub fn setfsgid(gid: ::gid_t) -> ::c_int; @@ -3568,6 +3726,7 @@ extern "C" { timeout: *const ::timespec, sigmask: *const sigset_t, ) -> ::c_int; + pub fn pthread_mutex_consistent(mutex: *mut pthread_mutex_t) -> ::c_int; pub fn pthread_mutex_timedlock( lock: *mut pthread_mutex_t, abstime: *const ::timespec, @@ -3683,6 +3842,14 @@ extern "C" { attr: *const pthread_mutexattr_t, pshared: *mut ::c_int, ) -> ::c_int; + pub fn pthread_mutexattr_getrobust( + attr: *const pthread_mutexattr_t, + robustness: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_mutexattr_setrobust( + attr: *mut pthread_mutexattr_t, + robustness: ::c_int, + ) -> ::c_int; pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; pub fn faccessat( dirfd: ::c_int, @@ -3850,6 +4017,13 @@ extern "C" { pub fn gethostid() -> ::c_long; pub fn pthread_getcpuclockid(thread: ::pthread_t, clk_id: *mut ::clockid_t) -> ::c_int; + pub fn memmem( + haystack: *const ::c_void, + haystacklen: ::size_t, + needle: *const ::c_void, + needlelen: ::size_t, + ) -> *mut ::c_void; + pub fn sched_getcpu() -> ::c_int; } cfg_if! { @@ -3878,3 +4052,10 @@ cfg_if! { } } expand_align!(); + +cfg_if! { + if #[cfg(libc_non_exhaustive)] { + mod non_exhaustive; + pub use self::non_exhaustive::*; + } +} diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index 4e0f6c51..97d91f4a 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -150,6 +150,77 @@ s! { pub f_namemax: ::c_ulong, __f_spare: [::c_int; 6], } + + pub struct mcontext_t { + pub trap_no: ::c_ulong, + pub error_code: ::c_ulong, + pub oldmask: ::c_ulong, + pub arm_r0: ::c_ulong, + pub arm_r1: ::c_ulong, + pub arm_r2: ::c_ulong, + pub arm_r3: ::c_ulong, + pub arm_r4: ::c_ulong, + pub arm_r5: ::c_ulong, + pub arm_r6: ::c_ulong, + pub arm_r7: ::c_ulong, + pub arm_r8: ::c_ulong, + pub arm_r9: ::c_ulong, + pub arm_r10: ::c_ulong, + pub arm_fp: ::c_ulong, + pub arm_ip: ::c_ulong, + pub arm_sp: ::c_ulong, + pub arm_lr: ::c_ulong, + pub arm_pc: ::c_ulong, + pub arm_cpsr: ::c_ulong, + pub fault_address: ::c_ulong, + } +} + +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: ::sigset_t, + pub uc_regspace: [::c_ulonglong; 64], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for ucontext_t { + fn eq(&self, other: &ucontext_t) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask == other.uc_sigmask + } + } + impl Eq for ucontext_t {} + impl ::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_link) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_sigmask", &self.uc_sigmask) + .finish() + } + } + impl ::hash::Hash for ucontext_t { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask.hash(state); + } + } + } } pub const SIGSTKSZ: ::size_t = 8192; @@ -161,10 +232,6 @@ pub const O_NOFOLLOW: ::c_int = 0x8000; pub const O_ASYNC: ::c_int = 0x2000; pub const O_LARGEFILE: ::c_int = 0o400000; -pub const FIOCLEX: ::c_int = 0x5451; -pub const FIONCLEX: ::c_int = 0x5450; -pub const FIONBIO: ::c_int = 0x5421; - pub const RLIMIT_RSS: ::c_int = 5; pub const RLIMIT_NOFILE: ::c_int = 7; pub const RLIMIT_AS: ::c_int = 9; @@ -404,55 +471,9 @@ pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; -pub const TCGETS: ::c_int = 0x5401; -pub const TCSETS: ::c_int = 0x5402; -pub const TCSETSW: ::c_int = 0x5403; -pub const TCSETSF: ::c_int = 0x5404; -pub const TCGETA: ::c_int = 0x5405; -pub const TCSETA: ::c_int = 0x5406; -pub const TCSETAW: ::c_int = 0x5407; -pub const TCSETAF: ::c_int = 0x5408; -pub const TCSBRK: ::c_int = 0x5409; -pub const TCXONC: ::c_int = 0x540A; -pub const TCFLSH: ::c_int = 0x540B; -pub const TIOCGSOFTCAR: ::c_int = 0x5419; -pub const TIOCSSOFTCAR: ::c_int = 0x541A; -pub const TIOCLINUX: ::c_int = 0x541C; -pub const TIOCGSERIAL: ::c_int = 0x541E; -pub const TIOCEXCL: ::c_int = 0x540C; -pub const TIOCNXCL: ::c_int = 0x540D; -pub const TIOCSCTTY: ::c_int = 0x540E; -pub const TIOCGPGRP: ::c_int = 0x540F; -pub const TIOCSPGRP: ::c_int = 0x5410; -pub const TIOCOUTQ: ::c_int = 0x5411; -pub const TIOCSTI: ::c_int = 0x5412; -pub const TIOCGWINSZ: ::c_int = 0x5413; -pub const TIOCSWINSZ: ::c_int = 0x5414; -pub const TIOCMGET: ::c_int = 0x5415; -pub const TIOCMBIS: ::c_int = 0x5416; -pub const TIOCMBIC: ::c_int = 0x5417; -pub const TIOCMSET: ::c_int = 0x5418; -pub const FIONREAD: ::c_int = 0x541B; -pub const TIOCCONS: ::c_int = 0x541D; - -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; - pub const POLLWRNORM: ::c_short = 0x100; pub const POLLWRBAND: ::c_short = 0x200; -pub const TIOCM_LE: ::c_int = 0x001; -pub const TIOCM_DTR: ::c_int = 0x002; -pub const TIOCM_RTS: ::c_int = 0x004; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; -pub const TIOCM_CD: ::c_int = TIOCM_CAR; -pub const TIOCM_RI: ::c_int = TIOCM_RNG; - // Syscall table pub const SYS_restart_syscall: ::c_long = 0; pub const SYS_exit: ::c_long = 1; diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index a94ebb6a..3d8b84de 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -129,17 +129,6 @@ s! { pub f_namemax: ::c_ulong, __f_spare: [::c_int; 6], } - - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } } pub const AF_FILE: ::c_int = 1; @@ -234,12 +223,6 @@ pub const F_GETOWN: ::c_int = 9; pub const F_GETOWNER_UIDS: ::c_int = 17; pub const F_GETOWN_EX: ::c_int = 16; pub const F_GETSIG: ::c_int = 11; -pub const FIOASYNC: ::c_int = 21586; -pub const FIOCLEX: ::c_int = 21585; -pub const FIONBIO: ::c_int = 21537; -pub const FIONCLEX: ::c_int = 21584; -pub const FIONREAD: ::c_int = 21531; -pub const FIOQSIZE: ::c_int = 21600; pub const F_LINUX_SPECIFIC_BASE: ::c_int = 1024; pub const FLUSHO: ::c_int = 4096; pub const F_OFD_GETLK: ::c_int = 36; @@ -666,83 +649,10 @@ pub const SYS_waitid: ::c_int = 95; pub const SYS_write: ::c_int = 64; pub const SYS_writev: ::c_int = 66; pub const SYS_statx: ::c_int = 291; -pub const TCFLSH: ::c_int = 21515; -pub const TCGETA: ::c_int = 21509; -pub const TCGETS: ::c_int = 21505; -pub const TCGETX: ::c_int = 21554; -pub const TCSBRK: ::c_int = 21513; -pub const TCSBRKP: ::c_int = 21541; -pub const TCSETA: ::c_int = 21510; -pub const TCSETAF: ::c_int = 21512; -pub const TCSETAW: ::c_int = 21511; -pub const TCSETS: ::c_int = 21506; -pub const TCSETSF: ::c_int = 21508; -pub const TCSETSW: ::c_int = 21507; -pub const TCSETX: ::c_int = 21555; -pub const TCSETXF: ::c_int = 21556; -pub const TCSETXW: ::c_int = 21557; -pub const TCXONC: ::c_int = 21514; -pub const TIOCCONS: ::c_int = 21533; -pub const TIOCEXCL: ::c_int = 21516; -pub const TIOCGETD: ::c_int = 21540; -pub const TIOCGICOUNT: ::c_int = 21597; -pub const TIOCGLCKTRMIOS: ::c_int = 21590; -pub const TIOCGPGRP: ::c_int = 21519; -pub const TIOCGRS485: ::c_int = 21550; -pub const TIOCGSERIAL: ::c_int = 21534; -pub const TIOCGSID: ::c_int = 21545; -pub const TIOCGSOFTCAR: ::c_int = 21529; -pub const TIOCGWINSZ: ::c_int = 21523; -pub const TIOCLINUX: ::c_int = 21532; -pub const TIOCMBIC: ::c_int = 21527; -pub const TIOCMBIS: ::c_int = 21526; -pub const TIOCM_CAR: ::c_int = 64; -pub const TIOCM_CD: ::c_int = 64; -pub const TIOCM_CTS: ::c_int = 32; -pub const TIOCM_DSR: ::c_int = 256; -pub const TIOCM_DTR: ::c_int = 2; -pub const TIOCMGET: ::c_int = 21525; -pub const TIOCMIWAIT: ::c_int = 21596; -pub const TIOCM_LE: ::c_int = 1; pub const TIOCM_LOOP: ::c_int = 32768; pub const TIOCM_OUT1: ::c_int = 8192; pub const TIOCM_OUT2: ::c_int = 16384; -pub const TIOCM_RI: ::c_int = 128; -pub const TIOCM_RNG: ::c_int = 128; -pub const TIOCM_RTS: ::c_int = 4; -pub const TIOCMSET: ::c_int = 21528; -pub const TIOCM_SR: ::c_int = 16; -pub const TIOCM_ST: ::c_int = 8; -pub const TIOCNOTTY: ::c_int = 21538; -pub const TIOCNXCL: ::c_int = 21517; -pub const TIOCOUTQ: ::c_int = 21521; -pub const TIOCPKT: ::c_int = 21536; -pub const TIOCPKT_DATA: ::c_int = 0; -pub const TIOCPKT_DOSTOP: ::c_int = 32; -pub const TIOCPKT_FLUSHREAD: ::c_int = 1; -pub const TIOCPKT_FLUSHWRITE: ::c_int = 2; -pub const TIOCPKT_IOCTL: ::c_int = 64; -pub const TIOCPKT_NOSTOP: ::c_int = 16; -pub const TIOCPKT_START: ::c_int = 8; -pub const TIOCPKT_STOP: ::c_int = 4; -pub const TIOCSCTTY: ::c_int = 21518; -pub const TIOCSERCONFIG: ::c_int = 21587; -pub const TIOCSERGETLSR: ::c_int = 21593; -pub const TIOCSERGETMULTI: ::c_int = 21594; -pub const TIOCSERGSTRUCT: ::c_int = 21592; -pub const TIOCSERGWILD: ::c_int = 21588; -pub const TIOCSERSETMULTI: ::c_int = 21595; -pub const TIOCSERSWILD: ::c_int = 21589; pub const TIOCSER_TEMT: ::c_int = 1; -pub const TIOCSETD: ::c_int = 21539; -pub const TIOCSLCKTRMIOS: ::c_int = 21591; -pub const TIOCSPGRP: ::c_int = 21520; -pub const TIOCSRS485: ::c_int = 21551; -pub const TIOCSSERIAL: ::c_int = 21535; -pub const TIOCSSOFTCAR: ::c_int = 21530; -pub const TIOCSTI: ::c_int = 21522; -pub const TIOCSWINSZ: ::c_int = 21524; -pub const TIOCVHANGUP: ::c_int = 21559; pub const TOSTOP: ::c_int = 256; pub const VEOF: ::c_int = 4; pub const VEOL2: ::c_int = 16; diff --git a/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/src/unix/linux_like/linux/musl/b32/mips/mod.rs index 0a67f74c..2942f58a 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -172,10 +172,6 @@ pub const O_NOFOLLOW: ::c_int = 0o400000; pub const O_ASYNC: ::c_int = 0o10000; pub const O_LARGEFILE: ::c_int = 0x2000; -pub const FIOCLEX: ::c_int = 0x6601; -pub const FIONCLEX: ::c_int = 0x6602; -pub const FIONBIO: ::c_int = 0x667E; - pub const RLIMIT_RSS: ::c_int = 7; pub const RLIMIT_NOFILE: ::c_int = 5; pub const RLIMIT_AS: ::c_int = 6; @@ -413,55 +409,9 @@ pub const IEXTEN: ::tcflag_t = 0o000400; pub const TOSTOP: ::tcflag_t = 0o100000; pub const FLUSHO: ::tcflag_t = 0o020000; -pub const TCGETS: ::c_int = 0x540D; -pub const TCSETS: ::c_int = 0x540E; -pub const TCSETSW: ::c_int = 0x540F; -pub const TCSETSF: ::c_int = 0x5410; -pub const TCGETA: ::c_int = 0x5401; -pub const TCSETA: ::c_int = 0x5402; -pub const TCSETAW: ::c_int = 0x5403; -pub const TCSETAF: ::c_int = 0x5404; -pub const TCSBRK: ::c_int = 0x5405; -pub const TCXONC: ::c_int = 0x5406; -pub const TCFLSH: ::c_int = 0x5407; -pub const TIOCGSOFTCAR: ::c_int = 0x5481; -pub const TIOCSSOFTCAR: ::c_int = 0x5482; -pub const TIOCLINUX: ::c_int = 0x5483; -pub const TIOCGSERIAL: ::c_int = 0x5484; -pub const TIOCEXCL: ::c_int = 0x740D; -pub const TIOCNXCL: ::c_int = 0x740E; -pub const TIOCSCTTY: ::c_int = 0x5480; -pub const TIOCGPGRP: ::c_int = 0x40047477; -pub const TIOCSPGRP: ::c_int = 0x80047476; -pub const TIOCOUTQ: ::c_int = 0x7472; -pub const TIOCSTI: ::c_int = 0x5472; -pub const TIOCGWINSZ: ::c_int = 0x40087468; -pub const TIOCSWINSZ: ::c_int = 0x80087467; -pub const TIOCMGET: ::c_int = 0x741D; -pub const TIOCMBIS: ::c_int = 0x741B; -pub const TIOCMBIC: ::c_int = 0x741C; -pub const TIOCMSET: ::c_int = 0x741A; -pub const FIONREAD: ::c_int = 0x467F; -pub const TIOCCONS: ::c_int = 0x80047478; - -pub const TIOCGRS485: ::c_int = 0x4020542E; -pub const TIOCSRS485: ::c_int = 0xC020542F; - pub const POLLWRNORM: ::c_short = 0x4; pub const POLLWRBAND: ::c_short = 0x100; -pub const TIOCM_LE: ::c_int = 0x001; -pub const TIOCM_DTR: ::c_int = 0x002; -pub const TIOCM_RTS: ::c_int = 0x004; -pub const TIOCM_ST: ::c_int = 0x010; -pub const TIOCM_SR: ::c_int = 0x020; -pub const TIOCM_CTS: ::c_int = 0x040; -pub const TIOCM_CAR: ::c_int = 0x100; -pub const TIOCM_CD: ::c_int = TIOCM_CAR; -pub const TIOCM_RNG: ::c_int = 0x200; -pub const TIOCM_RI: ::c_int = TIOCM_RNG; -pub const TIOCM_DSR: ::c_int = 0x400; - pub const SYS_syscall: ::c_long = 4000 + 0; pub const SYS_exit: ::c_long = 4000 + 1; pub const SYS_fork: ::c_long = 4000 + 2; diff --git a/src/unix/linux_like/linux/musl/b32/mod.rs b/src/unix/linux_like/linux/musl/b32/mod.rs index f54e5d9c..ae91ce40 100644 --- a/src/unix/linux_like/linux/musl/b32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mod.rs @@ -38,12 +38,6 @@ s! { pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; -pub const TIOCINQ: ::c_int = ::FIONREAD; - -extern "C" { - pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; -} - cfg_if! { if #[cfg(any(target_arch = "x86"))] { mod x86; diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index dacd78e0..ca0c393d 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -165,10 +165,6 @@ pub const O_NOFOLLOW: ::c_int = 0x8000; pub const O_ASYNC: ::c_int = 0x2000; pub const O_LARGEFILE: ::c_int = 0x10000; -pub const FIOCLEX: ::c_int = 0x20006601; -pub const FIONCLEX: ::c_int = 0x20006602; -pub const FIONBIO: ::c_int = 0x8004667E; - pub const RLIMIT_RSS: ::c_int = 5; pub const RLIMIT_NOFILE: ::c_int = 7; pub const RLIMIT_AS: ::c_int = 9; @@ -406,55 +402,9 @@ pub const IEXTEN: ::tcflag_t = 0x00000400; pub const TOSTOP: ::tcflag_t = 0x00400000; pub const FLUSHO: ::tcflag_t = 0x00800000; -pub const TCGETS: ::c_int = 0x402C7413; -pub const TCSETS: ::c_int = 0x802C7414; -pub const TCSETSW: ::c_int = 0x802C7415; -pub const TCSETSF: ::c_int = 0x802C7416; -pub const TCGETA: ::c_int = 0x40147417; -pub const TCSETA: ::c_int = 0x80147418; -pub const TCSETAW: ::c_int = 0x80147419; -pub const TCSETAF: ::c_int = 0x8014741C; -pub const TCSBRK: ::c_int = 0x2000741D; -pub const TCXONC: ::c_int = 0x2000741E; -pub const TCFLSH: ::c_int = 0x2000741F; -pub const TIOCGSOFTCAR: ::c_int = 0x5419; -pub const TIOCSSOFTCAR: ::c_int = 0x541A; -pub const TIOCLINUX: ::c_int = 0x541C; -pub const TIOCGSERIAL: ::c_int = 0x541E; -pub const TIOCEXCL: ::c_int = 0x540C; -pub const TIOCNXCL: ::c_int = 0x540D; -pub const TIOCSCTTY: ::c_int = 0x540E; -pub const TIOCGPGRP: ::c_int = 0x40047477; -pub const TIOCSPGRP: ::c_int = 0x80047476; -pub const TIOCOUTQ: ::c_int = 0x40047473; -pub const TIOCSTI: ::c_int = 0x5412; -pub const TIOCGWINSZ: ::c_int = 0x40087468; -pub const TIOCSWINSZ: ::c_int = 0x80087467; -pub const TIOCMGET: ::c_int = 0x5415; -pub const TIOCMBIS: ::c_int = 0x5416; -pub const TIOCMBIC: ::c_int = 0x5417; -pub const TIOCMSET: ::c_int = 0x5418; -pub const FIONREAD: ::c_int = 0x4004667F; -pub const TIOCCONS: ::c_int = 0x541D; - -pub const TIOCGRS485: ::c_int = 0x542e; -pub const TIOCSRS485: ::c_int = 0x542f; - pub const POLLWRNORM: ::c_short = 0x100; pub const POLLWRBAND: ::c_short = 0x200; -pub const TIOCM_LE: ::c_int = 0x001; -pub const TIOCM_DTR: ::c_int = 0x002; -pub const TIOCM_RTS: ::c_int = 0x004; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; -pub const TIOCM_CD: ::c_int = TIOCM_CAR; -pub const TIOCM_RI: ::c_int = TIOCM_RNG; - // Syscall table pub const SYS_restart_syscall: ::c_long = 0; pub const SYS_exit: ::c_long = 1; diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 64891323..0bdb96fb 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -221,10 +221,6 @@ pub const O_NOFOLLOW: ::c_int = 0x20000; pub const O_ASYNC: ::c_int = 0x2000; pub const O_LARGEFILE: ::c_int = 0o0100000; -pub const FIOCLEX: ::c_int = 0x5451; -pub const FIONCLEX: ::c_int = 0x5450; -pub const FIONBIO: ::c_int = 0x5421; - pub const RLIMIT_RSS: ::c_int = 5; pub const RLIMIT_NOFILE: ::c_int = 7; pub const RLIMIT_AS: ::c_int = 9; @@ -465,55 +461,9 @@ pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; -pub const TCGETS: ::c_int = 0x5401; -pub const TCSETS: ::c_int = 0x5402; -pub const TCSETSW: ::c_int = 0x5403; -pub const TCSETSF: ::c_int = 0x5404; -pub const TCGETA: ::c_int = 0x5405; -pub const TCSETA: ::c_int = 0x5406; -pub const TCSETAW: ::c_int = 0x5407; -pub const TCSETAF: ::c_int = 0x5408; -pub const TCSBRK: ::c_int = 0x5409; -pub const TCXONC: ::c_int = 0x540A; -pub const TCFLSH: ::c_int = 0x540B; -pub const TIOCGSOFTCAR: ::c_int = 0x5419; -pub const TIOCSSOFTCAR: ::c_int = 0x541A; -pub const TIOCLINUX: ::c_int = 0x541C; -pub const TIOCGSERIAL: ::c_int = 0x541E; -pub const TIOCEXCL: ::c_int = 0x540C; -pub const TIOCNXCL: ::c_int = 0x540D; -pub const TIOCSCTTY: ::c_int = 0x540E; -pub const TIOCGPGRP: ::c_int = 0x540F; -pub const TIOCSPGRP: ::c_int = 0x5410; -pub const TIOCOUTQ: ::c_int = 0x5411; -pub const TIOCSTI: ::c_int = 0x5412; -pub const TIOCGWINSZ: ::c_int = 0x5413; -pub const TIOCSWINSZ: ::c_int = 0x5414; -pub const TIOCMGET: ::c_int = 0x5415; -pub const TIOCMBIS: ::c_int = 0x5416; -pub const TIOCMBIC: ::c_int = 0x5417; -pub const TIOCMSET: ::c_int = 0x5418; -pub const FIONREAD: ::c_int = 0x541B; -pub const TIOCCONS: ::c_int = 0x541D; - -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; - pub const POLLWRNORM: ::c_short = 0x100; pub const POLLWRBAND: ::c_short = 0x200; -pub const TIOCM_LE: ::c_int = 0x001; -pub const TIOCM_DTR: ::c_int = 0x002; -pub const TIOCM_RTS: ::c_int = 0x004; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; -pub const TIOCM_CD: ::c_int = TIOCM_CAR; -pub const TIOCM_RI: ::c_int = TIOCM_RNG; - // Syscall table pub const SYS_restart_syscall: ::c_long = 0; pub const SYS_exit: ::c_long = 1; diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs index 73162c94..d901c9e2 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -49,6 +49,13 @@ s! { __unused: [::c_uint; 2], } + pub struct user_regs_struct { + pub regs: [::c_ulonglong; 31], + pub sp: ::c_ulonglong, + pub pc: ::c_ulonglong, + pub pstate: ::c_ulonglong, + } + pub struct ipc_perm { pub __ipc_perm_key: ::key_t, pub uid: ::uid_t, @@ -551,7 +558,6 @@ pub const SYS_mount_setattr: ::c_long = 442; pub const RLIMIT_NLIMITS: ::c_int = 15; pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS; -pub const TIOCINQ: ::c_int = ::FIONREAD; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; pub const CBAUD: ::tcflag_t = 0o0010017; @@ -621,9 +627,6 @@ pub const B3000000: ::speed_t = 0o010015; pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; -pub const FIOCLEX: ::c_int = 0x5451; -pub const FIONCLEX: ::c_int = 0x5450; -pub const FIONBIO: ::c_int = 0x5421; pub const EDEADLK: ::c_int = 35; pub const EDEADLOCK: ::c_int = EDEADLK; @@ -634,55 +637,6 @@ pub const VMIN: usize = 6; pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; -pub const TCGETS: ::c_int = 0x5401; -pub const TCSETS: ::c_int = 0x5402; -pub const TCSETSW: ::c_int = 0x5403; -pub const TCSETSF: ::c_int = 0x5404; -pub const TCGETA: ::c_int = 0x5405; -pub const TCSETA: ::c_int = 0x5406; -pub const TCSETAW: ::c_int = 0x5407; -pub const TCSETAF: ::c_int = 0x5408; -pub const TCSBRK: ::c_int = 0x5409; -pub const TCXONC: ::c_int = 0x540A; -pub const TCFLSH: ::c_int = 0x540B; -pub const TIOCGSOFTCAR: ::c_int = 0x5419; -pub const TIOCSSOFTCAR: ::c_int = 0x541A; -pub const TIOCLINUX: ::c_int = 0x541C; -pub const TIOCGSERIAL: ::c_int = 0x541E; -pub const TIOCEXCL: ::c_int = 0x540C; -pub const TIOCNXCL: ::c_int = 0x540D; -pub const TIOCSCTTY: ::c_int = 0x540E; -pub const TIOCGPGRP: ::c_int = 0x540F; -pub const TIOCSPGRP: ::c_int = 0x5410; -pub const TIOCOUTQ: ::c_int = 0x5411; -pub const TIOCSTI: ::c_int = 0x5412; -pub const TIOCGWINSZ: ::c_int = 0x5413; -pub const TIOCSWINSZ: ::c_int = 0x5414; -pub const TIOCMGET: ::c_int = 0x5415; -pub const TIOCMBIS: ::c_int = 0x5416; -pub const TIOCMBIC: ::c_int = 0x5417; -pub const TIOCMSET: ::c_int = 0x5418; -pub const FIONREAD: ::c_int = 0x541B; -pub const TIOCCONS: ::c_int = 0x541D; - -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; - -pub const TIOCM_LE: ::c_int = 0x001; -pub const TIOCM_DTR: ::c_int = 0x002; -pub const TIOCM_RTS: ::c_int = 0x004; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; -pub const TIOCM_CD: ::c_int = TIOCM_CAR; -pub const TIOCM_RI: ::c_int = TIOCM_RNG; - -extern "C" { - pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; -} cfg_if! { if #[cfg(libc_align)] { diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index 4605a07e..eb06ce7f 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -505,6 +505,7 @@ pub const ENOPROTOOPT: ::c_int = 99; pub const EPROTONOSUPPORT: ::c_int = 120; pub const ESOCKTNOSUPPORT: ::c_int = 121; pub const EOPNOTSUPP: ::c_int = 122; +pub const ENOTSUP: ::c_int = EOPNOTSUPP; pub const EPFNOSUPPORT: ::c_int = 123; pub const EAFNOSUPPORT: ::c_int = 124; pub const EADDRINUSE: ::c_int = 125; @@ -557,10 +558,6 @@ pub const MAP_HUGETLB: ::c_int = 0x080000; pub const SOCK_STREAM: ::c_int = 2; pub const SOCK_DGRAM: ::c_int = 1; -pub const FIOCLEX: ::c_int = 0x6601; -pub const FIONCLEX: ::c_int = 0x6602; -pub const FIONBIO: ::c_int = 0x667e; - pub const SA_ONSTACK: ::c_int = 0x08000000; pub const SA_SIGINFO: ::c_int = 0x00000008; pub const SA_NOCLDWAIT: ::c_int = 0x00010000; @@ -609,38 +606,6 @@ pub const F_OFD_GETLK: ::c_int = 36; pub const F_OFD_SETLK: ::c_int = 37; pub const F_OFD_SETLKW: ::c_int = 38; -pub const TCGETS: ::c_int = 0x540d; -pub const TCSETS: ::c_int = 0x540e; -pub const TCSETSW: ::c_int = 0x540f; -pub const TCSETSF: ::c_int = 0x5410; -pub const TCGETA: ::c_int = 0x5401; -pub const TCSETA: ::c_int = 0x5402; -pub const TCSETAW: ::c_int = 0x5403; -pub const TCSETAF: ::c_int = 0x5404; -pub const TCSBRK: ::c_int = 0x5405; -pub const TCXONC: ::c_int = 0x5406; -pub const TCFLSH: ::c_int = 0x5407; -pub const TIOCGSOFTCAR: ::c_int = 0x5481; -pub const TIOCSSOFTCAR: ::c_int = 0x5482; -pub const TIOCINQ: ::c_int = 0x467f; -pub const TIOCLINUX: ::c_int = 0x5483; -pub const TIOCGSERIAL: ::c_int = 0x5484; -pub const TIOCEXCL: ::c_int = 0x740d; -pub const TIOCNXCL: ::c_int = 0x740e; -pub const TIOCSCTTY: ::c_int = 0x5480; -pub const TIOCGPGRP: ::c_int = 0x40047477; -pub const TIOCSPGRP: ::c_int = 0x80047476_u32 as i32; -pub const TIOCOUTQ: ::c_int = 0x7472; -pub const TIOCSTI: ::c_int = 0x5472; -pub const TIOCGWINSZ: ::c_int = 0x40087468; -pub const TIOCSWINSZ: ::c_int = 0x80087467_u32 as i32; -pub const TIOCMGET: ::c_int = 0x741d; -pub const TIOCMBIS: ::c_int = 0x741b; -pub const TIOCMBIC: ::c_int = 0x741c; -pub const TIOCMSET: ::c_int = 0x741a; -pub const FIONREAD: ::c_int = 0x467f; -pub const TIOCCONS: ::c_int = 0x80047478_u32 as i32; - pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; @@ -696,7 +661,6 @@ pub const FFDLY: ::tcflag_t = 0o100000; pub const VTDLY: ::tcflag_t = 0o040000; pub const XTABS: ::tcflag_t = 0o014000; -pub const BOTHER: ::speed_t = 0o010000; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; @@ -713,15 +677,4 @@ pub const B3000000: ::speed_t = 0o010015; pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; -pub const TIOCM_ST: ::c_int = 0x010; -pub const TIOCM_SR: ::c_int = 0x020; -pub const TIOCM_CTS: ::c_int = 0x040; -pub const TIOCM_CAR: ::c_int = 0x100; -pub const TIOCM_RNG: ::c_int = 0x200; -pub const TIOCM_DSR: ::c_int = 0x400; - pub const EHWPOISON: ::c_int = 168; - -extern "C" { - pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; -} diff --git a/src/unix/linux_like/linux/musl/b64/mod.rs b/src/unix/linux_like/linux/musl/b64/mod.rs index cfcdaaec..7261b95d 100644 --- a/src/unix/linux_like/linux/musl/b64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/mod.rs @@ -163,6 +163,9 @@ cfg_if! { } else if #[cfg(any(target_arch = "x86_64"))] { mod x86_64; pub use self::x86_64::*; + } else if #[cfg(any(target_arch = "riscv64"))] { + mod riscv64; + pub use self::riscv64::*; } else { // Unknown target_arch } diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index d7e233a8..05ec9713 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -601,9 +601,6 @@ pub const SYS_process_madvise: ::c_long = 440; pub const SYS_epoll_pwait2: ::c_long = 441; pub const SYS_mount_setattr: ::c_long = 442; -pub const FIOCLEX: ::c_int = 0x20006601; -pub const FIONCLEX: ::c_int = 0x20006602; -pub const FIONBIO: ::c_int = 0x8004667e; pub const EDEADLK: ::c_int = 58; pub const EDEADLOCK: ::c_int = EDEADLK; @@ -614,53 +611,9 @@ pub const VMIN: usize = 5; pub const IEXTEN: ::tcflag_t = 0x00000400; pub const TOSTOP: ::tcflag_t = 0x00400000; pub const FLUSHO: ::tcflag_t = 0x00800000; -pub const TCGETS: ::c_int = 0x403c7413; -pub const TCSETS: ::c_int = 0x803c7414; -pub const TCSETSW: ::c_int = 0x803c7415; -pub const TCSETSF: ::c_int = 0x803c7416; -pub const TCGETA: ::c_int = 0x40147417; -pub const TCSETA: ::c_int = 0x80147418; -pub const TCSETAW: ::c_int = 0x80147419; -pub const TCSETAF: ::c_int = 0x8014741c; -pub const TCSBRK: ::c_int = 0x2000741d; -pub const TCXONC: ::c_int = 0x2000741e; -pub const TCFLSH: ::c_int = 0x2000741f; -pub const TIOCGSOFTCAR: ::c_int = 0x5419; -pub const TIOCSSOFTCAR: ::c_int = 0x541A; -pub const TIOCLINUX: ::c_int = 0x541C; -pub const TIOCGSERIAL: ::c_int = 0x541E; -pub const TIOCEXCL: ::c_int = 0x540C; -pub const TIOCNXCL: ::c_int = 0x540D; -pub const TIOCSCTTY: ::c_int = 0x540E; -pub const TIOCGPGRP: ::c_int = 0x40047477; -pub const TIOCSPGRP: ::c_int = 0x80047476; -pub const TIOCOUTQ: ::c_int = 0x40047473; -pub const TIOCGWINSZ: ::c_int = 0x40087468; -pub const TIOCSWINSZ: ::c_int = 0x80087467; -pub const TIOCMGET: ::c_int = 0x5415; -pub const TIOCMBIS: ::c_int = 0x5416; -pub const TIOCMBIC: ::c_int = 0x5417; -pub const TIOCMSET: ::c_int = 0x5418; -pub const FIONREAD: ::c_int = 0x4004667f; -pub const TIOCCONS: ::c_int = 0x541D; -pub const TIOCM_LE: ::c_int = 0x001; -pub const TIOCM_DTR: ::c_int = 0x002; -pub const TIOCM_RTS: ::c_int = 0x004; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; -pub const TIOCM_CD: ::c_int = TIOCM_CAR; -pub const TIOCM_RI: ::c_int = TIOCM_RNG; - -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; pub const RLIMIT_NLIMITS: ::c_int = 15; pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS; -pub const TIOCINQ: ::c_int = ::FIONREAD; pub const MCL_CURRENT: ::c_int = 0x2000; pub const MCL_FUTURE: ::c_int = 0x4000; pub const CBAUD: ::tcflag_t = 0xff; @@ -732,7 +685,3 @@ pub const B2500000: ::speed_t = 0o00033; pub const B3000000: ::speed_t = 0o00034; pub const B3500000: ::speed_t = 0o00035; pub const B4000000: ::speed_t = 0o00036; - -extern "C" { - pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; -} diff --git a/src/unix/linux_like/linux/musl/b64/riscv64/align.rs b/src/unix/linux_like/linux/musl/b64/riscv64/align.rs new file mode 100644 index 00000000..48d152a5 --- /dev/null +++ b/src/unix/linux_like/linux/musl/b64/riscv64/align.rs @@ -0,0 +1,44 @@ +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct ucontext_t { + pub __uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_sigmask: ::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct mcontext_t { + pub __gregs: [::c_ulong; 32], + pub __fpregs: __riscv_mc_fp_state, + } + + #[allow(missing_debug_implementations)] + pub union __riscv_mc_fp_state { + pub __f: __riscv_mc_f_ext_state, + pub __d: __riscv_mc_d_ext_state, + pub __q: __riscv_mc_q_ext_state, + } + + #[allow(missing_debug_implementations)] + pub struct __riscv_mc_f_ext_state { + pub __f: [::c_uint; 32], + pub __fcsr: ::c_uint, + } + + #[allow(missing_debug_implementations)] + pub struct __riscv_mc_d_ext_state { + pub __f: [::c_ulonglong; 32], + pub __fcsr: ::c_uint, + } + + #[allow(missing_debug_implementations)] + #[repr(align(16))] + pub struct __riscv_mc_q_ext_state { + pub __f: [::c_ulonglong; 64], + pub __fcsr: ::c_uint, + pub __glibc_reserved: [::c_uint; 3], + } +} diff --git a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs new file mode 100644 index 00000000..5dd34daf --- /dev/null +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -0,0 +1,741 @@ +//! RISC-V-specific definitions for 64-bit linux-like values + +pub type c_char = u8; +pub type wchar_t = ::c_int; + +pub type nlink_t = ::c_uint; +pub type blksize_t = ::c_int; +pub type fsblkcnt64_t = ::c_ulong; +pub type fsfilcnt64_t = ::c_ulong; +pub type __u64 = ::c_ulonglong; + +s! { + pub struct pthread_attr_t { + __size: [::c_ulong; 7], + } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub __pad1: ::dev_t, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub __pad2: ::c_int, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_int; 2usize], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + pub st_ino: ::ino64_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub __pad1: ::dev_t, + pub st_size: ::off64_t, + pub st_blksize: ::blksize_t, + pub __pad2: ::c_int, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_int; 2], + } + + pub struct statfs { + pub f_type: ::c_long, + pub f_bsize: ::c_long, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_long, + pub f_frsize: ::c_long, + pub f_flags: ::c_long, + pub f_spare: [::c_long; 4], + } + + pub struct statfs64 { + pub f_type: ::c_long, + pub f_bsize: ::c_long, + pub f_blocks: ::fsblkcnt64_t, + pub f_bfree: ::fsblkcnt64_t, + pub f_bavail: ::fsblkcnt64_t, + pub f_files: ::fsfilcnt64_t, + pub f_ffree: ::fsfilcnt64_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_long, + pub f_frsize: ::c_long, + pub f_flags: ::c_long, + pub f_spare: [::c_long; 4], + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + pub __f_spare: [::c_int; 6], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt64_t, + pub f_bfree: ::fsblkcnt64_t, + pub f_bavail: ::fsblkcnt64_t, + pub f_files: ::fsfilcnt64_t, + pub f_ffree: ::fsfilcnt64_t, + pub f_favail: ::fsfilcnt64_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + pub __f_spare: [::c_int; 6], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + #[doc(hidden)] + #[deprecated( + since="0.2.54", + note="Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [::c_int; 29], + _align: [u64; 0], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t, + } + + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_int, + pub sa_restorer: ::Option<unsafe extern "C" fn()>, + } + + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::c_ushort, + __pad1: ::c_ushort, + pub __seq: ::c_ushort, + __pad2: ::c_ushort, + __unused1: ::c_ulong, + __unused2: ::c_ulong, + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __unused5: ::c_ulong, + __unused6: ::c_ulong, + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } +} + +pub const SYS_read: ::c_long = 63; +pub const SYS_write: ::c_long = 64; +pub const SYS_close: ::c_long = 57; +pub const SYS_fstat: ::c_long = 80; +pub const SYS_lseek: ::c_long = 62; +pub const SYS_mmap: ::c_long = 222; +pub const SYS_mprotect: ::c_long = 226; +pub const SYS_munmap: ::c_long = 215; +pub const SYS_brk: ::c_long = 214; +pub const SYS_rt_sigaction: ::c_long = 134; +pub const SYS_rt_sigprocmask: ::c_long = 135; +pub const SYS_rt_sigreturn: ::c_long = 139; +pub const SYS_ioctl: ::c_long = 29; +pub const SYS_pread64: ::c_long = 67; +pub const SYS_pwrite64: ::c_long = 68; +pub const SYS_readv: ::c_long = 65; +pub const SYS_writev: ::c_long = 66; +pub const SYS_sched_yield: ::c_long = 124; +pub const SYS_mremap: ::c_long = 216; +pub const SYS_msync: ::c_long = 227; +pub const SYS_mincore: ::c_long = 232; +pub const SYS_madvise: ::c_long = 233; +pub const SYS_shmget: ::c_long = 194; +pub const SYS_shmat: ::c_long = 196; +pub const SYS_shmctl: ::c_long = 195; +pub const SYS_dup: ::c_long = 23; +pub const SYS_nanosleep: ::c_long = 101; +pub const SYS_getitimer: ::c_long = 102; +pub const SYS_setitimer: ::c_long = 103; +pub const SYS_getpid: ::c_long = 172; +pub const SYS_sendfile: ::c_long = 71; +pub const SYS_socket: ::c_long = 198; +pub const SYS_connect: ::c_long = 203; +pub const SYS_accept: ::c_long = 202; +pub const SYS_sendto: ::c_long = 206; +pub const SYS_recvfrom: ::c_long = 207; +pub const SYS_sendmsg: ::c_long = 211; +pub const SYS_recvmsg: ::c_long = 212; +pub const SYS_shutdown: ::c_long = 210; +pub const SYS_bind: ::c_long = 200; +pub const SYS_listen: ::c_long = 201; +pub const SYS_getsockname: ::c_long = 204; +pub const SYS_getpeername: ::c_long = 205; +pub const SYS_socketpair: ::c_long = 199; +pub const SYS_setsockopt: ::c_long = 208; +pub const SYS_getsockopt: ::c_long = 209; +pub const SYS_clone: ::c_long = 220; +pub const SYS_execve: ::c_long = 221; +pub const SYS_exit: ::c_long = 93; +pub const SYS_wait4: ::c_long = 260; +pub const SYS_kill: ::c_long = 129; +pub const SYS_uname: ::c_long = 160; +pub const SYS_semget: ::c_long = 190; +pub const SYS_semop: ::c_long = 193; +pub const SYS_semctl: ::c_long = 191; +pub const SYS_shmdt: ::c_long = 197; +pub const SYS_msgget: ::c_long = 186; +pub const SYS_msgsnd: ::c_long = 189; +pub const SYS_msgrcv: ::c_long = 188; +pub const SYS_msgctl: ::c_long = 187; +pub const SYS_fcntl: ::c_long = 25; +pub const SYS_flock: ::c_long = 32; +pub const SYS_fsync: ::c_long = 82; +pub const SYS_fdatasync: ::c_long = 83; +pub const SYS_truncate: ::c_long = 45; +pub const SYS_ftruncate: ::c_long = 46; +pub const SYS_getcwd: ::c_long = 17; +pub const SYS_chdir: ::c_long = 49; +pub const SYS_fchdir: ::c_long = 50; +pub const SYS_fchmod: ::c_long = 52; +pub const SYS_fchown: ::c_long = 55; +pub const SYS_umask: ::c_long = 166; +pub const SYS_gettimeofday: ::c_long = 169; +pub const SYS_getrlimit: ::c_long = 163; +pub const SYS_getrusage: ::c_long = 165; +pub const SYS_sysinfo: ::c_long = 179; +pub const SYS_times: ::c_long = 153; +pub const SYS_ptrace: ::c_long = 117; +pub const SYS_getuid: ::c_long = 174; +pub const SYS_syslog: ::c_long = 116; +pub const SYS_getgid: ::c_long = 176; +pub const SYS_setuid: ::c_long = 146; +pub const SYS_setgid: ::c_long = 144; +pub const SYS_geteuid: ::c_long = 175; +pub const SYS_getegid: ::c_long = 177; +pub const SYS_setpgid: ::c_long = 154; +pub const SYS_getppid: ::c_long = 173; +pub const SYS_setsid: ::c_long = 157; +pub const SYS_setreuid: ::c_long = 145; +pub const SYS_setregid: ::c_long = 143; +pub const SYS_getgroups: ::c_long = 158; +pub const SYS_setgroups: ::c_long = 159; +pub const SYS_setresuid: ::c_long = 147; +pub const SYS_getresuid: ::c_long = 148; +pub const SYS_setresgid: ::c_long = 149; +pub const SYS_getresgid: ::c_long = 150; +pub const SYS_getpgid: ::c_long = 155; +pub const SYS_setfsuid: ::c_long = 151; +pub const SYS_setfsgid: ::c_long = 152; +pub const SYS_getsid: ::c_long = 156; +pub const SYS_capget: ::c_long = 90; +pub const SYS_capset: ::c_long = 91; +pub const SYS_rt_sigpending: ::c_long = 136; +pub const SYS_rt_sigtimedwait: ::c_long = 137; +pub const SYS_rt_sigqueueinfo: ::c_long = 138; +pub const SYS_rt_sigsuspend: ::c_long = 133; +pub const SYS_sigaltstack: ::c_long = 132; +pub const SYS_personality: ::c_long = 92; +pub const SYS_statfs: ::c_long = 43; +pub const SYS_fstatfs: ::c_long = 44; +pub const SYS_getpriority: ::c_long = 141; +pub const SYS_setpriority: ::c_long = 140; +pub const SYS_sched_setparam: ::c_long = 118; +pub const SYS_sched_getparam: ::c_long = 121; +pub const SYS_sched_setscheduler: ::c_long = 119; +pub const SYS_sched_getscheduler: ::c_long = 120; +pub const SYS_sched_get_priority_max: ::c_long = 125; +pub const SYS_sched_get_priority_min: ::c_long = 126; +pub const SYS_sched_rr_get_interval: ::c_long = 127; +pub const SYS_mlock: ::c_long = 228; +pub const SYS_munlock: ::c_long = 229; +pub const SYS_mlockall: ::c_long = 230; +pub const SYS_munlockall: ::c_long = 231; +pub const SYS_vhangup: ::c_long = 58; +pub const SYS_pivot_root: ::c_long = 41; +pub const SYS_prctl: ::c_long = 167; +pub const SYS_adjtimex: ::c_long = 171; +pub const SYS_setrlimit: ::c_long = 164; +pub const SYS_chroot: ::c_long = 51; +pub const SYS_sync: ::c_long = 81; +pub const SYS_acct: ::c_long = 89; +pub const SYS_settimeofday: ::c_long = 170; +pub const SYS_mount: ::c_long = 40; +pub const SYS_umount2: ::c_long = 39; +pub const SYS_swapon: ::c_long = 224; +pub const SYS_swapoff: ::c_long = 225; +pub const SYS_reboot: ::c_long = 142; +pub const SYS_sethostname: ::c_long = 161; +pub const SYS_setdomainname: ::c_long = 162; +pub const SYS_init_module: ::c_long = 105; +pub const SYS_delete_module: ::c_long = 106; +pub const SYS_quotactl: ::c_long = 60; +pub const SYS_nfsservctl: ::c_long = 42; +pub const SYS_gettid: ::c_long = 178; +pub const SYS_readahead: ::c_long = 213; +pub const SYS_setxattr: ::c_long = 5; +pub const SYS_lsetxattr: ::c_long = 6; +pub const SYS_fsetxattr: ::c_long = 7; +pub const SYS_getxattr: ::c_long = 8; +pub const SYS_lgetxattr: ::c_long = 9; +pub const SYS_fgetxattr: ::c_long = 10; +pub const SYS_listxattr: ::c_long = 11; +pub const SYS_llistxattr: ::c_long = 12; +pub const SYS_flistxattr: ::c_long = 13; +pub const SYS_removexattr: ::c_long = 14; +pub const SYS_lremovexattr: ::c_long = 15; +pub const SYS_fremovexattr: ::c_long = 16; +pub const SYS_tkill: ::c_long = 130; +pub const SYS_futex: ::c_long = 98; +pub const SYS_sched_setaffinity: ::c_long = 122; +pub const SYS_sched_getaffinity: ::c_long = 123; +pub const SYS_io_setup: ::c_long = 0; +pub const SYS_io_destroy: ::c_long = 1; +pub const SYS_io_getevents: ::c_long = 4; +pub const SYS_io_submit: ::c_long = 2; +pub const SYS_io_cancel: ::c_long = 3; +pub const SYS_lookup_dcookie: ::c_long = 18; +pub const SYS_remap_file_pages: ::c_long = 234; +pub const SYS_getdents64: ::c_long = 61; +pub const SYS_set_tid_address: ::c_long = 96; +pub const SYS_restart_syscall: ::c_long = 128; +pub const SYS_semtimedop: ::c_long = 192; +pub const SYS_fadvise64: ::c_long = 223; +pub const SYS_timer_create: ::c_long = 107; +pub const SYS_timer_settime: ::c_long = 110; +pub const SYS_timer_gettime: ::c_long = 108; +pub const SYS_timer_getoverrun: ::c_long = 109; +pub const SYS_timer_delete: ::c_long = 111; +pub const SYS_clock_settime: ::c_long = 112; +pub const SYS_clock_gettime: ::c_long = 113; +pub const SYS_clock_getres: ::c_long = 114; +pub const SYS_clock_nanosleep: ::c_long = 115; +pub const SYS_exit_group: ::c_long = 94; +pub const SYS_epoll_ctl: ::c_long = 21; +pub const SYS_tgkill: ::c_long = 131; +pub const SYS_mbind: ::c_long = 235; +pub const SYS_set_mempolicy: ::c_long = 237; +pub const SYS_get_mempolicy: ::c_long = 236; +pub const SYS_mq_open: ::c_long = 180; +pub const SYS_mq_unlink: ::c_long = 181; +pub const SYS_mq_timedsend: ::c_long = 182; +pub const SYS_mq_timedreceive: ::c_long = 183; +pub const SYS_mq_notify: ::c_long = 184; +pub const SYS_mq_getsetattr: ::c_long = 185; +pub const SYS_kexec_load: ::c_long = 104; +pub const SYS_waitid: ::c_long = 95; +pub const SYS_add_key: ::c_long = 217; +pub const SYS_request_key: ::c_long = 218; +pub const SYS_keyctl: ::c_long = 219; +pub const SYS_ioprio_set: ::c_long = 30; +pub const SYS_ioprio_get: ::c_long = 31; +pub const SYS_inotify_add_watch: ::c_long = 27; +pub const SYS_inotify_rm_watch: ::c_long = 28; +pub const SYS_migrate_pages: ::c_long = 238; +pub const SYS_openat: ::c_long = 56; +pub const SYS_mkdirat: ::c_long = 34; +pub const SYS_mknodat: ::c_long = 33; +pub const SYS_fchownat: ::c_long = 54; +pub const SYS_newfstatat: ::c_long = 79; +pub const SYS_unlinkat: ::c_long = 35; +pub const SYS_linkat: ::c_long = 37; +pub const SYS_symlinkat: ::c_long = 36; +pub const SYS_readlinkat: ::c_long = 78; +pub const SYS_fchmodat: ::c_long = 53; +pub const SYS_faccessat: ::c_long = 48; +pub const SYS_pselect6: ::c_long = 72; +pub const SYS_ppoll: ::c_long = 73; +pub const SYS_unshare: ::c_long = 97; +pub const SYS_set_robust_list: ::c_long = 99; +pub const SYS_get_robust_list: ::c_long = 100; +pub const SYS_splice: ::c_long = 76; +pub const SYS_tee: ::c_long = 77; +pub const SYS_sync_file_range: ::c_long = 84; +pub const SYS_vmsplice: ::c_long = 75; +pub const SYS_move_pages: ::c_long = 239; +pub const SYS_utimensat: ::c_long = 88; +pub const SYS_epoll_pwait: ::c_long = 22; +pub const SYS_timerfd_create: ::c_long = 85; +pub const SYS_fallocate: ::c_long = 47; +pub const SYS_timerfd_settime: ::c_long = 86; +pub const SYS_timerfd_gettime: ::c_long = 87; +pub const SYS_accept4: ::c_long = 242; +pub const SYS_signalfd4: ::c_long = 74; +pub const SYS_eventfd2: ::c_long = 19; +pub const SYS_epoll_create1: ::c_long = 20; +pub const SYS_dup3: ::c_long = 24; +pub const SYS_pipe2: ::c_long = 59; +pub const SYS_inotify_init1: ::c_long = 26; +pub const SYS_preadv: ::c_long = 69; +pub const SYS_pwritev: ::c_long = 70; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 240; +pub const SYS_perf_event_open: ::c_long = 241; +pub const SYS_recvmmsg: ::c_long = 243; +pub const SYS_fanotify_init: ::c_long = 262; +pub const SYS_fanotify_mark: ::c_long = 263; +pub const SYS_prlimit64: ::c_long = 261; +pub const SYS_name_to_handle_at: ::c_long = 264; +pub const SYS_open_by_handle_at: ::c_long = 265; +pub const SYS_clock_adjtime: ::c_long = 266; +pub const SYS_syncfs: ::c_long = 267; +pub const SYS_sendmmsg: ::c_long = 269; +pub const SYS_setns: ::c_long = 268; +pub const SYS_getcpu: ::c_long = 168; +pub const SYS_process_vm_readv: ::c_long = 270; +pub const SYS_process_vm_writev: ::c_long = 271; +pub const SYS_kcmp: ::c_long = 272; +pub const SYS_finit_module: ::c_long = 273; +pub const SYS_sched_setattr: ::c_long = 274; +pub const SYS_sched_getattr: ::c_long = 275; +pub const SYS_renameat2: ::c_long = 276; +pub const SYS_seccomp: ::c_long = 277; +pub const SYS_getrandom: ::c_long = 278; +pub const SYS_memfd_create: ::c_long = 279; +pub const SYS_bpf: ::c_long = 280; +pub const SYS_execveat: ::c_long = 281; +pub const SYS_userfaultfd: ::c_long = 282; +pub const SYS_membarrier: ::c_long = 283; +pub const SYS_mlock2: ::c_long = 284; +pub const SYS_copy_file_range: ::c_long = 285; +pub const SYS_preadv2: ::c_long = 286; +pub const SYS_pwritev2: ::c_long = 287; +pub const SYS_pkey_mprotect: ::c_long = 288; +pub const SYS_pkey_alloc: ::c_long = 289; +pub const SYS_pkey_free: ::c_long = 290; +pub const SYS_statx: ::c_long = 291; +pub const SYS_pidfd_send_signal: ::c_long = 424; +pub const SYS_io_uring_setup: ::c_long = 425; +pub const SYS_io_uring_enter: ::c_long = 426; +pub const SYS_io_uring_register: ::c_long = 427; +pub const SYS_open_tree: ::c_long = 428; +pub const SYS_move_mount: ::c_long = 429; +pub const SYS_fsopen: ::c_long = 430; +pub const SYS_fsconfig: ::c_long = 431; +pub const SYS_fsmount: ::c_long = 432; +pub const SYS_fspick: ::c_long = 433; +pub const SYS_pidfd_open: ::c_long = 434; +pub const SYS_clone3: ::c_long = 435; +pub const SYS_close_range: ::c_long = 436; +pub const SYS_openat2: ::c_long = 437; +pub const SYS_pidfd_getfd: ::c_long = 438; +pub const SYS_faccessat2: ::c_long = 439; +pub const SYS_process_madvise: ::c_long = 440; +pub const SYS_epoll_pwait2: ::c_long = 441; +pub const SYS_mount_setattr: ::c_long = 442; + +pub const O_APPEND: ::c_int = 1024; +pub const O_DIRECT: ::c_int = 0x4000; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_LARGEFILE: ::c_int = 0; +pub const O_NOFOLLOW: ::c_int = 0x20000; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; +pub const O_ASYNC: ::c_int = 0x2000; + +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; + +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EMULTIHOP: ::c_int = 72; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EBADMSG: ::c_int = 74; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EUCLEAN: ::c_int = 117; +pub const ENOTNAM: ::c_int = 118; +pub const ENAVAIL: ::c_int = 119; +pub const EISNAM: ::c_int = 120; +pub const EREMOTEIO: ::c_int = 121; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const EHWPOISON: ::c_int = 133; +pub const ERFKILL: ::c_int = 132; + +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; + +pub const F_GETLK: ::c_int = 5; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; +pub const F_SETOWN: ::c_int = 8; +pub const F_OFD_GETLK: ::c_int = 36; +pub const F_OFD_SETLK: ::c_int = 37; +pub const F_OFD_SETLKW: ::c_int = 38; + +pub const VEOF: usize = 4; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; + +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; +pub const MAP_HUGETLB: ::c_int = 0x040000; +pub const MAP_SYNC: ::c_int = 0x080000; + +pub const RLIMIT_NLIMITS: ::c_int = 15; +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::c_int = 0x00000800; +pub const TAB2: ::c_int = 0x00001000; +pub const TAB3: ::c_int = 0x00001800; +pub const CR1: ::c_int = 0x00000200; +pub const CR2: ::c_int = 0x00000400; +pub const CR3: ::c_int = 0x00000600; +pub const FF1: ::c_int = 0x00008000; +pub const BS1: ::c_int = 0x00002000; +pub const VT1: ::c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const EDEADLK: ::c_int = 35; +pub const EDEADLOCK: ::c_int = EDEADLK; +pub const EXTPROC: ::tcflag_t = 0x00010000; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: ::tcflag_t = 0x00008000; +pub const TOSTOP: ::tcflag_t = 0x00000100; +pub const FLUSHO: ::tcflag_t = 0x00001000; + +pub const NGREG: usize = 32; +pub const REG_PC: usize = 0; +pub const REG_RA: usize = 1; +pub const REG_SP: usize = 2; +pub const REG_TP: usize = 4; +pub const REG_S0: usize = 8; +pub const REG_S1: usize = 9; +pub const REG_A0: usize = 10; +pub const REG_S2: usize = 18; +pub const REG_NARGS: usize = 8; + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } +} diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index 3bdac44d..5fdd03d2 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -141,9 +141,6 @@ pub const EDEADLK: ::c_int = 35; pub const ENOSYS: ::c_int = 38; pub const ENOTCONN: ::c_int = 107; pub const ETIMEDOUT: ::c_int = 110; -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONCLEX: ::c_ulong = 0x5450; -pub const FIONBIO: ::c_ulong = 0x5421; pub const O_APPEND: ::c_int = 1024; pub const O_CREAT: ::c_int = 64; pub const O_EXCL: ::c_int = 128; @@ -296,45 +293,6 @@ pub const F_OFD_GETLK: ::c_int = 36; pub const F_OFD_SETLK: ::c_int = 37; pub const F_OFD_SETLKW: ::c_int = 38; -pub const TCGETS: ::c_int = 0x5401; -pub const TCSETS: ::c_int = 0x5402; -pub const TCSETSW: ::c_int = 0x5403; -pub const TCSETSF: ::c_int = 0x5404; -pub const TCGETA: ::c_int = 0x5405; -pub const TCSETA: ::c_int = 0x5406; -pub const TCSETAW: ::c_int = 0x5407; -pub const TCSETAF: ::c_int = 0x5408; -pub const TCSBRK: ::c_int = 0x5409; -pub const TCXONC: ::c_int = 0x540A; -pub const TCFLSH: ::c_int = 0x540B; -pub const TIOCGSOFTCAR: ::c_int = 0x5419; -pub const TIOCSSOFTCAR: ::c_int = 0x541A; -pub const TIOCINQ: ::c_int = 0x541B; -pub const TIOCEXCL: ::c_int = 0x540C; -pub const TIOCNXCL: ::c_int = 0x540D; -pub const TIOCSCTTY: ::c_int = 0x540E; -pub const TIOCGPGRP: ::c_int = 0x540F; -pub const TIOCSPGRP: ::c_int = 0x5410; -pub const TIOCOUTQ: ::c_int = 0x5411; -pub const TIOCSTI: ::c_int = 0x5412; -pub const TIOCGWINSZ: ::c_int = 0x5413; -pub const TIOCSWINSZ: ::c_int = 0x5414; -pub const TIOCMGET: ::c_int = 0x5415; -pub const TIOCMBIS: ::c_int = 0x5416; -pub const TIOCMBIC: ::c_int = 0x5417; -pub const TIOCMSET: ::c_int = 0x5418; -pub const FIONREAD: ::c_int = 0x541B; -pub const TIOCCONS: ::c_int = 0x541D; - -pub const TIOCLINUX: ::c_int = 0x541C; -pub const TIOCGSERIAL: ::c_int = 0x541E; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - pub const VTIME: usize = 5; pub const VSWTC: usize = 7; pub const VSTART: usize = 8; @@ -374,7 +332,6 @@ pub const PARODD: ::tcflag_t = 0o001000; pub const HUPCL: ::tcflag_t = 0o002000; pub const CLOCAL: ::tcflag_t = 0o004000; pub const CBAUDEX: ::tcflag_t = 0o010000; -pub const BOTHER: ::speed_t = 0o010000; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; @@ -752,7 +709,3 @@ pub const SYS_faccessat2: ::c_long = 439; pub const SYS_process_madvise: ::c_long = 440; pub const SYS_epoll_pwait2: ::c_long = 441; pub const SYS_mount_setattr: ::c_long = 442; - -extern "C" { - pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; -} diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs index dac9f990..08d7c5b5 100644 --- a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -673,9 +673,6 @@ pub const O_RSYNC: ::c_int = 1052672; pub const O_DSYNC: ::c_int = 4096; pub const O_ASYNC: ::c_int = 0x2000; -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; - pub const SIGSTKSZ: ::size_t = 8192; pub const MINSIGSTKSZ: ::size_t = 2048; @@ -822,7 +819,6 @@ pub const MAP_SYNC: ::c_int = 0x080000; pub const RLIMIT_NLIMITS: ::c_int = 15; pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS; -pub const TIOCINQ: ::c_int = ::FIONREAD; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; pub const CBAUD: ::tcflag_t = 0o0010017; @@ -892,9 +888,6 @@ pub const B3000000: ::speed_t = 0o010015; pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; -pub const FIOCLEX: ::c_int = 0x5451; -pub const FIONCLEX: ::c_int = 0x5450; -pub const FIONBIO: ::c_int = 0x5421; pub const EDEADLK: ::c_int = 35; pub const EDEADLOCK: ::c_int = EDEADLK; @@ -905,52 +898,6 @@ pub const VMIN: usize = 6; pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; -pub const TCGETS: ::c_int = 0x5401; -pub const TCSETS: ::c_int = 0x5402; -pub const TCSETSW: ::c_int = 0x5403; -pub const TCSETSF: ::c_int = 0x5404; -pub const TCGETA: ::c_int = 0x5405; -pub const TCSETA: ::c_int = 0x5406; -pub const TCSETAW: ::c_int = 0x5407; -pub const TCSETAF: ::c_int = 0x5408; -pub const TCSBRK: ::c_int = 0x5409; -pub const TCXONC: ::c_int = 0x540A; -pub const TCFLSH: ::c_int = 0x540B; -pub const TIOCGSOFTCAR: ::c_int = 0x5419; -pub const TIOCSSOFTCAR: ::c_int = 0x541A; -pub const TIOCLINUX: ::c_int = 0x541C; -pub const TIOCGSERIAL: ::c_int = 0x541E; -pub const TIOCEXCL: ::c_int = 0x540C; -pub const TIOCNXCL: ::c_int = 0x540D; -pub const TIOCSCTTY: ::c_int = 0x540E; -pub const TIOCGPGRP: ::c_int = 0x540F; -pub const TIOCSPGRP: ::c_int = 0x5410; -pub const TIOCOUTQ: ::c_int = 0x5411; -pub const TIOCSTI: ::c_int = 0x5412; -pub const TIOCGWINSZ: ::c_int = 0x5413; -pub const TIOCSWINSZ: ::c_int = 0x5414; -pub const TIOCMGET: ::c_int = 0x5415; -pub const TIOCMBIS: ::c_int = 0x5416; -pub const TIOCMBIC: ::c_int = 0x5417; -pub const TIOCMSET: ::c_int = 0x5418; -pub const FIONREAD: ::c_int = 0x541B; -pub const TIOCCONS: ::c_int = 0x541D; - -pub const TIOCM_LE: ::c_int = 0x001; -pub const TIOCM_DTR: ::c_int = 0x002; -pub const TIOCM_RTS: ::c_int = 0x004; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; -pub const TIOCM_CD: ::c_int = TIOCM_CAR; -pub const TIOCM_RI: ::c_int = TIOCM_RNG; - -extern "C" { - pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; -} cfg_if! { if #[cfg(libc_align)] { diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 6b2dd898..5a20ae59 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -24,6 +24,16 @@ pub type rlim_t = ::c_ulonglong; pub type flock64 = flock; +cfg_if! { + if #[cfg(doc)] { + // Used in `linux::arch` to define ioctl constants. + pub(crate) type Ioctl = ::c_int; + } else { + #[doc(hidden)] + pub type Ioctl = ::c_int; + } +} + impl siginfo_t { pub unsafe fn si_addr(&self) -> *mut ::c_void { #[repr(C)] @@ -133,24 +143,6 @@ s! { __dummy4: [::c_char; 16], } - pub struct nlmsghdr { - pub nlmsg_len: u32, - pub nlmsg_type: u16, - pub nlmsg_flags: u16, - pub nlmsg_seq: u32, - pub nlmsg_pid: u32, - } - - pub struct nlmsgerr { - pub error: ::c_int, - pub msg: nlmsghdr, - } - - pub struct nlattr { - pub nla_len: u16, - pub nla_type: u16, - } - pub struct sigaction { pub sa_sigaction: ::sighandler_t, pub sa_mask: ::sigset_t, @@ -226,12 +218,6 @@ s! { pub rt_irtt: ::c_ushort, } - pub struct ip_mreqn { - pub imr_multiaddr: ::in_addr, - pub imr_address: ::in_addr, - pub imr_ifindex: ::c_int, - } - pub struct __exit_status { pub e_termination: ::c_short, pub e_exit: ::c_short, @@ -646,9 +632,6 @@ pub const RLIMIT_RTPRIO: ::c_int = 14; pub const REG_OK: ::c_int = 0; -pub const TIOCSBRK: ::c_int = 0x5427; -pub const TIOCCBRK: ::c_int = 0x5428; - pub const PRIO_PROCESS: ::c_int = 0; pub const PRIO_PGRP: ::c_int = 1; pub const PRIO_USER: ::c_int = 2; @@ -753,27 +736,11 @@ extern "C" { old_limit: *mut ::rlimit64, ) -> ::c_int; + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; pub fn ptrace(request: ::c_int, ...) -> ::c_long; pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; - pub fn pthread_getaffinity_np( - thread: ::pthread_t, - cpusetsize: ::size_t, - cpuset: *mut ::cpu_set_t, - ) -> ::c_int; - pub fn pthread_setaffinity_np( - thread: ::pthread_t, - cpusetsize: ::size_t, - cpuset: *const ::cpu_set_t, - ) -> ::c_int; - pub fn sched_getcpu() -> ::c_int; - pub fn memmem( - haystack: *const ::c_void, - haystacklen: ::size_t, - needle: *const ::c_void, - needlelen: ::size_t, - ) -> *mut ::c_void; // Musl targets need the `mask` argument of `fanotify_mark` be specified // `::c_ulonglong` instead of `u64` or there will be a type mismatch between // `long long unsigned int` and the expected `uint64_t`. @@ -793,6 +760,11 @@ extern "C" { pub fn adjtimex(buf: *mut ::timex) -> ::c_int; pub fn clock_adjtime(clk_id: ::clockid_t, buf: *mut ::timex) -> ::c_int; + + pub fn ctermid(s: *mut ::c_char) -> *mut ::c_char; + + pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int; + pub fn mlock2(addr: *const ::c_void, len: ::size_t, flags: ::c_uint) -> ::c_int; } cfg_if! { @@ -800,7 +772,8 @@ cfg_if! { target_arch = "aarch64", target_arch = "mips64", target_arch = "powerpc64", - target_arch = "s390x"))] { + target_arch = "s390x", + target_arch = "riscv64"))] { mod b64; pub use self::b64::*; } else if #[cfg(any(target_arch = "x86", diff --git a/src/unix/linux_like/linux/no_align.rs b/src/unix/linux_like/linux/no_align.rs index de64be5a..7af8092c 100644 --- a/src/unix/linux_like/linux/no_align.rs +++ b/src/unix/linux_like/linux/no_align.rs @@ -62,6 +62,7 @@ macro_rules! expand_align { pub struct pthread_mutex_t { #[cfg(any(target_arch = "mips", target_arch = "arm", + target_arch = "m68k", target_arch = "powerpc", target_arch = "sparc", all(target_arch = "x86_64", @@ -69,6 +70,7 @@ macro_rules! expand_align { __align: [::c_long; 0], #[cfg(not(any(target_arch = "mips", target_arch = "arm", + target_arch = "m68k", target_arch = "powerpc", target_arch = "sparc", all(target_arch = "x86_64", @@ -80,6 +82,7 @@ macro_rules! expand_align { pub struct pthread_rwlock_t { #[cfg(any(target_arch = "mips", target_arch = "arm", + target_arch = "m68k", target_arch = "powerpc", target_arch = "sparc", all(target_arch = "x86_64", @@ -87,6 +90,7 @@ macro_rules! expand_align { __align: [::c_long; 0], #[cfg(not(any(target_arch = "mips", target_arch = "arm", + target_arch = "m68k", target_arch = "powerpc", target_arch = "sparc", all(target_arch = "x86_64", diff --git a/src/unix/linux_like/linux/non_exhaustive.rs b/src/unix/linux_like/linux/non_exhaustive.rs new file mode 100644 index 00000000..e2e2cb84 --- /dev/null +++ b/src/unix/linux_like/linux/non_exhaustive.rs @@ -0,0 +1,9 @@ +s! { + // linux/openat2.h + #[non_exhaustive] + pub struct open_how { + pub flags: ::__u64, + pub mode: ::__u64, + pub resolve: ::__u64, + } +} diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index dc6518c0..c1008a48 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -44,14 +44,14 @@ s! { pub struct stat { pub st_dev: ::c_ulonglong, - pub __pad1: ::c_ushort, + __pad1: ::c_ushort, pub st_ino: ::ino_t, pub st_mode: ::mode_t, pub st_nlink: ::nlink_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, pub st_rdev: ::c_ulonglong, - pub __pad2: ::c_ushort, + __pad2: ::c_ushort, pub st_size: ::off_t, pub st_blksize: ::blksize_t, pub st_blocks: ::blkcnt_t, @@ -61,8 +61,8 @@ s! { pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, - pub __uclibc_unused4: ::c_ulong, - pub __uclibc_unused5: ::c_ulong, + __unused4: ::c_ulong, + __unused5: ::c_ulong, } pub struct stat64 @@ -202,44 +202,44 @@ s! { pub cuid: ::uid_t, pub cgid: ::gid_t, pub mode: ::c_ushort, - pub __pad1: ::c_ushort, + __pad1: ::c_ushort, pub __seq: ::c_ushort, - pub __pad2: ::c_ushort, - pub __uclibc_unused1: ::c_ulong, - pub __uclibc_unused2: ::c_ulong, + __pad2: ::c_ushort, + __unused1: ::c_ulong, + __unused2: ::c_ulong, } pub struct msqid_ds { pub msg_perm: ::ipc_perm, pub msg_stime: ::time_t, - pub __uclibc_unused1: ::c_ulong, + __unused1: ::c_ulong, pub msg_rtime: ::time_t, - pub __uclibc_unused2: ::c_ulong, + __unused2: ::c_ulong, pub msg_ctime: ::time_t, - pub __uclibc_unused3: ::c_ulong, - pub __msg_cbytes: ::c_ulong, + __unused3: ::c_ulong, + __msg_cbytes: ::c_ulong, pub msg_qnum: ::msgqnum_t, pub msg_qbytes: ::msglen_t, pub msg_lspid: ::pid_t, pub msg_lrpid: ::pid_t, - pub __uclibc_unused4: ::c_ulong, - pub __uclibc_unused5: ::c_ulong, + __unused4: ::c_ulong, + __unused5: ::c_ulong, } pub struct shmid_ds { pub shm_perm: ::ipc_perm, pub shm_segsz: ::size_t, pub shm_atime: ::time_t, - pub __uclibc_unused1: ::c_ulong, + __unused1: ::c_ulong, pub shm_dtime: ::time_t, - pub __uclibc_unused2: ::c_ulong, + __unused2: ::c_ulong, pub shm_ctime: ::time_t, - pub __uclibc_unused3: ::c_ulong, + __unused3: ::c_ulong, pub shm_cpid: ::pid_t, pub shm_lpid: ::pid_t, pub shm_nattch: ::shmatt_t, - pub __uclibc_unused4: ::c_ulong, - pub __uclibc_unused5: ::c_ulong, + __unused4: ::c_ulong, + __unused5: ::c_ulong, } } @@ -417,9 +417,6 @@ pub const EUSERS: ::c_int = 0x57; pub const EXFULL: ::c_int = 0x36; pub const FF1: ::c_int = 0x8000; pub const FFDLY: ::c_int = 0x8000; -pub const FIONBIO: ::c_ulong = 0x5421; -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONCLEX: ::c_ulong = 0x5450; pub const FLUSHO: ::tcflag_t = 0x1000; pub const F_GETLK: ::c_int = 0x5; pub const F_SETLK: ::c_int = 0x6; @@ -469,6 +466,7 @@ pub const PENDIN: ::tcflag_t = 0x4000; pub const POLLWRBAND: ::c_short = 0x200; pub const POLLWRNORM: ::c_short = 0x100; pub const PTHREAD_STACK_MIN: ::size_t = 16384; +pub const RTLD_GLOBAL: ::c_int = 0x00100; // These are typed unsigned to match sigaction pub const SA_NOCLDSTOP: ::c_ulong = 0x1; @@ -886,10 +884,9 @@ pub const SYS_pwritev2: ::c_long = 393; pub const SYS_pkey_mprotect: ::c_long = 394; pub const SYS_pkey_alloc: ::c_long = 395; pub const SYS_pkey_free: ::c_long = 396; - -extern "C" { - pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; -} +pub const SYS_statx: ::c_int = 397; +pub const SYS_pidfd_open: ::c_long = 434; +pub const SYS_clone3: ::c_long = 435; cfg_if! { if #[cfg(libc_align)] { diff --git a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs index 8edde11a..0791bd4f 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -625,6 +625,7 @@ pub const SYS_pwritev2: ::c_long = 4000 + 362; pub const SYS_pkey_mprotect: ::c_long = 4000 + 363; pub const SYS_pkey_alloc: ::c_long = 4000 + 364; pub const SYS_pkey_free: ::c_long = 4000 + 365; +pub const SYS_clone3: ::c_long = 4000 + 435; #[link(name = "util")] extern "C" { @@ -636,7 +637,6 @@ extern "C" { newp: *mut ::c_void, newlen: ::size_t, ) -> ::c_int; - pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; pub fn glob64( pattern: *const ::c_char, flags: ::c_int, diff --git a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs index 735eb851..1f693b1f 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs @@ -197,11 +197,6 @@ pub const RLIM_INFINITY: ::rlim_t = 0xffff_ffff_ffff_ffff; pub const SYS_gettid: ::c_long = 5178; // Valid for n64 -#[link(name = "util")] -extern "C" { - pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; -} - cfg_if! { if #[cfg(libc_align)] { mod align; diff --git a/src/unix/linux_like/linux/uclibc/mips/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mod.rs index 28fa9a22..bf81c16b 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mod.rs @@ -32,22 +32,13 @@ pub const EPOLL_CLOEXEC: ::c_int = 0x80000; pub const EFD_CLOEXEC: ::c_int = 0x80000; -pub const BUFSIZ: ::c_uint = 4096; pub const TMP_MAX: ::c_uint = 238328; -pub const FOPEN_MAX: ::c_uint = 16; -pub const POSIX_MADV_DONTNEED: ::c_int = 4; pub const _SC_2_C_VERSION: ::c_int = 96; pub const O_ACCMODE: ::c_int = 3; pub const O_DIRECT: ::c_int = 0x8000; pub const O_DIRECTORY: ::c_int = 0x10000; pub const O_NOFOLLOW: ::c_int = 0x20000; -pub const NI_MAXHOST: ::socklen_t = 1025; -pub const RLIMIT_NOFILE: ::c_int = 5; -pub const RLIMIT_AS: ::c_int = 6; -pub const RLIMIT_RSS: ::c_int = 7; -pub const RLIMIT_NPROC: ::c_int = 8; -pub const RLIMIT_MEMLOCK: ::c_int = 9; pub const RLIMIT_NLIMITS: ::c_int = 15; pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS; @@ -87,7 +78,6 @@ pub const EXFULL: ::c_int = 52; pub const ENOANO: ::c_int = 53; pub const EBADRQC: ::c_int = 54; pub const EBADSLT: ::c_int = 55; -pub const EDEADLOCK: ::c_int = 56; pub const EMULTIHOP: ::c_int = 74; pub const EOVERFLOW: ::c_int = 79; pub const ENOTUNIQ: ::c_int = 80; @@ -164,10 +154,6 @@ pub const SOCK_STREAM: ::c_int = 2; pub const SOCK_DGRAM: ::c_int = 1; pub const SOCK_SEQPACKET: ::c_int = 5; -pub const FIOCLEX: ::c_ulong = 0x6601; -pub const FIONCLEX: ::c_ulong = 0x6602; -pub const FIONBIO: ::c_ulong = 0x667e; - pub const SA_ONSTACK: ::c_uint = 0x08000000; pub const SA_SIGINFO: ::c_uint = 0x00000008; pub const SA_NOCLDWAIT: ::c_int = 0x00010000; @@ -189,7 +175,6 @@ pub const SIGTSTP: ::c_int = 24; pub const SIGURG: ::c_int = 21; pub const SIGIO: ::c_int = 22; pub const SIGSYS: ::c_int = 12; -pub const SIGPOLL: ::c_int = 22; pub const SIGPWR: ::c_int = 19; pub const SIG_SETMASK: ::c_int = 3; pub const SIG_BLOCK: ::c_int = 0x1; @@ -216,47 +201,12 @@ pub const CPU_SETSIZE: ::c_int = 0x400; pub const EFD_NONBLOCK: ::c_int = 0x80; pub const F_GETLK: ::c_int = 14; -pub const F_GETOWN: ::c_int = 23; -pub const F_SETOWN: ::c_int = 24; pub const F_SETLK: ::c_int = 6; pub const F_SETLKW: ::c_int = 7; pub const SFD_NONBLOCK: ::c_int = 0x80; -pub const TCGETS: ::c_ulong = 0x540d; -pub const TCSETS: ::c_ulong = 0x540e; -pub const TCSETSW: ::c_ulong = 0x540f; -pub const TCSETSF: ::c_ulong = 0x5410; -pub const TCGETA: ::c_ulong = 0x5401; -pub const TCSETA: ::c_ulong = 0x5402; -pub const TCSETAW: ::c_ulong = 0x5403; -pub const TCSETAF: ::c_ulong = 0x5404; -pub const TCSBRK: ::c_ulong = 0x5405; -pub const TCXONC: ::c_ulong = 0x5406; -pub const TCFLSH: ::c_ulong = 0x5407; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5481; -pub const TIOCSSOFTCAR: ::c_ulong = 0x5482; -pub const TIOCINQ: ::c_ulong = 0x467f; -pub const TIOCLINUX: ::c_ulong = 0x5483; -pub const TIOCGSERIAL: ::c_ulong = 0x5484; -pub const TIOCEXCL: ::c_ulong = 0x740d; -pub const TIOCNXCL: ::c_ulong = 0x740e; -pub const TIOCSCTTY: ::c_ulong = 0x5480; -pub const TIOCGPGRP: ::c_ulong = 0x40047477; -pub const TIOCSPGRP: ::c_ulong = 0x80047476; -pub const TIOCOUTQ: ::c_ulong = 0x7472; -pub const TIOCSTI: ::c_ulong = 0x5472; -pub const TIOCGWINSZ: ::c_ulong = 0x40087468; -pub const TIOCSWINSZ: ::c_ulong = 0x80087467; -pub const TIOCMGET: ::c_ulong = 0x741d; -pub const TIOCMBIS: ::c_ulong = 0x741b; -pub const TIOCMBIC: ::c_ulong = 0x741c; -pub const TIOCMSET: ::c_ulong = 0x741a; -pub const FIONREAD: ::c_ulong = 0x467f; -pub const TIOCCONS: ::c_ulong = 0x80047478; - pub const RTLD_GLOBAL: ::c_int = 0x4; -pub const RTLD_NOLOAD: ::c_int = 0x8; pub const SIGSTKSZ: ::size_t = 8192; pub const CBAUD: ::tcflag_t = 0o0010017; @@ -316,8 +266,6 @@ pub const B4800: ::speed_t = 0o000014; pub const B9600: ::speed_t = 0o000015; pub const B19200: ::speed_t = 0o000016; pub const B38400: ::speed_t = 0o000017; -pub const EXTA: ::speed_t = B19200; -pub const EXTB: ::speed_t = B38400; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 396e33d5..912e2aa4 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -2,6 +2,18 @@ pub type shmatt_t = ::c_ulong; pub type msgqnum_t = ::c_ulong; pub type msglen_t = ::c_ulong; pub type regoff_t = ::c_int; +pub type __rlimit_resource_t = ::c_uint; +pub type __priority_which_t = ::c_uint; + +cfg_if! { + if #[cfg(doc)] { + // Used in `linux::arch` to define ioctl constants. + pub(crate) type Ioctl = ::c_ulong; + } else { + #[doc(hidden)] + pub type Ioctl = ::c_ulong; + } +} s! { pub struct statvfs { // Different than GNU! @@ -34,6 +46,38 @@ s! { __re_nsub: ::size_t, __bitfield: u8, } + + pub struct rtentry { + pub rt_pad1: ::c_ulong, + pub rt_dst: ::sockaddr, + pub rt_gateway: ::sockaddr, + pub rt_genmask: ::sockaddr, + pub rt_flags: ::c_ushort, + pub rt_pad2: ::c_short, + pub rt_pad3: ::c_ulong, + pub rt_tos: ::c_uchar, + pub rt_class: ::c_uchar, + #[cfg(target_pointer_width = "64")] + pub rt_pad4: [::c_short; 3usize], + #[cfg(not(target_pointer_width = "64"))] + pub rt_pad4: ::c_short, + pub rt_metric: ::c_short, + pub rt_dev: *mut ::c_char, + pub rt_mtu: ::c_ulong, + pub rt_window: ::c_ulong, + pub rt_irtt: ::c_ushort, + } + + pub struct __exit_status { + pub e_termination: ::c_short, + pub e_exit: ::c_short, + } + + pub struct ptrace_peeksiginfo_args { + pub off: ::__u64, + pub flags: ::__u32, + pub nr: ::__s32, + } } pub const MCL_CURRENT: ::c_int = 0x0001; @@ -43,55 +87,10 @@ pub const SIGEV_THREAD_ID: ::c_int = 4; pub const AF_VSOCK: ::c_int = 40; -pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; -pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; -pub const AFS_SUPER_MAGIC: ::c_long = 0x5346414f; -pub const AUTOFS_SUPER_MAGIC: ::c_long = 0x0187; +// Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the +// following are only available on newer Linux versions than the versions +// currently used in CI in some configurations, so we define them here. pub const BINDERFS_SUPER_MAGIC: ::c_long = 0x6c6f6f70; -pub const BPF_FS_MAGIC: ::c_long = 0xcafe4a11; -pub const BTRFS_SUPER_MAGIC: ::c_long = 0x9123683e; -pub const CGROUP2_SUPER_MAGIC: ::c_long = 0x63677270; -pub const CGROUP_SUPER_MAGIC: ::c_long = 0x27e0eb; -pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; -pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; -pub const DEBUGFS_MAGIC: ::c_long = 0x64626720; -pub const DEVPTS_SUPER_MAGIC: ::c_long = 0x1cd1; -pub const ECRYPTFS_SUPER_MAGIC: ::c_long = 0xf15f; -pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; -pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; -pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; -pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; -pub const F2FS_SUPER_MAGIC: ::c_long = 0xf2f52010; -pub const FUTEXFS_SUPER_MAGIC: ::c_long = 0xbad1dea; -pub const HOSTFS_SUPER_MAGIC: ::c_long = 0x00c0ffee; -pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; -pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; -pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; -pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; -pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; -pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; -pub const MINIX3_SUPER_MAGIC: ::c_long = 0x4d5a; -pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; -pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; -pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; -pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; -pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; -pub const NILFS_SUPER_MAGIC: ::c_long = 0x3434; -pub const OCFS2_SUPER_MAGIC: ::c_long = 0x7461636f; -pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; -pub const OVERLAYFS_SUPER_MAGIC: ::c_long = 0x794c7630; -pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; -pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; -pub const QNX6_SUPER_MAGIC: ::c_long = 0x68191122; -pub const RDTGROUP_SUPER_MAGIC: ::c_long = 0x7655821; -pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; -pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; -pub const SYSFS_MAGIC: ::c_long = 0x62656572; -pub const TMPFS_MAGIC: ::c_long = 0x01021994; -pub const TRACEFS_MAGIC: ::c_long = 0x74726163; -pub const UDF_SUPER_MAGIC: ::c_long = 0x15013346; -pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; -pub const XENFS_SUPER_MAGIC: ::c_long = 0xabba1974; pub const XFS_SUPER_MAGIC: ::c_long = 0x58465342; pub const PTRACE_TRACEME: ::c_int = 0; @@ -122,7 +121,6 @@ pub const PTRACE_SETREGSET: ::c_int = 0x4205; pub const PTRACE_SEIZE: ::c_int = 0x4206; pub const PTRACE_INTERRUPT: ::c_int = 0x4207; pub const PTRACE_LISTEN: ::c_int = 0x4208; -pub const PTRACE_O_MASK: ::c_int = 0x000000ff; pub const POSIX_FADV_DONTNEED: ::c_int = 4; pub const POSIX_FADV_NOREUSE: ::c_int = 5; @@ -223,7 +221,70 @@ pub const PRIO_USER: ::c_int = 2; pub const ST_RELATIME: ::c_ulong = 4096; +pub const AF_NFC: ::c_int = PF_NFC; +pub const BUFSIZ: ::c_int = 4096; +pub const EDEADLOCK: ::c_int = EDEADLK; +pub const EXTA: ::c_uint = B19200; +pub const EXTB: ::c_uint = B38400; +pub const EXTPROC: ::tcflag_t = 0200000; +pub const FAN_MARK_FILESYSTEM: ::c_int = 0x00000100; +pub const FAN_MARK_INODE: ::c_int = 0x00000000; +pub const FAN_MARK_MOUNT: ::c_int = 0x10; +pub const FOPEN_MAX: ::c_int = 16; +pub const F_GETOWN: ::c_int = 9; +pub const F_OFD_GETLK: ::c_int = 36; +pub const F_OFD_SETLK: ::c_int = 37; +pub const F_OFD_SETLKW: ::c_int = 38; +pub const F_RDLCK: ::c_int = 0; +pub const F_SETOWN: ::c_int = 8; +pub const F_UNLCK: ::c_int = 2; +pub const F_WRLCK: ::c_int = 1; +pub const IPV6_MULTICAST_ALL: ::c_int = 29; +pub const IPV6_ROUTER_ALERT_ISOLATE: ::c_int = 30; +pub const MAP_HUGE_SHIFT: ::c_int = 26; +pub const MAP_HUGE_MASK: ::c_int = 0x3f; +pub const MAP_HUGE_64KB: ::c_int = 16 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_512KB: ::c_int = 19 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_1MB: ::c_int = 20 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_2MB: ::c_int = 21 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_8MB: ::c_int = 23 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_16MB: ::c_int = 24 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_32MB: ::c_int = 25 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_256MB: ::c_int = 28 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_512MB: ::c_int = 29 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_1GB: ::c_int = 30 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_2GB: ::c_int = 31 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_16GB: ::c_int = 34 << MAP_HUGE_SHIFT; +pub const MINSIGSTKSZ: ::c_int = 2048; +pub const MSG_COPY: ::c_int = 040000; +pub const NI_MAXHOST: ::socklen_t = 1025; +pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; +pub const PACKET_MR_UNICAST: ::c_int = 3; +pub const PF_NFC: ::c_int = 39; +pub const PF_VSOCK: ::c_int = 40; +pub const POSIX_MADV_DONTNEED: ::c_int = 4; +pub const PTRACE_EVENT_STOP: ::c_int = 128; +pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209; +pub const RLIMIT_AS: ::c_int = 9; +pub const RLIMIT_MEMLOCK: ::c_int = 8; +pub const RLIMIT_NLIMITS: ::c_int = 15; +pub const RLIMIT_NOFILE: ::c_int = 7; +pub const RLIMIT_NPROC: ::c_int = 6; +pub const RLIMIT_RSS: ::c_int = 5; +pub const RLIMIT_RTTIME: ::c_int = 15; +pub const RTLD_NOLOAD: ::c_int = 0x00004; +pub const RUSAGE_THREAD: ::c_int = 1; +pub const SHM_EXEC: ::c_int = 0100000; +pub const SIGPOLL: ::c_int = SIGIO; +pub const SOCK_DCCP: ::c_int = 6; +pub const SOCK_PACKET: ::c_int = 10; +pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; +pub const UDP_GRO: ::c_int = 104; +pub const UDP_SEGMENT: ::c_int = 103; +pub const YESEXPR: ::c_int = ((5) << 8) | (0); + extern "C" { + pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int; pub fn pthread_rwlockattr_getkind_np( @@ -289,6 +350,19 @@ extern "C" { ) -> ::ssize_t; pub fn sethostid(hostid: ::c_long) -> ::c_int; + pub fn fanotify_mark( + fd: ::c_int, + flags: ::c_uint, + mask: u64, + dirfd: ::c_int, + path: *const ::c_char, + ) -> ::c_int; + pub fn getrlimit64(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit64) -> ::c_int; + pub fn setrlimit64(resource: ::__rlimit_resource_t, rlim: *const ::rlimit64) -> ::c_int; + pub fn getrlimit(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::__rlimit_resource_t, rlim: *const ::rlimit) -> ::c_int; + pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int; + pub fn setpriority(which: ::__priority_which_t, who: ::id_t, prio: ::c_int) -> ::c_int; } cfg_if! { diff --git a/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs b/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs index 16ec0ef9..c7cbafa1 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs @@ -46,3 +46,8 @@ pub struct pthread_attr_t { // L4Re requires a min stack size of 64k; that isn't defined in uClibc, but // somewhere in the core libraries. uClibc wants 16k, but that's not enough. pub const PTHREAD_STACK_MIN: usize = 65536; + +// Misc other constants required for building. +pub const SIGIO: ::c_int = 29; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; diff --git a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs index 4f7974c5..aa51beac 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -292,8 +292,13 @@ s_no_extra_traits! { } // constants +pub const ENAMETOOLONG: ::c_int = 36; // File name too long +pub const ENOTEMPTY: ::c_int = 39; // Directory not empty +pub const ELOOP: ::c_int = 40; // Too many symbolic links encountered pub const EADDRINUSE: ::c_int = 98; // Address already in use pub const EADDRNOTAVAIL: ::c_int = 99; // Cannot assign requested address +pub const ENETDOWN: ::c_int = 100; // Network is down +pub const ENETUNREACH: ::c_int = 101; // Network is unreachable pub const ECONNABORTED: ::c_int = 103; // Software caused connection abort pub const ECONNREFUSED: ::c_int = 111; // Connection refused pub const ECONNRESET: ::c_int = 104; // Connection reset by peer @@ -301,6 +306,9 @@ pub const EDEADLK: ::c_int = 35; // Resource deadlock would occur pub const ENOSYS: ::c_int = 38; // Function not implemented pub const ENOTCONN: ::c_int = 107; // Transport endpoint is not connected pub const ETIMEDOUT: ::c_int = 110; // connection timed out +pub const ESTALE: ::c_int = 116; // Stale file handle +pub const EHOSTUNREACH: ::c_int = 113; // No route to host +pub const EDQUOT: ::c_int = 122; // Quota exceeded pub const EOPNOTSUPP: ::c_int = 0x5f; pub const ENODATA: ::c_int = 0x3d; pub const O_APPEND: ::c_int = 02000; @@ -309,6 +317,7 @@ pub const O_CLOEXEC: ::c_int = 0x80000; pub const O_CREAT: ::c_int = 0100; pub const O_DIRECTORY: ::c_int = 0200000; pub const O_EXCL: ::c_int = 0200; +pub const O_NOFOLLOW: ::c_int = 0x20000; pub const O_NONBLOCK: ::c_int = 04000; pub const O_TRUNC: ::c_int = 01000; pub const NCCS: usize = 32; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index a8b03320..125c5d4e 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -25,6 +25,12 @@ s! { pub imr_interface: in_addr, } + pub struct ip_mreqn { + pub imr_multiaddr: in_addr, + pub imr_address: in_addr, + pub imr_ifindex: ::c_int, + } + pub struct ip_mreq_source { pub imr_multiaddr: in_addr, pub imr_interface: in_addr, @@ -877,6 +883,8 @@ pub const IPPROTO_MH: ::c_int = 135; pub const IPPROTO_UDPLITE: ::c_int = 136; /// raw IP packet pub const IPPROTO_RAW: ::c_int = 255; +pub const IPPROTO_BEETPH: ::c_int = 94; +pub const IPPROTO_MPLS: ::c_int = 137; pub const MCAST_EXCLUDE: ::c_int = 0; pub const MCAST_INCLUDE: ::c_int = 1; @@ -913,6 +921,7 @@ pub const IPV6_JOIN_ANYCAST: ::c_int = 27; pub const IPV6_LEAVE_ANYCAST: ::c_int = 28; pub const IPV6_IPSEC_POLICY: ::c_int = 34; pub const IPV6_XFRM_POLICY: ::c_int = 35; +pub const IPV6_HDRINCL: ::c_int = 36; pub const IPV6_RECVPKTINFO: ::c_int = 49; pub const IPV6_PKTINFO: ::c_int = 50; pub const IPV6_RECVHOPLIMIT: ::c_int = 51; @@ -948,6 +957,8 @@ pub const IPV6_PMTUDISC_DONT: ::c_int = 0; pub const IPV6_PMTUDISC_WANT: ::c_int = 1; pub const IPV6_PMTUDISC_DO: ::c_int = 2; pub const IPV6_PMTUDISC_PROBE: ::c_int = 3; +pub const IPV6_PMTUDISC_INTERFACE: ::c_int = 4; +pub const IPV6_PMTUDISC_OMIT: ::c_int = 5; pub const TCP_NODELAY: ::c_int = 1; pub const TCP_MAXSEG: ::c_int = 2; @@ -1023,21 +1034,27 @@ pub const FD_SETSIZE: usize = 1024; pub const EPOLLIN: ::c_int = 0x1; pub const EPOLLPRI: ::c_int = 0x2; pub const EPOLLOUT: ::c_int = 0x4; +pub const EPOLLERR: ::c_int = 0x8; +pub const EPOLLHUP: ::c_int = 0x10; pub const EPOLLRDNORM: ::c_int = 0x40; pub const EPOLLRDBAND: ::c_int = 0x80; pub const EPOLLWRNORM: ::c_int = 0x100; pub const EPOLLWRBAND: ::c_int = 0x200; pub const EPOLLMSG: ::c_int = 0x400; -pub const EPOLLERR: ::c_int = 0x8; -pub const EPOLLHUP: ::c_int = 0x10; +pub const EPOLLRDHUP: ::c_int = 0x2000; +pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000; +pub const EPOLLWAKEUP: ::c_int = 0x20000000; +pub const EPOLLONESHOT: ::c_int = 0x40000000; pub const EPOLLET: ::c_int = 0x80000000; pub const EPOLL_CTL_ADD: ::c_int = 1; pub const EPOLL_CTL_MOD: ::c_int = 3; pub const EPOLL_CTL_DEL: ::c_int = 2; +pub const MNT_FORCE: ::c_int = 0x1; pub const MNT_DETACH: ::c_int = 0x2; pub const MNT_EXPIRE: ::c_int = 0x4; +pub const UMOUNT_NOFOLLOW: ::c_int = 0x8; pub const Q_GETFMT: ::c_int = 0x800004; pub const Q_GETINFO: ::c_int = 0x800005; @@ -1053,8 +1070,6 @@ pub const QIF_USAGE: u32 = 10; pub const QIF_TIMES: u32 = 48; pub const QIF_ALL: u32 = 63; -pub const MNT_FORCE: ::c_int = 0x1; - pub const Q_SYNC: ::c_int = 0x800001; pub const Q_QUOTAON: ::c_int = 0x800002; pub const Q_QUOTAOFF: ::c_int = 0x800003; @@ -1117,6 +1132,7 @@ pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000; pub const CLONE_DETACHED: ::c_int = 0x400000; pub const CLONE_UNTRACED: ::c_int = 0x800000; pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000; +pub const CLONE_NEWCGROUP: ::c_int = 0x02000000; pub const CLONE_NEWUTS: ::c_int = 0x04000000; pub const CLONE_NEWIPC: ::c_int = 0x08000000; pub const CLONE_NEWUSER: ::c_int = 0x10000000; @@ -1132,11 +1148,15 @@ pub const WCONTINUED: ::c_int = 0x00000008; pub const WNOWAIT: ::c_int = 0x01000000; // Options for personality(2). +pub const ADDR_NO_RANDOMIZE: ::c_int = 0x0040000; pub const MMAP_PAGE_ZERO: ::c_int = 0x0100000; +pub const ADDR_COMPAT_LAYOUT: ::c_int = 0x0200000; +pub const READ_IMPLIES_EXEC: ::c_int = 0x0400000; pub const ADDR_LIMIT_32BIT: ::c_int = 0x0800000; pub const SHORT_INODE: ::c_int = 0x1000000; pub const WHOLE_SECONDS: ::c_int = 0x2000000; pub const STICKY_TIMEOUTS: ::c_int = 0x4000000; +pub const ADDR_LIMIT_3GB: ::c_int = 0x8000000; // Options set using PTRACE_SETOPTIONS. pub const PTRACE_O_TRACESYSGOOD: ::c_int = 0x00000001; @@ -1147,6 +1167,9 @@ pub const PTRACE_O_TRACEEXEC: ::c_int = 0x00000010; pub const PTRACE_O_TRACEVFORKDONE: ::c_int = 0x00000020; pub const PTRACE_O_TRACEEXIT: ::c_int = 0x00000040; pub const PTRACE_O_TRACESECCOMP: ::c_int = 0x00000080; +pub const PTRACE_O_SUSPEND_SECCOMP: ::c_int = 0x00200000; +pub const PTRACE_O_EXITKILL: ::c_int = 0x00100000; +pub const PTRACE_O_MASK: ::c_int = 0x003000ff; // Wait extended result codes for the above trace options. pub const PTRACE_EVENT_FORK: ::c_int = 1; @@ -1221,6 +1244,10 @@ pub const POLLHUP: ::c_short = 0x10; pub const POLLNVAL: ::c_short = 0x20; pub const POLLRDNORM: ::c_short = 0x040; pub const POLLRDBAND: ::c_short = 0x080; +#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64")))] +pub const POLLRDHUP: ::c_short = 0x2000; +#[cfg(any(target_arch = "sparc", target_arch = "sparc64"))] +pub const POLLRDHUP: ::c_short = 0x800; pub const IPTOS_LOWDELAY: u8 = 0x10; pub const IPTOS_THROUGHPUT: u8 = 0x08; @@ -1345,20 +1372,114 @@ pub const ARPHRD_VOID: u16 = 0xFFFF; pub const ARPHRD_NONE: u16 = 0xFFFE; cfg_if! { - if #[cfg(not(target_env = "uclibc"))] { - pub const IPPROTO_BEETPH: ::c_int = 94; - pub const IPPROTO_MPLS: ::c_int = 137; - pub const IPV6_HDRINCL: ::c_int = 36; - pub const IPV6_PMTUDISC_INTERFACE: ::c_int = 4; - pub const IPV6_PMTUDISC_OMIT: ::c_int = 5; - pub const CLONE_NEWCGROUP: ::c_int = 0x02000000; - pub const ADDR_NO_RANDOMIZE: ::c_int = 0x0040000; - pub const ADDR_COMPAT_LAYOUT: ::c_int = 0x0200000; - pub const READ_IMPLIES_EXEC: ::c_int = 0x0400000; - pub const ADDR_LIMIT_3GB: ::c_int = 0x8000000; - pub const PTRACE_O_EXITKILL: ::c_int = 0x00100000; - pub const PTRACE_O_SUSPEND_SECCOMP: ::c_int = 0x00200000; - pub const PTRACE_O_MASK: ::c_int = 0x003000ff; + if #[cfg(target_os = "emscripten")] { + // Emscripten does not define any `*_SUPER_MAGIC` constants. + } else if #[cfg(not(target_arch = "s390x"))] { + pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5; + pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff; + pub const AFS_SUPER_MAGIC: ::c_long = 0x5346414f; + pub const AUTOFS_SUPER_MAGIC: ::c_long = 0x0187; + pub const BPF_FS_MAGIC: ::c_long = 0xcafe4a11; + pub const BTRFS_SUPER_MAGIC: ::c_long = 0x9123683e; + pub const CGROUP2_SUPER_MAGIC: ::c_long = 0x63677270; + pub const CGROUP_SUPER_MAGIC: ::c_long = 0x27e0eb; + pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245; + pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45; + pub const DEBUGFS_MAGIC: ::c_long = 0x64626720; + pub const DEVPTS_SUPER_MAGIC: ::c_long = 0x1cd1; + pub const ECRYPTFS_SUPER_MAGIC: ::c_long = 0xf15f; + pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53; + pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53; + pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; + pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; + pub const F2FS_SUPER_MAGIC: ::c_long = 0xf2f52010; + pub const FUSE_SUPER_MAGIC: ::c_long = 0x65735546; + pub const FUTEXFS_SUPER_MAGIC: ::c_long = 0xbad1dea; + pub const HOSTFS_SUPER_MAGIC: ::c_long = 0x00c0ffee; + pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; + pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6; + pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660; + pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6; + pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478; + pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468; + pub const MINIX3_SUPER_MAGIC: ::c_long = 0x4d5a; + pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f; + pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f; + pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44; + pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c; + pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969; + pub const NILFS_SUPER_MAGIC: ::c_long = 0x3434; + pub const OCFS2_SUPER_MAGIC: ::c_long = 0x7461636f; + pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1; + pub const OVERLAYFS_SUPER_MAGIC: ::c_long = 0x794c7630; + pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0; + pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f; + pub const QNX6_SUPER_MAGIC: ::c_long = 0x68191122; + pub const RDTGROUP_SUPER_MAGIC: ::c_long = 0x7655821; + pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973; + pub const SECURITYFS_MAGIC: ::c_long = 0x73636673; + pub const SELINUX_MAGIC: ::c_long = 0xf97cff8c; + pub const SMACK_MAGIC: ::c_long = 0x43415d53; + pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b; + pub const SYSFS_MAGIC: ::c_long = 0x62656572; + pub const TMPFS_MAGIC: ::c_long = 0x01021994; + pub const TRACEFS_MAGIC: ::c_long = 0x74726163; + pub const UDF_SUPER_MAGIC: ::c_long = 0x15013346; + pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2; + pub const XENFS_SUPER_MAGIC: ::c_long = 0xabba1974; + } else if #[cfg(target_arch = "s390x")] { + pub const ADFS_SUPER_MAGIC: ::c_uint = 0x0000adf5; + pub const AFFS_SUPER_MAGIC: ::c_uint = 0x0000adff; + pub const AFS_SUPER_MAGIC: ::c_uint = 0x5346414f; + pub const AUTOFS_SUPER_MAGIC: ::c_uint = 0x0187; + pub const BPF_FS_MAGIC: ::c_uint = 0xcafe4a11; + pub const BTRFS_SUPER_MAGIC: ::c_uint = 0x9123683e; + pub const CGROUP2_SUPER_MAGIC: ::c_uint = 0x63677270; + pub const CGROUP_SUPER_MAGIC: ::c_uint = 0x27e0eb; + pub const CODA_SUPER_MAGIC: ::c_uint = 0x73757245; + pub const CRAMFS_MAGIC: ::c_uint = 0x28cd3d45; + pub const DEBUGFS_MAGIC: ::c_uint = 0x64626720; + pub const DEVPTS_SUPER_MAGIC: ::c_uint = 0x1cd1; + pub const ECRYPTFS_SUPER_MAGIC: ::c_uint = 0xf15f; + pub const EFS_SUPER_MAGIC: ::c_uint = 0x00414a53; + pub const EXT2_SUPER_MAGIC: ::c_uint = 0x0000ef53; + pub const EXT3_SUPER_MAGIC: ::c_uint = 0x0000ef53; + pub const EXT4_SUPER_MAGIC: ::c_uint = 0x0000ef53; + pub const F2FS_SUPER_MAGIC: ::c_uint = 0xf2f52010; + pub const FUSE_SUPER_MAGIC: ::c_uint = 0x65735546; + pub const FUTEXFS_SUPER_MAGIC: ::c_uint = 0xbad1dea; + pub const HOSTFS_SUPER_MAGIC: ::c_uint = 0x00c0ffee; + pub const HPFS_SUPER_MAGIC: ::c_uint = 0xf995e849; + pub const HUGETLBFS_MAGIC: ::c_uint = 0x958458f6; + pub const ISOFS_SUPER_MAGIC: ::c_uint = 0x00009660; + pub const JFFS2_SUPER_MAGIC: ::c_uint = 0x000072b6; + pub const MINIX2_SUPER_MAGIC2: ::c_uint = 0x00002478; + pub const MINIX2_SUPER_MAGIC: ::c_uint = 0x00002468; + pub const MINIX3_SUPER_MAGIC: ::c_uint = 0x4d5a; + pub const MINIX_SUPER_MAGIC2: ::c_uint = 0x0000138f; + pub const MINIX_SUPER_MAGIC: ::c_uint = 0x0000137f; + pub const MSDOS_SUPER_MAGIC: ::c_uint = 0x00004d44; + pub const NCP_SUPER_MAGIC: ::c_uint = 0x0000564c; + pub const NFS_SUPER_MAGIC: ::c_uint = 0x00006969; + pub const NILFS_SUPER_MAGIC: ::c_uint = 0x3434; + pub const OCFS2_SUPER_MAGIC: ::c_uint = 0x7461636f; + pub const OPENPROM_SUPER_MAGIC: ::c_uint = 0x00009fa1; + pub const OVERLAYFS_SUPER_MAGIC: ::c_uint = 0x794c7630; + pub const PROC_SUPER_MAGIC: ::c_uint = 0x00009fa0; + pub const QNX4_SUPER_MAGIC: ::c_uint = 0x0000002f; + pub const QNX6_SUPER_MAGIC: ::c_uint = 0x68191122; + pub const RDTGROUP_SUPER_MAGIC: ::c_uint = 0x7655821; + pub const REISERFS_SUPER_MAGIC: ::c_uint = 0x52654973; + pub const SECURITYFS_MAGIC: ::c_uint = 0x73636673; + pub const SELINUX_MAGIC: ::c_uint = 0xf97cff8c; + pub const SMACK_MAGIC: ::c_uint = 0x43415d53; + pub const SMB_SUPER_MAGIC: ::c_uint = 0x0000517b; + pub const SYSFS_MAGIC: ::c_uint = 0x62656572; + pub const TMPFS_MAGIC: ::c_uint = 0x01021994; + pub const TRACEFS_MAGIC: ::c_uint = 0x74726163; + pub const UDF_SUPER_MAGIC: ::c_uint = 0x15013346; + pub const USBDEVICE_SUPER_MAGIC: ::c_uint = 0x00009fa2; + pub const XENFS_SUPER_MAGIC: ::c_uint = 0xabba1974; } } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 3ac1669b..5ff2294e 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -305,21 +305,21 @@ cfg_if! { } else if #[cfg(all(target_os = "linux", any(target_env = "gnu", target_env = "uclibc"), feature = "rustc-dep-of-std"))] { - #[link(name = "util", kind = "static-nobundle", + #[link(name = "util", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] - #[link(name = "rt", kind = "static-nobundle", + #[link(name = "rt", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] - #[link(name = "pthread", kind = "static-nobundle", + #[link(name = "pthread", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] - #[link(name = "m", kind = "static-nobundle", + #[link(name = "m", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] - #[link(name = "dl", kind = "static-nobundle", + #[link(name = "dl", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] - #[link(name = "c", kind = "static-nobundle", + #[link(name = "c", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] - #[link(name = "gcc_eh", kind = "static-nobundle", + #[link(name = "gcc_eh", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] - #[link(name = "gcc", kind = "static-nobundle", + #[link(name = "gcc", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "util", cfg(not(target_feature = "crt-static")))] #[link(name = "rt", cfg(not(target_feature = "crt-static")))] @@ -330,7 +330,7 @@ cfg_if! { extern {} } else if #[cfg(target_env = "musl")] { #[cfg_attr(feature = "rustc-dep-of-std", - link(name = "c", kind = "static", + link(name = "c", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static")))] #[cfg_attr(feature = "rustc-dep-of-std", link(name = "c", cfg(not(target_feature = "crt-static"))))] @@ -372,7 +372,7 @@ cfg_if! { extern {} } else if #[cfg(target_os = "redox")] { #[cfg_attr(feature = "rustc-dep-of-std", - link(name = "c", kind = "static-nobundle", + link(name = "c", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static")))] #[cfg_attr(feature = "rustc-dep-of-std", link(name = "c", cfg(not(target_feature = "crt-static"))))] diff --git a/src/unix/newlib/horizon/mod.rs b/src/unix/newlib/horizon/mod.rs new file mode 100644 index 00000000..a154d727 --- /dev/null +++ b/src/unix/newlib/horizon/mod.rs @@ -0,0 +1,194 @@ +//! ARMv6K Nintendo 3DS C Newlib definitions + +pub type c_char = u8; +pub type c_long = i32; +pub type c_ulong = u32; + +pub type wchar_t = ::c_uint; + +pub type in_port_t = ::c_ushort; +pub type u_register_t = ::c_uint; +pub type u_char = ::c_uchar; +pub type u_short = ::c_ushort; +pub type u_int = ::c_uint; +pub type u_long = c_ulong; +pub type ushort = ::c_ushort; +pub type uint = ::c_uint; +pub type ulong = c_ulong; +pub type clock_t = c_ulong; +pub type daddr_t = c_long; +pub type caddr_t = *mut c_char; +pub type sbintime_t = ::c_longlong; + +// External implementations are needed to use networking and threading. +s! { + pub struct sockaddr { + pub sa_family: ::sa_family_t, + pub sa_data: [::c_char; 26usize], + } + + pub struct sockaddr_storage { + pub ss_family: ::sa_family_t, + pub __ss_padding: [::c_char; 26usize], + } + + pub struct sockaddr_in { + pub sin_family: ::sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: ::in_addr, + } + + pub struct sockaddr_in6 { + pub sin6_family: ::sa_family_t, + pub sin6_port: ::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: ::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct sockaddr_un { + pub sun_len: ::c_uchar, + pub sun_family: ::sa_family_t, + pub sun_path: [::c_char; 104usize], + } +} + +pub const SIGEV_NONE: ::c_int = 1; +pub const SIGEV_SIGNAL: ::c_int = 2; +pub const SIGEV_THREAD: ::c_int = 3; +pub const SA_NOCLDSTOP: ::c_int = 1; +pub const MINSIGSTKSZ: ::c_int = 2048; +pub const SIGSTKSZ: ::c_int = 8192; +pub const SS_ONSTACK: ::c_int = 1; +pub const SS_DISABLE: ::c_int = 2; +pub const SIG_SETMASK: ::c_int = 0; +pub const SIG_BLOCK: ::c_int = 1; +pub const SIG_UNBLOCK: ::c_int = 2; +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGTRAP: ::c_int = 5; +pub const SIGABRT: ::c_int = 6; +pub const SIGEMT: ::c_int = 7; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGBUS: ::c_int = 10; +pub const SIGSEGV: ::c_int = 11; +pub const SIGSYS: ::c_int = 12; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; +pub const SIGURG: ::c_int = 16; +pub const SIGSTOP: ::c_int = 17; +pub const SIGTSTP: ::c_int = 18; +pub const SIGCONT: ::c_int = 19; +pub const SIGCHLD: ::c_int = 20; +pub const SIGCLD: ::c_int = 20; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGIO: ::c_int = 23; +pub const SIGPOLL: ::c_int = 23; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGLOST: ::c_int = 29; +pub const SIGUSR1: ::c_int = 30; +pub const SIGUSR2: ::c_int = 31; +pub const NSIG: ::c_int = 32; +pub const CLOCK_ENABLED: ::c_uint = 1; +pub const CLOCK_DISABLED: ::c_uint = 0; +pub const CLOCK_ALLOWED: ::c_uint = 1; +pub const CLOCK_DISALLOWED: ::c_uint = 0; +pub const TIMER_ABSTIME: ::c_uint = 4; +pub const SOL_SOCKET: ::c_int = 65535; +pub const MSG_OOB: ::c_int = 1; +pub const MSG_PEEK: ::c_int = 2; +pub const MSG_DONTWAIT: ::c_int = 4; +pub const MSG_DONTROUTE: ::c_int = 0; +pub const MSG_WAITALL: ::c_int = 0; +pub const MSG_MORE: ::c_int = 0; +pub const MSG_NOSIGNAL: ::c_int = 0; +pub const SOL_CONFIG: ::c_uint = 65534; + +pub const _SC_PAGESIZE: ::c_int = 8; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 51; + +pub const PTHREAD_STACK_MIN: ::size_t = 4096; +pub const WNOHANG: ::c_int = 1; + +pub const POLLIN: ::c_short = 0x0001; +pub const POLLPRI: ::c_short = 0x0002; +pub const POLLOUT: ::c_short = 0x0004; +pub const POLLRDNORM: ::c_short = 0x0040; +pub const POLLWRNORM: ::c_short = POLLOUT; +pub const POLLRDBAND: ::c_short = 0x0080; +pub const POLLWRBAND: ::c_short = 0x0100; +pub const POLLERR: ::c_short = 0x0008; +pub const POLLHUP: ::c_short = 0x0010; +pub const POLLNVAL: ::c_short = 0x0020; + +pub const EAI_AGAIN: ::c_int = 2; +pub const EAI_BADFLAGS: ::c_int = 3; +pub const EAI_FAIL: ::c_int = 4; +pub const EAI_SERVICE: ::c_int = 9; +pub const EAI_SYSTEM: ::c_int = 11; +pub const EAI_BADHINTS: ::c_int = 12; +pub const EAI_PROTOCOL: ::c_int = 13; +pub const EAI_OVERFLOW: ::c_int = 14; +pub const EAI_MAX: ::c_int = 15; + +pub const AF_UNIX: ::c_int = 1; +pub const AF_INET6: ::c_int = 23; + +pub const FIONBIO: ::c_ulong = 1; + +pub const RTLD_DEFAULT: *mut ::c_void = 0 as *mut ::c_void; + +// Horizon OS works doesn't or can't hold any of this information +safe_f! { + pub {const} fn WIFSTOPPED(_status: ::c_int) -> bool { + false + } + + pub {const} fn WSTOPSIG(_status: ::c_int) -> ::c_int { + 0 + } + + pub {const} fn WIFCONTINUED(_status: ::c_int) -> bool { + true + } + + pub {const} fn WIFSIGNALED(_status: ::c_int) -> bool { + false + } + + pub {const} fn WTERMSIG(_status: ::c_int) -> ::c_int { + 0 + } + + pub {const} fn WIFEXITED(_status: ::c_int) -> bool { + true + } + + pub {const} fn WEXITSTATUS(_status: ::c_int) -> ::c_int { + 0 + } + + pub {const} fn WCOREDUMP(_status: ::c_int) -> bool { + false + } +} + +extern "C" { + pub fn pthread_create( + native: *mut ::pthread_t, + attr: *const ::pthread_attr_t, + f: extern "C" fn(_: *mut ::c_void) -> *mut ::c_void, + value: *mut ::c_void, + ) -> ::c_int; + + pub fn gethostid() -> ::c_long; +} diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 3a7cfa4a..f1d738cb 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -15,14 +15,29 @@ pub type off_t = i64; pub type pthread_t = ::c_ulong; pub type pthread_key_t = ::c_uint; pub type rlim_t = u32; -pub type sa_family_t = u8; + +cfg_if! { + if #[cfg(target_os = "horizon")] { + pub type sa_family_t = u16; + } else { + pub type sa_family_t = u8; + } +} + pub type socklen_t = u32; pub type speed_t = u32; pub type suseconds_t = i32; pub type tcflag_t = ::c_uint; -pub type time_t = i32; pub type useconds_t = u32; +cfg_if! { + if #[cfg(target_os = "horizon")] { + pub type time_t = ::c_longlong; + } else { + pub type time_t = i32; + } +} + s! { // The order of the `ai_addr` field in this struct is crucial // for converting between the Rust and C types. @@ -477,7 +492,13 @@ pub const SO_SNDLOWAT: ::c_int = 0x1003; pub const SO_RCVLOWAT: ::c_int = 0x1004; pub const SO_SNDTIMEO: ::c_int = 0x1005; pub const SO_RCVTIMEO: ::c_int = 0x1006; -pub const SO_ERROR: ::c_int = 0x1007; +cfg_if! { + if #[cfg(target_os = "horizon")] { + pub const SO_ERROR: ::c_int = 0x1009; + } else { + pub const SO_ERROR: ::c_int = 0x1007; + } +} pub const SO_TYPE: ::c_int = 0x1008; pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC; @@ -512,7 +533,13 @@ pub const TCP_KEEPIDLE: ::c_int = 256; pub const TCP_KEEPINTVL: ::c_int = 512; pub const TCP_KEEPCNT: ::c_int = 1024; -pub const IP_TOS: ::c_int = 3; +cfg_if! { + if #[cfg(target_os = "horizon")] { + pub const IP_TOS: ::c_int = 7; + } else { + pub const IP_TOS: ::c_int = 3; + } +} pub const IP_TTL: ::c_int = 8; pub const IP_MULTICAST_IF: ::c_int = 9; pub const IP_MULTICAST_TTL: ::c_int = 10; @@ -706,6 +733,9 @@ cfg_if! { if #[cfg(target_os = "espidf")] { mod espidf; pub use self::espidf::*; + } else if #[cfg(target_os = "horizon")] { + mod horizon; + pub use self::horizon::*; } else if #[cfg(target_arch = "arm")] { mod arm; pub use self::arm::*; diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index f2a2d629..9836551d 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1001,6 +1001,8 @@ extern "C" { set: *const ::sigset_t, oldset: *mut ::sigset_t, ) -> ::c_int; + pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int; + pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; // sys/epoll.h pub fn epoll_create(size: ::c_int) -> ::c_int; diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs index 5a8b0836..c86c6d69 100644 --- a/src/unix/solarish/illumos.rs +++ b/src/unix/solarish/illumos.rs @@ -13,6 +13,12 @@ s! { pub shm_ctime: ::time_t, pub shm_pad4: [i64; 4], } + + pub struct fil_info { + pub fi_flags: ::c_int, + pub fi_pos: ::c_int, + pub fi_name: [::c_char; ::FILNAME_MAX as usize], + } } pub const AF_LOCAL: ::c_int = 1; // AF_UNIX @@ -27,11 +33,37 @@ pub const TCP_KEEPCNT: ::c_int = 35; pub const TCP_KEEPINTVL: ::c_int = 36; pub const TCP_CONGESTION: ::c_int = 37; -pub const F_OFD_GETLK: ::c_int = 50; -pub const F_OFD_SETLKL: ::c_int = 51; -pub const F_OFD_SETLKW: ::c_int = 52; -pub const F_FLOCK: ::c_int = 55; -pub const F_FLOCKW: ::c_int = 56; +// These constants are correct for 64-bit programs or 32-bit programs that are +// not using large-file mode. If Rust ever supports anything other than 64-bit +// compilation on illumos, this may require adjustment: +pub const F_OFD_GETLK: ::c_int = 47; +pub const F_OFD_SETLK: ::c_int = 48; +pub const F_OFD_SETLKW: ::c_int = 49; +pub const F_FLOCK: ::c_int = 53; +pub const F_FLOCKW: ::c_int = 54; + +pub const FIL_ATTACH: ::c_int = 0x1; +pub const FIL_DETACH: ::c_int = 0x2; +pub const FIL_LIST: ::c_int = 0x3; +pub const FILNAME_MAX: ::c_int = 32; +pub const FILF_PROG: ::c_int = 0x1; +pub const FILF_AUTO: ::c_int = 0x2; +pub const FILF_BYPASS: ::c_int = 0x4; +pub const SOL_FILTER: ::c_int = 0xfffc; + +pub const MR_HDR_AOUT: ::c_uint = 0x3; + +pub const B1000000: ::speed_t = 24; +pub const B1152000: ::speed_t = 25; +pub const B1500000: ::speed_t = 26; +pub const B2000000: ::speed_t = 27; +pub const B2500000: ::speed_t = 28; +pub const B3000000: ::speed_t = 29; +pub const B3500000: ::speed_t = 30; +pub const B4000000: ::speed_t = 31; + +// sys/systeminfo.h +pub const SI_ADDRESS_WIDTH: ::c_int = 520; extern "C" { pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; @@ -49,4 +81,5 @@ extern "C" { pub fn preadv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t; pub fn pwritev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t; + pub fn getpagesizes2(pagesize: *mut ::size_t, nelem: ::c_int) -> ::c_int; } diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 8ee388ce..e5aca85a 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -27,6 +27,7 @@ pub type projid_t = ::c_int; pub type zoneid_t = ::c_int; pub type psetid_t = ::c_int; pub type processorid_t = ::c_int; +pub type chipid_t = ::c_int; pub type suseconds_t = ::c_long; pub type off_t = ::c_long; @@ -35,6 +36,7 @@ pub type socklen_t = ::c_uint; pub type sa_family_t = u16; pub type pthread_t = ::c_uint; pub type pthread_key_t = ::c_uint; +pub type thread_t = ::c_uint; pub type blksize_t = ::c_int; pub type nl_item = ::c_int; pub type mqd_t = *mut ::c_void; @@ -42,6 +44,16 @@ pub type id_t = ::c_int; pub type idtype_t = ::c_uint; pub type shmatt_t = ::c_ulong; +pub type lgrp_rsrc_t = ::c_int; +pub type lgrp_affinity_t = ::c_int; +pub type lgrp_id_t = ::id_t; +pub type lgrp_mem_size_t = ::c_longlong; +pub type lgrp_cookie_t = ::uintptr_t; +pub type lgrp_content_t = ::c_uint; +pub type lgrp_lat_between_t = ::c_uint; +pub type lgrp_mem_size_flag_t = ::c_uint; +pub type lgrp_view_t = ::c_uint; + #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} impl ::Copy for timezone {} @@ -266,6 +278,13 @@ s! { pub f_fstr: [::c_char; 32] } + pub struct sendfilevec_t { + pub sfv_fd: ::c_int, + pub sfv_flag: ::c_uint, + pub sfv_off: ::off_t, + pub sfv_len: ::size_t, + } + pub struct sched_param { pub sched_priority: ::c_int, sched_pad: [::c_int; 8] @@ -417,6 +436,29 @@ s! { pub maxerror: i32, pub esterror: i32, } + + pub struct mmapobj_result_t { + pub mr_addr: ::caddr_t, + pub mr_msize: ::size_t, + pub mr_fsize: ::size_t, + pub mr_offset: ::size_t, + pub mr_prot: ::c_uint, + pub mr_flags: ::c_uint, + } + + pub struct lgrp_affinity_args { + pub idtype: ::idtype_t, + pub id: ::id_t, + pub lgrp: ::lgrp_id_t, + pub aff: ::lgrp_affinity_t, + } + + pub struct processor_info_t { + pub pi_state: ::c_int, + pub pi_processor_type: [::c_char; PI_TYPELEN as usize], + pub pi_fputypes: [::c_char; PI_FPUTYPE as usize], + pub pi_clock: ::c_int, + } } s_no_extra_traits! { @@ -503,14 +545,16 @@ s_no_extra_traits! { } #[cfg(libc_union)] + #[cfg_attr(libc_align, repr(align(16)))] pub union pad128_t { - pub _q: ::c_double, + // pub _q in this structure would be a "long double", of 16 bytes pub _l: [i32; 4], } #[cfg(libc_union)] + #[cfg_attr(libc_align, repr(align(16)))] pub union upad128_t { - pub _q: ::c_double, + // pub _q in this structure would be a "long double", of 16 bytes pub _l: [u32; 4], } } @@ -842,7 +886,7 @@ cfg_if! { impl PartialEq for pad128_t { fn eq(&self, other: &pad128_t) -> bool { unsafe { - self._q == other._q || + // FIXME: self._q == other._q || self._l == other._l } } @@ -854,7 +898,7 @@ cfg_if! { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { f.debug_struct("pad128_t") - .field("_q", &{self._q}) + // FIXME: .field("_q", &{self._q}) .field("_l", &{self._l}) .finish() } @@ -864,7 +908,7 @@ cfg_if! { impl ::hash::Hash for pad128_t { fn hash<H: ::hash::Hasher>(&self, state: &mut H) { unsafe { - state.write_i64(self._q as i64); + // FIXME: state.write_i64(self._q as i64); self._l.hash(state); } } @@ -873,7 +917,7 @@ cfg_if! { impl PartialEq for upad128_t { fn eq(&self, other: &upad128_t) -> bool { unsafe { - self._q == other._q || + // FIXME: self._q == other._q || self._l == other._l } } @@ -885,7 +929,7 @@ cfg_if! { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { f.debug_struct("upad128_t") - .field("_q", &{self._q}) + // FIXME: .field("_q", &{self._q}) .field("_l", &{self._l}) .finish() } @@ -895,7 +939,7 @@ cfg_if! { impl ::hash::Hash for upad128_t { fn hash<H: ::hash::Hasher>(&self, state: &mut H) { unsafe { - state.write_i64(self._q as i64); + // FIXME: state.write_i64(self._q as i64); self._l.hash(state); } } @@ -1200,7 +1244,7 @@ pub const PS_QUERY: ::c_int = -2; pub const PS_MYID: ::c_int = -3; pub const PS_SOFT: ::c_int = -4; pub const PS_HARD: ::c_int = -5; -pub const PS_QUERY_TIME: ::c_int = -6; +pub const PS_QUERY_TYPE: ::c_int = -6; pub const PS_SYSTEM: ::c_int = 1; pub const PS_PRIVATE: ::c_int = 2; @@ -1232,6 +1276,11 @@ pub const MS_SYNC: ::c_int = 0x0004; pub const MS_ASYNC: ::c_int = 0x0001; pub const MS_INVALIDATE: ::c_int = 0x0002; +pub const MMOBJ_PADDING: ::c_uint = 0x10000; +pub const MMOBJ_INTERPRET: ::c_uint = 0x20000; +pub const MR_PADDING: ::c_uint = 0x1; +pub const MR_HDR_ELF: ::c_uint = 0x2; + pub const EPERM: ::c_int = 1; pub const ENOENT: ::c_int = 2; pub const ESRCH: ::c_int = 3; @@ -1489,6 +1538,42 @@ pub const AF_INET_OFFLOAD: ::c_int = 30; pub const AF_TRILL: ::c_int = 31; pub const AF_PACKET: ::c_int = 32; +pub const PF_UNSPEC: ::c_int = AF_UNSPEC; +pub const PF_UNIX: ::c_int = AF_UNIX; +pub const PF_LOCAL: ::c_int = PF_UNIX; +pub const PF_FILE: ::c_int = PF_UNIX; +pub const PF_INET: ::c_int = AF_INET; +pub const PF_IMPLINK: ::c_int = AF_IMPLINK; +pub const PF_PUP: ::c_int = AF_PUP; +pub const PF_CHAOS: ::c_int = AF_CHAOS; +pub const PF_NS: ::c_int = AF_NS; +pub const PF_NBS: ::c_int = AF_NBS; +pub const PF_ECMA: ::c_int = AF_ECMA; +pub const PF_DATAKIT: ::c_int = AF_DATAKIT; +pub const PF_CCITT: ::c_int = AF_CCITT; +pub const PF_SNA: ::c_int = AF_SNA; +pub const PF_DECnet: ::c_int = AF_DECnet; +pub const PF_DLI: ::c_int = AF_DLI; +pub const PF_LAT: ::c_int = AF_LAT; +pub const PF_HYLINK: ::c_int = AF_HYLINK; +pub const PF_APPLETALK: ::c_int = AF_APPLETALK; +pub const PF_NIT: ::c_int = AF_NIT; +pub const PF_802: ::c_int = AF_802; +pub const PF_OSI: ::c_int = AF_OSI; +pub const PF_X25: ::c_int = AF_X25; +pub const PF_OSINET: ::c_int = AF_OSINET; +pub const PF_GOSIP: ::c_int = AF_GOSIP; +pub const PF_IPX: ::c_int = AF_IPX; +pub const PF_ROUTE: ::c_int = AF_ROUTE; +pub const PF_LINK: ::c_int = AF_LINK; +pub const PF_INET6: ::c_int = AF_INET6; +pub const PF_KEY: ::c_int = AF_KEY; +pub const PF_NCA: ::c_int = AF_NCA; +pub const PF_POLICY: ::c_int = AF_POLICY; +pub const PF_INET_OFFLOAD: ::c_int = AF_INET_OFFLOAD; +pub const PF_TRILL: ::c_int = AF_TRILL; +pub const PF_PACKET: ::c_int = AF_PACKET; + pub const SOCK_DGRAM: ::c_int = 1; pub const SOCK_STREAM: ::c_int = 2; pub const SOCK_RAW: ::c_int = 4; @@ -1973,6 +2058,18 @@ pub const TIOCMGET: ::c_int = tIOC | 29; pub const TIOCREMOTE: ::c_int = tIOC | 30; pub const TIOCSIGNAL: ::c_int = tIOC | 31; +pub const TIOCM_LE: ::c_int = 0o0001; +pub const TIOCM_DTR: ::c_int = 0o0002; +pub const TIOCM_RTS: ::c_int = 0o0004; +pub const TIOCM_ST: ::c_int = 0o0010; +pub const TIOCM_SR: ::c_int = 0o0020; +pub const TIOCM_CTS: ::c_int = 0o0040; +pub const TIOCM_CAR: ::c_int = 0o0100; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RNG: ::c_int = 0o0200; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; +pub const TIOCM_DSR: ::c_int = 0o0400; + pub const EPOLLIN: ::c_int = 0x1; pub const EPOLLPRI: ::c_int = 0x2; pub const EPOLLOUT: ::c_int = 0x4; @@ -2021,6 +2118,10 @@ pub const B921600: speed_t = 23; pub const CSTART: ::tcflag_t = 0o21; pub const CSTOP: ::tcflag_t = 0o23; pub const CSWTCH: ::tcflag_t = 0o32; +pub const CBAUD: ::tcflag_t = 0o17; +pub const CIBAUD: ::tcflag_t = 0o3600000; +pub const CBAUDEXT: ::tcflag_t = 0o10000000; +pub const CIBAUDEXT: ::tcflag_t = 0o20000000; pub const CSIZE: ::tcflag_t = 0o000060; pub const CS5: ::tcflag_t = 0; pub const CS6: ::tcflag_t = 0o000020; @@ -2044,20 +2145,26 @@ pub const ISTRIP: ::tcflag_t = 0o000040; pub const INLCR: ::tcflag_t = 0o000100; pub const IGNCR: ::tcflag_t = 0o000200; pub const ICRNL: ::tcflag_t = 0o000400; +pub const IUCLC: ::tcflag_t = 0o001000; pub const IXON: ::tcflag_t = 0o002000; pub const IXOFF: ::tcflag_t = 0o010000; pub const IXANY: ::tcflag_t = 0o004000; pub const IMAXBEL: ::tcflag_t = 0o020000; +pub const DOSMODE: ::tcflag_t = 0o100000; pub const OPOST: ::tcflag_t = 0o000001; +pub const OLCUC: ::tcflag_t = 0o000002; pub const ONLCR: ::tcflag_t = 0o000004; pub const OCRNL: ::tcflag_t = 0o000010; pub const ONOCR: ::tcflag_t = 0o000020; pub const ONLRET: ::tcflag_t = 0o000040; +pub const OFILL: ::tcflag_t = 0o0000100; +pub const OFDEL: ::tcflag_t = 0o0000200; pub const CREAD: ::tcflag_t = 0o000200; pub const PARENB: ::tcflag_t = 0o000400; pub const PARODD: ::tcflag_t = 0o001000; pub const HUPCL: ::tcflag_t = 0o002000; pub const CLOCAL: ::tcflag_t = 0o004000; +pub const CRTSXOFF: ::tcflag_t = 0o10000000000; pub const CRTSCTS: ::tcflag_t = 0o20000000000; pub const ISIG: ::tcflag_t = 0o000001; pub const ICANON: ::tcflag_t = 0o000002; @@ -2191,6 +2298,73 @@ pub const SCHED_IA: ::c_int = 4; pub const SCHED_FSS: ::c_int = 5; pub const SCHED_FX: ::c_int = 6; +// sys/priv.h +pub const PRIV_DEBUG: ::c_uint = 0x0001; +pub const PRIV_AWARE: ::c_uint = 0x0002; +pub const PRIV_AWARE_INHERIT: ::c_uint = 0x0004; +pub const __PROC_PROTECT: ::c_uint = 0x0008; +pub const NET_MAC_AWARE: ::c_uint = 0x0010; +pub const NET_MAC_AWARE_INHERIT: ::c_uint = 0x0020; +pub const PRIV_AWARE_RESET: ::c_uint = 0x0040; +pub const PRIV_XPOLICY: ::c_uint = 0x0080; +pub const PRIV_PFEXEC: ::c_uint = 0x0100; +pub const PRIV_USER: ::c_uint = PRIV_DEBUG + | NET_MAC_AWARE + | NET_MAC_AWARE_INHERIT + | PRIV_XPOLICY + | PRIV_AWARE_RESET + | PRIV_PFEXEC; + +// sys/systeminfo.h +pub const SI_SYSNAME: ::c_int = 1; +pub const SI_HOSTNAME: ::c_int = 2; +pub const SI_RELEASE: ::c_int = 3; +pub const SI_VERSION: ::c_int = 4; +pub const SI_MACHINE: ::c_int = 5; +pub const SI_ARCHITECTURE: ::c_int = 6; +pub const SI_HW_SERIAL: ::c_int = 7; +pub const SI_HW_PROVIDER: ::c_int = 8; +pub const SI_SET_HOSTNAME: ::c_int = 258; +pub const SI_SET_SRPC_DOMAIN: ::c_int = 265; +pub const SI_PLATFORM: ::c_int = 513; +pub const SI_ISALIST: ::c_int = 514; +pub const SI_DHCP_CACHE: ::c_int = 515; +pub const SI_ARCHITECTURE_32: ::c_int = 516; +pub const SI_ARCHITECTURE_64: ::c_int = 517; +pub const SI_ARCHITECTURE_K: ::c_int = 518; +pub const SI_ARCHITECTURE_NATIVE: ::c_int = 519; + +// sys/lgrp_user.h +pub const LGRP_COOKIE_NONE: ::lgrp_cookie_t = 0; +pub const LGRP_AFF_NONE: ::lgrp_affinity_t = 0x0; +pub const LGRP_AFF_WEAK: ::lgrp_affinity_t = 0x10; +pub const LGRP_AFF_STRONG: ::lgrp_affinity_t = 0x100; +pub const LGRP_RSRC_COUNT: ::lgrp_rsrc_t = 2; +pub const LGRP_RSRC_CPU: ::lgrp_rsrc_t = 0; +pub const LGRP_RSRC_MEM: ::lgrp_rsrc_t = 1; +pub const LGRP_CONTENT_ALL: ::lgrp_content_t = 0; +pub const LGRP_CONTENT_HIERARCHY: ::lgrp_content_t = LGRP_CONTENT_ALL; +pub const LGRP_CONTENT_DIRECT: ::lgrp_content_t = 1; +pub const LGRP_LAT_CPU_TO_MEM: ::lgrp_lat_between_t = 0; +pub const LGRP_MEM_SZ_FREE: ::lgrp_mem_size_flag_t = 0; +pub const LGRP_MEM_SZ_INSTALLED: ::lgrp_mem_size_flag_t = 1; +pub const LGRP_VIEW_CALLER: ::lgrp_view_t = 0; +pub const LGRP_VIEW_OS: ::lgrp_view_t = 1; + +// sys/processor.h + +pub const P_OFFLINE: ::c_int = 0x001; +pub const P_ONLINE: ::c_int = 0x002; +pub const P_STATUS: ::c_int = 0x003; +pub const P_FAULTED: ::c_int = 0x004; +pub const P_POWEROFF: ::c_int = 0x005; +pub const P_NOINTR: ::c_int = 0x006; +pub const P_SPARE: ::c_int = 0x007; +pub const P_DISABLED: ::c_int = 0x008; +pub const P_FORCED: ::c_int = 0x10000000; +pub const PI_TYPELEN: ::c_int = 16; +pub const PI_FPUTYPE: ::c_int = 32; + // As per sys/socket.h, header alignment must be 8 bytes on SPARC // and 4 bytes everywhere else: #[cfg(target_arch = "sparc64")] @@ -2309,6 +2483,10 @@ safe_f! { pub {const} fn WCOREDUMP(status: ::c_int) -> bool { (status & 0x80) != 0 } + + pub {const} fn MR_GET_TYPE(flags: ::c_uint) -> ::c_uint { + flags & 0x0000ffff + } } extern "C" { @@ -2415,6 +2593,8 @@ extern "C" { lock: *mut pthread_mutex_t, abstime: *const ::timespec, ) -> ::c_int; + pub fn pthread_getname_np(tid: ::pthread_t, name: *mut ::c_char, len: ::size_t) -> ::c_int; + pub fn pthread_setname_np(tid: ::pthread_t, name: *const ::c_char) -> ::c_int; pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, options: ::c_int) -> ::c_int; @@ -2592,6 +2772,7 @@ extern "C" { buflen: ::size_t, result: *mut *mut ::group, ) -> ::c_int; + pub fn thr_self() -> ::thread_t; pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t, oldset: *mut sigset_t) -> ::c_int; pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; pub fn getgrnam(name: *const ::c_char) -> *mut ::group; @@ -2751,11 +2932,108 @@ extern "C" { old_binding: *mut processorid_t, ) -> ::c_int; pub fn p_online(processorid: ::processorid_t, flag: ::c_int) -> ::c_int; + pub fn processor_info(processorid: ::processorid_t, infop: *mut processor_info_t) -> ::c_int; pub fn getexecname() -> *const ::c_char; pub fn gethostid() -> ::c_long; - pub fn sethostid(hostid: ::c_long) -> ::c_int; + + pub fn getpflags(flags: ::c_uint) -> ::c_uint; + pub fn setpflags(flags: ::c_uint, value: ::c_uint) -> ::c_int; + + pub fn sysinfo(command: ::c_int, buf: *mut ::c_char, count: ::c_long) -> ::c_int; +} + +#[link(name = "sendfile")] +extern "C" { + pub fn sendfile(out_fd: ::c_int, in_fd: ::c_int, off: *mut ::off_t, len: ::size_t) + -> ::ssize_t; + pub fn sendfilev( + fildes: ::c_int, + vec: *const sendfilevec_t, + sfvcnt: ::c_int, + xferred: *mut ::size_t, + ) -> ::ssize_t; + // #include <link.h> + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + pub fn dl_iterate_phdr( + callback: ::Option< + unsafe extern "C" fn( + info: *mut dl_phdr_info, + size: usize, + data: *mut ::c_void, + ) -> ::c_int, + >, + data: *mut ::c_void, + ) -> ::c_int; + pub fn getpagesize() -> ::c_int; + pub fn getpagesizes(pagesize: *mut ::size_t, nelem: ::c_int) -> ::c_int; + pub fn mmapobj( + fd: ::c_int, + flags: ::c_uint, + storage: *mut mmapobj_result_t, + elements: *mut ::c_uint, + arg: *mut ::c_void, + ) -> ::c_int; + pub fn meminfo( + inaddr: *const u64, + addr_count: ::c_int, + info_req: *const ::c_uint, + info_count: ::c_int, + outdata: *mut u64, + validity: *mut ::c_uint, + ) -> ::c_int; + + pub fn strcasecmp_l(s1: *const ::c_char, s2: *const ::c_char, loc: ::locale_t) -> ::c_int; + pub fn strncasecmp_l( + s1: *const ::c_char, + s2: *const ::c_char, + n: ::size_t, + loc: ::locale_t, + ) -> ::c_int; + pub fn strsep(string: *mut *mut ::c_char, delim: *const ::c_char) -> *mut ::c_char; +} + +#[link(name = "lgrp")] +extern "C" { + pub fn lgrp_init(view: lgrp_view_t) -> lgrp_cookie_t; + pub fn lgrp_fini(cookie: lgrp_cookie_t) -> ::c_int; + pub fn lgrp_affinity_get( + idtype: ::idtype_t, + id: ::id_t, + lgrp: ::lgrp_id_t, + ) -> ::lgrp_affinity_t; + pub fn lgrp_affinity_set( + idtype: ::idtype_t, + id: ::id_t, + lgrp: ::lgrp_id_t, + aff: lgrp_affinity_t, + ) -> ::lgrp_affinity_t; + pub fn lgrp_cpus( + cookie: ::lgrp_cookie_t, + lgrp: ::lgrp_id_t, + cpuids: *mut ::processorid_t, + count: ::c_uint, + content: ::lgrp_content_t, + ) -> ::c_int; + pub fn lgrp_mem_size( + cookie: ::lgrp_cookie_t, + lgrp: ::lgrp_id_t, + tpe: ::lgrp_mem_size_flag_t, + content: ::lgrp_content_t, + ) -> ::lgrp_mem_size_t; + pub fn lgrp_nlgrps(cookie: ::lgrp_cookie_t) -> ::c_int; + pub fn lgrp_view(cookie: ::lgrp_cookie_t) -> ::lgrp_view_t; + pub fn lgrp_home(idtype: ::idtype_t, id: ::id_t) -> ::lgrp_id_t; + pub fn lgrp_version(version: ::c_int) -> ::c_int; + pub fn lgrp_resources( + cookie: ::lgrp_cookie_t, + lgrp: ::lgrp_id_t, + lgrps: *mut ::lgrp_id_t, + count: ::c_uint, + tpe: ::lgrp_rsrc_t, + ) -> ::c_int; + pub fn lgrp_root(cookie: ::lgrp_cookie_t) -> ::lgrp_id_t; } mod compat; @@ -2777,5 +3055,8 @@ cfg_if! { if #[cfg(target_arch = "x86_64")] { mod x86_64; pub use self::x86_64::*; + } else if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; } } diff --git a/src/unix/solarish/x86.rs b/src/unix/solarish/x86.rs new file mode 100644 index 00000000..23f52ad3 --- /dev/null +++ b/src/unix/solarish/x86.rs @@ -0,0 +1,29 @@ +pub type Elf32_Addr = ::c_ulong; +pub type Elf32_Half = ::c_ushort; +pub type Elf32_Off = ::c_ulong; +pub type Elf32_Sword = ::c_long; +pub type Elf32_Word = ::c_ulong; +pub type Elf32_Lword = ::c_ulonglong; +pub type Elf32_Phdr = __c_anonymous_Elf32_Phdr; + +s! { + pub struct __c_anonymous_Elf32_Phdr { + pub p_type: ::Elf32_Word, + pub p_offset: ::Elf32_Off, + pub p_vaddr: ::Elf32_Addr, + pub p_paddr: ::Elf32_Addr, + pub p_filesz: ::Elf32_Word, + pub p_memsz: ::Elf32_Word, + pub p_flags: ::Elf32_Word, + pub p_align: ::Elf32_Word, + } + + pub struct dl_phdr_info { + pub dlpi_addr: ::Elf32_Addr, + pub dlpi_name: *const ::c_char, + pub dlpi_phdr: *const ::Elf32_Phdr, + pub dlpi_phnum: ::Elf32_Half, + pub dlpi_adds: ::c_ulonglong, + pub dlpi_subs: ::c_ulonglong, + } +} diff --git a/src/unix/solarish/x86_64.rs b/src/unix/solarish/x86_64.rs index a7107b0a..5f75bdb7 100644 --- a/src/unix/solarish/x86_64.rs +++ b/src/unix/solarish/x86_64.rs @@ -1,5 +1,15 @@ pub type greg_t = ::c_long; +pub type Elf64_Addr = ::c_ulong; +pub type Elf64_Half = ::c_ushort; +pub type Elf64_Off = ::c_ulong; +pub type Elf64_Sword = ::c_int; +pub type Elf64_Sxword = ::c_long; +pub type Elf64_Word = ::c_uint; +pub type Elf64_Xword = ::c_ulong; +pub type Elf64_Lword = ::c_ulong; +pub type Elf64_Phdr = __c_anonymous_Elf64_Phdr; + s! { pub struct __c_anonymous_fpchip_state { pub cw: u16, @@ -17,6 +27,26 @@ s! { pub status: u32, pub xstatus: u32, } + + pub struct __c_anonymous_Elf64_Phdr { + pub p_type: ::Elf64_Word, + pub p_flags: ::Elf64_Word, + pub p_offset: ::Elf64_Off, + pub p_vaddr: ::Elf64_Addr, + pub p_paddr: ::Elf64_Addr, + pub p_filesz: ::Elf64_Xword, + pub p_memsz: ::Elf64_Xword, + pub p_align: ::Elf64_Xword, + } + + pub struct dl_phdr_info { + pub dlpi_addr: ::Elf64_Addr, + pub dlpi_name: *const ::c_char, + pub dlpi_phdr: *const ::Elf64_Phdr, + pub dlpi_phnum: ::Elf64_Half, + pub dlpi_adds: ::c_ulonglong, + pub dlpi_subs: ::c_ulonglong, + } } s_no_extra_traits! { @@ -32,7 +62,7 @@ s_no_extra_traits! { pub struct mcontext_t { pub gregs: [::greg_t; 28], - pub fpgregs: fpregset_t, + pub fpregs: fpregset_t, } pub struct ucontext_t { @@ -89,7 +119,7 @@ cfg_if! { impl PartialEq for mcontext_t { fn eq(&self, other: &mcontext_t) -> bool { self.gregs == other.gregs && - self.fpgregs == other.fpgregs + self.fpregs == other.fpregs } } impl Eq for mcontext_t {} @@ -97,7 +127,7 @@ cfg_if! { fn fmt(&self, f:&mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("mcontext_t") .field("gregs", &self.gregs) - .field("fpgregs", &self.fpgregs) + .field("fpregs", &self.fpregs) .finish() } } diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 2772d68d..2772d68d 100755..100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs diff --git a/src/wasi.rs b/src/wasi.rs index f66ca928..ef88fac7 100644 --- a/src/wasi.rs +++ b/src/wasi.rs @@ -1,3 +1,5 @@ +use super::{Send, Sync}; + pub use ffi::c_void; pub type c_char = i8; @@ -36,6 +38,15 @@ pub type blksize_t = c_long; pub type blkcnt_t = i64; pub type nfds_t = c_ulong; pub type wchar_t = i32; +pub type nl_item = c_int; + +s_no_extra_traits! { + #[repr(align(16))] + #[allow(missing_debug_implementations)] + pub struct max_align_t { + priv_: [f64; 4] + } +} pub type __wasi_rights_t = u64; @@ -51,6 +62,16 @@ pub enum __locale_struct {} pub type locale_t = *mut __locale_struct; +s_paren! { + // in wasi-libc clockid_t is const struct __clockid* (where __clockid is an opaque struct), + // but that's an implementation detail that we don't want to have to deal with + #[repr(transparent)] + pub struct clockid_t(*const u8); +} + +unsafe impl Send for clockid_t {} +unsafe impl Sync for clockid_t {} + s! { #[repr(align(8))] pub struct fpos_t { @@ -342,9 +363,86 @@ pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; pub const _SC_IOV_MAX: c_int = 60; pub const _SC_SYMLOOP_MAX: c_int = 173; +pub static CLOCK_MONOTONIC: clockid_t = unsafe { clockid_t(ptr_addr_of!(_CLOCK_MONOTONIC)) }; +pub static CLOCK_PROCESS_CPUTIME_ID: clockid_t = + unsafe { clockid_t(ptr_addr_of!(_CLOCK_PROCESS_CPUTIME_ID)) }; +pub static CLOCK_REALTIME: clockid_t = unsafe { clockid_t(ptr_addr_of!(_CLOCK_REALTIME)) }; +pub static CLOCK_THREAD_CPUTIME_ID: clockid_t = + unsafe { clockid_t(ptr_addr_of!(_CLOCK_THREAD_CPUTIME_ID)) }; + +pub const ABDAY_1: ::nl_item = 0x20000; +pub const ABDAY_2: ::nl_item = 0x20001; +pub const ABDAY_3: ::nl_item = 0x20002; +pub const ABDAY_4: ::nl_item = 0x20003; +pub const ABDAY_5: ::nl_item = 0x20004; +pub const ABDAY_6: ::nl_item = 0x20005; +pub const ABDAY_7: ::nl_item = 0x20006; + +pub const DAY_1: ::nl_item = 0x20007; +pub const DAY_2: ::nl_item = 0x20008; +pub const DAY_3: ::nl_item = 0x20009; +pub const DAY_4: ::nl_item = 0x2000A; +pub const DAY_5: ::nl_item = 0x2000B; +pub const DAY_6: ::nl_item = 0x2000C; +pub const DAY_7: ::nl_item = 0x2000D; + +pub const ABMON_1: ::nl_item = 0x2000E; +pub const ABMON_2: ::nl_item = 0x2000F; +pub const ABMON_3: ::nl_item = 0x20010; +pub const ABMON_4: ::nl_item = 0x20011; +pub const ABMON_5: ::nl_item = 0x20012; +pub const ABMON_6: ::nl_item = 0x20013; +pub const ABMON_7: ::nl_item = 0x20014; +pub const ABMON_8: ::nl_item = 0x20015; +pub const ABMON_9: ::nl_item = 0x20016; +pub const ABMON_10: ::nl_item = 0x20017; +pub const ABMON_11: ::nl_item = 0x20018; +pub const ABMON_12: ::nl_item = 0x20019; + +pub const MON_1: ::nl_item = 0x2001A; +pub const MON_2: ::nl_item = 0x2001B; +pub const MON_3: ::nl_item = 0x2001C; +pub const MON_4: ::nl_item = 0x2001D; +pub const MON_5: ::nl_item = 0x2001E; +pub const MON_6: ::nl_item = 0x2001F; +pub const MON_7: ::nl_item = 0x20020; +pub const MON_8: ::nl_item = 0x20021; +pub const MON_9: ::nl_item = 0x20022; +pub const MON_10: ::nl_item = 0x20023; +pub const MON_11: ::nl_item = 0x20024; +pub const MON_12: ::nl_item = 0x20025; + +pub const AM_STR: ::nl_item = 0x20026; +pub const PM_STR: ::nl_item = 0x20027; + +pub const D_T_FMT: ::nl_item = 0x20028; +pub const D_FMT: ::nl_item = 0x20029; +pub const T_FMT: ::nl_item = 0x2002A; +pub const T_FMT_AMPM: ::nl_item = 0x2002B; + +pub const ERA: ::nl_item = 0x2002C; +pub const ERA_D_FMT: ::nl_item = 0x2002E; +pub const ALT_DIGITS: ::nl_item = 0x2002F; +pub const ERA_D_T_FMT: ::nl_item = 0x20030; +pub const ERA_T_FMT: ::nl_item = 0x20031; + +pub const CODESET: ::nl_item = 14; +pub const CRNCYSTR: ::nl_item = 0x4000F; +pub const RADIXCHAR: ::nl_item = 0x10000; +pub const THOUSEP: ::nl_item = 0x10001; +pub const YESEXPR: ::nl_item = 0x50000; +pub const NOEXPR: ::nl_item = 0x50001; +pub const YESSTR: ::nl_item = 0x50002; +pub const NOSTR: ::nl_item = 0x50003; + #[cfg_attr( feature = "rustc-dep-of-std", - link(name = "c", kind = "static", cfg(target_feature = "crt-static")) + link( + name = "c", + kind = "static", + modifiers = "-bundle", + cfg(target_feature = "crt-static") + ) )] #[cfg_attr( feature = "rustc-dep-of-std", @@ -417,15 +515,14 @@ extern "C" { pub fn asctime_r(a: *const tm, b: *mut c_char) -> *mut c_char; pub fn ctime_r(a: *const time_t, b: *mut c_char) -> *mut c_char; + static _CLOCK_MONOTONIC: u8; + static _CLOCK_PROCESS_CPUTIME_ID: u8; + static _CLOCK_REALTIME: u8; + static _CLOCK_THREAD_CPUTIME_ID: u8; pub fn nanosleep(a: *const timespec, b: *mut timespec) -> c_int; - // pub fn clock_getres(a: clockid_t, b: *mut timespec) -> c_int; - // pub fn clock_gettime(a: clockid_t, b: *mut timespec) -> c_int; - // pub fn clock_nanosleep( - // a: clockid_t, - // a2: c_int, - // b: *const timespec, - // c: *mut timespec, - // ) -> c_int; + pub fn clock_getres(a: clockid_t, b: *mut timespec) -> c_int; + pub fn clock_gettime(a: clockid_t, b: *mut timespec) -> c_int; + pub fn clock_nanosleep(a: clockid_t, a2: c_int, b: *const timespec, c: *mut timespec) -> c_int; pub fn isalnum(c: c_int) -> c_int; pub fn isalpha(c: c_int) -> c_int; @@ -623,6 +720,11 @@ extern "C" { pub fn newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t; pub fn uselocale(loc: ::locale_t) -> ::locale_t; pub fn sched_yield() -> ::c_int; + pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char; + pub fn chdir(dir: *const c_char) -> ::c_int; + + pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; + pub fn nl_langinfo_l(item: ::nl_item, loc: ::locale_t) -> *mut ::c_char; pub fn __wasilibc_register_preopened_fd(fd: c_int, path: *const c_char) -> c_int; pub fn __wasilibc_fd_renumber(fd: c_int, newfd: c_int) -> c_int; diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 71af46a2..08cba4ed 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -27,6 +27,8 @@ pub type wchar_t = u16; pub type clock_t = i32; +pub type errno_t = ::c_int; + cfg_if! { if #[cfg(all(target_arch = "x86", target_env = "gnu"))] { pub type time_t = i32; @@ -317,6 +319,8 @@ extern "C" { pub fn feof(stream: *mut FILE) -> c_int; pub fn ferror(stream: *mut FILE) -> c_int; pub fn perror(s: *const c_char); + pub fn printf(format: *const c_char, ...) -> ::c_int; + pub fn fprintf(stream: *mut FILE, format: *const c_char, ...) -> ::c_int; pub fn atoi(s: *const c_char) -> c_int; pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float; @@ -372,6 +376,8 @@ extern "C" { #[link_name = "_gmtime64_s"] pub fn gmtime_s(destTime: *mut tm, srcTime: *const time_t) -> ::c_int; + #[link_name = "_localtime64_s"] + pub fn localtime_s(tmDest: *mut tm, sourceTime: *const time_t) -> ::errno_t; #[link_name = "_time64"] pub fn time(destTime: *mut time_t) -> time_t; #[link_name = "_chmod"] diff --git a/src/windows/msvc.rs b/src/windows/msvc/mod.rs index b4c98a84..f5a1d95f 100644 --- a/src/windows/msvc.rs +++ b/src/windows/msvc/mod.rs @@ -10,4 +10,11 @@ extern "C" { pub fn stricmp(s1: *const ::c_char, s2: *const ::c_char) -> ::c_int; #[link_name = "_strnicmp"] pub fn strnicmp(s1: *const ::c_char, s2: *const ::c_char, n: ::size_t) -> ::c_int; + #[link_name = "_memccpy"] + pub fn memccpy( + dest: *mut ::c_void, + src: *const ::c_void, + c: ::c_int, + count: ::size_t, + ) -> *mut ::c_void; } |