diff --git a/.cirrus.yml b/.cirrus.yml index 1650f3ead158b..18753922ed651 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -15,7 +15,7 @@ task: task: name: nightly x86_64-unknown-freebsd-14 freebsd_instance: - image: freebsd-14-0-release-amd64-ufs + image: freebsd-14-1-release-amd64-ufs setup_script: - pkg install -y libnghttp2 curl - curl https://sh.rustup.rs -sSf --output rustup.sh diff --git a/.github/workflows/full_ci.yml b/.github/workflows/full_ci.yml index f3067925da2bf..042d81b158c0c 100644 --- a/.github/workflows/full_ci.yml +++ b/.github/workflows/full_ci.yml @@ -3,8 +3,7 @@ name: full CI on: merge_group: pull_request: - branches: - - libc-0.2 + types: [opened, synchronize, reopened] jobs: docker_linux_tier1: @@ -32,12 +31,12 @@ jobs: contents: read # to fetch code (actions/checkout) name: macOS - runs-on: macos-13 + runs-on: macos-14 strategy: fail-fast: true matrix: target: [ - x86_64-apple-darwin, + aarch64-apple-darwin, ] steps: - uses: actions/checkout@v4 @@ -63,6 +62,7 @@ jobs: ARCH_BITS: 64 ARCH: x86_64 - target: x86_64-pc-windows-msvc + # FIXME: It currently causes segfaults. #- target: i686-pc-windows-gnu # env: # ARCH_BITS: 32 @@ -140,45 +140,6 @@ jobs: - name: Execute run-docker.sh run: LIBC_CI=1 sh ./ci/run-docker.sh ${{ matrix.target }} - # These targets are tier 3 or otherwise need to have CI build std via -Zbuild-std. - # Because of this, only the nightly compiler can be used on these targets. - docker_linux_build_std: - permissions: - contents: read # to fetch code (actions/checkout) - - if: ${{ false }} # This is currently broken - name: Docker Linux Build-Std Targets - needs: [docker_linux_tier1, style_check] - runs-on: ubuntu-22.04 - strategy: - fail-fast: true - max-parallel: 12 - matrix: - target: [ - armv7-unknown-linux-uclibceabihf - ] - steps: - - uses: actions/checkout@v4 - - name: Setup Rust toolchain - run: TOOLCHAIN=nightly INSTALL_RUST_SRC=1 sh ./ci/install-rust.sh - - name: Execute run-docker.sh - run: LIBC_CI=1 TOOLCHAIN=nightly LIBC_CI_ZBUILD_STD=1 sh ./ci/run-docker.sh ${{ matrix.target }} - - # devkitpro's pacman needs to be connected from Docker. - docker_switch: - permissions: - contents: read # to fetch code (actions/checkout) - - name: Docker Switch - needs: [docker_linux_tier1, style_check] - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - - name: Setup Rust toolchain - run: sh ./ci/install-rust.sh - - name: Execute run-docker.sh - run: LIBC_CI=1 sh ./ci/run-docker.sh switch - build_channels_linux: permissions: contents: read # to fetch code (actions/checkout) @@ -196,13 +157,7 @@ jobs: stable, beta, nightly, - # FIXME: Disabled due to: - # error: failed to parse registry's information for: serde - #1.13.0, - 1.19.0, - 1.24.0, - 1.25.0, - 1.30.0, + 1.71.0, ] steps: - uses: actions/checkout@v4 @@ -224,17 +179,10 @@ jobs: max-parallel: 4 matrix: target: - - { toolchain: stable, os: macos-13 } - - { toolchain: beta, os: macos-13 } - - { toolchain: nightly, os: macos-13 } - # Use macOS 11 for older toolchains as newer Xcode donesn't work well. - # FIXME: Disabled due to: - # error: failed to parse registry's information for: serde - #- { toolchain: 1.13.0, os: macos-11 } - - { toolchain: 1.19.0, os: macos-11 } - - { toolchain: 1.24.0, os: macos-11 } - - { toolchain: 1.25.0, os: macos-11 } - - { toolchain: 1.30.0, os: macos-11 } + - { toolchain: stable, os: macos-14 } + - { toolchain: beta, os: macos-14 } + - { toolchain: nightly, os: macos-14 } + - { toolchain: 1.71.0, os: macos-14 } runs-on: ${{ matrix.target.os }} steps: - uses: actions/checkout@v4 @@ -255,10 +203,7 @@ jobs: fail-fast: true matrix: toolchain: [ - 1.19.0, - 1.24.0, - 1.25.0, - 1.30.0, + 1.71.0, stable, ] steps: @@ -291,11 +236,9 @@ jobs: needs: [ docker_linux_tier1, docker_linux_tier2, - #docker_linux_build_std, macos, windows, style_check, - docker_switch, build_channels_linux, build_channels_macos, build_channels_windows, diff --git a/Cargo.toml b/Cargo.toml index 062f76472fa9c..11b54fa0b3446 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libc" -version = "0.2.155" +version = "0.2.151" authors = ["The Rust Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" @@ -14,6 +14,7 @@ exclude = ["/ci/*", "/.github/*", "/.cirrus.yml", "/triagebot.toml"] description = """ Raw FFI bindings to platform libraries like libc. """ +rust-version = "1.71.0" [package.metadata.docs.rs] features = ["const-extern-fn", "extra_traits"] @@ -46,7 +47,8 @@ targets = [ "armv7-wrs-vxworks-eabihf", "armv7r-none-eabi", "armv7r-none-eabihf", - "hexagon-unknown-linux-musl", + # FIXME(hexagon): excluded due to duplicate symbol errors + # "hexagon-unknown-linux-musl", "i586-pc-windows-msvc", "i586-unknown-linux-gnu", "i586-unknown-linux-musl", @@ -61,13 +63,13 @@ targets = [ "i686-unknown-netbsd", "i686-unknown-openbsd", "i686-wrs-vxworks", + "loongarch64-unknown-linux-gnu", "mips-unknown-linux-gnu", "mips-unknown-linux-musl", "mips64-unknown-linux-gnuabi64", "mips64-unknown-linux-muslabi64", "mips64el-unknown-linux-gnuabi64", "mips64el-unknown-linux-muslabi64", - "mipsel-sony-psp", "mipsel-unknown-linux-gnu", "mipsel-unknown-linux-musl", "nvptx64-nvidia-cuda", @@ -139,8 +141,6 @@ align = [] rustc-dep-of-std = ['align', 'rustc-std-workspace-core'] extra_traits = [] const-extern-fn = [] -# use_std is deprecated, use `std` instead -use_std = ['std'] [workspace] members = ["libc-test"] diff --git a/README.md b/README.md index 395b94ce0c8f3..4b72be03179aa 100644 --- a/README.md +++ b/README.md @@ -47,25 +47,11 @@ libc = "0.2" If you use Rust >= 1.62, this feature is implicitly enabled. Otherwise it requires a nightly rustc. -* **deprecated**: `use_std` is deprecated, and is equivalent to `std`. - ## Rust version support -The minimum supported Rust toolchain version is currently **Rust 1.13.0**. +The minimum supported Rust toolchain version is currently **Rust 1.71.0** (libc does not currently have any policy regarding changes to the minimum -supported Rust version; such policy is a work in progress.) APIs requiring -newer Rust features are only available on newer Rust toolchains: - -| Feature | Version | -|----------------------|---------| -| `union` | 1.19.0 | -| `const mem::size_of` | 1.24.0 | -| `repr(align)` | 1.25.0 | -| `extra_traits` | 1.25.0 | -| `core::ffi::c_void` | 1.30.0 | -| `repr(packed(N))` | 1.33.0 | -| `cfg(target_vendor)` | 1.33.0 | -| `const-extern-fn` | 1.62.0 | +supported Rust version; such policy is a work in progress). ## Platform support diff --git a/build.rs b/build.rs index ee0d86edecb81..6bcaafc791715 100644 --- a/build.rs +++ b/build.rs @@ -1,7 +1,6 @@ use std::env; use std::process::Command; use std::str; -use std::string::String; // List of cfgs this build script is allowed to set. The list is needed to support check-cfg, as we // need to know all the possible cfgs that this script will set. If you need to set another cfg @@ -15,27 +14,14 @@ const ALLOWED_CFGS: &'static [&'static str] = &[ "freebsd13", "freebsd14", "freebsd15", - "libc_align", - "libc_cfg_target_vendor", "libc_const_extern_fn", "libc_const_extern_fn_unstable", - "libc_const_size_of", - "libc_core_cvoid", "libc_deny_warnings", - "libc_int128", - "libc_long_array", - "libc_non_exhaustive", - "libc_packedN", - "libc_priv_mod_use", - "libc_ptr_addr_of", - "libc_thread_local", - "libc_underscore_const_names", - "libc_union", ]; // Extra values to allow for check-cfg. const CHECK_CFG_EXTRA: &'static [(&'static str, &'static [&'static str])] = &[ - ("target_os", &["switch", "aix", "ohos", "hurd", "visionos"]), + ("target_os", &["switch", "aix", "ohos", "hurd"]), ("target_env", &["illumos", "wasi", "aix", "ohos"]), ( "target_arch", @@ -49,31 +35,30 @@ fn main() { let (rustc_minor_ver, is_nightly) = rustc_minor_nightly(); let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); - let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok(); - let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok(); let libc_ci = env::var("LIBC_CI").is_ok(); let libc_check_cfg = env::var("LIBC_CHECK_CFG").is_ok() || rustc_minor_ver >= 80; - - if env::var("CARGO_FEATURE_USE_STD").is_ok() { - println!( - "cargo:warning=\"libc's use_std cargo feature is deprecated since libc 0.2.55; \ - please consider using the `std` cargo feature instead\"" - ); - } + let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok(); // The ABI of libc used by std is backward compatible with FreeBSD 12. // The ABI of libc from crates.io is backward compatible with FreeBSD 11. // // On CI, we detect the actual FreeBSD version and match its ABI exactly, // running tests to ensure that the ABI is correct. - match which_freebsd() { - Some(10) if libc_ci => set_cfg("freebsd10"), - Some(11) if libc_ci => set_cfg("freebsd11"), - Some(12) if libc_ci || rustc_dep_of_std => set_cfg("freebsd12"), - Some(13) if libc_ci => set_cfg("freebsd13"), - Some(14) if libc_ci => set_cfg("freebsd14"), - Some(15) if libc_ci => set_cfg("freebsd15"), - Some(_) | None => set_cfg("freebsd11"), + let which_freebsd = if libc_ci { + which_freebsd().unwrap_or(11) + } else if rustc_dep_of_std { + 12 + } else { + 11 + }; + match which_freebsd { + x if x < 10 => panic!("FreeBSD older than 10 is not supported"), + 10 => set_cfg("freebsd10"), + 11 => set_cfg("freebsd11"), + 12 => set_cfg("freebsd12"), + 13 => set_cfg("freebsd13"), + 14 => set_cfg("freebsd14"), + _ => set_cfg("freebsd15"), } match emcc_version_code() { @@ -87,68 +72,6 @@ fn main() { set_cfg("libc_deny_warnings"); } - // Rust >= 1.15 supports private module use: - if rustc_minor_ver >= 15 || rustc_dep_of_std { - set_cfg("libc_priv_mod_use"); - } - - // Rust >= 1.19 supports unions: - if rustc_minor_ver >= 19 || rustc_dep_of_std { - set_cfg("libc_union"); - } - - // Rust >= 1.24 supports const mem::size_of: - if rustc_minor_ver >= 24 || rustc_dep_of_std { - set_cfg("libc_const_size_of"); - } - - // Rust >= 1.25 supports repr(align): - if rustc_minor_ver >= 25 || rustc_dep_of_std || align_cargo_feature { - set_cfg("libc_align"); - } - - // Rust >= 1.26 supports i128 and u128: - if rustc_minor_ver >= 26 || rustc_dep_of_std { - set_cfg("libc_int128"); - } - - // Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it. - // Otherwise, it defines an incompatible type to retaining - // backwards-compatibility. - if rustc_minor_ver >= 30 || rustc_dep_of_std { - set_cfg("libc_core_cvoid"); - } - - // Rust >= 1.33 supports repr(packed(N)) and cfg(target_vendor). - if rustc_minor_ver >= 33 || rustc_dep_of_std { - set_cfg("libc_packedN"); - set_cfg("libc_cfg_target_vendor"); - } - - // Rust >= 1.40 supports #[non_exhaustive]. - if rustc_minor_ver >= 40 || rustc_dep_of_std { - set_cfg("libc_non_exhaustive"); - } - - // Rust >= 1.47 supports long array: - if rustc_minor_ver >= 47 || rustc_dep_of_std { - set_cfg("libc_long_array"); - } - - if rustc_minor_ver >= 51 || rustc_dep_of_std { - set_cfg("libc_ptr_addr_of"); - } - - // Rust >= 1.37.0 allows underscores as anonymous constant names. - if rustc_minor_ver >= 37 || rustc_dep_of_std { - set_cfg("libc_underscore_const_names"); - } - - // #[thread_local] is currently unstable - if rustc_dep_of_std { - set_cfg("libc_thread_local"); - } - // Rust >= 1.62.0 allows to use `const_extern_fn` for "Rust" and "C". if rustc_minor_ver >= 62 { set_cfg("libc_const_extern_fn"); @@ -234,20 +157,14 @@ fn rustc_minor_nightly() -> (u32, bool) { } fn which_freebsd() -> Option { - let output = std::process::Command::new("freebsd-version").output().ok(); - if output.is_none() { - return None; - } - let output = output.unwrap(); + let output = std::process::Command::new("freebsd-version") + .output() + .ok()?; if !output.status.success() { return None; } - let stdout = String::from_utf8(output.stdout).ok(); - if stdout.is_none() { - return None; - } - let stdout = stdout.unwrap(); + let stdout = String::from_utf8(output.stdout).ok()?; match &stdout { s if s.starts_with("10") => Some(10), @@ -264,20 +181,12 @@ fn emcc_version_code() -> Option { let output = std::process::Command::new("emcc") .arg("-dumpversion") .output() - .ok(); - if output.is_none() { - return None; - } - let output = output.unwrap(); + .ok()?; if !output.status.success() { return None; } - let stdout = String::from_utf8(output.stdout).ok(); - if stdout.is_none() { - return None; - } - let version = stdout.unwrap(); + let version = String::from_utf8(output.stdout).ok()?; // Some Emscripten versions come with `-git` attached, so split the // version string also on the `-` char. diff --git a/ci/README.md b/ci/README.md index c8c23cfc947a9..c8da26f796557 100644 --- a/ci/README.md +++ b/ci/README.md @@ -158,7 +158,7 @@ about above), and then shut down. poweroff 1. Exit the post install shell: `exit` - 1. Back in in the installer choose Reboot + 1. Back in the installer choose Reboot 1. If all went well the machine should reboot and show a login prompt. If you switch to the serial console by choosing View > serial0 in the qemu menu, you should be logged in as root. diff --git a/ci/build.sh b/ci/build.sh index 41225f9cdffd6..512c9cfc9a12a 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -147,8 +147,6 @@ x86_64-unknown-redox \ RUST_APPLE_TARGETS="\ aarch64-apple-ios \ -x86_64-apple-darwin \ -x86_64-apple-ios \ " RUST_NIGHTLY_APPLE_TARGETS="\ @@ -211,6 +209,8 @@ for TARGET in $TARGETS; do done # Targets which are not available via rustup and must be built with -Zbuild-std +# FIXME(hexagon): hexagon-unknown-linux-musl should be tested but currently has +# duplicate symbol errors from `compiler_builtins`. RUST_LINUX_NO_CORE_TARGETS="\ aarch64-pc-windows-msvc \ aarch64-unknown-freebsd \ @@ -223,7 +223,6 @@ armebv7r-none-eabihf \ armv7-wrs-vxworks-eabihf \ armv7r-none-eabi \ armv7r-none-eabihf \ -hexagon-unknown-linux-musl \ i586-pc-windows-msvc \ i686-pc-windows-msvc \ i686-unknown-haiku \ @@ -238,7 +237,6 @@ mips64el-unknown-linux-gnuabi64 \ mips64el-unknown-linux-muslabi64 \ mipsel-unknown-linux-gnu \ mipsel-unknown-linux-musl \ -mipsel-sony-psp \ nvptx64-nvidia-cuda \ powerpc-unknown-linux-gnuspe \ powerpc-unknown-netbsd \ diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 9705c2ef1151a..8d85ad794ed53 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -1,7 +1,6 @@ [package] name = "libc-test" -version = "0.2.155" -edition = "2018" +version = "0.2.151" authors = ["The Rust Project Developers"] license = "MIT OR Apache-2.0" build = "build.rs" @@ -13,7 +12,7 @@ A test crate for the libc crate. [dependencies.libc] path = ".." -version = "0.2.155" +version = "0.2.151" default-features = false [build-dependencies] @@ -86,3 +85,8 @@ harness = true name = "semver" path = "test/semver.rs" harness = false + +[[test]] +name = "primitive_types" +path = "test/primitive_types.rs" +harness = true diff --git a/libc-test/build.rs b/libc-test/build.rs index 2bd6060ec33ec..f2c6c3ccddf5a 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -67,20 +67,7 @@ fn do_ctest() { } fn ctest_cfg() -> ctest::TestGenerator { - let mut cfg = ctest::TestGenerator::new(); - let libc_cfgs = [ - "libc_priv_mod_use", - "libc_union", - "libc_const_size_of", - "libc_align", - "libc_core_cvoid", - "libc_packedN", - "libc_thread_local", - ]; - for f in &libc_cfgs { - cfg.cfg(f, None); - } - cfg + ctest::TestGenerator::new() } fn do_semver() { @@ -95,7 +82,8 @@ fn do_semver() { let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap(); // `libc-test/semver` dir. - let mut semver_root = PathBuf::from("semver"); + let mut semver_root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); + semver_root.push("semver"); // NOTE: Windows has the same `family` as `os`, no point in including it // twice. @@ -105,10 +93,7 @@ fn do_semver() { if family != os && os != "android" { process_semver_file(&mut output, &mut semver_root, &family); } - // We don't do semver for unknown targets. - if vendor != "unknown" { - process_semver_file(&mut output, &mut semver_root, &vendor); - } + process_semver_file(&mut output, &mut semver_root, &vendor); process_semver_file(&mut output, &mut semver_root, &os); let os_arch = format!("{}-{}", os, arch); process_semver_file(&mut output, &mut semver_root, &os_arch); @@ -156,9 +141,6 @@ fn process_semver_file>(output: &mut W, path: &mut Path } fn main() { - // Avoid unnecessary re-building. - println!("cargo:rerun-if-changed=build.rs"); - do_cc(); do_ctest(); do_semver(); @@ -215,14 +197,6 @@ fn test_apple(target: &str) { "libproc.h", "limits.h", "locale.h", - "mach-o/dyld.h", - "mach/mach_init.h", - "mach/mach.h", - "mach/mach_time.h", - "mach/mach_types.h", - "mach/mach_vm.h", - "mach/thread_act.h", - "mach/thread_policy.h", "malloc/malloc.h", "net/bpf.h", "net/dlil.h", @@ -239,6 +213,7 @@ fn test_apple(target: &str) { "netinet/ip.h", "netinet/tcp.h", "netinet/udp.h", + "netinet6/in6_var.h", "os/lock.h", "os/signpost.h", "poll.h", @@ -319,6 +294,8 @@ fn test_apple(target: &str) { "tcp_connection_info" => true, // FIXME: The size is changed in recent macOSes. "malloc_introspection_t" => true, + // sonoma changes the padding `rmx_filler` field. + "rt_metrics" => true, _ => false, } @@ -334,10 +311,6 @@ fn test_apple(target: &str) { }); cfg.skip_const(move |name| { - // They're declared via `deprecated_mach` and we don't support it anymore. - if name.starts_with("VM_FLAGS_") { - return true; - } match name { // These OSX constants are removed in Sierra. // https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html @@ -354,9 +327,6 @@ fn test_apple(target: &str) { cfg.skip_fn(move |name| { // skip those that are manually verified match name { - // FIXME: https://github.com/rust-lang/libc/issues/1272 - "execv" | "execve" | "execvp" => true, - // close calls the close_nocancel system call "close" => true, @@ -384,6 +354,7 @@ fn test_apple(target: &str) { // MAXPATHLEN is too big for auto-derive traits on arrays. ("vnode_info_path", "vip_path") => true, ("ifreq", "ifr_ifru") => true, + ("in6_ifreq", "ifr_ifru") => true, ("ifkpi", "ifk_data") => true, ("ifconf", "ifc_ifcu") => true, _ => false, @@ -548,38 +519,11 @@ fn test_openbsd(target: &str) { } }); - cfg.skip_const(move |name| { - match name { - // Removed in OpenBSD 6.0 - "KERN_USERMOUNT" | "KERN_ARND" => true, - // Removed in OpenBSD 7.2 - "KERN_NSELCOLL" => true, - // Good chance it's going to be wrong depending on the host release - "KERN_MAXID" | "NET_RT_MAXID" => true, - "EV_SYSFLAGS" => true, - _ => false, - } - }); - cfg.skip_fn(move |name| { match name { - // FIXME: https://github.com/rust-lang/libc/issues/1272 - "execv" | "execve" | "execvp" | "execvpe" => true, - - // Removed in OpenBSD 6.5 - // https://marc.info/?l=openbsd-cvs&m=154723400730318 - "mincore" => true, - // futex() has volatile arguments, but that doesn't exist in Rust. "futex" => true, - // Available for openBSD 7.3 - "mimmutable" => true, - - // Removed in OpenBSD 7.5 - // https://marc.info/?l=openbsd-cvs&m=170239504300386 - "syscall" => true, - _ => false, } }); @@ -743,14 +687,7 @@ fn test_windows(target: &str) { } }); - cfg.skip_fn(move |name| { - match name { - // FIXME: https://github.com/rust-lang/libc/issues/1272 - "execv" | "execve" | "execvp" | "execvpe" => true, - - _ => false, - } - }); + cfg.skip_fn(|_| false); cfg.generate("../src/lib.rs", "main.rs"); } @@ -1023,7 +960,7 @@ fn test_solarish(target: &str) { "cfmakeraw" | "cfsetspeed" => true, // const-ness issues - "execv" | "execve" | "execvp" | "settimeofday" | "sethostname" => true, + "settimeofday" | "sethostname" => true, // Solaris-different "getpwent_r" | "getgrent_r" | "updwtmpx" if is_illumos => true, @@ -1231,8 +1168,6 @@ fn test_netbsd(target: &str) { cfg.skip_fn(move |name| { match name { - // FIXME: https://github.com/rust-lang/libc/issues/1272 - "execv" | "execve" | "execvp" => true, // FIXME: netbsd 10 minimum "getentropy" | "getrandom" => true, @@ -1460,9 +1395,6 @@ fn test_dragonflybsd(target: &str) { cfg.skip_fn(move |name| { // skip those that are manually verified match name { - // FIXME: https://github.com/rust-lang/libc/issues/1272 - "execv" | "execve" | "execvp" | "fexecve" => true, - "getrlimit" | "getrlimit64" | // non-int in 1st arg "setrlimit" | "setrlimit64" | // non-int in 1st arg "prlimit" | "prlimit64" // non-int in 2nd arg @@ -1618,7 +1550,6 @@ fn test_android(target: &str) { "sched.h", "semaphore.h", "signal.h", - "spawn.h", "stddef.h", "stdint.h", "stdio.h", @@ -1704,6 +1635,8 @@ fn test_android(target: &str) { "linux/netfilter/nfnetlink_log.h", "linux/netfilter/nfnetlink_queue.h", "linux/netfilter/nf_tables.h", + "linux/netfilter_arp.h", + "linux/netfilter_bridge.h", "linux/netfilter_ipv4.h", "linux/netfilter_ipv6.h", "linux/netfilter_ipv6/ip6_tables.h", @@ -1773,9 +1706,9 @@ fn test_android(target: &str) { // These are tested in the `linux_elf.rs` file. "Elf64_Phdr" | "Elf32_Phdr" => true, - // These are intended to be opaque - "posix_spawn_file_actions_t" => true, - "posix_spawnattr_t" => true, + + // FIXME: Somehow fails to test after removing cfg hacks: + "__uint128" => true, _ => false, } }); @@ -1958,8 +1891,8 @@ fn test_android(target: &str) { cfg.skip_fn(move |name| { // skip those that are manually verified match name { - // FIXME: https://github.com/rust-lang/libc/issues/1272 - "execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true, + // FIXME: for unknown reasons linker unable to find "fexecve" + "fexecve" => true, // There are two versions of the sterror_r function, see // @@ -1981,7 +1914,7 @@ fn test_android(target: &str) { "__system_property_wait" => true, // Added in API level 30, but tests use level 28. - "mlock2" => true, + "memfd_create" | "mlock2" | "renameat2" | "statx" | "statx_timestamp" => true, // Added in glibc 2.25. "getentropy" => true, @@ -2286,6 +2219,12 @@ fn test_freebsd(target: &str) { // should've been used anywhere anyway. "TDF_UNUSED23" => true, + // Removed in FreeBSD 15 + "TDF_CANSWAP" | "TDF_SWAPINREQ" => true, + + // Unaccessible in FreeBSD 15 + "TDI_SWAPPED" | "P_SWAPPINGOUT" | "P_SWAPPINGIN" => true, + // Removed in FreeBSD 14 (git a6b55ee6be1) "IFF_KNOWSEPOCH" => true, @@ -2348,7 +2287,7 @@ fn test_freebsd(target: &str) { true } - // Added in in FreeBSD 13.0 (r367776 and r367287) + // Added in FreeBSD 13.0 (r367776 and r367287) "SCM_CREDS2" | "LOCAL_CREDS_PERSISTENT" if Some(13) > freebsd_ver => true, // Added in FreeBSD 14 @@ -2479,8 +2418,18 @@ fn test_freebsd(target: &str) { true } + // Added in FreeBSD 14.1 + "KCMP_FILE" | "KCMP_FILEOBJ" | "KCMP_FILES" | "KCMP_SIGHAND" | "KCMP_VM" + if Some(14) > freebsd_ver => + { + true + } + // FIXME: Removed in FreeBSD 15: - "LOCAL_CONNWAIT" if freebsd_ver >= Some(15) => true, + "LOCAL_CONNWAIT" => true, + + // FIXME: The values has been changed in FreeBSD 15: + "CLOCK_BOOTTIME" if Some(15) <= freebsd_ver => true, _ => false, } @@ -2540,10 +2489,6 @@ fn test_freebsd(target: &str) { cfg.skip_fn(move |name| { // skip those that are manually verified match name { - // FIXME: https://github.com/rust-lang/libc/issues/1272 - // execvpe is introduced in FreeBSD 14.1. - "execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true, - // The `uname` function in the `utsname.h` FreeBSD header is a C // inline function (has no symbol) that calls the `__xuname` symbol. // Therefore the function pointer comparison does not make sense for it. @@ -2593,6 +2538,9 @@ fn test_freebsd(target: &str) { true } + // Those are introduced in FreeBSD 14.1. + "kcmp" => true, + _ => false, } }); @@ -3143,9 +3091,6 @@ fn test_neutrino(target: &str) { cfg.skip_fn(move |name| { // skip those that are manually verified match name { - // FIXME: https://github.com/rust-lang/libc/issues/1272 - "execv" | "execve" | "execvp" | "execvpe" => true, - // wrong signature "signal" => true, @@ -3379,7 +3324,6 @@ fn test_linux(target: &str) { "netinet/ip.h", "netinet/tcp.h", "netinet/udp.h", - "netpacket/packet.h", "poll.h", "pthread.h", "pty.h", @@ -3462,8 +3406,7 @@ fn test_linux(target: &str) { // Include linux headers at the end: headers! { cfg: - [loongarch64]: "asm/hwcap.h", - [riscv64]: "asm/hwcap.h", + [loongarch64 || riscv64]: "asm/hwcap.h", "asm/mman.h", [gnu]: "linux/aio_abi.h", "linux/can.h", @@ -3481,6 +3424,7 @@ fn test_linux(target: &str) { "linux/if_addr.h", "linux/if_alg.h", "linux/if_ether.h", + "linux/if_packet.h", "linux/if_tun.h", "linux/if_xdp.h", "linux/input.h", @@ -3500,6 +3444,8 @@ fn test_linux(target: &str) { "linux/netfilter/nfnetlink_log.h", "linux/netfilter/nfnetlink_queue.h", "linux/netfilter/nf_tables.h", + "linux/netfilter_arp.h", + "linux/netfilter_bridge.h", "linux/netfilter_ipv4.h", "linux/netfilter_ipv6.h", "linux/netfilter_ipv6/ip6_tables.h", @@ -3587,6 +3533,14 @@ fn test_linux(target: &str) { }); cfg.skip_type(move |ty| { + // FIXME: very recent additions to musl, not yet released. + // also apparently some glibc versions + if ty == "Elf32_Relr" || ty == "Elf64_Relr" { + return true; + } + if sparc64 && (ty == "Elf32_Rela" || ty == "Elf64_Rela") { + return true; + } match ty { // FIXME: `sighandler_t` type is incorrect, see: // https://github.com/rust-lang/libc/issues/1359 @@ -3612,6 +3566,9 @@ fn test_linux(target: &str) { "priority_t" if musl => true, "name_t" if musl => true, + // FIXME: Somehow fails to test after removing cfg hacks: + "__uint128" => true, + t => { if musl { // LFS64 types have been removed in musl 1.2.4+ @@ -3657,6 +3614,23 @@ fn test_linux(target: &str) { if (gnu && sparc64) && (ty == "ip_mreqn" || ty == "hwtstamp_config") { return true; } + // FIXME: pass by value for structs that are not an even 32/64 bits on + // big-endian systems corrupts the value for unknown reasons. + if (sparc64 || ppc || ppc64 || s390x) + && (ty == "sockaddr_pkt" + || ty == "tpacket_auxdata" + || ty == "tpacket_hdr_variant1" + || ty == "tpacket_req3" + || ty == "tpacket_stats_v3" + || ty == "tpacket_req_u") + { + return true; + } + // FIXME: musl doesn't compile with `struct fanout_args` for unknown reasons. + if musl && ty == "fanout_args" { + return true; + } + match ty { // These cannot be tested when "resolv.h" is included and are tested // in the `linux_elf.rs` file. @@ -3835,10 +3809,6 @@ fn test_linux(target: &str) { if name.starts_with("NI_IDN") { return true; } - // FIXME: Requires >= 6.3 kernel headers - if name == "MFD_NOEXEC_SEAL" || name == "MFD_EXEC" { - return true; - } } match name { // These constants are not available if gnu headers have been included @@ -3920,10 +3890,7 @@ fn test_linux(target: &str) { if ppc64 || riscv64 => true, // FIXME: requires more recent kernel headers on CI - | "MFD_EXEC" - | "MFD_NOEXEC_SEAL" - | "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" - if sparc64 => true, + "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" if sparc64 => true, // FIXME: Not currently available in headers on ARM and musl. "NETLINK_GET_STRICT_CHK" if arm || musl => true, @@ -3995,9 +3962,15 @@ fn test_linux(target: &str) { | "MINSIGSTKSZ" if gnu => true, - // FIXME: Linux >= 5.16 changed its value: + // FIXME: Linux >= 5.10: + // https://github.com/torvalds/linux/commit/d25e2e9388eda61b6e298585024ee3355f50c493 + "NF_INET_INGRESS" if musl => true, + + // FIXME: Linux >= 5.16: // https://github.com/torvalds/linux/commit/42df6e1d221dddc0f2acf2be37e68d553ad65f96 - "NF_NETDEV_NUMHOOKS" => true, + "NF_NETDEV_EGRESS" if musl || sparc64 => true, + // value changed + "NF_NETDEV_NUMHOOKS" if musl || sparc64 => true, // FIXME: requires Linux >= 5.6: | "RESOLVE_BENEATH" @@ -4161,6 +4134,9 @@ fn test_linux(target: &str) { true } + // FIXME: Requires >= 6.6 kernel headers. + "SYS_fchmodat2" => true, + // FIXME: seems to not be available all the time (from : "PF_VCPU" | "PF_IDLE" @@ -4203,9 +4179,6 @@ fn test_linux(target: &str) { cfg.skip_fn(move |name| { // skip those that are manually verified match name { - // FIXME: https://github.com/rust-lang/libc/issues/1272 - "execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true, - // There are two versions of the sterror_r function, see // // https://linux.die.net/man/3/strerror_r @@ -4376,12 +4349,18 @@ fn test_linux(target: &str) { // Linux >= 5.11 tweaked the `svm_zero` field of the `sockaddr_vm` struct. // https://github.com/torvalds/linux/commit/dc8eeef73b63ed8988224ba6b5ed19a615163a7f (struct_ == "sockaddr_vm" && field == "svm_zero") || + // Linux >= 5.11 had added the svm_flags field to the `sockaddr_vm` struct. + (struct_ == "sockaddr_vm" && field == "svm_flags") || // the `ifr_ifru` field is an anonymous union (struct_ == "ifreq" && field == "ifr_ifru") || // the `ifc_ifcu` field is an anonymous union (struct_ == "ifconf" && field == "ifc_ifcu") || // glibc uses a single array `uregs` instead of individual fields. - (struct_ == "user_regs" && arm) + (struct_ == "user_regs" && arm) || + // the `ifr_ifrn` field is an anonymous union + (struct_ == "iwreq" && field == "ifr_ifrn") || + // the `key` field is a zero-sized array + (struct_ == "iw_encode_ext" && field == "key") }); cfg.skip_roundtrip(move |s| match s { @@ -4790,8 +4769,6 @@ fn test_haiku(target: &str) { cfg.skip_fn(move |name| { // skip those that are manually verified match name { - // FIXME: https://github.com/rust-lang/libc/issues/1272 - "execv" | "execve" | "execvp" | "execvpe" => true, // FIXME: does not exist on haiku "open_wmemstream" => true, "mlockall" | "munlockall" => true, diff --git a/libc-test/semver/TODO-linux.txt b/libc-test/semver/TODO-linux.txt index 7855498efafcf..8427cf1ea12c8 100644 --- a/libc-test/semver/TODO-linux.txt +++ b/libc-test/semver/TODO-linux.txt @@ -1,4 +1,4 @@ -# The following symbols are not not available in some combinations of +# The following symbols are not available in some combinations of # musl/gnu/android and/or architecture. KEYCTL_CAPABILITIES KEYCTL_CAPS0_BIG_KEY diff --git a/libc-test/semver/android-aarch64.txt b/libc-test/semver/android-aarch64.txt index 8a38e32dd5022..cc95c6a29f25b 100644 --- a/libc-test/semver/android-aarch64.txt +++ b/libc-test/semver/android-aarch64.txt @@ -10,8 +10,7 @@ HWCAP2_SVESM4 PROT_BTI PROT_MTE SYS_arch_specific_syscall -SYS_lseek -SYS_mmap +SYS_memfd_secret SYS_syscalls SYS_fcntl __system_property_wait diff --git a/libc-test/semver/android-i686.txt b/libc-test/semver/android-i686.txt index eb6ecadba60b5..78911584cbf2d 100644 --- a/libc-test/semver/android-i686.txt +++ b/libc-test/semver/android-i686.txt @@ -1,3 +1,4 @@ +SYS_memfd_secret __c_anonymous_uc_sigmask __c_anonymous_uc_sigmask_with_padding time64_t diff --git a/libc-test/semver/android-x86_64.txt b/libc-test/semver/android-x86_64.txt index c4bb87bccb66d..3aa3a6a77a638 100644 --- a/libc-test/semver/android-x86_64.txt +++ b/libc-test/semver/android-x86_64.txt @@ -44,6 +44,7 @@ SYS_arch_prctl SYS_epoll_ctl_old SYS_epoll_wait_old SYS_kexec_file_load +SYS_memfd_secret SYS_msgctl SYS_msgget SYS_msgrcv diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 21b277a018747..5375b80d8a186 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -627,7 +627,6 @@ FUTEX_CMP_REQUEUE FUTEX_CMP_REQUEUE_PI FUTEX_FD FUTEX_LOCK_PI -FUTEX_LOCK_PI2 FUTEX_PRIVATE_FLAG FUTEX_REQUEUE FUTEX_TRYLOCK_PI @@ -1215,9 +1214,7 @@ MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ MFD_ALLOW_SEALING MFD_CLOEXEC -MFD_EXEC MFD_HUGETLB -MFD_NOEXEC_SEAL MINIX2_SUPER_MAGIC MINIX2_SUPER_MAGIC2 MINIX_SUPER_MAGIC @@ -1647,8 +1644,29 @@ NFULNL_COPY_PACKET NFULNL_MSG_CONFIG NFULNL_MSG_PACKET NF_ACCEPT +NF_ARP +NF_ARP_FORWARD +NF_ARP_IN +NF_ARP_NUMHOOKS +NF_ARP_OUT +NF_BR_BROUTING +NF_BR_FORWARD +NF_BR_LOCAL_IN +NF_BR_LOCAL_OUT +NF_BR_NUMHOOKS +NF_BR_POST_ROUTING +NF_BR_PRE_ROUTING +NF_BR_PRI_BRNF +NF_BR_PRI_FILTER_BRIDGED +NF_BR_PRI_FILTER_OTHER +NF_BR_PRI_FIRST +NF_BR_PRI_LAST +NF_BR_PRI_NAT_DST_BRIDGED +NF_BR_PRI_NAT_DST_OTHER +NF_BR_PRI_NAT_SRC NF_DROP NF_INET_FORWARD +NF_INET_INGRESS NF_INET_LOCAL_IN NF_INET_LOCAL_OUT NF_INET_NUMHOOKS @@ -1670,6 +1688,7 @@ NF_IP6_PRI_MANGLE NF_IP6_PRI_NAT_DST NF_IP6_PRI_NAT_SRC NF_IP6_PRI_RAW +NF_IP6_PRI_RAW_BEFORE_DEFRAG NF_IP6_PRI_SECURITY NF_IP6_PRI_SELINUX_FIRST NF_IP6_PRI_SELINUX_LAST @@ -1690,10 +1709,12 @@ NF_IP_PRI_MANGLE NF_IP_PRI_NAT_DST NF_IP_PRI_NAT_SRC NF_IP_PRI_RAW +NF_IP_PRI_RAW_BEFORE_DEFRAG NF_IP_PRI_SECURITY NF_IP_PRI_SELINUX_FIRST NF_IP_PRI_SELINUX_LAST NF_MAX_VERDICT +NF_NETDEV_EGRESS NF_NETDEV_INGRESS NF_NETDEV_NUMHOOKS NF_QUEUE @@ -2032,6 +2053,7 @@ RTLD_LAZY RTLD_LOCAL RTLD_NOLOAD RTLD_NOW +RTLD_NODELETE TCA_UNSPEC TCA_KIND TCA_OPTIONS @@ -2452,7 +2474,9 @@ SYS_clock_gettime SYS_clock_nanosleep SYS_clock_settime SYS_clone +SYS_clone3 SYS_close +SYS_close_range SYS_connect SYS_copy_file_range SYS_delete_module @@ -2461,12 +2485,14 @@ SYS_dup3 SYS_epoll_create1 SYS_epoll_ctl SYS_epoll_pwait +SYS_epoll_pwait2 SYS_eventfd2 SYS_execve SYS_execveat SYS_exit SYS_exit_group SYS_faccessat +SYS_faccessat2 SYS_fallocate SYS_fanotify_init SYS_fanotify_mark @@ -2488,6 +2514,7 @@ SYS_fsopen SYS_fspick SYS_fsync SYS_futex +SYS_futex_waitv SYS_get_mempolicy SYS_get_robust_list SYS_getcpu @@ -2533,6 +2560,9 @@ SYS_kcmp SYS_kexec_load SYS_keyctl SYS_kill +SYS_landlock_add_rule +SYS_landlock_create_ruleset +SYS_landlock_restrict_self SYS_lgetxattr SYS_linkat SYS_listen @@ -2552,6 +2582,7 @@ SYS_mlock SYS_mlock2 SYS_mlockall SYS_mount +SYS_mount_setattr SYS_move_mount SYS_move_pages SYS_mprotect @@ -2572,8 +2603,11 @@ SYS_nfsservctl SYS_open_by_handle_at SYS_open_tree SYS_openat +SYS_openat2 SYS_perf_event_open SYS_personality +SYS_pidfd_getfd +SYS_pidfd_open SYS_pidfd_send_signal SYS_pipe2 SYS_pivot_root @@ -2586,6 +2620,8 @@ SYS_pread64 SYS_preadv SYS_preadv2 SYS_prlimit64 +SYS_process_madvise +SYS_process_mrelease SYS_process_vm_readv SYS_process_vm_writev SYS_pselect6 @@ -2594,6 +2630,7 @@ SYS_pwrite64 SYS_pwritev SYS_pwritev2 SYS_quotactl +SYS_quotactl_fd SYS_read SYS_readahead SYS_readlinkat @@ -2633,6 +2670,7 @@ SYS_sendmmsg SYS_sendmsg SYS_sendto SYS_set_mempolicy +SYS_set_mempolicy_home_node SYS_set_robust_list SYS_set_tid_address SYS_setdomainname @@ -2921,21 +2959,6 @@ _SC_HOST_NAME_MAX _SC_IOV_MAX _SC_IPV6 _SC_JOB_CONTROL -_SC_LEVEL1_DCACHE_ASSOC -_SC_LEVEL1_DCACHE_LINESIZE -_SC_LEVEL1_DCACHE_SIZE -_SC_LEVEL1_ICACHE_ASSOC -_SC_LEVEL1_ICACHE_LINESIZE -_SC_LEVEL1_ICACHE_SIZE -_SC_LEVEL2_CACHE_ASSOC -_SC_LEVEL2_CACHE_LINESIZE -_SC_LEVEL2_CACHE_SIZE -_SC_LEVEL3_CACHE_ASSOC -_SC_LEVEL3_CACHE_LINESIZE -_SC_LEVEL3_CACHE_SIZE -_SC_LEVEL4_CACHE_ASSOC -_SC_LEVEL4_CACHE_LINESIZE -_SC_LEVEL4_CACHE_SIZE _SC_LINE_MAX _SC_LOGIN_NAME_MAX _SC_MAPPED_FILES @@ -3006,7 +3029,6 @@ _SC_TRACE_USER_EVENT_MAX _SC_TTY_NAME_MAX _SC_TYPED_MEMORY_OBJECTS _SC_TZNAME_MAX -_SC_UIO_MAXIOV _SC_V7_ILP32_OFF32 _SC_V7_ILP32_OFFBIG _SC_V7_LP64_OFF64 @@ -3373,6 +3395,7 @@ memalign memchr memcmp memcpy +memfd_create memmem memmove memrchr @@ -3388,6 +3411,7 @@ mknodat mkstemp mktime mlock +mlock2 mlockall mmap mmap64 @@ -3577,6 +3601,7 @@ remove removexattr rename renameat +renameat2 res_init rewind rewinddir @@ -3701,6 +3726,8 @@ statfs statfs64 statvfs statvfs64 +statx +statx_timestamp strcasecmp strcasestr strcat @@ -3812,7 +3839,6 @@ utimes utmp utmpname utsname -vfork vmsplice wait wait4 diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index e01934bf0ceb3..b4e91dd083463 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -428,6 +428,7 @@ FSOPT_REPORT_FULLSIZE FSOPT_RETURN_REALDEV F_ALLOCATEALL F_ALLOCATECONTIG +F_ALLOCATEPERSIST F_BARRIERFSYNC F_FREEZE_FS F_FULLFSYNC @@ -1355,9 +1356,6 @@ STA_RONLY STA_UNSYNC ST_NOSUID ST_RDONLY -SUPERPAGE_NONE -SUPERPAGE_SIZE_2MB -SUPERPAGE_SIZE_ANY SYSPROTO_CONTROL SYSPROTO_EVENT S_IEXEC @@ -1518,95 +1516,10 @@ UTUN_OPT_IFNAME VDISCARD VDSUSP VLNEXT -VM_FLAGS_ALIAS_MASK -VM_FLAGS_ANYWHERE -VM_FLAGS_FIXED -VM_FLAGS_NO_CACHE -VM_FLAGS_OVERWRITE -VM_FLAGS_PURGABLE -VM_FLAGS_RANDOM_ADDR -VM_FLAGS_RESILIENT_CODESIGN -VM_FLAGS_RESILIENT_MEDIA -VM_FLAGS_RETURN_4K_DATA_ADDR -VM_FLAGS_RETURN_DATA_ADDR -VM_FLAGS_SUPERPAGE_MASK -VM_FLAGS_SUPERPAGE_NONE -VM_FLAGS_SUPERPAGE_SHIFT -VM_FLAGS_SUPERPAGE_SIZE_2MB -VM_FLAGS_SUPERPAGE_SIZE_ANY -VM_FLAGS_USER_ALLOCATE -VM_FLAGS_USER_MAP -VM_FLAGS_USER_REMAP VM_LOADAVG VM_MACHFACTOR VM_MAKE_TAG VM_MAXID -VM_MEMORY_ACCELERATE -VM_MEMORY_ANALYSIS_TOOL -VM_MEMORY_APPKIT -VM_MEMORY_APPLICATION_SPECIFIC_1 -VM_MEMORY_APPLICATION_SPECIFIC_16 -VM_MEMORY_ASL -VM_MEMORY_ASSETSD -VM_MEMORY_ATS -VM_MEMORY_CARBON -VM_MEMORY_CGIMAGE -VM_MEMORY_COREDATA -VM_MEMORY_COREDATA_OBJECTIDS -VM_MEMORY_COREGRAPHICS -VM_MEMORY_COREGRAPHICS_BACKINGSTORES -VM_MEMORY_COREGRAPHICS_DATA -VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS -VM_MEMORY_COREGRAPHICS_MISC -VM_MEMORY_COREGRAPHICS_SHARED -VM_MEMORY_COREGRAPHICS_XALLOC -VM_MEMORY_COREIMAGE -VM_MEMORY_COREPROFILE -VM_MEMORY_CORESERVICES -VM_MEMORY_COREUI -VM_MEMORY_COREUIFILE -VM_MEMORY_CORPSEINFO -VM_MEMORY_DHMM -VM_MEMORY_DYLD -VM_MEMORY_DYLD_MALLOC -VM_MEMORY_DYLIB -VM_MEMORY_FOUNDATION -VM_MEMORY_GENEALOGY -VM_MEMORY_GLSL -VM_MEMORY_GUARD -VM_MEMORY_IMAGEIO -VM_MEMORY_IOKIT -VM_MEMORY_JAVA -VM_MEMORY_JAVASCRIPT_CORE -VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR -VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE -VM_MEMORY_LAYERKIT -VM_MEMORY_LIBDISPATCH -VM_MEMORY_MACH_MSG -VM_MEMORY_MALLOC -VM_MEMORY_MALLOC_HUGE -VM_MEMORY_MALLOC_LARGE -VM_MEMORY_MALLOC_LARGE_REUSABLE -VM_MEMORY_MALLOC_LARGE_REUSED -VM_MEMORY_MALLOC_NANO -VM_MEMORY_MALLOC_SMALL -VM_MEMORY_MALLOC_TINY -VM_MEMORY_OBJC_DISPATCHERS -VM_MEMORY_OPENCL -VM_MEMORY_OS_ALLOC_ONCE -VM_MEMORY_RAWCAMERA -VM_MEMORY_REALLOC -VM_MEMORY_SBRK -VM_MEMORY_SCENEKIT -VM_MEMORY_SHARED_PMAP -VM_MEMORY_SKYWALK -VM_MEMORY_SQLITE -VM_MEMORY_STACK -VM_MEMORY_SWIFT_METADATA -VM_MEMORY_SWIFT_RUNTIME -VM_MEMORY_TCMALLOC -VM_MEMORY_UNSHARED_PMAP -VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS VM_METER VM_PROT_EXECUTE VM_PROT_NONE @@ -1687,7 +1600,6 @@ _IOFBF _IOLBF _IONBF _NSGetEnviron -_NSGetExecutablePath _POSIX_VDISABLE _PTHREAD_COND_SIG_init _PTHREAD_MUTEX_SIG_init @@ -1822,10 +1734,6 @@ __PTHREAD_RWLOCKATTR_SIZE__ __PTHREAD_RWLOCK_SIZE__ __darwin_mcontext64 __error -_dyld_get_image_header -_dyld_get_image_name -_dyld_get_image_vmaddr_slide -_dyld_image_count abs acct aio_cancel @@ -1953,9 +1861,7 @@ getxattr glob glob_t globfree -iconv -iconv_close -iconv_open +icmp6_ifstat iconv_t id_t idtype_t @@ -1969,6 +1875,9 @@ ifkpi ifreq image_offset in6_pktinfo +in6_addrlifetime +in6_ifreq +in6_ifstat in_pktinfo initgroups integer_t @@ -1990,18 +1899,6 @@ lockf log2phys login_tty lutimes -mach_absolute_time -mach_header -mach_header_64 -mach_host_self -mach_port_t -mach_thread_self -mach_timebase_info -mach_timebase_info_data_t -mach_vm_address_t -mach_vm_map -mach_vm_offset_t -mach_vm_size_t madvise malloc_default_zone malloc_good_size @@ -2126,8 +2023,6 @@ pthread_cancel pthread_condattr_getpshared pthread_condattr_setpshared pthread_cpu_number_np -pthread_create_from_mach_thread -pthread_from_mach_thread_np pthread_get_stackaddr_np pthread_get_stacksize_np pthread_getname_np @@ -2266,6 +2161,7 @@ timeval32 timex truncate ttyname_r +u_quad_t ucontext_t unmount useconds_t diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index febed0b3a7aa9..a0cc6c6c83fc5 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -326,9 +326,6 @@ GLOB_NOESCAPE GLOB_NOMATCH GLOB_NOSORT GLOB_NOSPACE -GRND_INSECURE -GRND_NONBLOCK -GRND_RANDOM HW_BYTEORDER HW_DISKNAMES HW_DISKSTATS @@ -1311,7 +1308,6 @@ fstatfs futimes getdomainname getdtablesize -getentropy getgrent getgrent_r getgrgid @@ -1335,7 +1331,6 @@ getprogname getpwent getpwent_r getpwnam_r -getrandom getresgid getresuid getrlimit @@ -1592,3 +1587,5 @@ xucred eaccess dirname basename +IP_RECVTTL +IPV6_RECVHOPLIMIT diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 0ecf213448247..bb6d67c6d0079 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -144,6 +144,100 @@ BUFSIZ BUS_ADRALN BUS_ADRERR BUS_OBJERR +CAP_READ +CAP_RIGHTS_VERSION_00 +CAP_RIGHTS_VERSION +CAP_WRITE +CAP_SEEK_TELL +CAP_SEEK +CAP_PREAD +CAP_PWRITE +CAP_MMAP +CAP_MMAP_R +CAP_MMAP_W +CAP_MMAP_X +CAP_MMAP_RW +CAP_MMAP_RX +CAP_MMAP_WX +CAP_MMAP_RWX +CAP_CREATE +CAP_FEXECVE +CAP_FSYNC +CAP_FTRUNCATE +CAP_LOOKUP +CAP_FCHDIR +CAP_FCHFLAGS +CAP_CHFLAGSAT +CAP_FCHMOD +CAP_FCHMODAT +CAP_FCHOWN +CAP_FCHOWNAT +CAP_FCNTL +CAP_FLOCK +CAP_FPATHCONF +CAP_FSCK +CAP_FSTAT +CAP_FSTATAT +CAP_FSTATFS +CAP_FUTIMES +CAP_FUTIMESAT +CAP_LINKAT_TARGET +CAP_MKDIRAT +CAP_MKFIFOAT +CAP_MKNODAT +CAP_RENAMEAT_SOURCE +CAP_SYMLINKAT +CAP_UNLINKAT +CAP_ACCEPT +CAP_BIND +CAP_CONNECT +CAP_GETPEERNAME +CAP_GETSOCKNAME +CAP_GETSOCKOPT +CAP_LISTEN +CAP_PEELOFF +CAP_RECV +CAP_SEND +CAP_SETSOCKOPT +CAP_SHUTDOWN +CAP_BINDAT +CAP_CONNECTAT +CAP_LINKAT_SOURCE +CAP_RENAMEAT_TARGET +CAP_SOCK_CLIENT +CAP_SOCK_SERVER +CAP_ALL0 +CAP_UNUSED0_44 +CAP_UNUSED0_57 +CAP_MAC_GET +CAP_MAC_SET +CAP_SEM_GETVALUE +CAP_SEM_POST +CAP_SEM_WAIT +CAP_EVENT +CAP_KQUEUE_EVENT +CAP_IOCTL +CAP_TTYHOOK +CAP_PDGETPID +CAP_PDWAIT +CAP_PDKILL +CAP_EXTATTR_DELETE +CAP_EXTATTR_GET +CAP_EXTATTR_LIST +CAP_EXTATTR_SET +CAP_ACL_CHECK +CAP_ACL_DELETE +CAP_ACL_GET +CAP_ACL_SET +CAP_KQUEUE_CHANGE +CAP_KQUEUE +CAP_ALL1 +CAP_UNUSED1_22 +CAP_UNUSED1_57 +CAP_FCNTL_GETFL +CAP_FCNTL_SETFL +CAP_FCNTL_GETOWN +CAP_FCNTL_SETOWN CCAR_OFLOW CCTS_OFLOW CDSR_OFLOW @@ -592,6 +686,11 @@ JAIL_SYS_DISABLE JAIL_SYS_INHERIT JAIL_SYS_NEW JAIL_UPDATE +KCMP_FILE +KCMP_FILEOBJ +KCMP_FILES +KCMP_SIGHAND +KCMP_VM KENV_GET KENV_SET KENV_UNSET @@ -1879,6 +1978,7 @@ jail_get jail_remove jail_set jrand48 +kcmp kevent key_t killpg @@ -2252,3 +2352,5 @@ closefrom close_range eventfd_read eventfd_write +IP_RECVTTL +IPV6_RECVHOPLIMIT diff --git a/libc-test/semver/linux-aarch64.txt b/libc-test/semver/linux-aarch64.txt index a4ab1b2e568e0..6c92db32d8104 100644 --- a/libc-test/semver/linux-aarch64.txt +++ b/libc-test/semver/linux-aarch64.txt @@ -38,6 +38,8 @@ BPF_W BPF_X BPF_XOR CIBAUD +Elf32_Rela +Elf64_Rela FICLONE FICLONERANGE MADV_SOFT_OFFLINE diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 09625b8280c5a..79c051f4c7c50 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -511,6 +511,9 @@ XSK_UNALIGNED_BUF_ADDR_MASK XDP_PKT_CONTD XENFS_SUPER_MAGIC XFS_SUPER_MAGIC +_CS_GNU_LIBC_VERSION +_CS_GNU_LIBPTHREAD_VERSION +_CS_PATH _SC_2_C_VERSION _SC_BASE _SC_CHARCLASS_NAME_MAX @@ -611,18 +614,19 @@ aio_write aiocb backtrace clock_adjtime +confstr copy_file_range ctermid dlinfo dlmopen endutxent explicit_bzero +fgetgrent_r fgetspent_r futimes getauxval getentropy getgrent_r -fgetgrent_r getloadavg getpt getpwent_r @@ -643,6 +647,7 @@ lio_listio mallinfo mallinfo2 malloc_info +malloc_stats malloc_trim malloc_usable_size mallopt @@ -691,6 +696,9 @@ euidaccess eaccess asctime_r ctime_r +strftime +strftime_l +strptime dirname posix_basename gnu_basename diff --git a/libc-test/semver/linux-i686.txt b/libc-test/semver/linux-i686.txt index a14498adc8396..aa379e1dcec62 100644 --- a/libc-test/semver/linux-i686.txt +++ b/libc-test/semver/linux-i686.txt @@ -13,6 +13,8 @@ EDI EDX EFL EIP +Elf32_Rela +Elf64_Rela ES ESI FS diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index 7e5a81194bdf8..f6e293aa9b7fc 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -56,13 +56,22 @@ aio_return aio_suspend aio_write aiocb +asctime_r +basename clock_adjtime copy_file_range ctermid +dirname +eaccess +endutxent +euidaccess explicit_bzero futimes getauxval getloadavg +getutxent +getutxid +getutxline lio_listio ntptimeval open_wmemstream @@ -71,11 +80,11 @@ prlimit prlimit64 process_vm_readv process_vm_writev +pututxline pwritev64 reallocarray +setutxent +strftime +strftime_l +strptime timex -euidaccess -eaccess -asctime_r -dirname -basename diff --git a/libc-test/semver/linux-powerpc64.txt b/libc-test/semver/linux-powerpc64.txt index 99be508e6bd59..77718d9ce47f0 100644 --- a/libc-test/semver/linux-powerpc64.txt +++ b/libc-test/semver/linux-powerpc64.txt @@ -2,6 +2,8 @@ B2500000 B3000000 B3500000 B4000000 +Elf32_Rela +Elf64_Rela KEYCTL_CAPABILITIES KEYCTL_CAPS0_BIG_KEY KEYCTL_CAPS0_CAPABILITIES diff --git a/libc-test/semver/linux-riscv64gc.txt b/libc-test/semver/linux-riscv64gc.txt index 2691801511782..dcaa86e7eab6e 100644 --- a/libc-test/semver/linux-riscv64gc.txt +++ b/libc-test/semver/linux-riscv64gc.txt @@ -3,6 +3,8 @@ B3000000 B3500000 B4000000 CIBAUD +Elf32_Rela +Elf64_Rela KEYCTL_CAPABILITIES KEYCTL_CAPS0_BIG_KEY KEYCTL_CAPS0_CAPABILITIES diff --git a/libc-test/semver/linux-x86_64.txt b/libc-test/semver/linux-x86_64.txt index 6ad111e7308cc..8ae1037764e84 100644 --- a/libc-test/semver/linux-x86_64.txt +++ b/libc-test/semver/linux-x86_64.txt @@ -40,6 +40,8 @@ BPF_XOR CIBAUD CS DS +Elf32_Rela +Elf64_Rela ES FS GS diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 1e0ac781ef7d9..b09fd745357fd 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -416,8 +416,14 @@ EKEYREJECTED EKEYREVOKED EL2HLT EL2NSYNC +ELF32_R_SYM +ELF32_R_TYPE +ELF32_R_INFO EL3HLT EL3RST +ELF64_R_SYM +ELF64_R_TYPE +ELF64_R_INFO ELFCLASS32 ELFCLASS64 ELFCLASSNONE @@ -695,17 +701,24 @@ Elf32_Ehdr Elf32_Half Elf32_Off Elf32_Phdr +Elf32_Rel +Elf32_Relr Elf32_Section Elf32_Shdr Elf32_Sym +Elf32_Sword Elf32_Word +Elf32_Xword Elf64_Addr Elf64_Ehdr Elf64_Half Elf64_Off Elf64_Phdr +Elf64_Rel +Elf64_Relr Elf64_Section Elf64_Shdr +Elf64_Sword Elf64_Sxword Elf64_Sym Elf64_Word @@ -1449,9 +1462,7 @@ MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ MFD_ALLOW_SEALING MFD_CLOEXEC -MFD_EXEC MFD_HUGETLB -MFD_NOEXEC_SEAL MINSIGSTKSZ MMAP_PAGE_ZERO MNT_DETACH @@ -1682,8 +1693,29 @@ NFULNL_COPY_PACKET NFULNL_MSG_CONFIG NFULNL_MSG_PACKET NF_ACCEPT +NF_ARP +NF_ARP_FORWARD +NF_ARP_IN +NF_ARP_NUMHOOKS +NF_ARP_OUT +NF_BR_BROUTING +NF_BR_FORWARD +NF_BR_LOCAL_IN +NF_BR_LOCAL_OUT +NF_BR_NUMHOOKS +NF_BR_POST_ROUTING +NF_BR_PRE_ROUTING +NF_BR_PRI_BRNF +NF_BR_PRI_FILTER_BRIDGED +NF_BR_PRI_FILTER_OTHER +NF_BR_PRI_FIRST +NF_BR_PRI_LAST +NF_BR_PRI_NAT_DST_BRIDGED +NF_BR_PRI_NAT_DST_OTHER +NF_BR_PRI_NAT_SRC NF_DROP NF_INET_FORWARD +NF_INET_INGRESS NF_INET_LOCAL_IN NF_INET_LOCAL_OUT NF_INET_NUMHOOKS @@ -1705,6 +1737,7 @@ NF_IP6_PRI_MANGLE NF_IP6_PRI_NAT_DST NF_IP6_PRI_NAT_SRC NF_IP6_PRI_RAW +NF_IP6_PRI_RAW_BEFORE_DEFRAG NF_IP6_PRI_SECURITY NF_IP6_PRI_SELINUX_FIRST NF_IP6_PRI_SELINUX_LAST @@ -1725,10 +1758,12 @@ NF_IP_PRI_MANGLE NF_IP_PRI_NAT_DST NF_IP_PRI_NAT_SRC NF_IP_PRI_RAW +NF_IP_PRI_RAW_BEFORE_DEFRAG NF_IP_PRI_SECURITY NF_IP_PRI_SELINUX_FIRST NF_IP_PRI_SELINUX_LAST NF_MAX_VERDICT +NF_NETDEV_EGRESS NF_QUEUE NF_REPEAT NF_STOLEN @@ -1802,11 +1837,38 @@ O_RSYNC O_SYNC O_TMPFILE PACKET_ADD_MEMBERSHIP +PACKET_AUXDATA +PACKET_BROADCAST PACKET_DROP_MEMBERSHIP +PACKET_FANOUT +PACKET_FANOUT_CBPF +PACKET_FANOUT_CPU +PACKET_FANOUT_FLAG_DEFRAG +PACKET_FANOUT_FLAG_ROLLOVER +PACKET_FANOUT_FLAG_UNIQUEID +PACKET_FANOUT_HASH +PACKET_FANOUT_LB +PACKET_FANOUT_QM +PACKET_FANOUT_RND +PACKET_FANOUT_ROLLOVER +PACKET_HOST +PACKET_KERNEL +PACKET_LOOPBACK +PACKET_LOSS PACKET_MR_ALLMULTI PACKET_MR_MULTICAST PACKET_MR_PROMISC PACKET_MR_UNICAST +PACKET_MULTICAST +PACKET_OTHERHOST +PACKET_OUTGOING +PACKET_QDISC_BYPASS +PACKET_RESERVE +PACKET_RX_RING +PACKET_STATISTICS +PACKET_TIMESTAMP +PACKET_USER +PACKET_VERSION PENDIN PF_ALG PF_APPLETALK @@ -2720,6 +2782,8 @@ IW_ENC_CAPA_WPA2 IW_ENC_CAPA_CIPHER_TKIP IW_ENC_CAPA_CIPHER_CCMP IW_ENC_CAPA_4WAY_HANDSHAKE +IW_EVENT_CAPA_K_0 +IW_EVENT_CAPA_K_1 IW_PMKSA_ADD IW_PMKSA_REMOVE IW_PMKSA_FLUSH @@ -2728,6 +2792,11 @@ IW_PMKID_CAND_PREAUTH IW_EV_CHAR_PK_LEN IW_EV_LCP_PK_LEN IW_EV_POINT_PK_LEN +IW_EV_UINT_PK_LEN +IW_EV_FREQ_PK_LEN +IW_EV_PARAM_PK_LEN +IW_EV_ADDR_PK_LEN +IW_EV_QUAL_PK_LEN SI_LOAD_SHIFT SND_CNT SND_MAX @@ -3191,6 +3260,22 @@ TLS_GET_RECORD_TYPE TLS_RX TLS_SET_RECORD_TYPE TLS_TX +TP_STATUS_AVAILABLE +TP_STATUS_BLK_TMO +TP_STATUS_COPY +TP_STATUS_CSUMNOTREADY +TP_STATUS_CSUM_VALID +TP_STATUS_KERNEL +TP_STATUS_LOSING +TP_STATUS_SENDING +TP_STATUS_SEND_REQUEST +TP_STATUS_TS_RAW_HARDWARE +TP_STATUS_TS_SOFTWARE +TP_STATUS_TS_SYS_HARDWARE +TP_STATUS_USER +TP_STATUS_VLAN_TPID_VALID +TP_STATUS_VLAN_VALID +TP_STATUS_WRONG_FORMAT TUN_READQ_SIZE TUN_TAP_DEV TUN_TUN_DEV @@ -3453,6 +3538,7 @@ fanotify_event_metadata fanotify_init fanotify_mark fanotify_response +fanout_args fchdir fdatasync fdopendir @@ -3554,6 +3640,22 @@ ip_mreqn ip_mreq_source ipc_perm itimerspec +iw_discarded +iw_encode_ext +iw_event +iw_freq +iw_missed +iw_param +iw_pmkid_cand +iw_pmksa +iw_point +iw_priv_args +iw_quality +iw_range +iwreq +iwreq_data +iw_scan_req +iw_statistics j1939_filter jrand48 key_t @@ -3820,6 +3922,7 @@ sockaddr_alg sockaddr_can sockaddr_ll sockaddr_nl +sockaddr_pkt sockaddr_vm splice spwd @@ -3833,11 +3936,8 @@ statvfs64 strcasecmp strcasestr strchrnul -strftime -strftime_l strncasecmp strndup -strptime strsignal swapoff swapon @@ -3857,6 +3957,22 @@ timer_getoverrun timer_gettime timer_settime tmpfile64 +tpacket2_hdr +tpacket3_hdr +tpacket_auxdata +tpacket_bd_header_u +tpacket_bd_ts +tpacket_block_desc +tpacket_hdr +tpacket_hdr_v1 +tpacket_hdr_variant1 +tpacket_req +tpacket_req3 +tpacket_req_u +tpacket_rollover_stats +tpacket_stats +tpacket_stats_v3 +tpacket_versions truncate truncate64 ttyname_r @@ -3872,7 +3988,6 @@ unshare useconds_t uselocale utimensat -vfork vhangup vmsplice wait4 diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index fd4563212d60d..afb8afa7f50f0 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -331,7 +331,6 @@ ITIMER_PROF ITIMER_REAL ITIMER_VIRTUAL KERN_ARGMAX -KERN_ARND KERN_AUDIO KERN_BOOTTIME KERN_CACHEPCT @@ -357,7 +356,6 @@ KERN_JOB_CONTROL KERN_MALLOCSTATS KERN_MAXCLUSTERS KERN_MAXFILES -KERN_MAXID KERN_MAXLOCKSPERUID KERN_MAXPARTITIONS KERN_MAXPROC @@ -372,7 +370,6 @@ KERN_NFILES KERN_NGROUPS KERN_NOSUIDCOREDUMP KERN_NPROCS -KERN_NSELCOLL KERN_NTHREADS KERN_NUMVNODES KERN_OSRELEASE @@ -422,7 +419,6 @@ KERN_TIMECOUNTER KERN_TIMEOUT_STATS KERN_TTY KERN_TTYCOUNT -KERN_USERMOUNT KERN_VERSION KERN_WATCHDOG KVE_ADV_NORMAL @@ -1129,7 +1125,6 @@ memmem memrchr mfs_args mimmutable -mincore mkdirat mkfifoat mknodat @@ -1279,7 +1274,6 @@ strndup strsignal strtonum sync -syscall sysctl tcp_info telldir diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index 80095a09f5345..48b1e3c18278e 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -96,6 +96,17 @@ EUSERS EXFULL FIONREAD IMAXBEL +IP_RECVTOS +IP_TOS +IPPROTO_ICMP +IPPROTO_IDP +IPPROTO_IGMP +IPPROTO_IP +IPPROTO_IPV6 +IPPROTO_MAX +IPPROTO_PUP +IPPROTO_TCP +IPPROTO_UDP IPV6_ADD_MEMBERSHIP IPV6_DROP_MEMBERSHIP IUCLC @@ -129,6 +140,7 @@ SIGPWR SIGSTKFLT SOCK_CLOEXEC SOCK_NONBLOCK +SOCK_RAW SO_BSDCOMPAT SO_DOMAIN SO_NO_CHECK diff --git a/libc-test/semver/solarish.txt b/libc-test/semver/solarish.txt new file mode 100644 index 0000000000000..069508925c8ef --- /dev/null +++ b/libc-test/semver/solarish.txt @@ -0,0 +1 @@ +PIPE_BUF diff --git a/libc-test/semver/windows.txt b/libc-test/semver/windows.txt index fa3fb8efecd38..ad0a60d4719cd 100644 --- a/libc-test/semver/windows.txt +++ b/libc-test/semver/windows.txt @@ -149,6 +149,7 @@ accept access aligned_malloc aligned_free +aligned_realloc atexit atof atoi diff --git a/libc-test/test/primitive_types.rs b/libc-test/test/primitive_types.rs new file mode 100644 index 0000000000000..c125a92a58110 --- /dev/null +++ b/libc-test/test/primitive_types.rs @@ -0,0 +1,15 @@ +use std::any::TypeId; + +macro_rules! ok { + ($($t:ident)*) => {$( + assert!(TypeId::of::() == TypeId::of::(), + "{} is wrong", stringify!($t)); + )*} +} + +#[test] +fn same() { + use std::ffi; + ok!(c_char c_schar c_uchar c_short c_ushort c_int c_uint c_long c_ulong + c_longlong c_ulonglong c_float c_double); +} diff --git a/src/fixed_width_ints.rs b/src/fixed_width_ints.rs index 999de8f54f194..f24fa5dd2d1d7 100644 --- a/src/fixed_width_ints.rs +++ b/src/fixed_width_ints.rs @@ -20,7 +20,7 @@ pub type uint32_t = u32; pub type uint64_t = u64; cfg_if! { - if #[cfg(all(libc_int128, target_arch = "aarch64", not(target_os = "windows")))] { + if #[cfg(all(target_arch = "aarch64", not(any(target_os = "windows", target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))))] { // This introduces partial support for FFI with __int128 and // equivalent types on platforms where Rust's definition is validated // to match the standard C ABI of that platform. @@ -59,41 +59,43 @@ cfg_if! { /// C __uint128_t (alternate name for [__uint128][]) pub type __uint128_t = u128; - cfg_if! { - if #[cfg(libc_underscore_const_names)] { - macro_rules! static_assert_eq { - ($a:expr, $b:expr) => { - const _: [(); $a] = [(); $b]; - }; - } + macro_rules! static_assert_eq { + ($a:expr, $b:expr) => { + const _: [(); $a] = [(); $b]; + }; + } - // NOTE: if you add more platforms to here, you may need to cfg - // these consts. They should always match the platform's values - // for `sizeof(__int128)` and `_Alignof(__int128)`. - const _SIZE_128: usize = 16; - const _ALIGN_128: usize = 16; + // NOTE: if you add more platforms to here, you may need to cfg + // these consts. They should always match the platform's values + // for `sizeof(__int128)` and `_Alignof(__int128)`. + const _SIZE_128: usize = 16; + const _ALIGN_128: usize = 16; - // Since Rust doesn't officially guarantee that these types - // have compatible ABIs, we const assert that these values have the - // known size/align of the target platform's libc. If rustc ever - // tries to regress things, it will cause a compilation error. - // - // This isn't a bullet-proof solution because e.g. it doesn't - // catch the fact that llvm and gcc disagree on how x64 __int128 - // is actually *passed* on the stack (clang underaligns it for - // the same reason that rustc *never* properly aligns it). - static_assert_eq!(core::mem::size_of::<__int128>(), _SIZE_128); - static_assert_eq!(core::mem::align_of::<__int128>(), _ALIGN_128); + // Since Rust doesn't officially guarantee that these types + // have compatible ABIs, we const assert that these values have the + // known size/align of the target platform's libc. If rustc ever + // tries to regress things, it will cause a compilation error. + // + // This isn't a bullet-proof solution because e.g. it doesn't + // catch the fact that llvm and gcc disagree on how x64 __int128 + // is actually *passed* on the stack (clang underaligns it for + // the same reason that rustc *never* properly aligns it). + // FIXME: temporarily disabled because of a ctest2 bug. + // static_assert_eq!(core::mem::size_of::<__int128>(), _SIZE_128); + // static_assert_eq!(core::mem::align_of::<__int128>(), _ALIGN_128); - static_assert_eq!(core::mem::size_of::<__uint128>(), _SIZE_128); - static_assert_eq!(core::mem::align_of::<__uint128>(), _ALIGN_128); + // static_assert_eq!(core::mem::size_of::<__uint128>(), _SIZE_128); + // static_assert_eq!(core::mem::align_of::<__uint128>(), _ALIGN_128); - static_assert_eq!(core::mem::size_of::<__int128_t>(), _SIZE_128); - static_assert_eq!(core::mem::align_of::<__int128_t>(), _ALIGN_128); + // static_assert_eq!(core::mem::size_of::<__int128_t>(), _SIZE_128); + // static_assert_eq!(core::mem::align_of::<__int128_t>(), _ALIGN_128); - static_assert_eq!(core::mem::size_of::<__uint128_t>(), _SIZE_128); - static_assert_eq!(core::mem::align_of::<__uint128_t>(), _ALIGN_128); - } - } + // static_assert_eq!(core::mem::size_of::<__uint128_t>(), _SIZE_128); + // static_assert_eq!(core::mem::align_of::<__uint128_t>(), _ALIGN_128); + } else if #[cfg(all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos")))] { + /// /// C `__int128_t` + pub type __int128_t = i128; + /// /// C `__uint128_t` + pub type __uint128_t = u128; } } diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 4e028ff6cc45a..65d7e9005ddfe 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -380,7 +380,7 @@ s! { } pub struct fd_set { - fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE], + fds_bits: [::c_ulong; FD_SETSIZE as usize / ULONG_SIZE], } pub struct tm { @@ -1334,9 +1334,9 @@ pub const GRPQUOTA: ::c_int = 1; pub const SIGIOT: ::c_int = 6; -pub const S_ISUID: ::c_int = 0x800; -pub const S_ISGID: ::c_int = 0x400; -pub const S_ISVTX: ::c_int = 0x200; +pub const S_ISUID: ::mode_t = 0o4000; +pub const S_ISGID: ::mode_t = 0o2000; +pub const S_ISVTX: ::mode_t = 0o1000; pub const IF_NAMESIZE: ::size_t = 16; pub const IFNAMSIZ: ::size_t = IF_NAMESIZE; @@ -1467,26 +1467,26 @@ pub const O_RDONLY: ::c_int = 0; pub const O_WRONLY: ::c_int = 1; pub const O_RDWR: ::c_int = 2; -pub const S_IFIFO: ::mode_t = 4096; -pub const S_IFCHR: ::mode_t = 8192; -pub const S_IFBLK: ::mode_t = 24576; -pub const S_IFDIR: ::mode_t = 16384; -pub const S_IFREG: ::mode_t = 32768; -pub const S_IFLNK: ::mode_t = 40960; -pub const S_IFSOCK: ::mode_t = 49152; -pub const S_IFMT: ::mode_t = 61440; -pub const S_IRWXU: ::mode_t = 448; -pub const S_IXUSR: ::mode_t = 64; -pub const S_IWUSR: ::mode_t = 128; -pub const S_IRUSR: ::mode_t = 256; -pub const S_IRWXG: ::mode_t = 56; -pub const S_IXGRP: ::mode_t = 8; -pub const S_IWGRP: ::mode_t = 16; -pub const S_IRGRP: ::mode_t = 32; -pub const S_IRWXO: ::mode_t = 7; -pub const S_IXOTH: ::mode_t = 1; -pub const S_IWOTH: ::mode_t = 2; -pub const S_IROTH: ::mode_t = 4; +pub const S_IFIFO: ::mode_t = 0o1_0000; +pub const S_IFCHR: ::mode_t = 0o2_0000; +pub const S_IFBLK: ::mode_t = 0o6_0000; +pub const S_IFDIR: ::mode_t = 0o4_0000; +pub const S_IFREG: ::mode_t = 0o10_0000; +pub const S_IFLNK: ::mode_t = 0o12_0000; +pub const S_IFSOCK: ::mode_t = 0o14_0000; +pub const S_IFMT: ::mode_t = 0o17_0000; +pub const S_IRWXU: ::mode_t = 0o0700; +pub const S_IXUSR: ::mode_t = 0o0100; +pub const S_IWUSR: ::mode_t = 0o0200; +pub const S_IRUSR: ::mode_t = 0o0400; +pub const S_IRWXG: ::mode_t = 0o0070; +pub const S_IXGRP: ::mode_t = 0o0010; +pub const S_IWGRP: ::mode_t = 0o0020; +pub const S_IRGRP: ::mode_t = 0o0040; +pub const S_IRWXO: ::mode_t = 0o0007; +pub const S_IXOTH: ::mode_t = 0o0001; +pub const S_IWOTH: ::mode_t = 0o0002; +pub const S_IROTH: ::mode_t = 0o0004; pub const F_OK: ::c_int = 0; pub const R_OK: ::c_int = 4; pub const W_OK: ::c_int = 2; @@ -1827,7 +1827,7 @@ pub const SS_DISABLE: ::c_int = 2; pub const PATH_MAX: ::c_int = 4096; -pub const FD_SETSIZE: usize = 1024; +pub const FD_SETSIZE: ::c_int = 1024; pub const EPOLLIN: ::c_int = 0x1; pub const EPOLLPRI: ::c_int = 0x2; @@ -2283,9 +2283,9 @@ 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 S_IEXEC: mode_t = 64; -pub const S_IWRITE: mode_t = 128; -pub const S_IREAD: mode_t = 256; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IREAD: mode_t = 0o0400; pub const F_LOCK: ::c_int = 1; pub const F_TEST: ::c_int = 3; @@ -2315,17 +2315,15 @@ pub const RTLD_NOW: ::c_int = 0x2; pub const TCP_MD5SIG: ::c_int = 14; -align_const! { - pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - size: [0; __SIZEOF_PTHREAD_MUTEX_T], - }; - pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - size: [0; __SIZEOF_PTHREAD_COND_T], - }; - pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - size: [0; __SIZEOF_PTHREAD_RWLOCK_T], - }; -} +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], +}; pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; @@ -3677,13 +3675,13 @@ extern "C" { pub fn execl(path: *const c_char, arg0: *const c_char, ...) -> ::c_int; pub fn execle(path: *const ::c_char, arg0: *const ::c_char, ...) -> ::c_int; pub fn execlp(file: *const ::c_char, arg0: *const ::c_char, ...) -> ::c_int; - pub fn execv(prog: *const c_char, argv: *const *const c_char) -> ::c_int; + pub fn execv(prog: *const c_char, argv: *const *mut c_char) -> ::c_int; pub fn execve( prog: *const c_char, - argv: *const *const c_char, - envp: *const *const c_char, + argv: *const *mut c_char, + envp: *const *mut c_char, ) -> ::c_int; - pub fn execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int; + pub fn execvp(c: *const c_char, argv: *const *mut c_char) -> ::c_int; pub fn fork() -> pid_t; pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long; pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char; @@ -4025,14 +4023,10 @@ extern "C" { ) -> ::c_int; pub fn execvpe( file: *const ::c_char, - argv: *const *const ::c_char, - envp: *const *const ::c_char, - ) -> ::c_int; - pub fn fexecve( - fd: ::c_int, - argv: *const *const ::c_char, - envp: *const *const ::c_char, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char, ) -> ::c_int; + pub fn fexecve(fd: ::c_int, argv: *const *mut ::c_char, envp: *const *mut ::c_char) -> ::c_int; pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; @@ -4361,33 +4355,9 @@ cfg_if! { } } -cfg_if! { - if #[cfg(libc_align)] { - #[macro_use] - mod align; - } else { - #[macro_use] - mod no_align; - } -} +#[macro_use] +mod align; + expand_align!(); -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, - } - } -} +pub use ffi::c_void; diff --git a/src/hermit.rs b/src/hermit.rs new file mode 100644 index 0000000000000..145d1241b190b --- /dev/null +++ b/src/hermit.rs @@ -0,0 +1,446 @@ +//! Hermit C type definitions + +cfg_if! { + if #[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))] { + pub type c_char = u8; + } else { + pub type c_char = i8; + } +} + +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_long = i64; +pub type c_ulong = u64; +pub type c_longlong = i64; +pub type c_ulonglong = u64; +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type intptr_t = isize; +pub type uintptr_t = usize; + +pub type c_float = f32; +pub type c_double = f64; + +pub type size_t = usize; +pub type ssize_t = isize; +pub type ptrdiff_t = isize; + +pub type clockid_t = i32; +pub type in_addr_t = u32; +pub type in_port_t = u16; +pub type mode_t = u32; +pub type nfds_t = usize; +pub type pid_t = i32; +pub type sa_family_t = u8; +pub type socklen_t = u32; +pub type time_t = i64; + +s! { + pub struct addrinfo { + pub ai_flags: i32, + pub ai_family: i32, + pub ai_socktype: i32, + pub ai_protocol: i32, + pub ai_addrlen: socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut sockaddr, + pub ai_next: *mut addrinfo, + } + + pub struct dirent64 { + pub d_ino: u64, + pub d_off: i64, + pub d_reclen: u16, + pub d_type: u8, + pub d_name: [c_char; 256], + } + + #[repr(align(4))] + pub struct in6_addr { + pub s6_addr: [u8; 16], + } + + pub struct in_addr { + pub s_addr: in_addr_t, + } + + pub struct iovec { + iov_base: *mut c_void, + iov_len: usize, + } + + pub struct pollfd { + pub fd: i32, + pub events: i16, + pub revents: i16, + } + + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [c_char; 14], + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [c_char; 8], + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + 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_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + __ss_pad1: [u8; 6], + __ss_align: i64, + __ss_pad2: [u8; 112], + } + + pub struct stat { + pub st_dev: u64, + pub st_ino: u64, + pub st_nlink: u64, + pub st_mode: mode_t, + pub st_uid: u32, + pub st_gid: u32, + pub st_rdev: u64, + pub st_size: u64, + pub st_blksize: i64, + pub st_blocks: i64, + pub st_atim: timespec, + pub st_mtim: timespec, + pub st_ctim: timespec, + } + + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: i32, + } +} + +pub const AF_INET: i32 = 0; +pub const AF_INET6: i32 = 1; + +pub const CLOCK_REALTIME: clockid_t = 1; +pub const CLOCK_MONOTONIC: clockid_t = 4; + +pub const DT_UNKNOWN: u8 = 0; +pub const DT_FIFO: u8 = 1; +pub const DT_CHR: u8 = 2; +pub const DT_DIR: u8 = 4; +pub const DT_BLK: u8 = 6; +pub const DT_REG: u8 = 8; +pub const DT_LNK: u8 = 10; +pub const DT_SOCK: u8 = 12; +pub const DT_WHT: u8 = 14; + +pub const EAI_AGAIN: i32 = 2; +pub const EAI_BADFLAGS: i32 = 3; +pub const EAI_FAIL: i32 = 4; +pub const EAI_FAMILY: i32 = 5; +pub const EAI_MEMORY: i32 = 6; +pub const EAI_NODATA: i32 = 7; +pub const EAI_NONAME: i32 = 8; +pub const EAI_SERVICE: i32 = 9; +pub const EAI_SOCKTYPE: i32 = 10; +pub const EAI_SYSTEM: i32 = 11; +pub const EAI_OVERFLOW: i32 = 14; + +pub const EFD_SEMAPHORE: i16 = 0o1; +pub const EFD_NONBLOCK: i16 = 0o4000; +pub const EFD_CLOEXEC: i16 = 0o40000; + +pub const F_DUPFD: i32 = 0; +pub const F_GETFD: i32 = 1; +pub const F_SETFD: i32 = 2; +pub const F_GETFL: i32 = 3; +pub const F_SETFL: i32 = 4; + +pub const FD_CLOEXEC: i32 = 1; + +pub const FIONBIO: i32 = 0x8008667e; + +pub const FUTEX_RELATIVE_TIMEOUT: u32 = 1; + +pub const IP_TOS: i32 = 1; +pub const IP_TTL: i32 = 2; +pub const IP_ADD_MEMBERSHIP: i32 = 3; +pub const IP_DROP_MEMBERSHIP: i32 = 4; +pub const IP_MULTICAST_TTL: i32 = 5; +pub const IP_MULTICAST_LOOP: i32 = 7; + +pub const IPPROTO_IP: i32 = 0; +pub const IPPROTO_TCP: i32 = 6; +pub const IPPROTO_UDP: i32 = 17; +pub const IPPROTO_IPV6: i32 = 41; + +pub const IPV6_ADD_MEMBERSHIP: i32 = 12; +pub const IPV6_DROP_MEMBERSHIP: i32 = 13; +pub const IPV6_MULTICAST_LOOP: i32 = 19; +pub const IPV6_V6ONLY: i32 = 27; + +pub const MSG_PEEK: i32 = 1; + +pub const O_RDONLY: i32 = 0o0; +pub const O_WRONLY: i32 = 0o1; +pub const O_RDWR: i32 = 0o2; +pub const O_CREAT: i32 = 0o100; +pub const O_EXCL: i32 = 0o200; +pub const O_TRUNC: i32 = 0o1000; +pub const O_APPEND: i32 = 0o2000; +pub const O_NONBLOCK: i32 = 0o4000; +pub const O_DIRECTORY: i32 = 0o200000; + +pub const POLLIN: i16 = 0x1; +pub const POLLPRI: i16 = 0x2; +pub const POLLOUT: i16 = 0x4; +pub const POLLERR: i16 = 0x8; +pub const POLLHUP: i16 = 0x10; +pub const POLLNVAL: i16 = 0x20; +pub const POLLRDNORM: i16 = 0x040; +pub const POLLRDBAND: i16 = 0x080; +pub const POLLWRNORM: i16 = 0x0100; +pub const POLLWRBAND: i16 = 0x0200; +pub const POLLRDHUP: i16 = 0x2000; + +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IXOTH: mode_t = 0o0001; + +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFIFO: mode_t = 0o1_0000; + +pub const SHUT_RD: i32 = 0; +pub const SHUT_WR: i32 = 1; +pub const SHUT_RDWR: i32 = 2; + +pub const SO_REUSEADDR: i32 = 0x0004; +pub const SO_KEEPALIVE: i32 = 0x0008; +pub const SO_BROADCAST: i32 = 0x0020; +pub const SO_LINGER: i32 = 0x0080; +pub const SO_SNDBUF: i32 = 0x1001; +pub const SO_RCVBUF: i32 = 0x1002; +pub const SO_SNDTIMEO: i32 = 0x1005; +pub const SO_RCVTIMEO: i32 = 0x1006; +pub const SO_ERROR: i32 = 0x1007; + +pub const SOCK_STREAM: i32 = 1; +pub const SOCK_DGRAM: i32 = 2; +pub const SOCK_NONBLOCK: i32 = 0o4000; +pub const SOCK_CLOEXEC: i32 = 0o40000; + +pub const SOL_SOCKET: i32 = 4095; + +pub const STDIN_FILENO: c_int = 0; +pub const STDOUT_FILENO: c_int = 1; +pub const STDERR_FILENO: c_int = 2; + +pub const TCP_NODELAY: i32 = 1; + +extern "C" { + #[link_name = "sys_alloc"] + pub fn alloc(size: usize, align: usize) -> *mut u8; + + #[link_name = "sys_alloc_zeroed"] + pub fn alloc_zeroed(size: usize, align: usize) -> *mut u8; + + #[link_name = "sys_realloc"] + pub fn realloc(ptr: *mut u8, size: usize, align: usize, new_size: usize) -> *mut u8; + + #[link_name = "sys_dealloc"] + pub fn dealloc(ptr: *mut u8, size: usize, align: usize); + + #[link_name = "sys_exit"] + pub fn exit(status: i32) -> !; + + #[link_name = "sys_abort"] + pub fn abort() -> !; + + #[link_name = "sys_errno"] + pub fn errno() -> i32; + + #[link_name = "sys_clock_gettime"] + pub fn clock_gettime(clockid: clockid_t, tp: *mut timespec) -> i32; + + #[link_name = "sys_nanosleep"] + pub fn nanosleep(req: *const timespec) -> i32; + + #[link_name = "sys_available_parallelism"] + pub fn available_parallelism() -> usize; + + #[link_name = "sys_futex_wait"] + pub fn futex_wait( + address: *mut u32, + expected: u32, + timeout: *const timespec, + flags: u32, + ) -> i32; + + #[link_name = "sys_futex_wake"] + pub fn futex_wake(address: *mut u32, count: i32) -> i32; + + #[link_name = "sys_stat"] + pub fn stat(path: *const c_char, stat: *mut stat) -> i32; + + #[link_name = "sys_fstat"] + pub fn fstat(fd: i32, stat: *mut stat) -> i32; + + #[link_name = "sys_lstat"] + pub fn lstat(path: *const c_char, stat: *mut stat) -> i32; + + #[link_name = "sys_open"] + pub fn open(path: *const c_char, flags: i32, mode: mode_t) -> i32; + + #[link_name = "sys_unlink"] + pub fn unlink(path: *const c_char) -> i32; + + #[link_name = "sys_mkdir"] + pub fn mkdir(path: *const c_char, mode: mode_t) -> i32; + + #[link_name = "sys_rmdir"] + pub fn rmdir(path: *const c_char) -> i32; + + #[link_name = "sys_read"] + pub fn read(fd: i32, buf: *mut u8, len: usize) -> isize; + + #[link_name = "sys_write"] + pub fn write(fd: i32, buf: *const u8, len: usize) -> isize; + + #[link_name = "sys_readv"] + pub fn readv(fd: i32, iov: *const iovec, iovcnt: usize) -> isize; + + #[link_name = "sys_writev"] + pub fn writev(fd: i32, iov: *const iovec, iovcnt: usize) -> isize; + + #[link_name = "sys_close"] + pub fn close(fd: i32) -> i32; + + #[link_name = "sys_dup"] + pub fn dup(fd: i32) -> i32; + + #[link_name = "sys_fcntl"] + pub fn fcntl(fd: i32, cmd: i32, arg: i32) -> i32; + + #[link_name = "sys_getdents64"] + pub fn getdents64(fd: i32, dirp: *mut dirent64, count: usize) -> isize; + + #[link_name = "sys_getaddrinfo"] + pub fn getaddrinfo( + nodename: *const c_char, + servname: *const c_char, + hints: *const addrinfo, + res: *mut *mut addrinfo, + ) -> i32; + + #[link_name = "sys_freeaddrinfo"] + pub fn freeaddrinfo(ai: *mut addrinfo); + + #[link_name = "sys_socket"] + pub fn socket(domain: i32, ty: i32, protocol: i32) -> i32; + + #[link_name = "sys_bind"] + pub fn bind(sockfd: i32, addr: *const sockaddr, addrlen: socklen_t) -> i32; + + #[link_name = "sys_listen"] + pub fn listen(sockfd: i32, backlog: i32) -> i32; + + #[link_name = "sys_accept"] + pub fn accept(sockfd: i32, addr: *mut sockaddr, addrlen: *mut socklen_t) -> i32; + + #[link_name = "sys_connect"] + pub fn connect(sockfd: i32, addr: *const sockaddr, addrlen: socklen_t) -> i32; + + #[link_name = "sys_recv"] + pub fn recv(sockfd: i32, buf: *mut u8, len: usize, flags: i32) -> isize; + + #[link_name = "sys_recvfrom"] + pub fn recvfrom( + sockfd: i32, + buf: *mut c_void, + len: usize, + flags: i32, + addr: *mut sockaddr, + addrlen: *mut socklen_t, + ) -> isize; + + #[link_name = "sys_send"] + pub fn send(sockfd: i32, buf: *const c_void, len: usize, flags: i32) -> isize; + + #[link_name = "sys_sendto"] + pub fn sendto( + sockfd: i32, + buf: *const c_void, + len: usize, + flags: i32, + to: *const sockaddr, + tolen: socklen_t, + ) -> isize; + + #[link_name = "sys_getpeername"] + pub fn getpeername(sockfd: i32, addr: *mut sockaddr, addrlen: *mut socklen_t) -> i32; + + #[link_name = "sys_getsockname"] + pub fn getsockname(sockfd: i32, addr: *mut sockaddr, addrlen: *mut socklen_t) -> i32; + + #[link_name = "sys_getsockopt"] + pub fn getsockopt( + sockfd: i32, + level: i32, + optname: i32, + optval: *mut c_void, + optlen: *mut socklen_t, + ) -> i32; + + #[link_name = "sys_setsockopt"] + pub fn setsockopt( + sockfd: i32, + level: i32, + optname: i32, + optval: *const c_void, + optlen: socklen_t, + ) -> i32; + + #[link_name = "sys_ioctl"] + pub fn ioctl(sockfd: i32, cmd: i32, argp: *mut c_void) -> i32; + + #[link_name = "sys_shutdown"] + pub fn shutdown(sockfd: i32, how: i32) -> i32; + + #[link_name = "sys_eventfd"] + pub fn eventfd(initval: u64, flags: i16) -> i32; + + #[link_name = "sys_poll"] + pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: i32) -> i32; +} + +pub use ffi::c_void; diff --git a/src/lib.rs b/src/lib.rs index 1b6f0c077ab24..1fe44ce6eef08 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,17 +12,19 @@ redundant_semicolons, unused_macros, unused_macro_rules, + // FIXME: temporarily allow dead_code to fix CI: + // - https://github.com/rust-lang/libc/issues/3740 + // - https://github.com/rust-lang/rust/pull/126456 + dead_code, )] #![cfg_attr(libc_deny_warnings, deny(warnings))] // Attributes needed when building as part of the standard library #![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))] -#![cfg_attr(libc_thread_local, feature(thread_local))] // Enable extra lints: #![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))] #![deny(missing_copy_implementations, safe_packed_borrows)] #![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)] #![cfg_attr(feature = "rustc-dep-of-std", no_core)] -#![cfg_attr(libc_const_extern_fn_unstable, feature(const_extern_fn))] #[macro_use] mod macros; @@ -39,52 +41,25 @@ cfg_if! { } } -cfg_if! { - if #[cfg(libc_priv_mod_use)] { - #[cfg(libc_core_cvoid)] - #[allow(unused_imports)] - use core::ffi; - #[allow(unused_imports)] - use core::fmt; - #[allow(unused_imports)] - use core::hash; - #[allow(unused_imports)] - use core::num; - #[allow(unused_imports)] - use core::mem; - #[doc(hidden)] - #[allow(unused_imports)] - use core::clone::Clone; - #[doc(hidden)] - #[allow(unused_imports)] - use core::marker::{Copy, Send, Sync}; - #[doc(hidden)] - #[allow(unused_imports)] - use core::option::Option; - } else { - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::fmt; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::hash; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::num; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::mem; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::clone::Clone; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::marker::{Copy, Send, Sync}; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::option::Option; - } -} +#[doc(hidden)] +#[allow(unused_imports)] +use core::clone::Clone; +#[allow(unused_imports)] +use core::ffi; +#[allow(unused_imports)] +use core::fmt; +#[allow(unused_imports)] +use core::hash; +#[doc(hidden)] +#[allow(unused_imports)] +use core::marker::{Copy, Send, Sync}; +#[allow(unused_imports)] +use core::mem; +#[allow(unused_imports)] +use core::num; +#[doc(hidden)] +#[allow(unused_imports)] +use core::option::Option; cfg_if! { if #[cfg(windows)] { @@ -105,12 +80,6 @@ cfg_if! { mod switch; pub use switch::*; - } else if #[cfg(target_os = "psp")] { - mod fixed_width_ints; - pub use fixed_width_ints::*; - - mod psp; - pub use psp::*; } else if #[cfg(target_os = "vxworks")] { mod fixed_width_ints; pub use fixed_width_ints::*; diff --git a/src/macros.rs b/src/macros.rs index beb80024dbfa3..aa08505239c58 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -90,19 +90,15 @@ macro_rules! s_no_extra_traits { s_no_extra_traits!(it: $(#[$attr])* pub $t $i { $($field)* }); )*); (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => ( - cfg_if! { - if #[cfg(libc_union)] { - __item! { - #[repr(C)] - $(#[$attr])* - pub union $i { $($field)* } - } + __item! { + #[repr(C)] + $(#[$attr])* + pub union $i { $($field)* } + } - impl ::Copy for $i {} - impl ::Clone for $i { - fn clone(&self) -> $i { *self } - } - } + impl ::Copy for $i {} + impl ::Clone for $i { + fn clone(&self) -> $i { *self } } ); (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => ( @@ -154,35 +150,8 @@ macro_rules! s_paren { )*); } -// This is a pretty horrible hack to allow us to conditionally mark -// some functions as 'const', without requiring users of this macro -// to care about the "const-extern-fn" feature. -// -// When 'const-extern-fn' is enabled, we emit the captured 'const' keyword -// in the expanded function. -// -// When 'const-extern-fn' is disabled, we always emit a plain 'pub unsafe extern fn'. -// Note that the expression matched by the macro is exactly the same - this allows -// users of this macro to work whether or not 'const-extern-fn' is enabled -// -// Unfortunately, we need to duplicate most of this macro between the 'cfg_if' blocks. -// This is because 'const unsafe extern fn' won't even parse on older compilers, -// so we need to avoid emitting it at all of 'const-extern-fn'. -// -// Specifically, moving the 'cfg_if' into the macro body will *not* work. -// Doing so would cause the '#[cfg(feature = "const-extern-fn")]' to be emitted -// into user code. The 'cfg' gate will not stop Rust from trying to parse the -// 'pub const unsafe extern fn', so users would get a compiler error even when -// the 'const-extern-fn' feature is disabled -// -// Note that users of this macro need to place 'const' in a weird position -// (after the closing ')' for the arguments, but before the return type). -// This was the only way I could satisfy the following two requirements: -// 1. Avoid ambiguity errors from 'macro_rules!' (which happen when writing '$foo:ident fn' -// 2. Allow users of this macro to mix 'pub fn foo' and 'pub const fn bar' within the same -// 'f!' block cfg_if! { - if #[cfg(libc_const_extern_fn)] { + if #[cfg(feature = "const-extern-fn")] { macro_rules! f { ($($(#[$attr:meta])* pub $({$constness:ident})* fn $i:ident( $($arg:ident: $argty:ty),* @@ -282,66 +251,6 @@ macro_rules! __item { }; } -macro_rules! align_const { - ($($(#[$attr:meta])* - pub const $name:ident : $t1:ty - = $t2:ident { $($field:tt)* };)*) => ($( - #[cfg(libc_align)] - $(#[$attr])* - pub const $name : $t1 = $t2 { - $($field)* - }; - #[cfg(not(libc_align))] - $(#[$attr])* - pub const $name : $t1 = $t2 { - $($field)* - __align: [], - }; - )*) -} - -// This macro is used to deprecate items that should be accessed via the mach2 crate -macro_rules! deprecated_mach { - (pub const $id:ident: $ty:ty = $expr:expr;) => { - #[deprecated( - since = "0.2.55", - note = "Use the `mach2` crate instead", - )] - #[allow(deprecated)] - pub const $id: $ty = $expr; - }; - ($(pub const $id:ident: $ty:ty = $expr:expr;)*) => { - $( - deprecated_mach!( - pub const $id: $ty = $expr; - ); - )* - }; - (pub type $id:ident = $ty:ty;) => { - #[deprecated( - since = "0.2.55", - note = "Use the `mach2` crate instead", - )] - #[allow(deprecated)] - pub type $id = $ty; - }; - ($(pub type $id:ident = $ty:ty;)*) => { - $( - deprecated_mach!( - pub type $id = $ty; - ); - )* - } -} - -#[cfg(not(libc_ptr_addr_of))] -macro_rules! ptr_addr_of { - ($place:expr) => { - &$place - }; -} - -#[cfg(libc_ptr_addr_of)] macro_rules! ptr_addr_of { ($place:expr) => { ::core::ptr::addr_of!($place) diff --git a/src/sgx.rs b/src/sgx.rs index 7da6269399d9e..09cc33eb73589 100644 --- a/src/sgx.rs +++ b/src/sgx.rs @@ -26,22 +26,4 @@ pub type c_ulong = u64; pub const INT_MIN: c_int = -2147483648; pub const INT_MAX: c_int = 2147483647; -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, - } - } -} +pub use ffi::c_void; diff --git a/src/solid/mod.rs b/src/solid/mod.rs index f0f2ae89bde90..4c880796340eb 100644 --- a/src/solid/mod.rs +++ b/src/solid/mod.rs @@ -209,15 +209,15 @@ 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 S_IEXEC: c_short = 0o0100; +pub const S_IWRITE: c_short = 0o0200; +pub const S_IREAD: c_short = 0o0400; +pub const S_IFCHR: c_short = 0o2_0000; +pub const S_IFDIR: c_short = 0o4_0000; +pub const S_IFMT: c_short = 0o16_0000; +pub const S_IFIFO: c_short = 0o1_0000; +pub const S_IFBLK: c_short = 0o6_0000; +pub const S_IFREG: c_short = 0o10_0000; pub const LC_ALL: c_int = 0; pub const LC_COLLATE: c_int = 1; @@ -871,25 +871,7 @@ extern "C" { 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, - } - } -} +pub use ffi::c_void; cfg_if! { if #[cfg(target_arch = "aarch64")] { diff --git a/src/switch.rs b/src/switch.rs index 030ab20d7bd8e..1e8962823af84 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -28,22 +28,4 @@ pub type wchar_t = u32; pub const INT_MIN: c_int = -2147483648; pub const INT_MAX: c_int = 2147483647; -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, - } - } -} +pub use ffi::c_void; diff --git a/src/teeos/mod.rs b/src/teeos/mod.rs index 25e06ffaa3b10..dc8a5f776514b 100644 --- a/src/teeos/mod.rs +++ b/src/teeos/mod.rs @@ -48,7 +48,7 @@ pub type ssize_t = isize; pub type pid_t = c_int; -// aarch64 specifc +// aarch64 specific pub type c_char = u8; pub type wchar_t = u32; @@ -61,9 +61,9 @@ pub type c_ulong = u64; pub struct _CLongDouble(pub u128); // long double in C means A float point value, which has 128bit length. -// but some bit maybe not used, so the really length of long double could be 80(x86) or 128(power pc/IEEE) +// but some bit maybe not used, so the real length of long double could be 80(x86) or 128(power pc/IEEE) // this is different from f128(not stable and not included default) in Rust, so we use u128 for FFI(Rust to C). -// this is unstable and will couse to memfault/data abort. +// this is unstable and will cause to memfault/data abort. pub type c_longdouble = _CLongDouble; pub type pthread_t = c_ulong; diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index b3ce43a3722d1..1e2dedee9bffb 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -17,7 +17,7 @@ pub type rlim_t = ::c_ulong; pub type speed_t = ::c_uint; pub type tcflag_t = ::c_uint; pub type time_t = ::c_long; -pub type time64_t = ::int64_t; +pub type time64_t = u64; pub type timer_t = ::c_long; pub type wchar_t = ::c_uint; pub type nfds_t = ::c_int; @@ -25,7 +25,7 @@ pub type projid_t = ::c_int; pub type id_t = ::c_uint; pub type blksize64_t = ::c_ulonglong; pub type blkcnt64_t = ::c_ulonglong; -pub type sctp_assoc_t = ::uint32_t; +pub type sctp_assoc_t = u32; pub type suseconds_t = ::c_int; pub type useconds_t = ::c_uint; @@ -60,6 +60,7 @@ pub type posix_spawn_file_actions_t = *mut ::c_char; pub type iconv_t = *mut ::c_void; e! { + #[repr(u32)] pub enum uio_rw { UIO_READ = 0, UIO_WRITE, @@ -534,20 +535,17 @@ s! { } s_no_extra_traits! { - #[cfg(libc_union)] pub union __sigaction_sa_union { pub __su_handler: extern fn(c: ::c_int), pub __su_sigaction: extern fn(c: ::c_int, info: *mut siginfo_t, ptr: *mut ::c_void), } pub struct sigaction { - #[cfg(libc_union)] pub sa_union: __sigaction_sa_union, pub sa_mask: sigset_t, pub sa_flags: ::c_int, } - #[cfg(libc_union)] pub union __poll_ctl_ext_u { pub addr: *mut ::c_void, pub data32: u32, @@ -559,7 +557,6 @@ s_no_extra_traits! { pub command: u8, pub events: ::c_short, pub fd: ::c_int, - #[cfg(libc_union)] pub u: __poll_ctl_ext_u, pub reversed64: [u64; 6], } @@ -567,7 +564,6 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - #[cfg(libc_union)] impl PartialEq for __sigaction_sa_union { fn eq(&self, other: &__sigaction_sa_union) -> bool { unsafe { @@ -576,9 +572,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for __sigaction_sa_union {} - #[cfg(libc_union)] impl ::fmt::Debug for __sigaction_sa_union { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("__sigaction_sa_union") @@ -587,7 +581,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __sigaction_sa_union { fn hash(&self, state: &mut H) { unsafe { @@ -599,10 +592,7 @@ cfg_if! { impl PartialEq for sigaction { fn eq(&self, other: &sigaction) -> bool { - #[cfg(libc_union)] let union_eq = self.sa_union == other.sa_union; - #[cfg(not(libc_union))] - let union_eq = true; self.sa_mask == other.sa_mask && self.sa_flags == other.sa_flags && union_eq @@ -612,7 +602,6 @@ cfg_if! { impl ::fmt::Debug for sigaction { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { let mut struct_formatter = f.debug_struct("sigaction"); - #[cfg(libc_union)] struct_formatter.field("sa_union", &self.sa_union); struct_formatter.field("sa_mask", &self.sa_mask); struct_formatter.field("sa_flags", &self.sa_flags); @@ -621,14 +610,12 @@ cfg_if! { } impl ::hash::Hash for sigaction { fn hash(&self, state: &mut H) { - #[cfg(libc_union)] self.sa_union.hash(state); self.sa_mask.hash(state); self.sa_flags.hash(state); } } - #[cfg(libc_union)] impl PartialEq for __poll_ctl_ext_u { fn eq(&self, other: &__poll_ctl_ext_u) -> bool { unsafe { @@ -638,9 +625,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for __poll_ctl_ext_u {} - #[cfg(libc_union)] impl ::fmt::Debug for __poll_ctl_ext_u { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("__poll_ctl_ext_u") @@ -650,7 +635,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __poll_ctl_ext_u { fn hash(&self, state: &mut H) { unsafe { @@ -663,10 +647,7 @@ cfg_if! { impl PartialEq for poll_ctl_ext { fn eq(&self, other: &poll_ctl_ext) -> bool { - #[cfg(libc_union)] let union_eq = self.u == other.u; - #[cfg(not(libc_union))] - let union_eq = true; self.version == other.version && self.command == other.command && self.events == other.events @@ -683,7 +664,6 @@ cfg_if! { struct_formatter.field("command", &self.command); struct_formatter.field("events", &self.events); struct_formatter.field("fd", &self.fd); - #[cfg(libc_union)] struct_formatter.field("u", &self.u); struct_formatter.field("reversed64", &self.reversed64); struct_formatter.finish() @@ -695,7 +675,6 @@ cfg_if! { self.command.hash(state); self.events.hash(state); self.fd.hash(state); - #[cfg(libc_union)] self.u.hash(state); self.reversed64.hash(state); } @@ -983,8 +962,6 @@ pub const BPF_X: ::c_int = 8; // net/if.h pub const IFNET_SLOWHZ: ::c_int = 1; pub const IFQ_MAXLEN: ::c_int = 50; -pub const IF_NAMESIZE: ::c_int = 16; -pub const IFNAMSIZ: ::c_int = 16; pub const IFF_UP: ::c_int = 0x1; pub const IFF_BROADCAST: ::c_int = 0x2; pub const IFF_DEBUG: ::c_int = 0x4; @@ -1007,8 +984,6 @@ pub const ARPHRD_ETHER: ::c_int = 1; pub const ARPHRD_802_5: ::c_int = 6; pub const ARPHRD_802_3: ::c_int = 6; pub const ARPHRD_FDDI: ::c_int = 1; -pub const ARPOP_REQUEST: ::c_int = 1; -pub const ARPOP_REPLY: ::c_int = 2; // net/route.h pub const RTM_ADD: ::c_int = 0x1; @@ -1274,13 +1249,13 @@ pub const ENTER: ::c_int = 1; pub const SEM_FAILED: *mut sem_t = -1isize as *mut ::sem_t; // spawn.h -pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x1; -pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x2; -pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x4; -pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x8; -pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_int = 0x10; -pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x20; -pub const POSIX_SPAWN_FORK_HANDLERS: ::c_int = 0x1000; +pub const POSIX_SPAWN_SETPGROUP: ::c_short = 0x1; +pub const POSIX_SPAWN_SETSIGMASK: ::c_short = 0x2; +pub const POSIX_SPAWN_SETSIGDEF: ::c_short = 0x4; +pub const POSIX_SPAWN_SETSCHEDULER: ::c_short = 0x8; +pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_short = 0x10; +pub const POSIX_SPAWN_RESETIDS: ::c_short = 0x20; +pub const POSIX_SPAWN_FORK_HANDLERS: ::c_short = 0x1000; // stdio.h pub const EOF: ::c_int = -1; @@ -1616,29 +1591,29 @@ pub const MADV_WILLNEED: ::c_int = 3; pub const MADV_DONTNEED: ::c_int = 4; // sys/mode.h -pub const S_IFMT: mode_t = 0o170000; -pub const S_IFREG: mode_t = 0o100000; -pub const S_IFDIR: mode_t = 0o40000; -pub const S_IFBLK: mode_t = 0o60000; -pub const S_IFCHR: mode_t = 0o20000; -pub const S_IFIFO: mode_t = 0o10000; -pub const S_IRWXU: mode_t = 0o700; -pub const S_IRUSR: mode_t = 0o400; -pub const S_IWUSR: mode_t = 0o200; -pub const S_IXUSR: mode_t = 0o100; -pub const S_IRWXG: mode_t = 0o70; -pub const S_IRGRP: mode_t = 0o40; -pub const S_IWGRP: mode_t = 0o20; -pub const S_IXGRP: mode_t = 0o10; -pub const S_IRWXO: mode_t = 7; -pub const S_IROTH: mode_t = 4; -pub const S_IWOTH: mode_t = 2; -pub const S_IXOTH: mode_t = 1; -pub const S_IFLNK: mode_t = 0o120000; -pub const S_IFSOCK: mode_t = 0o140000; -pub const S_IEXEC: mode_t = 0o100; -pub const S_IWRITE: mode_t = 0o200; -pub const S_IREAD: mode_t = 0o400; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IREAD: mode_t = 0o0400; // sys/msg.h pub const MSG_NOERROR: ::c_int = 0o10000; @@ -2140,7 +2115,7 @@ pub const POWER_8: ::c_int = 0x10000; pub const POWER_9: ::c_int = 0x20000; // sys/time.h -pub const FD_SETSIZE: usize = 65534; +pub const FD_SETSIZE: ::c_int = 65534; pub const TIMEOFDAY: ::c_int = 9; pub const CLOCK_REALTIME: ::clockid_t = TIMEOFDAY as clockid_t; pub const CLOCK_MONOTONIC: ::clockid_t = 10; @@ -2832,11 +2807,7 @@ extern "C" { ) -> ::c_int; pub fn fattach(fildes: ::c_int, path: *const ::c_char) -> ::c_int; pub fn fdatasync(fd: ::c_int) -> ::c_int; - pub fn fexecve( - fd: ::c_int, - argv: *const *const ::c_char, - envp: *const *const ::c_char, - ) -> ::c_int; + pub fn fexecve(fd: ::c_int, argv: *const *mut ::c_char, envp: *const *mut ::c_char) -> ::c_int; pub fn ffs(value: ::c_int) -> ::c_int; pub fn ffsl(value: ::c_long) -> ::c_int; pub fn ffsll(value: ::c_longlong) -> ::c_int; diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index 2cacf29f6b418..deec291b28dca 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -199,7 +199,6 @@ s_no_extra_traits! { pub __pad: [::c_int; 3], } - #[cfg(libc_union)] pub union _kernel_simple_lock { pub _slock: ::c_long, // Should be pointer to 'lock_data_instrumented' @@ -228,9 +227,7 @@ s_no_extra_traits! { pub f_dir_off: ::c_long, // Should be pointer to 'cred' pub f_cred: *mut ::c_void, - #[cfg(libc_union)] pub f_lock: _kernel_simple_lock, - #[cfg(libc_union)] pub f_offset_lock: _kernel_simple_lock, pub f_vinfo: ::caddr_t, pub f_ops: *mut fileops_t, @@ -239,7 +236,6 @@ s_no_extra_traits! { pub f_fdata: [::c_char; 160], } - #[cfg(libc_union)] pub union __ld_info_file { pub _ldinfo_fd: ::c_int, pub _ldinfo_fp: *mut file, @@ -249,7 +245,6 @@ s_no_extra_traits! { pub struct ld_info { pub ldinfo_next: ::c_uint, pub ldinfo_flags: ::c_uint, - #[cfg(libc_union)] pub _file: __ld_info_file, pub ldinfo_textorg: *mut ::c_void, pub ldinfo_textsize: ::c_ulong, @@ -258,7 +253,6 @@ s_no_extra_traits! { pub ldinfo_filename: [::c_char; 2], } - #[cfg(libc_union)] pub union __pollfd_ext_u { pub addr: *mut ::c_void, pub data32: u32, @@ -269,7 +263,6 @@ s_no_extra_traits! { pub fd: ::c_int, pub events: ::c_ushort, pub revents: ::c_ushort, - #[cfg(libc_union)] pub data: __pollfd_ext_u, } } @@ -300,10 +293,6 @@ cfg_if! { if #[cfg(feature = "extra_traits")] { impl PartialEq for siginfo_t { fn eq(&self, other: &siginfo_t) -> bool { - #[cfg(libc_union)] - let value_eq = self.si_value == other.si_value; - #[cfg(not(libc_union))] - let value_eq = true; self.si_signo == other.si_signo && self.si_errno == other.si_errno && self.si_code == other.si_code @@ -313,7 +302,7 @@ cfg_if! { && self.si_addr == other.si_addr && self.si_band == other.si_band && self.__si_flags == other.__si_flags - && value_eq + && self.si_value == other.si_value } } impl Eq for siginfo_t {} @@ -328,7 +317,6 @@ cfg_if! { struct_formatter.field("si_status", &self.si_status); struct_formatter.field("si_addr", &self.si_addr); struct_formatter.field("si_band", &self.si_band); - #[cfg(libc_union)] struct_formatter.field("si_value", &self.si_value); struct_formatter.field("__si_flags", &self.__si_flags); struct_formatter.finish() @@ -344,13 +332,11 @@ cfg_if! { self.si_status.hash(state); self.si_addr.hash(state); self.si_band.hash(state); - #[cfg(libc_union)] self.si_value.hash(state); self.__si_flags.hash(state); } } - #[cfg(libc_union)] impl PartialEq for _kernel_simple_lock { fn eq(&self, other: &_kernel_simple_lock) -> bool { unsafe { @@ -359,9 +345,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for _kernel_simple_lock {} - #[cfg(libc_union)] impl ::fmt::Debug for _kernel_simple_lock { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("_kernel_simple_lock") @@ -370,7 +354,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for _kernel_simple_lock { fn hash(&self, state: &mut H) { unsafe { @@ -413,11 +396,6 @@ cfg_if! { impl PartialEq for file { fn eq(&self, other: &file) -> bool { - #[cfg(libc_union)] - let lock_eq = self.f_lock == other.f_lock - && self.f_offset_lock == other.f_offset_lock; - #[cfg(not(libc_union))] - let lock_eq = true; self.f_flag == other.f_flag && self.f_count == other.f_count && self.f_options == other.f_options @@ -431,7 +409,8 @@ cfg_if! { && self.f_parentp == other.f_parentp && self.f_fnamep == other.f_fnamep && self.f_fdata == other.f_fdata - && lock_eq + && self.f_lock == other.f_lock + && self.f_offset_lock == other.f_offset_lock } } impl Eq for file {} @@ -446,9 +425,7 @@ cfg_if! { struct_formatter.field("f_offset", &self.f_offset); struct_formatter.field("f_dir_off", &self.f_dir_off); struct_formatter.field("f_cred", &self.f_cred); - #[cfg(libc_union)] struct_formatter.field("f_lock", &self.f_lock); - #[cfg(libc_union)] struct_formatter.field("f_offset_lock", &self.f_offset_lock); struct_formatter.field("f_vinfo", &self.f_vinfo); struct_formatter.field("f_ops", &self.f_ops); @@ -468,9 +445,7 @@ cfg_if! { self.f_offset.hash(state); self.f_dir_off.hash(state); self.f_cred.hash(state); - #[cfg(libc_union)] self.f_lock.hash(state); - #[cfg(libc_union)] self.f_offset_lock.hash(state); self.f_vinfo.hash(state); self.f_ops.hash(state); @@ -480,7 +455,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __ld_info_file { fn eq(&self, other: &__ld_info_file) -> bool { unsafe { @@ -490,9 +464,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for __ld_info_file {} - #[cfg(libc_union)] impl ::fmt::Debug for __ld_info_file { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("__ld_info_file") @@ -502,7 +474,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __ld_info_file { fn hash(&self, state: &mut H) { unsafe { @@ -515,10 +486,6 @@ cfg_if! { impl PartialEq for ld_info { fn eq(&self, other: &ld_info) -> bool { - #[cfg(libc_union)] - let file_eq = self._file == other._file; - #[cfg(not(libc_union))] - let file_eq = true; self.ldinfo_next == other.ldinfo_next && self.ldinfo_flags == other.ldinfo_flags && self.ldinfo_textorg == other.ldinfo_textorg @@ -526,7 +493,7 @@ cfg_if! { && self.ldinfo_dataorg == other.ldinfo_dataorg && self.ldinfo_datasize == other.ldinfo_datasize && self.ldinfo_filename == other.ldinfo_filename - && file_eq + && self._file == other._file } } impl Eq for ld_info {} @@ -540,7 +507,6 @@ cfg_if! { struct_formatter.field("ldinfo_dataorg", &self.ldinfo_dataorg); struct_formatter.field("ldinfo_datasize", &self.ldinfo_datasize); struct_formatter.field("ldinfo_filename", &self.ldinfo_filename); - #[cfg(libc_union)] struct_formatter.field("_file", &self._file); struct_formatter.finish() } @@ -554,12 +520,10 @@ cfg_if! { self.ldinfo_dataorg.hash(state); self.ldinfo_datasize.hash(state); self.ldinfo_filename.hash(state); - #[cfg(libc_union)] self._file.hash(state); } } - #[cfg(libc_union)] impl PartialEq for __pollfd_ext_u { fn eq(&self, other: &__pollfd_ext_u) -> bool { unsafe { @@ -569,9 +533,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for __pollfd_ext_u {} - #[cfg(libc_union)] impl ::fmt::Debug for __pollfd_ext_u { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("__pollfd_ext_u") @@ -581,7 +543,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __pollfd_ext_u { fn hash(&self, state: &mut H) { unsafe { @@ -594,14 +555,10 @@ cfg_if! { impl PartialEq for pollfd_ext { fn eq(&self, other: &pollfd_ext) -> bool { - #[cfg(libc_union)] - let data_eq = self.data == other.data; - #[cfg(not(libc_union))] - let data_eq = true; self.fd == other.fd && self.events == other.events && self.revents == other.revents - && data_eq + && self.data == other.data } } impl Eq for pollfd_ext {} @@ -611,7 +568,6 @@ cfg_if! { struct_formatter.field("fd", &self.fd); struct_formatter.field("events", &self.events); struct_formatter.field("revents", &self.revents); - #[cfg(libc_union)] struct_formatter.field("data", &self.data); struct_formatter.finish() } @@ -621,7 +577,6 @@ cfg_if! { self.fd.hash(state); self.events.hash(state); self.revents.hash(state); - #[cfg(libc_union)] self.data.hash(state); } } diff --git a/src/unix/bsd/apple/b32/mod.rs b/src/unix/bsd/apple/b32/mod.rs index 0f1722f975744..4707fa4c99991 100644 --- a/src/unix/bsd/apple/b32/mod.rs +++ b/src/unix/bsd/apple/b32/mod.rs @@ -111,9 +111,5 @@ extern "C" { ) -> ::c_int; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/bsd/apple/b64/aarch64/align.rs b/src/unix/bsd/apple/b64/aarch64/align.rs index 131e15b69ad94..7f86a134649cf 100644 --- a/src/unix/bsd/apple/b64/aarch64/align.rs +++ b/src/unix/bsd/apple/b64/aarch64/align.rs @@ -39,16 +39,8 @@ s! { pub __pad: u32, } - // This type natively uses a uint128, but for a while we hacked - // it in with repr(align) and `[u64; 2]`. uint128 isn't available - // all the way back to our earliest supported versions so we - // preserver the old shim. - #[cfg_attr(not(libc_int128), repr(align(16)))] pub struct __darwin_arm_neon_state64 { - #[cfg(libc_int128)] pub __v: [::__uint128_t; 32], - #[cfg(not(libc_int128))] - pub __v: [[u64; 2]; 32], pub __fpsr: u32, pub __fpcr: u32, } diff --git a/src/unix/bsd/apple/b64/aarch64/mod.rs b/src/unix/bsd/apple/b64/aarch64/mod.rs index 79e9ac842f9ca..a32abf17008fd 100644 --- a/src/unix/bsd/apple/b64/aarch64/mod.rs +++ b/src/unix/bsd/apple/b64/aarch64/mod.rs @@ -6,9 +6,5 @@ s! { } } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/bsd/apple/b64/x86_64/mod.rs b/src/unix/bsd/apple/b64/x86_64/mod.rs index 653650c26289f..a15d6cfe47c31 100644 --- a/src/unix/bsd/apple/b64/x86_64/mod.rs +++ b/src/unix/bsd/apple/b64/x86_64/mod.rs @@ -172,9 +172,5 @@ s! { } } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index d9e3831ea2e1a..ff3326475970d 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -37,6 +37,8 @@ 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 quad_t = i64; +pub type u_quad_t = u64; pub type posix_spawnattr_t = *mut ::c_void; pub type posix_spawn_file_actions_t = *mut ::c_void; @@ -159,10 +161,6 @@ pub type copyfile_callback_t = ::Option< pub type attrgroup_t = u32; pub type vol_capabilities_set_t = [u32; 4]; -deprecated_mach! { - pub type mach_timebase_info_data_t = mach_timebase_info; -} - #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} impl ::Copy for timezone {} @@ -295,15 +293,6 @@ s! { pub ai_next: *mut addrinfo, } - #[deprecated( - since = "0.2.55", - note = "Use the `mach2` crate instead", - )] - pub struct mach_timebase_info { - pub numer: u32, - pub denom: u32, - } - pub struct stat { pub st_dev: dev_t, pub st_mode: mode_t, @@ -504,8 +493,7 @@ s! { pub rmx_rtt: u32, pub rmx_rttvar: u32, pub rmx_pksent: u32, - pub rmx_state: u32, - pub rmx_filler: [u32; 3], + pub rmx_filler: [u32; 4], } pub struct rt_msghdr { @@ -656,35 +644,6 @@ s! { pub cr_groups: [::gid_t;16] } - #[deprecated( - since = "0.2.55", - note = "Use the `mach2` crate instead", - )] - pub struct mach_header { - pub magic: u32, - pub cputype: cpu_type_t, - pub cpusubtype: cpu_subtype_t, - pub filetype: u32, - pub ncmds: u32, - pub sizeofcmds: u32, - pub flags: u32, - } - - #[deprecated( - since = "0.2.55", - note = "Use the `mach2` crate instead", - )] - pub struct mach_header_64 { - pub magic: u32, - pub cputype: cpu_type_t, - pub cpusubtype: cpu_subtype_t, - pub filetype: u32, - pub ncmds: u32, - pub sizeofcmds: u32, - pub flags: u32, - pub reserved: u32, - } - pub struct segment_command { pub cmd: u32, pub cmdsize: u32, @@ -1130,16 +1089,13 @@ s! { pub nativeattr: attribute_set_t, } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct ifconf { pub ifc_len: ::c_int, - #[cfg(libc_union)] pub ifc_ifcu: __c_anonymous_ifc_ifcu, - #[cfg(not(libc_union))] - pub ifc_ifcu: *mut ifreq, } - #[cfg_attr(libc_align, repr(align(8)))] + #[repr(align(8))] pub struct tcp_connection_info { pub tcpi_state: u8, pub tcpi_snd_wscale: u8, @@ -1181,10 +1137,81 @@ s! { pub tcpi_rxoutoforderbytes: u64, pub tcpi_rxretransmitpackets: u64, } + + pub struct in6_addrlifetime { + pub ia6t_expire: time_t, + pub ia6t_preferred: time_t, + pub ia6t_vltime: u32, + pub ia6t_pltime: u32, + } + + pub struct in6_ifstat { + pub ifs6_in_receive: ::u_quad_t, + pub ifs6_in_hdrerr: ::u_quad_t, + pub ifs6_in_toobig: ::u_quad_t, + pub ifs6_in_noroute: ::u_quad_t, + pub ifs6_in_addrerr: ::u_quad_t, + pub ifs6_in_protounknown: ::u_quad_t, + pub ifs6_in_truncated: ::u_quad_t, + pub ifs6_in_discard: ::u_quad_t, + pub ifs6_in_deliver: ::u_quad_t, + pub ifs6_out_forward: ::u_quad_t, + pub ifs6_out_request: ::u_quad_t, + pub ifs6_out_discard: ::u_quad_t, + pub ifs6_out_fragok: ::u_quad_t, + pub ifs6_out_fragfail: ::u_quad_t, + pub ifs6_out_fragcreat: ::u_quad_t, + pub ifs6_reass_reqd: ::u_quad_t, + pub ifs6_reass_ok: ::u_quad_t, + pub ifs6_atmfrag_rcvd: ::u_quad_t, + pub ifs6_reass_fail: ::u_quad_t, + pub ifs6_in_mcast: ::u_quad_t, + pub ifs6_out_mcast: ::u_quad_t, + pub ifs6_cantfoward_icmp6: ::u_quad_t, + pub ifs6_addr_expiry_cnt: ::u_quad_t, + pub ifs6_pfx_expiry_cnt: ::u_quad_t, + pub ifs6_defrtr_expiry_cnt: ::u_quad_t, + } + pub struct icmp6_ifstat { + pub ifs6_in_msg: ::u_quad_t, + pub ifs6_in_error: ::u_quad_t, + pub ifs6_in_dstunreach: ::u_quad_t, + pub ifs6_in_adminprohib: ::u_quad_t, + pub ifs6_in_timeexceed: ::u_quad_t, + pub ifs6_in_paramprob: ::u_quad_t, + pub ifs6_in_pkttoobig: ::u_quad_t, + pub ifs6_in_echo: ::u_quad_t, + pub ifs6_in_echoreply: ::u_quad_t, + pub ifs6_in_routersolicit: ::u_quad_t, + pub ifs6_in_routeradvert: ::u_quad_t, + pub ifs6_in_neighborsolicit: ::u_quad_t, + pub ifs6_in_neighboradvert: ::u_quad_t, + pub ifs6_in_redirect: ::u_quad_t, + pub ifs6_in_mldquery: ::u_quad_t, + pub ifs6_in_mldreport: ::u_quad_t, + pub ifs6_in_mlddone: ::u_quad_t, + pub ifs6_out_msg: ::u_quad_t, + pub ifs6_out_error: ::u_quad_t, + pub ifs6_out_dstunreach: ::u_quad_t, + pub ifs6_out_adminprohib: ::u_quad_t, + pub ifs6_out_timeexceed: ::u_quad_t, + pub ifs6_out_paramprob: ::u_quad_t, + pub ifs6_out_pkttoobig: ::u_quad_t, + pub ifs6_out_echo: ::u_quad_t, + pub ifs6_out_echoreply: ::u_quad_t, + pub ifs6_out_routersolicit: ::u_quad_t, + pub ifs6_out_routeradvert: ::u_quad_t, + pub ifs6_out_neighborsolicit: ::u_quad_t, + pub ifs6_out_neighboradvert: ::u_quad_t, + pub ifs6_out_redirect: ::u_quad_t, + pub ifs6_out_mldquery: ::u_quad_t, + pub ifs6_out_mldreport: ::u_quad_t, + pub ifs6_out_mlddone: ::u_quad_t, + } } s_no_extra_traits! { - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct kevent { pub ident: ::uintptr_t, pub filter: i16, @@ -1194,7 +1221,7 @@ s_no_extra_traits! { pub udata: *mut ::c_void, } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct semid_ds { // Note the manpage shows different types than the system header. pub sem_perm: ipc_perm, @@ -1207,7 +1234,7 @@ s_no_extra_traits! { pub sem_pad3: [i32; 4], } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct shmid_ds { pub shm_perm: ipc_perm, pub shm_segsz: ::size_t, @@ -1366,7 +1393,7 @@ s_no_extra_traits! { pub pth_name: [::c_char; MAXTHREADNAMESIZE], } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct if_data64 { pub ifi_type: ::c_uchar, pub ifi_typelen: ::c_uchar, @@ -1398,7 +1425,7 @@ s_no_extra_traits! { pub ifi_lastchange: timeval32, } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct if_msghdr2 { pub ifm_msglen: ::c_ushort, pub ifm_version: ::c_uchar, @@ -1413,7 +1440,7 @@ s_no_extra_traits! { pub ifm_data: if_data64, } - #[cfg_attr(libc_packedN, repr(packed(8)))] + #[repr(packed(8))] pub struct vm_statistics64 { pub free_count: natural_t, pub active_count: natural_t, @@ -1441,7 +1468,7 @@ s_no_extra_traits! { pub total_uncompressed_pages_in_compressor: u64, } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct mach_task_basic_info { pub virtual_size: mach_vm_size_t, pub resident_size: mach_vm_size_t, @@ -1452,7 +1479,7 @@ s_no_extra_traits! { pub suspend_count: integer_t, } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct log2phys { pub l2p_flags: ::c_uint, pub l2p_contigbytes: ::off_t, @@ -1463,7 +1490,7 @@ s_no_extra_traits! { _os_unfair_lock_opaque: u32, } - #[cfg_attr(libc_packedN, repr(packed(1)))] + #[repr(packed(1))] pub struct sockaddr_vm { pub svm_len: ::c_uchar, pub svm_family: ::sa_family_t, @@ -1478,21 +1505,18 @@ s_no_extra_traits! { pub ifdm_max: ::c_int, } - #[cfg(libc_union)] pub union __c_anonymous_ifk_data { pub ifk_ptr: *mut ::c_void, pub ifk_value: ::c_int, } - #[cfg_attr(libc_packedN, repr(packed(4)))] + #[repr(packed(4))] pub struct ifkpi { pub ifk_module_id: ::c_uint, pub ifk_type: ::c_uint, - #[cfg(libc_union)] pub ifk_data: __c_anonymous_ifk_data, } - #[cfg(libc_union)] pub union __c_anonymous_ifr_ifru { pub ifru_addr: ::sockaddr, pub ifru_dstaddr: ::sockaddr, @@ -1514,17 +1538,32 @@ s_no_extra_traits! { pub struct ifreq { 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: *mut ::c_char, pub ifcu_req: *mut ifreq, } + + pub union __c_anonymous_ifr_ifru6 { + pub ifru_addr: ::sockaddr_in6, + pub ifru_dstaddr: ::sockaddr_in6, + pub ifru_flags: ::c_int, + pub ifru_flags6: ::c_int, + pub ifru_metrics: ::c_int, + pub ifru_intval: ::c_int, + pub ifru_data: *mut ::c_char, + pub ifru_lifetime: in6_addrlifetime, + pub ifru_stat: in6_ifstat, + pub ifru_icmp6stat: icmp6_ifstat, + pub ifru_scope_id: [u32; SCOPE6_ID_MAX], + } + + pub struct in6_ifreq { + pub ifr_name: [::c_char; ::IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru6, + } } impl siginfo_t { @@ -1561,37 +1600,33 @@ impl siginfo_t { } } +s_no_extra_traits! { + pub union semun { + pub val: ::c_int, + pub buf: *mut semid_ds, + pub array: *mut ::c_ushort, + } +} + cfg_if! { - if #[cfg(libc_union)] { - s_no_extra_traits! { - pub union semun { - pub val: ::c_int, - pub buf: *mut semid_ds, - pub array: *mut ::c_ushort, + if #[cfg(feature = "extra_traits")] { + impl PartialEq for semun { + fn eq(&self, other: &semun) -> bool { + unsafe { self.val == other.val } } } - - cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for semun { - fn eq(&self, other: &semun) -> bool { - unsafe { self.val == other.val } - } - } - impl Eq for semun {} - impl ::fmt::Debug for semun { - fn fmt(&self, f: &mut ::fmt::Formatter) - -> ::fmt::Result { - f.debug_struct("semun") - .field("val", unsafe { &self.val }) - .finish() - } - } - impl ::hash::Hash for semun { - fn hash(&self, state: &mut H) { - unsafe { self.val.hash(state) }; - } - } + impl Eq for semun {} + impl ::fmt::Debug for semun { + fn fmt(&self, f: &mut ::fmt::Formatter) + -> ::fmt::Result { + f.debug_struct("semun") + .field("val", unsafe { &self.val }) + .finish() + } + } + impl ::hash::Hash for semun { + fn hash(&self, state: &mut H) { + unsafe { self.val.hash(state) }; } } } @@ -2902,7 +2937,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ifk_data { fn eq(&self, other: &__c_anonymous_ifk_data) -> bool { unsafe { @@ -2912,10 +2946,8 @@ cfg_if! { } } - #[cfg(libc_union)] impl Eq for __c_anonymous_ifk_data {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_ifk_data { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("__c_anonymous_ifk_data") @@ -2924,7 +2956,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifk_data { fn hash(&self, state: &mut H) { unsafe { @@ -2959,7 +2990,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ifr_ifru { fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { unsafe { @@ -2983,10 +3013,8 @@ cfg_if! { } } - #[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("__c_anonymous_ifr_ifru") @@ -3010,7 +3038,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifr_ifru { fn hash(&self, state: &mut H) { unsafe { @@ -3059,10 +3086,8 @@ cfg_if! { } } - #[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 { @@ -3072,7 +3097,6 @@ cfg_if! { } } - #[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") @@ -3082,13 +3106,80 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifc_ifcu { fn hash(&self, state: &mut H) { unsafe { self.ifcu_buf.hash(state) }; unsafe { self.ifcu_req.hash(state) }; } } + + impl PartialEq for __c_anonymous_ifr_ifru6 { + fn eq(&self, other: &__c_anonymous_ifr_ifru6) -> bool { + unsafe { + self.ifru_addr == other.ifru_addr + && self.ifru_dstaddr == other.ifru_dstaddr + && self.ifru_flags == other.ifru_flags + && self.ifru_flags6 == other.ifru_flags6 + && self.ifru_metrics == other.ifru_metrics + && self.ifru_intval == other.ifru_intval + && self.ifru_data == other.ifru_data + && self.ifru_scope_id + .iter() + .zip(other.ifru_scope_id.iter()) + .all(|(a,b)| a == b) + } + } + } + + impl Eq for __c_anonymous_ifr_ifru6 {} + + impl ::fmt::Debug for __c_anonymous_ifr_ifru6 { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("__c_anonymous_ifr_ifru6") + .field("ifru_addr", unsafe { &self.ifru_addr }) + .field("ifru_dstaddr", unsafe { &self.ifru_dstaddr }) + .field("ifru_flags", unsafe { &self.ifru_flags }) + .field("ifru_flags6", unsafe { &self.ifru_flags6 }) + .field("ifru_metrics", unsafe { &self.ifru_metrics }) + .field("ifru_intval", unsafe { &self.ifru_intval }) + .field("ifru_data", unsafe { &self.ifru_data }) + .field("ifru_scope_id", unsafe { &self.ifru_scope_id }) + .finish() + } + } + + impl ::hash::Hash for __c_anonymous_ifr_ifru6 { + fn hash(&self, state: &mut H) { + unsafe { + self.ifru_addr.hash(state); + self.ifru_dstaddr.hash(state); + self.ifru_flags.hash(state); + self.ifru_flags6.hash(state); + self.ifru_metrics.hash(state); + self.ifru_intval.hash(state); + self.ifru_data.hash(state); + self.ifru_scope_id.hash(state); + } + } + } + + impl PartialEq for in6_ifreq { + fn eq(&self, other: &in6_ifreq) -> bool { + self.ifr_name == other.ifr_name + && self.ifr_ifru == other.ifr_ifru + } + } + + impl Eq for in6_ifreq {} + + impl ::fmt::Debug for in6_ifreq { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("in6_ifreq") + .field("ifr_name", &self.ifr_name) + .field("ifr_ifru", &self.ifr_ifru) + .finish() + } + } } } @@ -3254,29 +3345,29 @@ pub const O_CLOEXEC: ::c_int = 0x01000000; pub const O_NOFOLLOW_ANY: ::c_int = 0x20000000; pub const O_EXEC: ::c_int = 0x40000000; pub const O_SEARCH: ::c_int = O_EXEC | O_DIRECTORY; -pub const S_IFIFO: mode_t = 4096; -pub const S_IFCHR: mode_t = 8192; -pub const S_IFBLK: mode_t = 24576; -pub const S_IFDIR: mode_t = 16384; -pub const S_IFREG: mode_t = 32768; -pub const S_IFLNK: mode_t = 40960; -pub const S_IFSOCK: mode_t = 49152; -pub const S_IFMT: mode_t = 61440; -pub const S_IEXEC: mode_t = 64; -pub const S_IWRITE: mode_t = 128; -pub const S_IREAD: mode_t = 256; -pub const S_IRWXU: mode_t = 448; -pub const S_IXUSR: mode_t = 64; -pub const S_IWUSR: mode_t = 128; -pub const S_IRUSR: mode_t = 256; -pub const S_IRWXG: mode_t = 56; -pub const S_IXGRP: mode_t = 8; -pub const S_IWGRP: mode_t = 16; -pub const S_IRGRP: mode_t = 32; -pub const S_IRWXO: mode_t = 7; -pub const S_IXOTH: mode_t = 1; -pub const S_IWOTH: mode_t = 2; -pub const S_IROTH: mode_t = 4; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IREAD: mode_t = 0o0400; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; pub const F_OK: ::c_int = 0; pub const R_OK: ::c_int = 4; pub const W_OK: ::c_int = 2; @@ -3349,107 +3440,6 @@ pub const PROCESSOR_TEMPERATURE: ::c_int = 0x10000002; pub const PROCESSOR_SET_LOAD_INFO: ::c_int = 4; pub const PROCESSOR_SET_BASIC_INFO: ::c_int = 5; -deprecated_mach! { - pub const VM_FLAGS_FIXED: ::c_int = 0x0000; - pub const VM_FLAGS_ANYWHERE: ::c_int = 0x0001; - pub const VM_FLAGS_PURGABLE: ::c_int = 0x0002; - pub const VM_FLAGS_RANDOM_ADDR: ::c_int = 0x0008; - pub const VM_FLAGS_NO_CACHE: ::c_int = 0x0010; - pub const VM_FLAGS_RESILIENT_CODESIGN: ::c_int = 0x0020; - pub const VM_FLAGS_RESILIENT_MEDIA: ::c_int = 0x0040; - pub const VM_FLAGS_OVERWRITE: ::c_int = 0x4000; - pub const VM_FLAGS_SUPERPAGE_MASK: ::c_int = 0x70000; - pub const VM_FLAGS_RETURN_DATA_ADDR: ::c_int = 0x100000; - pub const VM_FLAGS_RETURN_4K_DATA_ADDR: ::c_int = 0x800000; - pub const VM_FLAGS_ALIAS_MASK: ::c_int = 0xFF000000; - pub const VM_FLAGS_USER_ALLOCATE: ::c_int = 0xff07401f; - pub const VM_FLAGS_USER_MAP: ::c_int = 0xff97401f; - pub const VM_FLAGS_USER_REMAP: ::c_int = VM_FLAGS_FIXED | - VM_FLAGS_ANYWHERE | - VM_FLAGS_RANDOM_ADDR | - VM_FLAGS_OVERWRITE | - VM_FLAGS_RETURN_DATA_ADDR | - VM_FLAGS_RESILIENT_CODESIGN; - - pub const VM_FLAGS_SUPERPAGE_SHIFT: ::c_int = 16; - pub const SUPERPAGE_NONE: ::c_int = 0; - pub const SUPERPAGE_SIZE_ANY: ::c_int = 1; - pub const VM_FLAGS_SUPERPAGE_NONE: ::c_int = SUPERPAGE_NONE << - VM_FLAGS_SUPERPAGE_SHIFT; - pub const VM_FLAGS_SUPERPAGE_SIZE_ANY: ::c_int = SUPERPAGE_SIZE_ANY << - VM_FLAGS_SUPERPAGE_SHIFT; - pub const SUPERPAGE_SIZE_2MB: ::c_int = 2; - pub const VM_FLAGS_SUPERPAGE_SIZE_2MB: ::c_int = SUPERPAGE_SIZE_2MB << - VM_FLAGS_SUPERPAGE_SHIFT; - - pub const VM_MEMORY_MALLOC: ::c_int = 1; - pub const VM_MEMORY_MALLOC_SMALL: ::c_int = 2; - pub const VM_MEMORY_MALLOC_LARGE: ::c_int = 3; - pub const VM_MEMORY_MALLOC_HUGE: ::c_int = 4; - pub const VM_MEMORY_SBRK: ::c_int = 5; - pub const VM_MEMORY_REALLOC: ::c_int = 6; - pub const VM_MEMORY_MALLOC_TINY: ::c_int = 7; - pub const VM_MEMORY_MALLOC_LARGE_REUSABLE: ::c_int = 8; - pub const VM_MEMORY_MALLOC_LARGE_REUSED: ::c_int = 9; - pub const VM_MEMORY_ANALYSIS_TOOL: ::c_int = 10; - pub const VM_MEMORY_MALLOC_NANO: ::c_int = 11; - pub const VM_MEMORY_MACH_MSG: ::c_int = 20; - pub const VM_MEMORY_IOKIT: ::c_int = 21; - pub const VM_MEMORY_STACK: ::c_int = 30; - pub const VM_MEMORY_GUARD: ::c_int = 31; - pub const VM_MEMORY_SHARED_PMAP: ::c_int = 32; - pub const VM_MEMORY_DYLIB: ::c_int = 33; - pub const VM_MEMORY_OBJC_DISPATCHERS: ::c_int = 34; - pub const VM_MEMORY_UNSHARED_PMAP: ::c_int = 35; - pub const VM_MEMORY_APPKIT: ::c_int = 40; - pub const VM_MEMORY_FOUNDATION: ::c_int = 41; - pub const VM_MEMORY_COREGRAPHICS: ::c_int = 42; - pub const VM_MEMORY_CORESERVICES: ::c_int = 43; - pub const VM_MEMORY_CARBON: ::c_int = VM_MEMORY_CORESERVICES; - pub const VM_MEMORY_JAVA: ::c_int = 44; - pub const VM_MEMORY_COREDATA: ::c_int = 45; - pub const VM_MEMORY_COREDATA_OBJECTIDS: ::c_int = 46; - pub const VM_MEMORY_ATS: ::c_int = 50; - pub const VM_MEMORY_LAYERKIT: ::c_int = 51; - pub const VM_MEMORY_CGIMAGE: ::c_int = 52; - pub const VM_MEMORY_TCMALLOC: ::c_int = 53; - pub const VM_MEMORY_COREGRAPHICS_DATA: ::c_int = 54; - pub const VM_MEMORY_COREGRAPHICS_SHARED: ::c_int = 55; - pub const VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS: ::c_int = 56; - pub const VM_MEMORY_COREGRAPHICS_BACKINGSTORES: ::c_int = 57; - pub const VM_MEMORY_COREGRAPHICS_XALLOC: ::c_int = 58; - pub const VM_MEMORY_COREGRAPHICS_MISC: ::c_int = VM_MEMORY_COREGRAPHICS; - pub const VM_MEMORY_DYLD: ::c_int = 60; - pub const VM_MEMORY_DYLD_MALLOC: ::c_int = 61; - pub const VM_MEMORY_SQLITE: ::c_int = 62; - pub const VM_MEMORY_JAVASCRIPT_CORE: ::c_int = 63; - pub const VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR: ::c_int = 64; - pub const VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE: ::c_int = 65; - pub const VM_MEMORY_GLSL: ::c_int = 66; - pub const VM_MEMORY_OPENCL: ::c_int = 67; - pub const VM_MEMORY_COREIMAGE: ::c_int = 68; - pub const VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS: ::c_int = 69; - pub const VM_MEMORY_IMAGEIO: ::c_int = 70; - pub const VM_MEMORY_COREPROFILE: ::c_int = 71; - pub const VM_MEMORY_ASSETSD: ::c_int = 72; - pub const VM_MEMORY_OS_ALLOC_ONCE: ::c_int = 73; - pub const VM_MEMORY_LIBDISPATCH: ::c_int = 74; - pub const VM_MEMORY_ACCELERATE: ::c_int = 75; - pub const VM_MEMORY_COREUI: ::c_int = 76; - pub const VM_MEMORY_COREUIFILE: ::c_int = 77; - pub const VM_MEMORY_GENEALOGY: ::c_int = 78; - pub const VM_MEMORY_RAWCAMERA: ::c_int = 79; - pub const VM_MEMORY_CORPSEINFO: ::c_int = 80; - pub const VM_MEMORY_ASL: ::c_int = 81; - pub const VM_MEMORY_SWIFT_RUNTIME: ::c_int = 82; - pub const VM_MEMORY_SWIFT_METADATA: ::c_int = 83; - pub const VM_MEMORY_DHMM: ::c_int = 84; - pub const VM_MEMORY_SCENEKIT: ::c_int = 86; - pub const VM_MEMORY_SKYWALK: ::c_int = 87; - pub const VM_MEMORY_APPLICATION_SPECIFIC_1: ::c_int = 240; - pub const VM_MEMORY_APPLICATION_SPECIFIC_16: ::c_int = 255; -} - pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; pub const MCL_CURRENT: ::c_int = 0x0001; @@ -3609,6 +3599,7 @@ pub const F_GETPATH_NOFIRMLINK: ::c_int = 102; pub const F_ALLOCATECONTIG: ::c_uint = 0x02; pub const F_ALLOCATEALL: ::c_uint = 0x04; +pub const F_ALLOCATEPERSIST: ::c_uint = 0x08; pub const F_PEOFPOSMODE: ::c_int = 3; pub const F_VOLPOSMODE: ::c_int = 4; @@ -4253,6 +4244,8 @@ 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; // supports multicast +pub const SCOPE6_ID_MAX: ::size_t = 16; + pub const SHUT_RD: ::c_int = 0; pub const SHUT_WR: ::c_int = 1; pub const SHUT_RDWR: ::c_int = 2; @@ -4430,7 +4423,7 @@ pub const OS_SIGNPOST_INTERVAL_END: ::os_signpost_type_t = 0x02; pub const MINSIGSTKSZ: ::size_t = 32768; pub const SIGSTKSZ: ::size_t = 131072; -pub const FD_SETSIZE: usize = 1024; +pub const FD_SETSIZE: ::c_int = 1024; pub const ST_NOSUID: ::c_ulong = 2; @@ -5064,13 +5057,13 @@ pub const MNT_SNAPSHOT: ::c_int = 0x40000000; pub const MNT_NOBLOCK: ::c_int = 0x00020000; // sys/spawn.h: -pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x0001; -pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x0002; -pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x0004; -pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x0008; -pub const POSIX_SPAWN_SETEXEC: ::c_int = 0x0040; -pub const POSIX_SPAWN_START_SUSPENDED: ::c_int = 0x0080; -pub const POSIX_SPAWN_CLOEXEC_DEFAULT: ::c_int = 0x4000; +pub const POSIX_SPAWN_RESETIDS: ::c_short = 0x0001; +pub const POSIX_SPAWN_SETPGROUP: ::c_short = 0x0002; +pub const POSIX_SPAWN_SETSIGDEF: ::c_short = 0x0004; +pub const POSIX_SPAWN_SETSIGMASK: ::c_short = 0x0008; +pub const POSIX_SPAWN_SETEXEC: ::c_short = 0x0040; +pub const POSIX_SPAWN_START_SUSPENDED: ::c_short = 0x0080; +pub const POSIX_SPAWN_CLOEXEC_DEFAULT: ::c_short = 0x4000; // sys/ipc.h: pub const IPC_CREAT: ::c_int = 0x200; @@ -5460,82 +5453,49 @@ pub const VMADDR_CID_RESERVED: ::c_uint = 1; pub const VMADDR_CID_HOST: ::c_uint = 2; pub const VMADDR_PORT_ANY: ::c_uint = 0xFFFFFFFF; -cfg_if! { - if #[cfg(libc_const_extern_fn)] { - const fn __DARWIN_ALIGN32(p: usize) -> usize { - const __DARWIN_ALIGNBYTES32: usize = ::mem::size_of::() - 1; - p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32 - } - } else if #[cfg(libc_const_size_of)] { - fn __DARWIN_ALIGN32(p: usize) -> usize { - const __DARWIN_ALIGNBYTES32: usize = ::mem::size_of::() - 1; - p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32 - } - } else { - fn __DARWIN_ALIGN32(p: usize) -> usize { - let __DARWIN_ALIGNBYTES32: usize = ::mem::size_of::() - 1; - p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32 - } - } +const fn __DARWIN_ALIGN32(p: usize) -> usize { + const __DARWIN_ALIGNBYTES32: usize = ::mem::size_of::() - 1; + p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32 } -cfg_if! { - if #[cfg(libc_const_size_of)] { - pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / ::mem::size_of::()) - as mach_msg_type_number_t; - pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / - ::mem::size_of::()) as mach_msg_type_number_t; - pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / ::mem::size_of::()) - as mach_msg_type_number_t; - pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / ::mem::size_of::()) - as mach_msg_type_number_t; - pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / ::mem::size_of::()) - as mach_msg_type_number_t; - pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / ::mem::size_of::()) - as mach_msg_type_number_t; - pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / - ::mem::size_of::()) as mach_msg_type_number_t; - pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / ::mem::size_of::()) - as mach_msg_type_number_t; - pub const THREAD_IDENTIFIER_INFO_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / ::mem::size_of::()) - as mach_msg_type_number_t; - pub const THREAD_EXTENDED_INFO_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / ::mem::size_of::()) - as mach_msg_type_number_t; - - pub const TASK_THREAD_TIMES_INFO_COUNT: u32 = - (::mem::size_of::() - / ::mem::size_of::()) as u32; - pub const MACH_TASK_BASIC_INFO_COUNT: u32 = (::mem::size_of::() - / ::mem::size_of::()) as u32; - pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t = - (::mem::size_of::() / ::mem::size_of::()) - as mach_msg_type_number_t; - } else { - pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t = 1; - pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t = 4; - pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t = 1; - pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t = 1; - pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t = 1; - pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t = 1; - pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t = 1; - 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; - } -} +pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; +pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; +pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; +pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; +pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; +pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; +pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; +pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; +pub const THREAD_IDENTIFIER_INFO_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; +pub const THREAD_EXTENDED_INFO_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; + +pub const TASK_THREAD_TIMES_INFO_COUNT: u32 = + (::mem::size_of::() / ::mem::size_of::()) as u32; +pub const MACH_TASK_BASIC_INFO_COUNT: u32 = + (::mem::size_of::() / ::mem::size_of::()) as u32; +pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t = + (::mem::size_of::() / ::mem::size_of::()) + as mach_msg_type_number_t; f! { pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, @@ -5728,13 +5688,6 @@ extern "C" { newp: *mut ::c_void, newlen: ::size_t, ) -> ::c_int; - #[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 `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; - pub fn mach_thread_self() -> mach_port_t; pub fn pthread_setname_np(name: *const ::c_char) -> ::c_int; 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; @@ -6050,15 +6003,6 @@ 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 `mach2` crate instead")] - pub fn _dyld_image_count() -> u32; - #[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 `mach2` crate instead")] - pub fn _dyld_get_image_vmaddr_slide(image_index: u32) -> ::intptr_t; - #[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( pid: *mut ::pid_t, @@ -6322,23 +6266,8 @@ extern "C" { pub fn CCRandomGenerateBytes(bytes: *mut ::c_void, size: ::size_t) -> ::CCRNGStatus; pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; - pub fn _NSGetExecutablePath(buf: *mut ::c_char, bufsize: *mut u32) -> ::c_int; pub fn _NSGetEnviron() -> *mut *mut *mut ::c_char; - pub fn mach_vm_map( - target_task: ::vm_map_t, - address: *mut ::mach_vm_address_t, - size: ::mach_vm_size_t, - mask: ::mach_vm_offset_t, - flags: ::c_int, - object: ::mem_entry_name_port_t, - offset: ::memory_object_offset_t, - copy: ::boolean_t, - cur_protection: ::vm_prot_t, - max_protection: ::vm_prot_t, - inheritance: ::vm_inherit_t, - ) -> ::kern_return_t; - pub fn vm_allocate( target_task: vm_map_t, address: *mut vm_address_t, @@ -6366,7 +6295,6 @@ extern "C" { out_processor_infoCnt: *mut mach_msg_type_number_t, ) -> ::kern_return_t; - pub static mut mach_task_self_: ::mach_port_t; pub fn task_for_pid( host: ::mach_port_t, pid: ::pid_t, @@ -6483,10 +6411,6 @@ extern "C" { ) -> ::c_int; } -pub unsafe fn mach_task_self() -> ::mach_port_t { - mach_task_self_ -} - cfg_if! { if #[cfg(target_os = "macos")] { extern "C" { @@ -6495,7 +6419,7 @@ cfg_if! { } } cfg_if! { - if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "visionos"))] { + if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos"))] { extern "C" { pub fn memmem( haystack: *const ::c_void, @@ -6512,22 +6436,6 @@ cfg_if! { } } -// These require a dependency on `libiconv`, and including this when built as -// part of `std` means every Rust program gets it. Ideally we would have a link -// modifier to only include these if they are used, but we do not. -#[cfg_attr(not(feature = "rustc-dep-of-std"), link(name = "iconv"))] -extern "C" { - pub fn iconv_open(tocode: *const ::c_char, fromcode: *const ::c_char) -> iconv_t; - pub fn iconv( - cd: iconv_t, - inbuf: *mut *mut ::c_char, - inbytesleft: *mut ::size_t, - outbuf: *mut *mut ::c_char, - outbytesleft: *mut ::size_t, - ) -> ::size_t; - pub fn iconv_close(cd: iconv_t) -> ::c_int; -} - cfg_if! { if #[cfg(target_pointer_width = "32")] { mod b32; @@ -6540,9 +6448,5 @@ cfg_if! { } } -cfg_if! { - if #[cfg(libc_long_array)] { - mod long_array; - pub use self::long_array::*; - } -} +mod long_array; +pub use self::long_array::*; diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 6ade7949afb0f..489b82adb84b9 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1723,10 +1723,3 @@ extern "C" { entry: vm_map_entry_t, ) -> vm_map_entry_t; } - -cfg_if! { - if #[cfg(libc_thread_local)] { - mod errno; - pub use self::errno::*; - } -} diff --git a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs index e8be8815c028e..d240eb001ad5d 100644 --- a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -33,16 +33,7 @@ s_no_extra_traits! { } } -// 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; - } -} +pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1; cfg_if! { if #[cfg(feature = "extra_traits")] { diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs index 300b3dd45ca9d..af3c8a7cf6f6c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -36,15 +36,6 @@ s! { } } -// 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_int>() - 1; - } else { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = 4 - 1; - } -} +pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 28366c59fd94e..53f1f7adcaffd 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -971,10 +971,7 @@ s! { pub struct ifconf { pub ifc_len: ::c_int, - #[cfg(libc_union)] pub ifc_ifcu: __c_anonymous_ifc_ifcu, - #[cfg(not(libc_union))] - pub ifc_ifcu: *mut ifreq, } pub struct au_mask_t { @@ -1046,41 +1043,49 @@ s! { pub tcpi_snd_rexmitpack: u32, pub tcpi_rcv_ooopack: u32, pub tcpi_snd_zerowin: u32, + #[cfg(freebsd13)] + pub __tcpi_delivered_ce: u32, #[cfg(any(freebsd15, freebsd14))] pub tcpi_delivered_ce: u32, + #[cfg(freebsd13)] + pub __tcpi_received_ce: u32, #[cfg(any(freebsd15, freebsd14))] pub tcpi_received_ce: u32, - #[cfg(any(freebsd15, freebsd14))] + #[cfg(any(freebsd15, freebsd14, freebsd13))] pub __tcpi_delivered_e1_bytes: u32, - #[cfg(any(freebsd15, freebsd14))] + #[cfg(any(freebsd15, freebsd14, freebsd13))] pub __tcpi_delivered_e0_bytes: u32, - #[cfg(any(freebsd15, freebsd14))] + #[cfg(any(freebsd15, freebsd14, freebsd13))] pub __tcpi_delivered_ce_bytes: u32, - #[cfg(any(freebsd15, freebsd14))] + #[cfg(any(freebsd15, freebsd14, freebsd13))] pub __tcpi_received_e1_bytes: u32, - #[cfg(any(freebsd15, freebsd14))] + #[cfg(any(freebsd15, freebsd14, freebsd13))] pub __tcpi_received_e0_bytes: u32, - #[cfg(any(freebsd15, freebsd14))] + #[cfg(any(freebsd15, freebsd14, freebsd13))] pub __tcpi_received_ce_bytes: u32, + #[cfg(freebsd13)] + pub __tcpi_total_tlp: u32, #[cfg(any(freebsd15, freebsd14))] pub tcpi_total_tlp: u32, + #[cfg(freebsd13)] + pub __tcpi_total_tlp_bytes: u64, #[cfg(any(freebsd15, freebsd14))] pub tcpi_total_tlp_bytes: u64, - #[cfg(any(freebsd15, freebsd14))] + #[cfg(any(freebsd15, freebsd14, freebsd13))] pub tcpi_snd_una: u32, - #[cfg(any(freebsd15, freebsd14))] + #[cfg(any(freebsd15, freebsd14, freebsd13))] pub tcpi_snd_max: u32, - #[cfg(any(freebsd15, freebsd14))] + #[cfg(any(freebsd15, freebsd14, freebsd13))] pub tcpi_rcv_numsacks: u32, - #[cfg(any(freebsd15, freebsd14))] + #[cfg(any(freebsd15, freebsd14, freebsd13))] pub tcpi_rcv_adv: u32, - #[cfg(any(freebsd15, freebsd14))] + #[cfg(any(freebsd15, freebsd14, freebsd13))] pub tcpi_dupacks: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd14, freebsd13))] pub __tcpi_pad: [u32; 10], #[cfg(freebsd15)] pub __tcpi_pad: [u32; 14], - #[cfg(not(any(freebsd15, freebsd14)))] + #[cfg(not(any(freebsd15, freebsd14, freebsd13)))] pub __tcpi_pad: [u32; 26], } @@ -1359,7 +1364,6 @@ s_no_extra_traits! { pub __ut_spare: [::c_char; 64], } - #[cfg(libc_union)] pub union __c_anonymous_cr_pid { __cr_unused: *mut ::c_void, pub cr_pid: ::pid_t, @@ -1370,10 +1374,7 @@ s_no_extra_traits! { pub cr_uid: ::uid_t, pub cr_ngroups: ::c_short, pub cr_groups: [::gid_t; 16], - #[cfg(libc_union)] pub cr_pid__c_anonymous_union: __c_anonymous_cr_pid, - #[cfg(not(libc_union))] - __cr_unused1: *mut ::c_void, } pub struct sockaddr_dl { @@ -1415,24 +1416,20 @@ s_no_extra_traits! { pub devname: [::c_char; SPECNAMELEN as usize + 1], } - #[cfg(libc_union)] pub union __c_anonymous_elf32_auxv_union { pub a_val: ::c_int, } pub struct Elf32_Auxinfo { pub a_type: ::c_int, - #[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, @@ -1486,20 +1483,11 @@ s_no_extra_traits! { /// 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, @@ -1521,13 +1509,9 @@ s_no_extra_traits! { 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, @@ -1689,15 +1673,12 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_cr_pid { fn eq(&self, other: &__c_anonymous_cr_pid) -> bool { unsafe { self.cr_pid == other.cr_pid} } } - #[cfg(libc_union)] impl Eq for __c_anonymous_cr_pid {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_cr_pid { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("cr_pid") @@ -1705,7 +1686,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_cr_pid { fn hash(&self, state: &mut H) { unsafe { self.cr_pid.hash(state) }; @@ -1714,17 +1694,12 @@ cfg_if! { impl PartialEq for xucred { fn eq(&self, other: &xucred) -> bool { - #[cfg(libc_union)] - let equal_cr_pid = self.cr_pid__c_anonymous_union - == other.cr_pid__c_anonymous_union; - #[cfg(not(libc_union))] - let equal_cr_pid = self.__cr_unused1 == other.__cr_unused1; - self.cr_version == other.cr_version && self.cr_uid == other.cr_uid && self.cr_ngroups == other.cr_ngroups && self.cr_groups == other.cr_groups - && equal_cr_pid + && self.cr_pid__c_anonymous_union + == other.cr_pid__c_anonymous_union } } impl Eq for xucred {} @@ -1735,7 +1710,6 @@ cfg_if! { struct_formatter.field("cr_uid", &self.cr_uid); struct_formatter.field("cr_ngroups", &self.cr_ngroups); struct_formatter.field("cr_groups", &self.cr_groups); - #[cfg(libc_union)] struct_formatter.field( "cr_pid__c_anonymous_union", &self.cr_pid__c_anonymous_union @@ -1749,10 +1723,7 @@ cfg_if! { self.cr_uid.hash(state); self.cr_ngroups.hash(state); self.cr_groups.hash(state); - #[cfg(libc_union)] self.cr_pid__c_anonymous_union.hash(state); - #[cfg(not(libc_union))] - self.__cr_unused1.hash(state); } } @@ -1886,15 +1857,12 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_elf32_auxv_union { fn eq(&self, other: &__c_anonymous_elf32_auxv_union) -> bool { unsafe { self.a_val == other.a_val} } } - #[cfg(libc_union)] impl Eq for __c_anonymous_elf32_auxv_union {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_elf32_auxv_union { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("a_val") @@ -1902,13 +1870,6 @@ cfg_if! { .finish() } } - #[cfg(not(libc_union))] - impl PartialEq for Elf32_Auxinfo { - fn eq(&self, other: &Elf32_Auxinfo) -> bool { - self.a_type == other.a_type - } - } - #[cfg(libc_union)] impl PartialEq for Elf32_Auxinfo { fn eq(&self, other: &Elf32_Auxinfo) -> bool { self.a_type == other.a_type @@ -1916,15 +1877,6 @@ cfg_if! { } } impl Eq for Elf32_Auxinfo {} - #[cfg(not(libc_union))] - impl ::fmt::Debug for Elf32_Auxinfo { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("Elf32_Auxinfo") - .field("a_type", &self.a_type) - .finish() - } - } - #[cfg(libc_union)] impl ::fmt::Debug for Elf32_Auxinfo { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("Elf32_Auxinfo") @@ -1934,7 +1886,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ifr_ifru { fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { unsafe { @@ -1956,9 +1907,7 @@ cfg_if! { } } } - #[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") @@ -1980,7 +1929,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifr_ifru { fn hash(&self, state: &mut H) { unsafe { self.ifru_addr.hash(state) }; @@ -2022,10 +1970,8 @@ cfg_if! { } } - #[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 { @@ -2035,7 +1981,6 @@ cfg_if! { } } - #[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") @@ -2045,7 +1990,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifc_ifcu { fn hash(&self, state: &mut H) { unsafe { self.ifcu_buf.hash(state) }; @@ -2148,7 +2092,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ifi_epoch { fn eq(&self, other: &__c_anonymous_ifi_epoch) -> bool { unsafe { @@ -2157,9 +2100,7 @@ cfg_if! { } } } - #[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") @@ -2168,7 +2109,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifi_epoch { fn hash(&self, state: &mut H) { unsafe { @@ -2178,7 +2118,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ifi_lastchange { fn eq(&self, other: &__c_anonymous_ifi_lastchange) -> bool { unsafe { @@ -2187,9 +2126,7 @@ cfg_if! { } } } - #[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") @@ -2198,7 +2135,6 @@ cfg_if! { .finish() } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifi_lastchange { fn hash(&self, state: &mut H) { unsafe { @@ -2618,6 +2554,129 @@ pub const LIO_VECTORED: ::c_int = 4; pub const LIO_WRITEV: ::c_int = 5; pub const LIO_READV: ::c_int = 6; +// sys/caprights.h +pub const CAP_RIGHTS_VERSION_00: i32 = 0; +pub const CAP_RIGHTS_VERSION: i32 = CAP_RIGHTS_VERSION_00; + +// sys/capsicum.h +macro_rules! cap_right { + ($idx:expr, $bit:expr) => { + ((1u64 << (57 + ($idx))) | ($bit)) + }; +} +pub const CAP_READ: u64 = cap_right!(0, 0x0000000000000001u64); +pub const CAP_WRITE: u64 = cap_right!(0, 0x0000000000000002u64); +pub const CAP_SEEK_TELL: u64 = cap_right!(0, 0x0000000000000004u64); +pub const CAP_SEEK: u64 = CAP_SEEK_TELL | 0x0000000000000008u64; +pub const CAP_PREAD: u64 = CAP_SEEK | CAP_READ; +pub const CAP_PWRITE: u64 = CAP_SEEK | CAP_WRITE; +pub const CAP_MMAP: u64 = cap_right!(0, 0x0000000000000010u64); +pub const CAP_MMAP_R: u64 = CAP_MMAP | CAP_SEEK | CAP_READ; +pub const CAP_MMAP_W: u64 = CAP_MMAP | CAP_SEEK | CAP_WRITE; +pub const CAP_MMAP_X: u64 = CAP_MMAP | CAP_SEEK | 0x0000000000000020u64; +pub const CAP_MMAP_RW: u64 = CAP_MMAP_R | CAP_MMAP_W; +pub const CAP_MMAP_RX: u64 = CAP_MMAP_R | CAP_MMAP_X; +pub const CAP_MMAP_WX: u64 = CAP_MMAP_W | CAP_MMAP_X; +pub const CAP_MMAP_RWX: u64 = CAP_MMAP_R | CAP_MMAP_W | CAP_MMAP_X; +pub const CAP_CREATE: u64 = cap_right!(0, 0x0000000000000040u64); +pub const CAP_FEXECVE: u64 = cap_right!(0, 0x0000000000000080u64); +pub const CAP_FSYNC: u64 = cap_right!(0, 0x0000000000000100u64); +pub const CAP_FTRUNCATE: u64 = cap_right!(0, 0x0000000000000200u64); +pub const CAP_LOOKUP: u64 = cap_right!(0, 0x0000000000000400u64); +pub const CAP_FCHDIR: u64 = cap_right!(0, 0x0000000000000800u64); +pub const CAP_FCHFLAGS: u64 = cap_right!(0, 0x0000000000001000u64); +pub const CAP_CHFLAGSAT: u64 = CAP_FCHFLAGS | CAP_LOOKUP; +pub const CAP_FCHMOD: u64 = cap_right!(0, 0x0000000000002000u64); +pub const CAP_FCHMODAT: u64 = CAP_FCHMOD | CAP_LOOKUP; +pub const CAP_FCHOWN: u64 = cap_right!(0, 0x0000000000004000u64); +pub const CAP_FCHOWNAT: u64 = CAP_FCHOWN | CAP_LOOKUP; +pub const CAP_FCNTL: u64 = cap_right!(0, 0x0000000000008000u64); +pub const CAP_FLOCK: u64 = cap_right!(0, 0x0000000000010000u64); +pub const CAP_FPATHCONF: u64 = cap_right!(0, 0x0000000000020000u64); +pub const CAP_FSCK: u64 = cap_right!(0, 0x0000000000040000u64); +pub const CAP_FSTAT: u64 = cap_right!(0, 0x0000000000080000u64); +pub const CAP_FSTATAT: u64 = CAP_FSTAT | CAP_LOOKUP; +pub const CAP_FSTATFS: u64 = cap_right!(0, 0x0000000000100000u64); +pub const CAP_FUTIMES: u64 = cap_right!(0, 0x0000000000200000u64); +pub const CAP_FUTIMESAT: u64 = CAP_FUTIMES | CAP_LOOKUP; +// Note: this was named CAP_LINKAT prior to FreeBSD 11.0. +pub const CAP_LINKAT_TARGET: u64 = CAP_LOOKUP | 0x0000000000400000u64; +pub const CAP_MKDIRAT: u64 = CAP_LOOKUP | 0x0000000000800000u64; +pub const CAP_MKFIFOAT: u64 = CAP_LOOKUP | 0x0000000001000000u64; +pub const CAP_MKNODAT: u64 = CAP_LOOKUP | 0x0000000002000000u64; +// Note: this was named CAP_RENAMEAT prior to FreeBSD 11.0. +pub const CAP_RENAMEAT_SOURCE: u64 = CAP_LOOKUP | 0x0000000004000000u64; +pub const CAP_SYMLINKAT: u64 = CAP_LOOKUP | 0x0000000008000000u64; +pub const CAP_UNLINKAT: u64 = CAP_LOOKUP | 0x0000000010000000u64; +pub const CAP_ACCEPT: u64 = cap_right!(0, 0x0000000020000000u64); +pub const CAP_BIND: u64 = cap_right!(0, 0x0000000040000000u64); +pub const CAP_CONNECT: u64 = cap_right!(0, 0x0000000080000000u64); +pub const CAP_GETPEERNAME: u64 = cap_right!(0, 0x0000000100000000u64); +pub const CAP_GETSOCKNAME: u64 = cap_right!(0, 0x0000000200000000u64); +pub const CAP_GETSOCKOPT: u64 = cap_right!(0, 0x0000000400000000u64); +pub const CAP_LISTEN: u64 = cap_right!(0, 0x0000000800000000u64); +pub const CAP_PEELOFF: u64 = cap_right!(0, 0x0000001000000000u64); +pub const CAP_RECV: u64 = CAP_READ; +pub const CAP_SEND: u64 = CAP_WRITE; +pub const CAP_SETSOCKOPT: u64 = cap_right!(0, 0x0000002000000000u64); +pub const CAP_SHUTDOWN: u64 = cap_right!(0, 0x0000004000000000u64); +pub const CAP_BINDAT: u64 = CAP_LOOKUP | 0x0000008000000000u64; +pub const CAP_CONNECTAT: u64 = CAP_LOOKUP | 0x0000010000000000u64; +pub const CAP_LINKAT_SOURCE: u64 = CAP_LOOKUP | 0x0000020000000000u64; +pub const CAP_RENAMEAT_TARGET: u64 = CAP_LOOKUP | 0x0000040000000000u64; +pub const CAP_SOCK_CLIENT: u64 = CAP_CONNECT + | CAP_GETPEERNAME + | CAP_GETSOCKNAME + | CAP_GETSOCKOPT + | CAP_PEELOFF + | CAP_RECV + | CAP_SEND + | CAP_SETSOCKOPT + | CAP_SHUTDOWN; +pub const CAP_SOCK_SERVER: u64 = CAP_ACCEPT + | CAP_BIND + | CAP_GETPEERNAME + | CAP_GETSOCKNAME + | CAP_GETSOCKOPT + | CAP_LISTEN + | CAP_PEELOFF + | CAP_RECV + | CAP_SEND + | CAP_SETSOCKOPT + | CAP_SHUTDOWN; +pub const CAP_ALL0: u64 = cap_right!(0, 0x000007FFFFFFFFFFu64); +pub const CAP_UNUSED0_44: u64 = cap_right!(0, 0x0000080000000000u64); +pub const CAP_UNUSED0_57: u64 = cap_right!(0, 0x0100000000000000u64); +pub const CAP_MAC_GET: u64 = cap_right!(1, 0x0000000000000001u64); +pub const CAP_MAC_SET: u64 = cap_right!(1, 0x0000000000000002u64); +pub const CAP_SEM_GETVALUE: u64 = cap_right!(1, 0x0000000000000004u64); +pub const CAP_SEM_POST: u64 = cap_right!(1, 0x0000000000000008u64); +pub const CAP_SEM_WAIT: u64 = cap_right!(1, 0x0000000000000010u64); +pub const CAP_EVENT: u64 = cap_right!(1, 0x0000000000000020u64); +pub const CAP_KQUEUE_EVENT: u64 = cap_right!(1, 0x0000000000000040u64); +pub const CAP_IOCTL: u64 = cap_right!(1, 0x0000000000000080u64); +pub const CAP_TTYHOOK: u64 = cap_right!(1, 0x0000000000000100u64); +pub const CAP_PDGETPID: u64 = cap_right!(1, 0x0000000000000200u64); +pub const CAP_PDWAIT: u64 = cap_right!(1, 0x0000000000000400u64); +pub const CAP_PDKILL: u64 = cap_right!(1, 0x0000000000000800u64); +pub const CAP_EXTATTR_DELETE: u64 = cap_right!(1, 0x0000000000001000u64); +pub const CAP_EXTATTR_GET: u64 = cap_right!(1, 0x0000000000002000u64); +pub const CAP_EXTATTR_LIST: u64 = cap_right!(1, 0x0000000000004000u64); +pub const CAP_EXTATTR_SET: u64 = cap_right!(1, 0x0000000000008000u64); +pub const CAP_ACL_CHECK: u64 = cap_right!(1, 0x0000000000010000u64); +pub const CAP_ACL_DELETE: u64 = cap_right!(1, 0x0000000000020000u64); +pub const CAP_ACL_GET: u64 = cap_right!(1, 0x0000000000040000u64); +pub const CAP_ACL_SET: u64 = cap_right!(1, 0x0000000000080000u64); +pub const CAP_KQUEUE_CHANGE: u64 = cap_right!(1, 0x0000000000100000u64); +pub const CAP_KQUEUE: u64 = CAP_KQUEUE_EVENT | CAP_KQUEUE_CHANGE; +pub const CAP_ALL1: u64 = cap_right!(1, 0x00000000001FFFFFu64); +pub const CAP_UNUSED1_22: u64 = cap_right!(1, 0x0000000000200000u64); +pub const CAP_UNUSED1_57: u64 = cap_right!(1, 0x0100000000000000u64); +pub const CAP_FCNTL_GETFL: u32 = 1 << 3; +pub const CAP_FCNTL_SETFL: u32 = 1 << 4; +pub const CAP_FCNTL_GETOWN: u32 = 1 << 5; +pub const CAP_FCNTL_SETOWN: u32 = 1 << 6; + // sys/devicestat.h pub const DEVSTAT_N_TRANS_FLAGS: ::c_int = 4; pub const DEVSTAT_NAME_LEN: ::c_int = 16; @@ -3838,12 +3897,12 @@ pub const RTP_PRIO_REALTIME: ::c_ushort = 2; pub const RTP_PRIO_NORMAL: ::c_ushort = 3; pub const RTP_PRIO_IDLE: ::c_ushort = 4; -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_RESETIDS: ::c_short = 0x01; +pub const POSIX_SPAWN_SETPGROUP: ::c_short = 0x02; +pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_short = 0x04; +pub const POSIX_SPAWN_SETSCHEDULER: ::c_short = 0x08; +pub const POSIX_SPAWN_SETSIGDEF: ::c_short = 0x10; +pub const POSIX_SPAWN_SETSIGMASK: ::c_short = 0x20; // Flags for chflags(2) pub const UF_SYSTEM: ::c_ulong = 0x00000080; @@ -3875,6 +3934,11 @@ 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; pub const HOSTNAME_INCORRECTNAME: ::c_int = 1; @@ -4737,16 +4801,14 @@ pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC; pub const TFD_TIMER_ABSTIME: ::c_int = 0x01; pub const TFD_TIMER_CANCEL_ON_SET: ::c_int = 0x02; -cfg_if! { - if #[cfg(libc_const_extern_fn)] { - pub const fn MAP_ALIGNED(a: ::c_int) -> ::c_int { - a << 24 - } - } else { - pub fn MAP_ALIGNED(a: ::c_int) -> ::c_int { - a << 24 - } - } +pub const KCMP_FILE: ::c_int = 100; +pub const KCMP_FILEOBJ: ::c_int = 101; +pub const KCMP_FILES: ::c_int = 102; +pub const KCMP_SIGHAND: ::c_int = 103; +pub const KCMP_VM: ::c_int = 104; + +pub const fn MAP_ALIGNED(a: ::c_int) -> ::c_int { + a << 24 } const_fn! { @@ -5388,6 +5450,8 @@ extern "C" { 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; @@ -5463,8 +5527,16 @@ extern "C" { pub fn closefrom(lowfd: ::c_int); pub fn close_range(lowfd: ::c_uint, highfd: ::c_uint, flags: ::c_int) -> ::c_int; + pub fn kcmp( + pid1: ::pid_t, + pid2: ::pid_t, + type_: ::c_int, + idx1: ::c_ulong, + idx2: ::c_ulong, + ) -> ::c_int; + pub fn execvpe( - name: *const ::c_char, + file: *const ::c_char, argv: *const *const ::c_char, envp: *const *const ::c_char, ) -> ::c_int; diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs index a0120c337e0ad..0900005166a2e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -32,16 +32,6 @@ s! { } } -// 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_int>() - 1; - } else { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = 4 - 1; - } -} - +pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index 7f5b9752264e3..07f2f11cdc9a4 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -32,16 +32,7 @@ s! { } } -// 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(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs index f9fa1c2750b22..c5ea8ee203a72 100644 --- a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs @@ -35,16 +35,7 @@ s_no_extra_traits! { } } -// 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; - } -} +pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1; cfg_if! { if #[cfg(feature = "extra_traits")] { diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index 4046ec3109f14..29689c910689f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -77,16 +77,7 @@ s! { } } -// 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 = 4 - 1; - } -} +pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; cfg_if! { if #[cfg(feature = "extra_traits")] { diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index ae1fcf781047a..c94695ed06cfb 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -81,7 +81,6 @@ s_no_extra_traits! { pub xmm_pad: [u8; 224], } - #[cfg(libc_union)] pub union __c_anonymous_elf64_auxv_union { pub a_val: ::c_long, pub a_ptr: *mut ::c_void, @@ -90,7 +89,6 @@ s_no_extra_traits! { pub struct Elf64_Auxinfo { pub a_type: ::c_long, - #[cfg(libc_union)] pub a_un: __c_anonymous_elf64_auxv_union, } @@ -204,7 +202,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_elf64_auxv_union { fn eq(&self, other: &__c_anonymous_elf64_auxv_union) -> bool { unsafe { self.a_val == other.a_val @@ -212,9 +209,7 @@ cfg_if! { || self.a_fcn == other.a_fcn } } } - #[cfg(libc_union)] impl Eq for __c_anonymous_elf64_auxv_union {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_elf64_auxv_union { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("a_val") @@ -222,13 +217,6 @@ cfg_if! { .finish() } } - #[cfg(not(libc_union))] - impl PartialEq for Elf64_Auxinfo { - fn eq(&self, other: &Elf64_Auxinfo) -> bool { - self.a_type == other.a_type - } - } - #[cfg(libc_union)] impl PartialEq for Elf64_Auxinfo { fn eq(&self, other: &Elf64_Auxinfo) -> bool { self.a_type == other.a_type @@ -236,15 +224,6 @@ cfg_if! { } } impl Eq for Elf64_Auxinfo {} - #[cfg(not(libc_union))] - impl ::fmt::Debug for Elf64_Auxinfo { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("Elf64_Auxinfo") - .field("a_type", &self.a_type) - .finish() - } - } - #[cfg(libc_union)] impl ::fmt::Debug for Elf64_Auxinfo { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("Elf64_Auxinfo") @@ -302,16 +281,8 @@ cfg_if! { } } -// 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(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; + pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 @@ -326,9 +297,5 @@ pub const _MC_FPOWNED_NONE: c_long = 0x20000; pub const _MC_FPOWNED_FPU: c_long = 0x20001; pub const _MC_FPOWNED_PCB: c_long = 0x20002; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 9b555e42edf2d..89557e1520622 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -432,15 +432,7 @@ cfg_if! { } // Non-public helper constant -cfg_if! { - if #[cfg(all(not(libc_const_size_of), target_pointer_width = "32"))] { - const SIZEOF_LONG: usize = 4; - } else if #[cfg(all(not(libc_const_size_of), target_pointer_width = "64"))] { - const SIZEOF_LONG: usize = 8; - } else if #[cfg(libc_const_size_of)] { - const SIZEOF_LONG: usize = ::mem::size_of::<::c_long>(); - } -} +const SIZEOF_LONG: usize = ::mem::size_of::<::c_long>(); #[deprecated( since = "0.2.64", @@ -563,29 +555,29 @@ pub const TMP_MAX: ::c_uint = 308915776; pub const O_NOCTTY: ::c_int = 32768; pub const O_DIRECT: ::c_int = 0x00010000; -pub const S_IFIFO: mode_t = 4096; -pub const S_IFCHR: mode_t = 8192; -pub const S_IFBLK: mode_t = 24576; -pub const S_IFDIR: mode_t = 16384; -pub const S_IFREG: mode_t = 32768; -pub const S_IFLNK: mode_t = 40960; -pub const S_IFSOCK: mode_t = 49152; -pub const S_IFMT: mode_t = 61440; -pub const S_IEXEC: mode_t = 64; -pub const S_IWRITE: mode_t = 128; -pub const S_IREAD: mode_t = 256; -pub const S_IRWXU: mode_t = 448; -pub const S_IXUSR: mode_t = 64; -pub const S_IWUSR: mode_t = 128; -pub const S_IRUSR: mode_t = 256; -pub const S_IRWXG: mode_t = 56; -pub const S_IXGRP: mode_t = 8; -pub const S_IWGRP: mode_t = 16; -pub const S_IRGRP: mode_t = 32; -pub const S_IRWXO: mode_t = 7; -pub const S_IXOTH: mode_t = 1; -pub const S_IWOTH: mode_t = 2; -pub const S_IROTH: mode_t = 4; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IREAD: mode_t = 0o0400; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; pub const F_OK: ::c_int = 0; pub const R_OK: ::c_int = 4; pub const W_OK: ::c_int = 2; @@ -970,6 +962,8 @@ pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR; pub const IP_ADD_MEMBERSHIP: ::c_int = 12; pub const IP_DROP_MEMBERSHIP: ::c_int = 13; pub const IP_RECVIF: ::c_int = 20; +pub const IP_RECVTTL: ::c_int = 65; +pub const IPV6_RECVHOPLIMIT: ::c_int = 37; pub const IPV6_JOIN_GROUP: ::c_int = 12; pub const IPV6_LEAVE_GROUP: ::c_int = 13; pub const IPV6_CHECKSUM: ::c_int = 26; @@ -1201,7 +1195,7 @@ pub const SCHED_FIFO: ::c_int = 1; pub const SCHED_OTHER: ::c_int = 2; pub const SCHED_RR: ::c_int = 3; -pub const FD_SETSIZE: usize = 1024; +pub const FD_SETSIZE: ::c_int = 1024; pub const ST_NOSUID: ::c_ulong = 2; @@ -1456,11 +1450,6 @@ pub const RB_GDB: ::c_int = 0x8000; pub const RB_MUTE: ::c_int = 0x10000; pub const RB_SELFTEST: ::c_int = 0x20000; -// For getrandom() -pub const GRND_NONBLOCK: ::c_uint = 0x1; -pub const GRND_RANDOM: ::c_uint = 0x2; -pub const GRND_INSECURE: ::c_uint = 0x4; - safe_f! { pub {const} fn WIFCONTINUED(status: ::c_int) -> bool { status == 0x13 @@ -1513,11 +1502,7 @@ 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 fexecve(fd: ::c_int, argv: *const *mut ::c_char, envp: *const *mut ::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( @@ -1834,9 +1819,6 @@ extern "C" { abs_timeout: *const ::timespec, ) -> ::c_int; pub fn mq_unlink(name: *const ::c_char) -> ::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; } #[link(name = "util")] diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 6ee2a3de44035..83e675ca3474d 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -39,7 +39,6 @@ s! { target_os = "ios", target_os = "tvos", target_os = "watchos", - target_os = "visionos", target_os = "netbsd", target_os = "openbsd")))] pub pw_fields: ::c_int, @@ -60,10 +59,10 @@ s! { pub struct fd_set { #[cfg(all(target_pointer_width = "64", any(target_os = "freebsd", target_os = "dragonfly")))] - fds_bits: [i64; FD_SETSIZE / 64], + fds_bits: [i64; FD_SETSIZE as usize / 64], #[cfg(not(all(target_pointer_width = "64", any(target_os = "freebsd", target_os = "dragonfly"))))] - fds_bits: [i32; FD_SETSIZE / 32], + fds_bits: [i32; FD_SETSIZE as usize / 32], } pub struct tm { @@ -129,7 +128,7 @@ s_no_extra_traits! { pub struct sockaddr_un { pub sun_len: u8, pub sun_family: sa_family_t, - pub sun_path: [c_char; 104] + pub sun_path: [::c_char; 104] } pub struct utsname { @@ -633,7 +632,6 @@ extern "C" { pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; pub fn kqueue() -> ::c_int; pub fn unmount(target: *const ::c_char, arg: ::c_int) -> ::c_int; - pub fn syscall(num: ::c_int, ...) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__getpwent50")] pub fn getpwent() -> *mut passwd; pub fn setpwent(); @@ -918,7 +916,15 @@ extern "C" { } cfg_if! { - if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))] { + if #[cfg(not(target_os = "openbsd"))] { + extern "C" { + pub fn syscall(num: ::c_int, ...) -> ::c_int; + } + } +} + +cfg_if! { + if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))] { mod apple; pub use self::apple::*; } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd"))] { diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index e92cf65940141..35a8c0255be69 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -168,29 +168,29 @@ pub const FOPEN_MAX: ::c_uint = 20; pub const FILENAME_MAX: ::c_uint = 1024; pub const L_tmpnam: ::c_uint = 1024; pub const O_NOCTTY: ::c_int = 32768; -pub const S_IFIFO: mode_t = 4096; -pub const S_IFCHR: mode_t = 8192; -pub const S_IFBLK: mode_t = 24576; -pub const S_IFDIR: mode_t = 16384; -pub const S_IFREG: mode_t = 32768; -pub const S_IFLNK: mode_t = 40960; -pub const S_IFSOCK: mode_t = 49152; -pub const S_IFMT: mode_t = 61440; -pub const S_IEXEC: mode_t = 64; -pub const S_IWRITE: mode_t = 128; -pub const S_IREAD: mode_t = 256; -pub const S_IRWXU: mode_t = 448; -pub const S_IXUSR: mode_t = 64; -pub const S_IWUSR: mode_t = 128; -pub const S_IRUSR: mode_t = 256; -pub const S_IRWXG: mode_t = 56; -pub const S_IXGRP: mode_t = 8; -pub const S_IWGRP: mode_t = 16; -pub const S_IRGRP: mode_t = 32; -pub const S_IRWXO: mode_t = 7; -pub const S_IXOTH: mode_t = 1; -pub const S_IWOTH: mode_t = 2; -pub const S_IROTH: mode_t = 4; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IREAD: mode_t = 0o0400; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; pub const F_OK: ::c_int = 0; pub const R_OK: ::c_int = 4; pub const W_OK: ::c_int = 2; @@ -364,12 +364,12 @@ pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; pub const POSIX_MADV_WILLNEED: ::c_int = 3; pub const POSIX_MADV_DONTNEED: ::c_int = 4; -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_RESETIDS: ::c_short = 0x01; +pub const POSIX_SPAWN_SETPGROUP: ::c_short = 0x02; +pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_short = 0x04; +pub const POSIX_SPAWN_SETSCHEDULER: ::c_short = 0x08; +pub const POSIX_SPAWN_SETSIGDEF: ::c_short = 0x10; +pub const POSIX_SPAWN_SETSIGMASK: ::c_short = 0x20; pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; @@ -672,7 +672,6 @@ extern "C" { addrlen: *mut ::socklen_t, flags: ::c_int, ) -> ::c_int; - pub fn mincore(addr: *mut ::c_void, len: ::size_t, vec: *mut ::c_char) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__clock_getres50")] pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__clock_gettime50")] @@ -751,8 +750,8 @@ extern "C" { pub fn shmctl(shmid: ::c_int, cmd: ::c_int, buf: *mut ::shmid_ds) -> ::c_int; pub fn execvpe( file: *const ::c_char, - argv: *const *const ::c_char, - envp: *const *const ::c_char, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char, ) -> ::c_int; pub fn waitid( idtype: idtype_t, diff --git a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs index 45bca4778c20c..e285d0617ce20 100644 --- a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs @@ -8,7 +8,6 @@ pub type __cpu_simple_lock_nv_t = ::c_uchar; s! { pub struct __fregset { - #[cfg(libc_union)] pub __qregs: [__c_anonymous__freg; 32], pub __fpcr: u32, pub __fpsr: u32, @@ -30,7 +29,6 @@ s! { } s_no_extra_traits! { - #[cfg(libc_union)] #[repr(align(16))] pub union __c_anonymous__freg { pub __b8: [u8; 16], @@ -43,7 +41,6 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - #[cfg(libc_union)] impl PartialEq for __c_anonymous__freg { fn eq(&self, other: &__c_anonymous__freg) -> bool { unsafe { @@ -55,9 +52,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for __c_anonymous__freg {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous__freg { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { @@ -71,7 +66,6 @@ cfg_if! { } } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous__freg { fn hash(&self, state: &mut H) { unsafe { @@ -86,16 +80,7 @@ cfg_if! { } } -// 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_int>() - 1; - } else { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = 4 - 1; - } -} +pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 0; pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 1; diff --git a/src/unix/bsd/netbsdlike/netbsd/arm.rs b/src/unix/bsd/netbsdlike/netbsd/arm.rs index b5000d34d66fb..2da780ec6ddcb 100644 --- a/src/unix/bsd/netbsdlike/netbsd/arm.rs +++ b/src/unix/bsd/netbsdlike/netbsd/arm.rs @@ -5,16 +5,7 @@ pub type c_ulong = u32; pub type c_char = u8; pub type __cpu_simple_lock_nv_t = ::c_int; -// 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; - } -} +pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1; pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; diff --git a/src/unix/bsd/netbsdlike/netbsd/mips.rs b/src/unix/bsd/netbsdlike/netbsd/mips.rs index a536254ceb4b3..c25407fd97393 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mips.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mips.rs @@ -5,15 +5,7 @@ pub type c_ulong = u32; pub type c_char = i8; pub type __cpu_simple_lock_nv_t = ::c_int; -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; - } -} +pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1; pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 7c63db8e0e205..47ade8c087fd2 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -693,14 +693,12 @@ s! { 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, } @@ -739,7 +737,6 @@ s! { pub struct ifconf { pub ifc_len: ::c_int, - #[cfg(libc_union)] pub ifc_ifcu: __c_anonymous_ifc_ifcu, } @@ -898,13 +895,11 @@ s_no_extra_traits! { 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, @@ -1337,10 +1332,8 @@ cfg_if! { } } - #[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 { @@ -1350,7 +1343,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_posix_spawn_fae { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { @@ -1362,7 +1354,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_posix_spawn_fae { fn hash(&self, state: &mut H) { unsafe { @@ -1372,10 +1363,8 @@ cfg_if! { } } - #[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 { @@ -1385,7 +1374,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_ifc_ifcu { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { @@ -1397,7 +1385,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifc_ifcu { fn hash(&self, state: &mut H) { unsafe { @@ -1860,7 +1847,7 @@ pub const _SC_SCHED_RT_TS: ::c_int = 2001; pub const _SC_SCHED_PRI_MIN: ::c_int = 2002; pub const _SC_SCHED_PRI_MAX: ::c_int = 2003; -pub const FD_SETSIZE: usize = 0x100; +pub const FD_SETSIZE: ::c_int = 0x100; pub const ST_NOSUID: ::c_ulong = 8; @@ -2343,7 +2330,7 @@ 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_RETURNERROR: ::c_int = 0x40; +pub const POSIX_SPAWN_RETURNERROR: ::c_short = 0x40; // Flags for chflags(2) pub const SF_APPEND: ::c_ulong = 0x00040000; @@ -2414,17 +2401,8 @@ pub const RB_STRING: ::c_int = 0x000000400; pub const RB_POWERDOWN: ::c_int = RB_HALT | 0x000000800; pub const RB_USERCONF: ::c_int = 0x000001000; -cfg_if! { - - if #[cfg(libc_const_extern_fn)] { - pub const fn MAP_ALIGNED(alignment: ::c_int) -> ::c_int { - alignment << MAP_ALIGNMENT_SHIFT - } - } else { - pub fn MAP_ALIGNED(alignment: ::c_int) -> ::c_int { - alignment << MAP_ALIGNMENT_SHIFT - } - } +pub const fn MAP_ALIGNED(alignment: ::c_int) -> ::c_int { + alignment << MAP_ALIGNMENT_SHIFT } const_fn! { @@ -2924,6 +2902,8 @@ extern "C" { result: *mut *mut ::group, ) -> ::c_int; + pub fn mincore(addr: *mut ::c_void, len: ::size_t, vec: *mut ::c_char) -> ::c_int; + pub fn updwtmpx(file: *const ::c_char, ut: *const utmpx) -> ::c_int; pub fn getlastlogx(fname: *const ::c_char, uid: ::uid_t, ll: *mut lastlogx) -> *mut lastlogx; pub fn updlastlogx(fname: *const ::c_char, uid: ::uid_t, ll: *mut lastlogx) -> ::c_int; @@ -3107,14 +3087,9 @@ extern "C" { ) -> ::c_int; } -cfg_if! { - if #[cfg(libc_union)] { - extern { - // these functions use statvfs: - pub fn getmntinfo(mntbufp: *mut *mut ::statvfs, flags: ::c_int) -> ::c_int; - pub fn getvfsstat(buf: *mut statvfs, bufsize: ::size_t, flags: ::c_int) -> ::c_int; - } - } +extern "C" { + pub fn getmntinfo(mntbufp: *mut *mut ::statvfs, flags: ::c_int) -> ::c_int; + pub fn getvfsstat(buf: *mut statvfs, bufsize: ::size_t, flags: ::c_int) -> ::c_int; } cfg_if! { diff --git a/src/unix/bsd/netbsdlike/netbsd/powerpc.rs b/src/unix/bsd/netbsdlike/netbsd/powerpc.rs index e12fd5e112332..b4bfacf6a0185 100644 --- a/src/unix/bsd/netbsdlike/netbsd/powerpc.rs +++ b/src/unix/bsd/netbsdlike/netbsd/powerpc.rs @@ -5,16 +5,7 @@ pub type c_ulong = u32; pub type c_char = u8; pub type __cpu_simple_lock_nv_t = ::c_int; -// 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(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_double>() - 1; pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0; pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; diff --git a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs index bc09149efeabd..643940d03de85 100644 --- a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs @@ -5,15 +5,7 @@ pub type c_ulong = u64; pub type c_char = u8; pub type __cpu_simple_lock_nv_t = ::c_int; -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(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 0; pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 1; diff --git a/src/unix/bsd/netbsdlike/netbsd/x86.rs b/src/unix/bsd/netbsdlike/netbsd/x86.rs index daa89a11a67cb..d3a3967df17ef 100644 --- a/src/unix/bsd/netbsdlike/netbsd/x86.rs +++ b/src/unix/bsd/netbsdlike/netbsd/x86.rs @@ -3,13 +3,4 @@ pub type c_ulong = u32; pub type c_char = i8; pub type __cpu_simple_lock_nv_t = ::c_uchar; -// 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_int>() - 1; - } else { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = 4 - 1; - } -} +pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; diff --git a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs index ba259074f6129..a2087c34e43ef 100644 --- a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs @@ -22,16 +22,7 @@ s! { } } -// 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(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0; pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; diff --git a/src/unix/bsd/netbsdlike/openbsd/aarch64.rs b/src/unix/bsd/netbsdlike/openbsd/aarch64.rs index 2bc82e486c596..f2159c4dc2142 100644 --- a/src/unix/bsd/netbsdlike/openbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/aarch64.rs @@ -16,15 +16,6 @@ s! { } } -// 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(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/arm.rs b/src/unix/bsd/netbsdlike/openbsd/arm.rs index f1ab365d1cd1b..6394df9300245 100644 --- a/src/unix/bsd/netbsdlike/openbsd/arm.rs +++ b/src/unix/bsd/netbsdlike/openbsd/arm.rs @@ -2,15 +2,6 @@ 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(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_double>() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 8f470aff9a357..357662547b8e3 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -540,10 +540,7 @@ s! { pub struct ifreq { pub ifr_name: [::c_char; ::IFNAMSIZ], - #[cfg(libc_union)] pub ifr_ifru: __c_anonymous_ifr_ifru, - #[cfg(not(libc_union))] - pub ifr_ifru: ::sockaddr, } pub struct tcp_info { @@ -716,7 +713,6 @@ s_no_extra_traits! { align: [::c_char; 160], } - #[cfg(libc_union)] pub union __c_anonymous_ifr_ifru { pub ifru_addr: ::sockaddr, pub ifru_dstaddr: ::sockaddr, @@ -728,6 +724,31 @@ s_no_extra_traits! { pub ifru_data: ::caddr_t, pub ifru_index: ::c_uint, } + + pub struct statfs { + pub f_flags: u32, + pub f_bsize: u32, + pub f_iosize: u32, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: i64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: i64, + pub f_syncwrites: u64, + pub f_syncreads: u64, + pub f_asyncwrites: u64, + pub f_asyncreads: u64, + pub f_fsid: ::fsid_t, + pub f_namemax: u32, + pub f_owner: ::uid_t, + pub f_ctime: u64, + pub f_fstypename: [::c_char; 16], + pub f_mntonname: [::c_char; 90], + pub f_mntfromname: [::c_char; 90], + pub f_mntfromspec: [::c_char; 90], + pub mount_info: mount_info, + } } cfg_if! { @@ -935,7 +956,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ifr_ifru { fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { unsafe { @@ -952,10 +972,8 @@ cfg_if! { } } - #[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("__c_anonymous_ifr_ifru") @@ -972,7 +990,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ifr_ifru { fn hash(&self, state: &mut H) { unsafe { @@ -988,138 +1005,102 @@ cfg_if! { } } } - } -} -cfg_if! { - if #[cfg(libc_union)] { - s_no_extra_traits! { - // This type uses the union mount_info: - pub struct statfs { - pub f_flags: u32, - pub f_bsize: u32, - pub f_iosize: u32, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: i64, - pub f_files: u64, - pub f_ffree: u64, - pub f_favail: i64, - pub f_syncwrites: u64, - pub f_syncreads: u64, - pub f_asyncwrites: u64, - pub f_asyncreads: u64, - pub f_fsid: ::fsid_t, - pub f_namemax: u32, - pub f_owner: ::uid_t, - pub f_ctime: u64, - pub f_fstypename: [::c_char; 16], - pub f_mntonname: [::c_char; 90], - pub f_mntfromname: [::c_char; 90], - pub f_mntfromspec: [::c_char; 90], - pub mount_info: mount_info, + impl PartialEq for statfs { + fn eq(&self, other: &statfs) -> bool { + 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_favail == other.f_favail + && self.f_syncwrites == other.f_syncwrites + && self.f_syncreads == other.f_syncreads + && self.f_asyncwrites == other.f_asyncwrites + && self.f_asyncreads == other.f_asyncreads + && self.f_fsid == other.f_fsid + && self.f_namemax == other.f_namemax + && self.f_owner == other.f_owner + && self.f_ctime == other.f_ctime + && self.f_fstypename + .iter() + .zip(other.f_fstypename.iter()) + .all(|(a,b)| a == b) + && self.f_mntonname + .iter() + .zip(other.f_mntonname.iter()) + .all(|(a,b)| a == b) + && self.f_mntfromname + .iter() + .zip(other.f_mntfromname.iter()) + .all(|(a,b)| a == b) + && self.f_mntfromspec + .iter() + .zip(other.f_mntfromspec.iter()) + .all(|(a,b)| a == b) + && self.mount_info == other.mount_info } } - cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - 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_favail == other.f_favail - && self.f_syncwrites == other.f_syncwrites - && self.f_syncreads == other.f_syncreads - && self.f_asyncwrites == other.f_asyncwrites - && self.f_asyncreads == other.f_asyncreads - && self.f_fsid == other.f_fsid - && self.f_namemax == other.f_namemax - && self.f_owner == other.f_owner - && self.f_ctime == other.f_ctime - && self.f_fstypename - .iter() - .zip(other.f_fstypename.iter()) - .all(|(a,b)| a == b) - && self.f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a,b)| a == b) - && self.f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a,b)| a == b) - && self.f_mntfromspec - .iter() - .zip(other.f_mntfromspec.iter()) - .all(|(a,b)| a == b) - && self.mount_info == other.mount_info - } - } - - impl Eq for statfs { } - - impl ::fmt::Debug for statfs { - fn fmt(&self, f: &mut ::fmt::Formatter) - -> ::fmt::Result { - f.debug_struct("statfs") - .field("f_flags", &self.f_flags) - .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_favail", &self.f_favail) - .field("f_syncwrites", &self.f_syncwrites) - .field("f_syncreads", &self.f_syncreads) - .field("f_asyncwrites", &self.f_asyncwrites) - .field("f_asyncreads", &self.f_asyncreads) - .field("f_fsid", &self.f_fsid) - .field("f_namemax", &self.f_namemax) - .field("f_owner", &self.f_owner) - .field("f_ctime", &self.f_ctime) - // FIXME: .field("f_fstypename", &self.f_fstypename) - // FIXME: .field("f_mntonname", &self.f_mntonname) - // FIXME: .field("f_mntfromname", &self.f_mntfromname) - // FIXME: .field("f_mntfromspec", &self.f_mntfromspec) - .field("mount_info", &self.mount_info) - .finish() - } - } + impl Eq for statfs { } + + impl ::fmt::Debug for statfs { + fn fmt(&self, f: &mut ::fmt::Formatter) + -> ::fmt::Result { + f.debug_struct("statfs") + .field("f_flags", &self.f_flags) + .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_favail", &self.f_favail) + .field("f_syncwrites", &self.f_syncwrites) + .field("f_syncreads", &self.f_syncreads) + .field("f_asyncwrites", &self.f_asyncwrites) + .field("f_asyncreads", &self.f_asyncreads) + .field("f_fsid", &self.f_fsid) + .field("f_namemax", &self.f_namemax) + .field("f_owner", &self.f_owner) + .field("f_ctime", &self.f_ctime) + // FIXME: .field("f_fstypename", &self.f_fstypename) + // FIXME: .field("f_mntonname", &self.f_mntonname) + // FIXME: .field("f_mntfromname", &self.f_mntfromname) + // FIXME: .field("f_mntfromspec", &self.f_mntfromspec) + .field("mount_info", &self.mount_info) + .finish() + } + } - impl ::hash::Hash for statfs { - fn hash(&self, state: &mut H) { - 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_favail.hash(state); - self.f_syncwrites.hash(state); - self.f_syncreads.hash(state); - self.f_asyncwrites.hash(state); - self.f_asyncreads.hash(state); - self.f_fsid.hash(state); - self.f_namemax.hash(state); - self.f_owner.hash(state); - self.f_ctime.hash(state); - self.f_fstypename.hash(state); - self.f_mntonname.hash(state); - self.f_mntfromname.hash(state); - self.f_mntfromspec.hash(state); - self.mount_info.hash(state); - } - } + impl ::hash::Hash for statfs { + fn hash(&self, state: &mut H) { + 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_favail.hash(state); + self.f_syncwrites.hash(state); + self.f_syncreads.hash(state); + self.f_asyncwrites.hash(state); + self.f_asyncreads.hash(state); + self.f_fsid.hash(state); + self.f_namemax.hash(state); + self.f_owner.hash(state); + self.f_ctime.hash(state); + self.f_fstypename.hash(state); + self.f_mntonname.hash(state); + self.f_mntfromname.hash(state); + self.f_mntfromspec.hash(state); + self.mount_info.hash(state); } } } @@ -1267,12 +1248,6 @@ pub const NET_RT_IFLIST: ::c_int = 3; pub const NET_RT_STATS: ::c_int = 4; pub const NET_RT_TABLE: ::c_int = 5; pub const NET_RT_IFNAMES: ::c_int = 6; -#[doc(hidden)] -#[deprecated( - since = "0.2.95", - note = "Possibly increasing over the releases and might not be so used in the field" -)] -pub const NET_RT_MAXID: ::c_int = 7; pub const IPV6_JOIN_GROUP: ::c_int = 12; pub const IPV6_LEAVE_GROUP: ::c_int = 13; @@ -1441,7 +1416,7 @@ pub const _SC_AVPHYS_PAGES: ::c_int = 501; pub const _SC_NPROCESSORS_CONF: ::c_int = 502; pub const _SC_NPROCESSORS_ONLN: ::c_int = 503; -pub const FD_SETSIZE: usize = 1024; +pub const FD_SETSIZE: ::c_int = 1024; pub const SCHED_FIFO: ::c_int = 1; pub const SCHED_OTHER: ::c_int = 2; @@ -1573,21 +1548,16 @@ pub const KERN_NTHREADS: ::c_int = 26; pub const KERN_OSVERSION: ::c_int = 27; pub const KERN_SOMAXCONN: ::c_int = 28; pub const KERN_SOMINCONN: ::c_int = 29; -#[deprecated(since = "0.2.71", note = "Removed in OpenBSD 6.0")] -pub const KERN_USERMOUNT: ::c_int = 30; pub const KERN_NOSUIDCOREDUMP: ::c_int = 32; pub const KERN_FSYNC: ::c_int = 33; pub const KERN_SYSVMSG: ::c_int = 34; pub const KERN_SYSVSEM: ::c_int = 35; pub const KERN_SYSVSHM: ::c_int = 36; -#[deprecated(since = "0.2.71", note = "Removed in OpenBSD 6.0")] -pub const KERN_ARND: ::c_int = 37; pub const KERN_MSGBUFSIZE: ::c_int = 38; pub const KERN_MALLOCSTATS: ::c_int = 39; pub const KERN_CPTIME: ::c_int = 40; pub const KERN_NCHSTATS: ::c_int = 41; pub const KERN_FORKSTAT: ::c_int = 42; -pub const KERN_NSELCOLL: ::c_int = 43; pub const KERN_TTY: ::c_int = 44; pub const KERN_CCPU: ::c_int = 45; pub const KERN_FSCALE: ::c_int = 46; @@ -1627,11 +1597,6 @@ pub const KERN_AUDIO: ::c_int = 84; pub const KERN_CPUSTATS: ::c_int = 85; pub const KERN_PFSTATUS: ::c_int = 86; pub const KERN_TIMEOUT_STATS: ::c_int = 87; -#[deprecated( - since = "0.2.95", - note = "Possibly increasing over the releases and might not be so used in the field" -)] -pub const KERN_MAXID: ::c_int = 88; pub const KERN_PROC_ALL: ::c_int = 0; pub const KERN_PROC_PID: ::c_int = 1; @@ -2163,16 +2128,11 @@ extern "C" { ) -> *mut *mut ::c_char; } -cfg_if! { - if #[cfg(libc_union)] { - extern { - // these functions use statfs which uses the union mount_info: - pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; - pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; - pub fn getmntinfo(mntbufp: *mut *mut ::statfs, flags: ::c_int) -> ::c_int; - pub fn getfsstat(buf: *mut statfs, bufsize: ::size_t, flags: ::c_int) -> ::c_int; - } - } +extern "C" { + pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; + pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; + pub fn getmntinfo(mntbufp: *mut *mut ::statfs, flags: ::c_int) -> ::c_int; + pub fn getfsstat(buf: *mut statfs, bufsize: ::size_t, flags: ::c_int) -> ::c_int; } cfg_if! { diff --git a/src/unix/bsd/netbsdlike/openbsd/powerpc.rs b/src/unix/bsd/netbsdlike/openbsd/powerpc.rs index f1ab365d1cd1b..6394df9300245 100644 --- a/src/unix/bsd/netbsdlike/openbsd/powerpc.rs +++ b/src/unix/bsd/netbsdlike/openbsd/powerpc.rs @@ -2,15 +2,6 @@ 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(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_double>() - 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 index 99350ec8dc3d4..df0cdd6d1ac53 100644 --- a/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs @@ -2,15 +2,6 @@ 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(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 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 index 35f1672bbec9e..fbcc5a76bbed3 100644 --- a/src/unix/bsd/netbsdlike/openbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/riscv64.rs @@ -21,15 +21,6 @@ s! { } } -// 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(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/x86.rs b/src/unix/bsd/netbsdlike/openbsd/x86.rs index e87d0ff1e7d5d..a12107bc2a482 100644 --- a/src/unix/bsd/netbsdlike/openbsd/x86.rs +++ b/src/unix/bsd/netbsdlike/openbsd/x86.rs @@ -2,15 +2,6 @@ pub type c_long = i32; pub type c_ulong = u32; pub type c_char = i8; -// 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_int>() - 1; - } else { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = 4 - 1; - } -} +pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/bsd/netbsdlike/openbsd/x86_64.rs b/src/unix/bsd/netbsdlike/openbsd/x86_64.rs index 60dab004456fc..5cc7dc1fc060f 100644 --- a/src/unix/bsd/netbsdlike/openbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/x86_64.rs @@ -110,16 +110,7 @@ cfg_if! { } } -// 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(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 0e60a1c6e267b..4afbeedfc1f9a 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -771,27 +771,27 @@ pub const O_NOFOLLOW: ::c_int = 0x00080000; pub const O_NOCACHE: ::c_int = 0x00100000; pub const O_DIRECTORY: ::c_int = 0x00200000; -pub const S_IFIFO: ::mode_t = 4096; -pub const S_IFCHR: ::mode_t = 8192; -pub const S_IFBLK: ::mode_t = 24576; -pub const S_IFDIR: ::mode_t = 16384; -pub const S_IFREG: ::mode_t = 32768; -pub const S_IFLNK: ::mode_t = 40960; -pub const S_IFSOCK: ::mode_t = 49152; -pub const S_IFMT: ::mode_t = 61440; - -pub const S_IRWXU: ::mode_t = 0o00700; -pub const S_IRUSR: ::mode_t = 0o00400; -pub const S_IWUSR: ::mode_t = 0o00200; -pub const S_IXUSR: ::mode_t = 0o00100; -pub const S_IRWXG: ::mode_t = 0o00070; -pub const S_IRGRP: ::mode_t = 0o00040; -pub const S_IWGRP: ::mode_t = 0o00020; -pub const S_IXGRP: ::mode_t = 0o00010; -pub const S_IRWXO: ::mode_t = 0o00007; -pub const S_IROTH: ::mode_t = 0o00004; -pub const S_IWOTH: ::mode_t = 0o00002; -pub const S_IXOTH: ::mode_t = 0o00001; +pub const S_IFIFO: ::mode_t = 0o1_0000; +pub const S_IFCHR: ::mode_t = 0o2_0000; +pub const S_IFBLK: ::mode_t = 0o6_0000; +pub const S_IFDIR: ::mode_t = 0o4_0000; +pub const S_IFREG: ::mode_t = 0o10_0000; +pub const S_IFLNK: ::mode_t = 0o12_0000; +pub const S_IFSOCK: ::mode_t = 0o14_0000; +pub const S_IFMT: ::mode_t = 0o17_0000; + +pub const S_IRWXU: ::mode_t = 0o0700; +pub const S_IRUSR: ::mode_t = 0o0400; +pub const S_IWUSR: ::mode_t = 0o0200; +pub const S_IXUSR: ::mode_t = 0o0100; +pub const S_IRWXG: ::mode_t = 0o0070; +pub const S_IRGRP: ::mode_t = 0o0040; +pub const S_IWGRP: ::mode_t = 0o0020; +pub const S_IXGRP: ::mode_t = 0o0010; +pub const S_IRWXO: ::mode_t = 0o0007; +pub const S_IROTH: ::mode_t = 0o0004; +pub const S_IWOTH: ::mode_t = 0o0002; +pub const S_IXOTH: ::mode_t = 0o0001; pub const F_OK: ::c_int = 0; pub const R_OK: ::c_int = 4; @@ -1100,7 +1100,7 @@ pub const SA_ONESHOT: ::c_int = SA_RESETHAND; pub const SS_ONSTACK: ::c_int = 0x1; pub const SS_DISABLE: ::c_int = 0x2; -pub const FD_SETSIZE: usize = 1024; +pub const FD_SETSIZE: ::c_int = 1024; pub const RTLD_LOCAL: ::c_int = 0x0; pub const RTLD_NOW: ::c_int = 0x1; @@ -1550,11 +1550,11 @@ pub const LOG_PERROR: ::c_int = 32 << 12; pub const LOG_NOWAIT: ::c_int = 64 << 12; // spawn.h -pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01; -pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02; -pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x10; -pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x20; -pub const POSIX_SPAWN_SETSID: ::c_int = 0x40; +pub const POSIX_SPAWN_RESETIDS: ::c_short = 0x01; +pub const POSIX_SPAWN_SETPGROUP: ::c_short = 0x02; +pub const POSIX_SPAWN_SETSIGDEF: ::c_short = 0x10; +pub const POSIX_SPAWN_SETSIGMASK: ::c_short = 0x20; +pub const POSIX_SPAWN_SETSID: ::c_short = 0x40; const_fn! { {const} fn CMSG_ALIGN(len: usize) -> usize { @@ -1791,6 +1791,7 @@ extern "C" { lock: *mut pthread_mutex_t, abstime: *const ::timespec, ) -> ::c_int; + pub fn pthread_sigqueue(thread: ::pthread_t, sig: ::c_int, value: ::sigval) -> ::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; @@ -1841,8 +1842,8 @@ extern "C" { pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t; pub fn execvpe( file: *const ::c_char, - argv: *const *const ::c_char, - environment: *const *const ::c_char, + argv: *const *mut ::c_char, + environment: *const *mut ::c_char, ) -> ::c_int; pub fn getgrgid_r( gid: ::gid_t, diff --git a/src/unix/haiku/native.rs b/src/unix/haiku/native.rs index 62d6392fabdf5..77aa1cf16ae43 100644 --- a/src/unix/haiku/native.rs +++ b/src/unix/haiku/native.rs @@ -460,7 +460,6 @@ s! { } s_no_extra_traits! { - #[cfg(libc_union)] pub union cpuid_info { pub eax_0: __c_anonymous_eax_0, pub eax_1: __c_anonymous_eax_1, @@ -470,7 +469,6 @@ s_no_extra_traits! { pub regs: __c_anonymous_regs, } - #[cfg(libc_union)] pub union __c_anonymous_cpu_topology_info_data { pub root: cpu_topology_root_info, pub package: cpu_topology_package_info, @@ -481,16 +479,12 @@ s_no_extra_traits! { pub id: u32, pub type_: topology_level_type, pub level: u32, - #[cfg(libc_union)] pub data: __c_anonymous_cpu_topology_info_data, - #[cfg(not(libc_union))] - pub data: cpu_topology_core_info, } } cfg_if! { if #[cfg(feature = "extra_traits")] { - #[cfg(libc_union)] impl PartialEq for cpuid_info { fn eq(&self, other: &cpuid_info) -> bool { unsafe { @@ -503,9 +497,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for cpuid_info {} - #[cfg(libc_union)] impl ::fmt::Debug for cpuid_info { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { @@ -521,7 +513,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_cpu_topology_info_data { fn eq(&self, other: &__c_anonymous_cpu_topology_info_data) -> bool { unsafe { @@ -531,9 +522,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for __c_anonymous_cpu_topology_info_data {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_cpu_topology_info_data { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { @@ -956,6 +945,7 @@ pub const B_XATTR_TYPE: u32 = haiku_constant!('X', 'A', 'T', 'R'); pub const B_NETWORK_ADDRESS_TYPE: u32 = haiku_constant!('N', 'W', 'A', 'D'); pub const B_MIME_STRING_TYPE: u32 = haiku_constant!('M', 'I', 'M', 'S'); pub const B_ASCII_TYPE: u32 = haiku_constant!('T', 'E', 'X', 'T'); +pub const B_APP_IMAGE_SYMBOL: *const ::c_void = core::ptr::null(); extern "C" { // kernel/OS.h @@ -1310,7 +1300,7 @@ extern "C" { pub fn find_path_for_path_etc( path: *const ::c_char, dependency: *const ::c_char, - architectur: *const ::c_char, + architecture: *const ::c_char, baseDirectory: path_base_directory, subPath: *const ::c_char, flags: u32, @@ -1338,14 +1328,7 @@ extern "C" { pathString: *mut ::c_char, length: i32, ) -> status_t; -} - -cfg_if! { - if #[cfg(libc_union)] { - extern "C" { - pub fn get_cpuid(info: *mut cpuid_info, eaxRegister: u32, cpuNum: u32) -> status_t; - } - } + pub fn get_cpuid(info: *mut cpuid_info, eaxRegister: u32, cpuNum: u32) -> status_t; } // The following functions are defined as macros in C/C++ diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 2701649f6c646..73970f9c9355e 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -73,7 +73,6 @@ pub type __socklen_t = __u32_type; pub type __sig_atomic_t = ::c_int; pub type __time64_t = __int64_t; pub type ssize_t = __ssize_t; -pub type size_t = ::c_ulong; pub type wchar_t = ::c_int; pub type wint_t = ::c_uint; pub type gid_t = __gid_t; @@ -341,7 +340,7 @@ s! { pub ai_family: ::c_int, pub ai_socktype: ::c_int, pub ai_protocol: ::c_int, - pub ai_addrlen: socklen_t, + pub ai_addrlen: ::socklen_t, pub ai_addr: *mut sockaddr, pub ai_canonname: *mut ::c_char, pub ai_next: *mut addrinfo, @@ -349,11 +348,11 @@ s! { pub struct msghdr { pub msg_name: *mut ::c_void, - pub msg_namelen: socklen_t, + pub msg_namelen: ::socklen_t, pub msg_iov: *mut ::iovec, pub msg_iovlen: ::c_int, pub msg_control: *mut ::c_void, - pub msg_controllen: socklen_t, + pub msg_controllen: ::socklen_t, pub msg_flags: ::c_int, } @@ -678,8 +677,8 @@ s! { pub struct __pthread_attr { pub __schedparam: sched_param, pub __stackaddr: *mut ::c_void, - pub __stacksize: size_t, - pub __guardsize: size_t, + pub __stacksize: ::size_t, + pub __guardsize: ::size_t, pub __detachstate: __pthread_detachstate, pub __inheritsched: __pthread_inheritsched, pub __contentionscope: __pthread_contentionscope, @@ -728,7 +727,7 @@ s! { pub struct iovec { pub iov_base: *mut ::c_void, - pub iov_len: size_t, + pub iov_len: ::size_t, } pub struct passwd { @@ -1211,7 +1210,7 @@ pub const SHM_UNLOCK: ::c_int = 12; pub const STDIN_FILENO: ::c_int = 0; pub const STDOUT_FILENO: ::c_int = 1; pub const STDERR_FILENO: ::c_int = 2; -pub const __FD_SETSIZE: usize = 256; +pub const __FD_SETSIZE: ::c_int = 256; pub const R_OK: ::c_int = 4; pub const W_OK: ::c_int = 2; pub const X_OK: ::c_int = 1; @@ -1256,7 +1255,7 @@ pub const PDP_ENDIAN: usize = 3412; pub const BYTE_ORDER: usize = 1234; // sys/select.h -pub const FD_SETSIZE: usize = 256; +pub const FD_SETSIZE: ::c_int = 256; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 32; pub const __SIZEOF_PTHREAD_ATTR_T: usize = 32; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 28; @@ -1588,8 +1587,8 @@ pub const _POSIX_MQ_OPEN_MAX: usize = 8; pub const _POSIX_MQ_PRIO_MAX: usize = 32; pub const _POSIX_NAME_MAX: usize = 14; pub const _POSIX_NGROUPS_MAX: usize = 8; -pub const _POSIX_OPEN_MAX: usize = 20; -pub const _POSIX_FD_SETSIZE: usize = 20; +pub const _POSIX_OPEN_MAX: ::c_int = 20; +pub const _POSIX_FD_SETSIZE: ::c_int = 20; pub const _POSIX_PATH_MAX: usize = 256; pub const _POSIX_PIPE_BUF: usize = 512; pub const _POSIX_RE_DUP_MAX: usize = 255; @@ -2117,29 +2116,29 @@ pub const MINSIGSTKSZ: usize = 8192; pub const SIGSTKSZ: usize = 40960; // sys/stat.h -pub const __S_IFMT: mode_t = 61440; -pub const __S_IFDIR: mode_t = 16384; -pub const __S_IFCHR: mode_t = 8192; -pub const __S_IFBLK: mode_t = 24576; -pub const __S_IFREG: mode_t = 32768; -pub const __S_IFLNK: mode_t = 40960; -pub const __S_IFSOCK: mode_t = 49152; -pub const __S_IFIFO: mode_t = 4096; -pub const __S_ISUID: mode_t = 2048; -pub const __S_ISGID: mode_t = 1024; -pub const __S_ISVTX: mode_t = 512; -pub const __S_IREAD: mode_t = 256; -pub const __S_IWRITE: mode_t = 128; -pub const __S_IEXEC: mode_t = 64; -pub const S_INOCACHE: mode_t = 65536; -pub const S_IUSEUNK: mode_t = 131072; -pub const S_IUNKNOWN: mode_t = 1835008; -pub const S_IUNKSHIFT: mode_t = 12; -pub const S_IPTRANS: mode_t = 2097152; -pub const S_IATRANS: mode_t = 4194304; -pub const S_IROOT: mode_t = 8388608; -pub const S_ITRANS: mode_t = 14680064; -pub const S_IMMAP0: mode_t = 16777216; +pub const __S_IFMT: mode_t = 0o17_0000; +pub const __S_IFDIR: mode_t = 0o4_0000; +pub const __S_IFCHR: mode_t = 0o2_0000; +pub const __S_IFBLK: mode_t = 0o6_0000; +pub const __S_IFREG: mode_t = 0o10_0000; +pub const __S_IFLNK: mode_t = 0o12_0000; +pub const __S_IFSOCK: mode_t = 0o14_0000; +pub const __S_IFIFO: mode_t = 0o1_0000; +pub const __S_ISUID: mode_t = 0o4000; +pub const __S_ISGID: mode_t = 0o2000; +pub const __S_ISVTX: mode_t = 0o1000; +pub const __S_IREAD: mode_t = 0o0400; +pub const __S_IWRITE: mode_t = 0o0200; +pub const __S_IEXEC: mode_t = 0o0100; +pub const S_INOCACHE: mode_t = 0o20_0000; +pub const S_IUSEUNK: mode_t = 0o40_0000; +pub const S_IUNKNOWN: mode_t = 0o700_0000; +pub const S_IUNKSHIFT: mode_t = 0o0014; +pub const S_IPTRANS: mode_t = 0o1000_0000; +pub const S_IATRANS: mode_t = 0o2000_0000; +pub const S_IROOT: mode_t = 0o4000_0000; +pub const S_ITRANS: mode_t = 0o7000_0000; +pub const S_IMMAP0: mode_t = 0o10000_0000; pub const CMASK: mode_t = 18; pub const UF_SETTABLE: ::c_uint = 65535; pub const UF_NODUMP: ::c_uint = 1; @@ -2155,32 +2154,32 @@ pub const SF_NOUNLINK: ::c_uint = 1048576; pub const SF_SNAPSHOT: ::c_uint = 2097152; pub const UTIME_NOW: ::c_long = -1; pub const UTIME_OMIT: ::c_long = -2; -pub const S_IFMT: ::mode_t = 61440; -pub const S_IFDIR: ::mode_t = 16384; -pub const S_IFCHR: ::mode_t = 8192; -pub const S_IFBLK: ::mode_t = 24576; -pub const S_IFREG: ::mode_t = 32768; -pub const S_IFIFO: ::mode_t = 4096; -pub const S_IFLNK: ::mode_t = 40960; -pub const S_IFSOCK: ::mode_t = 49152; -pub const S_ISUID: ::mode_t = 2048; -pub const S_ISGID: ::mode_t = 1024; -pub const S_ISVTX: ::mode_t = 512; -pub const S_IRUSR: ::mode_t = 256; -pub const S_IWUSR: ::mode_t = 128; -pub const S_IXUSR: ::mode_t = 64; -pub const S_IRWXU: ::mode_t = 448; -pub const S_IREAD: ::mode_t = 256; -pub const S_IWRITE: ::mode_t = 128; -pub const S_IEXEC: ::mode_t = 64; -pub const S_IRGRP: ::mode_t = 32; -pub const S_IWGRP: ::mode_t = 16; -pub const S_IXGRP: ::mode_t = 8; -pub const S_IRWXG: ::mode_t = 56; -pub const S_IROTH: ::mode_t = 4; -pub const S_IWOTH: ::mode_t = 2; -pub const S_IXOTH: ::mode_t = 1; -pub const S_IRWXO: ::mode_t = 7; +pub const S_IFMT: ::mode_t = 0o17_0000; +pub const S_IFDIR: ::mode_t = 0o4_0000; +pub const S_IFCHR: ::mode_t = 0o2_0000; +pub const S_IFBLK: ::mode_t = 0o6_0000; +pub const S_IFREG: ::mode_t = 0o10_0000; +pub const S_IFIFO: ::mode_t = 0o1_0000; +pub const S_IFLNK: ::mode_t = 0o12_0000; +pub const S_IFSOCK: ::mode_t = 0o14_0000; +pub const S_ISUID: ::mode_t = 0o4000; +pub const S_ISGID: ::mode_t = 0o2000; +pub const S_ISVTX: ::mode_t = 0o1000; +pub const S_IRUSR: ::mode_t = 0o0400; +pub const S_IWUSR: ::mode_t = 0o0200; +pub const S_IXUSR: ::mode_t = 0o0100; +pub const S_IRWXU: ::mode_t = 0o0700; +pub const S_IREAD: ::mode_t = 0o0400; +pub const S_IWRITE: ::mode_t = 0o0200; +pub const S_IEXEC: ::mode_t = 0o0100; +pub const S_IRGRP: ::mode_t = 0o0040; +pub const S_IWGRP: ::mode_t = 0o0020; +pub const S_IXGRP: ::mode_t = 0o0010; +pub const S_IRWXG: ::mode_t = 0o0070; +pub const S_IROTH: ::mode_t = 0o0004; +pub const S_IWOTH: ::mode_t = 0o0002; +pub const S_IXOTH: ::mode_t = 0o0001; +pub const S_IRWXO: ::mode_t = 0o0007; pub const ACCESSPERMS: ::mode_t = 511; pub const ALLPERMS: ::mode_t = 4095; pub const DEFFILEMODE: ::mode_t = 438; @@ -2760,9 +2759,13 @@ pub const MREMAP_FIXED: ::c_int = 2; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; +// sys/xattr.h +pub const XATTR_CREATE: ::c_int = 0x1; +pub const XATTR_REPLACE: ::c_int = 0x2; + // spawn.h -pub const POSIX_SPAWN_USEVFORK: ::c_int = 64; -pub const POSIX_SPAWN_SETSID: ::c_int = 128; +pub const POSIX_SPAWN_USEVFORK: ::c_short = 64; +pub const POSIX_SPAWN_SETSID: ::c_short = 128; // sys/syslog.h pub const LOG_CRON: ::c_int = 9 << 3; @@ -3640,13 +3643,13 @@ extern "C" { __iovec: *const ::iovec, __count: ::c_int, __offset: __off_t, - ) -> ssize_t; + ) -> ::ssize_t; pub fn pwritev( __fd: ::c_int, __iovec: *const ::iovec, __count: ::c_int, __offset: __off_t, - ) -> ssize_t; + ) -> ::ssize_t; pub fn preadv64( fd: ::c_int, @@ -3727,7 +3730,7 @@ extern "C" { pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int; pub fn ftello64(stream: *mut ::FILE) -> ::off64_t; - pub fn bind(__fd: ::c_int, __addr: *const sockaddr, __len: socklen_t) -> ::c_int; + pub fn bind(__fd: ::c_int, __addr: *const sockaddr, __len: ::socklen_t) -> ::c_int; pub fn accept4( fd: ::c_int, @@ -3745,7 +3748,7 @@ extern "C" { pub fn recvmsg(__fd: ::c_int, __message: *mut msghdr, __flags: ::c_int) -> ::ssize_t; - pub fn sendmsg(__fd: ::c_int, __message: *const msghdr, __flags: ::c_int) -> ssize_t; + pub fn sendmsg(__fd: ::c_int, __message: *const msghdr, __flags: ::c_int) -> ::ssize_t; pub fn recvfrom( socket: ::c_int, @@ -4202,14 +4205,10 @@ extern "C" { ) -> ::c_int; pub fn execvpe( file: *const ::c_char, - argv: *const *const ::c_char, - envp: *const *const ::c_char, - ) -> ::c_int; - pub fn fexecve( - fd: ::c_int, - argv: *const *const ::c_char, - envp: *const *const ::c_char, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char, ) -> ::c_int; + pub fn fexecve(fd: ::c_int, argv: *const *mut ::c_char, envp: *const *mut ::c_char) -> ::c_int; pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; @@ -4349,7 +4348,7 @@ extern "C" { pub fn mmap64( __addr: *mut ::c_void, - __len: size_t, + __len: ::size_t, __prot: ::c_int, __flags: ::c_int, __fd: ::c_int, @@ -4666,15 +4665,8 @@ safe_f! { } } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } else { - mod no_align; - pub use self::no_align::*; - } -} +mod align; +pub use self::align::*; cfg_if! { if #[cfg(target_pointer_width = "64")] { diff --git a/src/unix/linux_like/android/b32/arm.rs b/src/unix/linux_like/android/b32/arm.rs index a062175eef746..26bfed18aba99 100644 --- a/src/unix/linux_like/android/b32/arm.rs +++ b/src/unix/linux_like/android/b32/arm.rs @@ -29,119 +29,115 @@ s! { } } +s_no_extra_traits! { + pub struct __c_anonymous_uc_sigmask_with_padding { + pub uc_sigmask: ::sigset_t, + /* Android has a wrong (smaller) sigset_t on x86. */ + __padding_rt_sigset: u32, + } + + pub union __c_anonymous_uc_sigmask { + uc_sigmask: __c_anonymous_uc_sigmask_with_padding, + uc_sigmask64: ::sigset64_t, + } + + 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__c_anonymous_union: __c_anonymous_uc_sigmask, + /* The kernel adds extra padding after uc_sigmask to match + * glibc sigset_t on ARM. */ + __padding: [c_char; 120], + __align: [::c_longlong; 0], + uc_regspace: [::c_ulong; 128], + } +} + cfg_if! { - if #[cfg(libc_union)] { - s_no_extra_traits! { - pub struct __c_anonymous_uc_sigmask_with_padding { - pub uc_sigmask: ::sigset_t, - /* Android has a wrong (smaller) sigset_t on x86. */ - __padding_rt_sigset: u32, + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __c_anonymous_uc_sigmask_with_padding { + fn eq( + &self, other: &__c_anonymous_uc_sigmask_with_padding + ) -> bool { + self.uc_sigmask == other.uc_sigmask + // Ignore padding } - - pub union __c_anonymous_uc_sigmask { - uc_sigmask: __c_anonymous_uc_sigmask_with_padding, - uc_sigmask64: ::sigset64_t, + } + impl Eq for __c_anonymous_uc_sigmask_with_padding {} + impl ::fmt::Debug for __c_anonymous_uc_sigmask_with_padding { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("uc_sigmask_with_padding") + .field("uc_sigmask_with_padding", &self.uc_sigmask) + // Ignore padding + .finish() } - - 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__c_anonymous_union: __c_anonymous_uc_sigmask, - /* The kernel adds extra padding after uc_sigmask to match - * glibc sigset_t on ARM. */ - __padding: [c_char; 120], - __align: [::c_longlong; 0], - uc_regspace: [::c_ulong; 128], + } + impl ::hash::Hash for __c_anonymous_uc_sigmask_with_padding { + fn hash(&self, state: &mut H) { + self.uc_sigmask.hash(state) + // Ignore padding } } - cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for __c_anonymous_uc_sigmask_with_padding { - fn eq( - &self, other: &__c_anonymous_uc_sigmask_with_padding - ) -> bool { - self.uc_sigmask == other.uc_sigmask - // Ignore padding - } - } - impl Eq for __c_anonymous_uc_sigmask_with_padding {} - impl ::fmt::Debug for __c_anonymous_uc_sigmask_with_padding { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("uc_sigmask_with_padding") - .field("uc_sigmask_with_padding", &self.uc_sigmask) - // Ignore padding - .finish() - } - } - impl ::hash::Hash for __c_anonymous_uc_sigmask_with_padding { - fn hash(&self, state: &mut H) { - self.uc_sigmask.hash(state) - // Ignore padding - } - } - - impl PartialEq for __c_anonymous_uc_sigmask { - fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { - unsafe { self.uc_sigmask == other.uc_sigmask } - } - } - impl Eq for __c_anonymous_uc_sigmask {} - impl ::fmt::Debug for __c_anonymous_uc_sigmask { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("uc_sigmask") - .field("uc_sigmask", unsafe { &self.uc_sigmask }) - .finish() - } - } - impl ::hash::Hash for __c_anonymous_uc_sigmask { - fn hash(&self, state: &mut H) { - unsafe { self.uc_sigmask.hash(state) } - } - } + impl PartialEq for __c_anonymous_uc_sigmask { + fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { + unsafe { self.uc_sigmask == other.uc_sigmask } + } + } + impl Eq for __c_anonymous_uc_sigmask {} + impl ::fmt::Debug for __c_anonymous_uc_sigmask { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("uc_sigmask") + .field("uc_sigmask", unsafe { &self.uc_sigmask }) + .finish() + } + } + impl ::hash::Hash for __c_anonymous_uc_sigmask { + fn hash(&self, state: &mut H) { + unsafe { self.uc_sigmask.hash(state) } + } + } - impl PartialEq for ucontext_t { - fn eq(&self, other: &Self) -> 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__c_anonymous_union - == other.uc_sigmask__c_anonymous_union - && &self.uc_regspace[..] == &other.uc_regspace[..] - // Ignore padding field - } - } - 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_flags) - .field("uc_link", &self.uc_link) - .field("uc_stack", &self.uc_stack) - .field("uc_mcontext", &self.uc_mcontext) - .field( - "uc_sigmask__c_anonymous_union", - &self.uc_sigmask__c_anonymous_union - ) - .field("uc_regspace", &&self.uc_regspace[..]) - // Ignore padding field - .finish() - } - } - impl ::hash::Hash for ucontext_t { - fn hash(&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__c_anonymous_union.hash(state); - self.uc_regspace[..].hash(state); - // Ignore padding field - } - } + impl PartialEq for ucontext_t { + fn eq(&self, other: &Self) -> 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__c_anonymous_union + == other.uc_sigmask__c_anonymous_union + && &self.uc_regspace[..] == &other.uc_regspace[..] + // Ignore padding field + } + } + 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_flags) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field( + "uc_sigmask__c_anonymous_union", + &self.uc_sigmask__c_anonymous_union + ) + .field("uc_regspace", &&self.uc_regspace[..]) + // Ignore padding field + .finish() + } + } + impl ::hash::Hash for ucontext_t { + fn hash(&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__c_anonymous_union.hash(state); + self.uc_regspace[..].hash(state); + // Ignore padding field } } } @@ -512,6 +508,22 @@ 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; // offsets in mcontext_t.gregs from sys/ucontext.h pub const REG_R0: ::c_int = 0; diff --git a/src/unix/linux_like/android/b32/mod.rs b/src/unix/linux_like/android/b32/mod.rs index 1f4f796f2a94a..aa29267f9db50 100644 --- a/src/unix/linux_like/android/b32/mod.rs +++ b/src/unix/linux_like/android/b32/mod.rs @@ -9,6 +9,7 @@ pub type sigset_t = ::c_ulong; pub type socklen_t = i32; pub type time64_t = i64; pub type __u64 = ::c_ulonglong; +pub type __s64 = ::c_longlong; s! { pub struct sigaction { diff --git a/src/unix/linux_like/android/b32/x86/mod.rs b/src/unix/linux_like/android/b32/x86/mod.rs index e549f3b5168e6..feec5ce6606a4 100644 --- a/src/unix/linux_like/android/b32/x86/mod.rs +++ b/src/unix/linux_like/android/b32/x86/mod.rs @@ -28,113 +28,109 @@ s! { } } +s_no_extra_traits! { + pub struct __c_anonymous_uc_sigmask_with_padding { + pub uc_sigmask: ::sigset_t, + /* Android has a wrong (smaller) sigset_t on x86. */ + __padding_rt_sigset: u32, + } + + pub union __c_anonymous_uc_sigmask { + uc_sigmask: __c_anonymous_uc_sigmask_with_padding, + uc_sigmask64: ::sigset64_t, + } + + 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__c_anonymous_union: __c_anonymous_uc_sigmask, + __padding_rt_sigset: u32, + __fpregs_mem: _libc_fpstate, + } +} + cfg_if! { - if #[cfg(libc_union)] { - s_no_extra_traits! { - pub struct __c_anonymous_uc_sigmask_with_padding { - pub uc_sigmask: ::sigset_t, - /* Android has a wrong (smaller) sigset_t on x86. */ - __padding_rt_sigset: u32, + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __c_anonymous_uc_sigmask_with_padding { + fn eq( + &self, other: &__c_anonymous_uc_sigmask_with_padding + ) -> bool { + self.uc_sigmask == other.uc_sigmask + // Ignore padding } - - pub union __c_anonymous_uc_sigmask { - uc_sigmask: __c_anonymous_uc_sigmask_with_padding, - uc_sigmask64: ::sigset64_t, + } + impl Eq for __c_anonymous_uc_sigmask_with_padding {} + impl ::fmt::Debug for __c_anonymous_uc_sigmask_with_padding { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("uc_sigmask_with_padding") + .field("uc_sigmask_with_padding", &self.uc_sigmask) + // Ignore padding + .finish() } - - 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__c_anonymous_union: __c_anonymous_uc_sigmask, - __padding_rt_sigset: u32, - __fpregs_mem: _libc_fpstate, + } + impl ::hash::Hash for __c_anonymous_uc_sigmask_with_padding { + fn hash(&self, state: &mut H) { + self.uc_sigmask.hash(state) + // Ignore padding } } - cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for __c_anonymous_uc_sigmask_with_padding { - fn eq( - &self, other: &__c_anonymous_uc_sigmask_with_padding - ) -> bool { - self.uc_sigmask == other.uc_sigmask - // Ignore padding - } - } - impl Eq for __c_anonymous_uc_sigmask_with_padding {} - impl ::fmt::Debug for __c_anonymous_uc_sigmask_with_padding { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("uc_sigmask_with_padding") - .field("uc_sigmask_with_padding", &self.uc_sigmask) - // Ignore padding - .finish() - } - } - impl ::hash::Hash for __c_anonymous_uc_sigmask_with_padding { - fn hash(&self, state: &mut H) { - self.uc_sigmask.hash(state) - // Ignore padding - } - } - - impl PartialEq for __c_anonymous_uc_sigmask { - fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { - unsafe { self.uc_sigmask == other.uc_sigmask } - } - } - impl Eq for __c_anonymous_uc_sigmask {} - impl ::fmt::Debug for __c_anonymous_uc_sigmask { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("uc_sigmask") - .field("uc_sigmask", unsafe { &self.uc_sigmask }) - .finish() - } - } - impl ::hash::Hash for __c_anonymous_uc_sigmask { - fn hash(&self, state: &mut H) { - unsafe { self.uc_sigmask.hash(state) } - } - } + impl PartialEq for __c_anonymous_uc_sigmask { + fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { + unsafe { self.uc_sigmask == other.uc_sigmask } + } + } + impl Eq for __c_anonymous_uc_sigmask {} + impl ::fmt::Debug for __c_anonymous_uc_sigmask { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("uc_sigmask") + .field("uc_sigmask", unsafe { &self.uc_sigmask }) + .finish() + } + } + impl ::hash::Hash for __c_anonymous_uc_sigmask { + fn hash(&self, state: &mut H) { + unsafe { self.uc_sigmask.hash(state) } + } + } - impl PartialEq for ucontext_t { - fn eq(&self, other: &Self) -> 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__c_anonymous_union - == other.uc_sigmask__c_anonymous_union - // Ignore padding field - } - } - 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_flags) - .field("uc_link", &self.uc_link) - .field("uc_stack", &self.uc_stack) - .field("uc_mcontext", &self.uc_mcontext) - .field( - "uc_sigmask__c_anonymous_union", - &self.uc_sigmask__c_anonymous_union - ) - // Ignore padding field - .finish() - } - } - impl ::hash::Hash for ucontext_t { - fn hash(&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__c_anonymous_union.hash(state); - // Ignore padding field - } - } + impl PartialEq for ucontext_t { + fn eq(&self, other: &Self) -> 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__c_anonymous_union + == other.uc_sigmask__c_anonymous_union + // Ignore padding field + } + } + 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_flags) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field( + "uc_sigmask__c_anonymous_union", + &self.uc_sigmask__c_anonymous_union + ) + // Ignore padding field + .finish() + } + } + impl ::hash::Hash for ucontext_t { + fn hash(&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__c_anonymous_union.hash(state); + // Ignore padding field } } } @@ -544,6 +540,23 @@ 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_memfd_secret: ::c_long = 447; +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; // offsets in user_regs_structs, from sys/reg.h pub const EBX: ::c_int = 0; @@ -614,9 +627,5 @@ f! { } } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index 7b87a1d49dc3e..46cde40ae4c73 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -1,6 +1,7 @@ pub type c_char = u8; pub type wchar_t = u32; pub type __u64 = ::c_ulonglong; +pub type __s64 = ::c_longlong; s! { pub struct stat { @@ -191,7 +192,6 @@ pub const SYS_vhangup: ::c_long = 58; pub const SYS_pipe2: ::c_long = 59; pub const SYS_quotactl: ::c_long = 60; pub const SYS_getdents64: ::c_long = 61; -pub const SYS_lseek: ::c_long = 62; pub const SYS_read: ::c_long = 63; pub const SYS_write: ::c_long = 64; pub const SYS_readv: ::c_long = 65; @@ -348,7 +348,6 @@ pub const SYS_request_key: ::c_long = 218; pub const SYS_keyctl: ::c_long = 219; pub const SYS_clone: ::c_long = 220; pub const SYS_execve: ::c_long = 221; -pub const SYS_mmap: ::c_long = 222; pub const SYS_swapon: ::c_long = 224; pub const SYS_swapoff: ::c_long = 225; pub const SYS_mprotect: ::c_long = 226; @@ -412,21 +411,30 @@ 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_syscalls: ::c_long = 436; +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_memfd_secret: ::c_long = 447; +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; +pub const SYS_syscalls: ::c_long = 451; pub const PROT_BTI: ::c_int = 0x10; pub const PROT_MTE: ::c_int = 0x20; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; -cfg_if! { - if #[cfg(libc_int128)] { - mod int128; - pub use self::int128::*; - } -} +mod int128; +pub use self::int128::*; diff --git a/src/unix/linux_like/android/b64/mod.rs b/src/unix/linux_like/android/b64/mod.rs index 67d0dacf17e93..9639e1b4fa589 100644 --- a/src/unix/linux_like/android/b64/mod.rs +++ b/src/unix/linux_like/android/b64/mod.rs @@ -288,6 +288,7 @@ pub const AT_BASE_PLATFORM: ::c_ulong = 24; pub const AT_RANDOM: ::c_ulong = 25; pub const AT_HWCAP2: ::c_ulong = 26; pub const AT_EXECFN: ::c_ulong = 31; +pub const AT_MINSIGSTKSZ: ::c_ulong = 51; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { value: 0, diff --git a/src/unix/linux_like/android/b64/riscv64/mod.rs b/src/unix/linux_like/android/b64/riscv64/mod.rs index 9d414dc15fb39..405b9ac005439 100644 --- a/src/unix/linux_like/android/b64/riscv64/mod.rs +++ b/src/unix/linux_like/android/b64/riscv64/mod.rs @@ -2,6 +2,7 @@ pub type c_char = i8; pub type wchar_t = u32; pub type greg_t = i64; pub type __u64 = ::c_ulonglong; +pub type __s64 = ::c_longlong; s! { pub struct stat { @@ -343,11 +344,23 @@ 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_syscalls: ::c_long = 436; +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_memfd_secret: ::c_long = 447; +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; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/android/b64/x86_64/mod.rs b/src/unix/linux_like/android/b64/x86_64/mod.rs index be6b5011c21cc..9062e2feea701 100644 --- a/src/unix/linux_like/android/b64/x86_64/mod.rs +++ b/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -2,6 +2,7 @@ pub type c_char = i8; pub type wchar_t = i32; pub type greg_t = i64; pub type __u64 = ::c_ulonglong; +pub type __s64 = ::c_longlong; s! { pub struct stat { @@ -104,35 +105,31 @@ s! { } +s_no_extra_traits! { + pub union __c_anonymous_uc_sigmask { + uc_sigmask: ::sigset_t, + uc_sigmask64: ::sigset64_t, + } +} + cfg_if! { - if #[cfg(libc_union)] { - s_no_extra_traits! { - pub union __c_anonymous_uc_sigmask { - uc_sigmask: ::sigset_t, - uc_sigmask64: ::sigset64_t, + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __c_anonymous_uc_sigmask { + fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { + unsafe { self.uc_sigmask == other.uc_sigmask } } } - - cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for __c_anonymous_uc_sigmask { - fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { - unsafe { self.uc_sigmask == other.uc_sigmask } - } - } - impl Eq for __c_anonymous_uc_sigmask {} - impl ::fmt::Debug for __c_anonymous_uc_sigmask { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("uc_sigmask") - .field("uc_sigmask", unsafe { &self.uc_sigmask }) - .finish() - } - } - impl ::hash::Hash for __c_anonymous_uc_sigmask { - fn hash(&self, state: &mut H) { - unsafe { self.uc_sigmask.hash(state) } - } - } + impl Eq for __c_anonymous_uc_sigmask {} + impl ::fmt::Debug for __c_anonymous_uc_sigmask { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("uc_sigmask") + .field("uc_sigmask", unsafe { &self.uc_sigmask }) + .finish() + } + } + impl ::hash::Hash for __c_anonymous_uc_sigmask { + fn hash(&self, state: &mut H) { + unsafe { self.uc_sigmask.hash(state) } } } } @@ -739,6 +736,23 @@ 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_memfd_secret: ::c_long = 447; +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; // offsets in user_regs_structs, from sys/reg.h pub const R15: ::c_int = 0; @@ -794,9 +808,5 @@ pub const REG_TRAPNO: ::c_int = 20; pub const REG_OLDMASK: ::c_int = 21; pub const REG_CR2: ::c_int = 22; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index fb0b06701507c..cf8b98d7e62c1 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -48,10 +48,6 @@ pub type Elf64_Xword = u64; pub type eventfd_t = u64; -// these structs sit behind a heap allocation on Android -pub type posix_spawn_file_actions_t = *mut ::c_void; -pub type posix_spawnattr_t = *mut ::c_void; - s! { pub struct stack_t { pub ss_sp: *mut ::c_void, @@ -514,8 +510,40 @@ s! { pub ifr6_addr: ::in6_addr, pub ifr6_prefixlen: u32, pub ifr6_ifindex: ::c_int, - } + } + + pub struct statx { + pub stx_mask: ::__u32, + pub stx_blksize: ::__u32, + pub stx_attributes: ::__u64, + pub stx_nlink: ::__u32, + pub stx_uid: ::__u32, + pub stx_gid: ::__u32, + pub stx_mode: ::__u16, + __statx_pad1: [::__u16; 1], + pub stx_ino: ::__u64, + pub stx_size: ::__u64, + pub stx_blocks: ::__u64, + pub stx_attributes_mask: ::__u64, + pub stx_atime: ::statx_timestamp, + pub stx_btime: ::statx_timestamp, + pub stx_ctime: ::statx_timestamp, + pub stx_mtime: ::statx_timestamp, + pub stx_rdev_major: ::__u32, + pub stx_rdev_minor: ::__u32, + pub stx_dev_major: ::__u32, + pub stx_dev_minor: ::__u32, + pub stx_mnt_id: ::__u64, + pub stx_dio_mem_align: ::__u32, + pub stx_dio_offset_align: ::__u32, + __statx_pad3: [::__u64; 12], + } + pub struct statx_timestamp { + pub tv_sec: ::__s64, + pub tv_nsec: ::__u32, + pub __reserved: ::__s32, + } } s_no_extra_traits! { @@ -594,13 +622,7 @@ s_no_extra_traits! { pub absflat: [::__s32; ABS_CNT], } - /// WARNING: The `PartialEq`, `Eq` and `Hash` implementations of this - /// type are unsound and will be removed in the future. - #[deprecated( - note = "this struct has unsafe trait implementations that will be \ - removed in the future", - since = "0.2.80" - )] + #[allow(missing_debug_implementations)] pub struct af_alg_iv { pub ivlen: u32, pub iv: [::c_uchar; 0], @@ -612,7 +634,6 @@ s_no_extra_traits! { __value: [[::c_char; 4]; 23], } - #[cfg(libc_union)] pub union __c_anonymous_ifr_ifru { pub ifru_addr: ::sockaddr, pub ifru_dstaddr: ::sockaddr, @@ -632,27 +653,17 @@ s_no_extra_traits! { pub struct ifreq { /// interface 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: *mut ::c_char, pub ifcu_req: *mut ::ifreq, } - /* Structure used in SIOCGIFCONF request. Used to retrieve interface - configuration for machine (useful for programs which must know all - networks accessible). */ pub struct ifconf { - pub ifc_len: ::c_int, /* Size of buffer. */ - #[cfg(libc_union)] + pub ifc_len: ::c_int, pub ifc_ifcu: __c_anonymous_ifc_ifcu, - #[cfg(not(libc_union))] - pub ifc_ifcu: *mut ::ifreq, } } @@ -1002,7 +1013,6 @@ cfg_if! { } } - #[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") @@ -1031,7 +1041,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_ifc_ifcu { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("ifr_ifru") @@ -1049,44 +1058,6 @@ cfg_if! { } } - #[allow(deprecated)] - impl af_alg_iv { - fn as_slice(&self) -> &[u8] { - unsafe { - ::core::slice::from_raw_parts( - self.iv.as_ptr(), - self.ivlen as usize - ) - } - } - } - - #[allow(deprecated)] - impl PartialEq for af_alg_iv { - fn eq(&self, other: &af_alg_iv) -> bool { - *self.as_slice() == *other.as_slice() - } - } - - #[allow(deprecated)] - impl Eq for af_alg_iv {} - - #[allow(deprecated)] - impl ::fmt::Debug for af_alg_iv { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("af_alg_iv") - .field("ivlen", &self.ivlen) - .finish() - } - } - - #[allow(deprecated)] - impl ::hash::Hash for af_alg_iv { - fn hash(&self, state: &mut H) { - self.as_slice().hash(state); - } - } - impl PartialEq for prop_info { fn eq(&self, other: &prop_info) -> bool { self.__name == other.__name && @@ -1186,155 +1157,140 @@ pub const _PC_SYNC_IO: ::c_int = 19; pub const FIONBIO: ::c_int = 0x5421; -pub const _SC_ARG_MAX: ::c_int = 0x0000; -pub const _SC_BC_BASE_MAX: ::c_int = 0x0001; -pub const _SC_BC_DIM_MAX: ::c_int = 0x0002; -pub const _SC_BC_SCALE_MAX: ::c_int = 0x0003; -pub const _SC_BC_STRING_MAX: ::c_int = 0x0004; -pub const _SC_CHILD_MAX: ::c_int = 0x0005; -pub const _SC_CLK_TCK: ::c_int = 0x0006; -pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 0x0007; -pub const _SC_EXPR_NEST_MAX: ::c_int = 0x0008; -pub const _SC_LINE_MAX: ::c_int = 0x0009; -pub const _SC_NGROUPS_MAX: ::c_int = 0x000a; -pub const _SC_OPEN_MAX: ::c_int = 0x000b; -pub const _SC_PASS_MAX: ::c_int = 0x000c; -pub const _SC_2_C_BIND: ::c_int = 0x000d; -pub const _SC_2_C_DEV: ::c_int = 0x000e; -pub const _SC_2_C_VERSION: ::c_int = 0x000f; -pub const _SC_2_CHAR_TERM: ::c_int = 0x0010; -pub const _SC_2_FORT_DEV: ::c_int = 0x0011; -pub const _SC_2_FORT_RUN: ::c_int = 0x0012; -pub const _SC_2_LOCALEDEF: ::c_int = 0x0013; -pub const _SC_2_SW_DEV: ::c_int = 0x0014; -pub const _SC_2_UPE: ::c_int = 0x0015; -pub const _SC_2_VERSION: ::c_int = 0x0016; -pub const _SC_JOB_CONTROL: ::c_int = 0x0017; -pub const _SC_SAVED_IDS: ::c_int = 0x0018; -pub const _SC_VERSION: ::c_int = 0x0019; -pub const _SC_RE_DUP_MAX: ::c_int = 0x001a; -pub const _SC_STREAM_MAX: ::c_int = 0x001b; -pub const _SC_TZNAME_MAX: ::c_int = 0x001c; -pub const _SC_XOPEN_CRYPT: ::c_int = 0x001d; -pub const _SC_XOPEN_ENH_I18N: ::c_int = 0x001e; -pub const _SC_XOPEN_SHM: ::c_int = 0x001f; -pub const _SC_XOPEN_VERSION: ::c_int = 0x0020; -pub const _SC_XOPEN_XCU_VERSION: ::c_int = 0x0021; -pub const _SC_XOPEN_REALTIME: ::c_int = 0x0022; -pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 0x0023; -pub const _SC_XOPEN_LEGACY: ::c_int = 0x0024; -pub const _SC_ATEXIT_MAX: ::c_int = 0x0025; -pub const _SC_IOV_MAX: ::c_int = 0x0026; -pub const _SC_UIO_MAXIOV: ::c_int = _SC_IOV_MAX; -pub const _SC_PAGESIZE: ::c_int = 0x0027; -pub const _SC_PAGE_SIZE: ::c_int = 0x0028; -pub const _SC_XOPEN_UNIX: ::c_int = 0x0029; -pub const _SC_XBS5_ILP32_OFF32: ::c_int = 0x002a; -pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 0x002b; -pub const _SC_XBS5_LP64_OFF64: ::c_int = 0x002c; -pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 0x002d; -pub const _SC_AIO_LISTIO_MAX: ::c_int = 0x002e; -pub const _SC_AIO_MAX: ::c_int = 0x002f; -pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 0x0030; -pub const _SC_DELAYTIMER_MAX: ::c_int = 0x0031; -pub const _SC_MQ_OPEN_MAX: ::c_int = 0x0032; -pub const _SC_MQ_PRIO_MAX: ::c_int = 0x0033; -pub const _SC_RTSIG_MAX: ::c_int = 0x0034; -pub const _SC_SEM_NSEMS_MAX: ::c_int = 0x0035; -pub const _SC_SEM_VALUE_MAX: ::c_int = 0x0036; -pub const _SC_SIGQUEUE_MAX: ::c_int = 0x0037; -pub const _SC_TIMER_MAX: ::c_int = 0x0038; -pub const _SC_ASYNCHRONOUS_IO: ::c_int = 0x0039; -pub const _SC_FSYNC: ::c_int = 0x003a; -pub const _SC_MAPPED_FILES: ::c_int = 0x003b; -pub const _SC_MEMLOCK: ::c_int = 0x003c; -pub const _SC_MEMLOCK_RANGE: ::c_int = 0x003d; -pub const _SC_MEMORY_PROTECTION: ::c_int = 0x003e; -pub const _SC_MESSAGE_PASSING: ::c_int = 0x003f; -pub const _SC_PRIORITIZED_IO: ::c_int = 0x0040; -pub const _SC_PRIORITY_SCHEDULING: ::c_int = 0x0041; -pub const _SC_REALTIME_SIGNALS: ::c_int = 0x0042; -pub const _SC_SEMAPHORES: ::c_int = 0x0043; -pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 0x0044; -pub const _SC_SYNCHRONIZED_IO: ::c_int = 0x0045; -pub const _SC_TIMERS: ::c_int = 0x0046; -pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 0x0047; -pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 0x0048; -pub const _SC_LOGIN_NAME_MAX: ::c_int = 0x0049; -pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 0x004a; -pub const _SC_THREAD_KEYS_MAX: ::c_int = 0x004b; -pub const _SC_THREAD_STACK_MIN: ::c_int = 0x004c; -pub const _SC_THREAD_THREADS_MAX: ::c_int = 0x004d; -pub const _SC_TTY_NAME_MAX: ::c_int = 0x004e; -pub const _SC_THREADS: ::c_int = 0x004f; -pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 0x0050; -pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 0x0051; -pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 0x0052; -pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 0x0053; -pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 0x0054; -pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 0x0055; -pub const _SC_NPROCESSORS_CONF: ::c_int = 0x0060; -pub const _SC_NPROCESSORS_ONLN: ::c_int = 0x0061; -pub const _SC_PHYS_PAGES: ::c_int = 0x0062; -pub const _SC_AVPHYS_PAGES: ::c_int = 0x0063; -pub const _SC_MONOTONIC_CLOCK: ::c_int = 0x0064; -pub const _SC_2_PBS: ::c_int = 0x0065; -pub const _SC_2_PBS_ACCOUNTING: ::c_int = 0x0066; -pub const _SC_2_PBS_CHECKPOINT: ::c_int = 0x0067; -pub const _SC_2_PBS_LOCATE: ::c_int = 0x0068; -pub const _SC_2_PBS_MESSAGE: ::c_int = 0x0069; -pub const _SC_2_PBS_TRACK: ::c_int = 0x006a; -pub const _SC_ADVISORY_INFO: ::c_int = 0x006b; -pub const _SC_BARRIERS: ::c_int = 0x006c; -pub const _SC_CLOCK_SELECTION: ::c_int = 0x006d; -pub const _SC_CPUTIME: ::c_int = 0x006e; -pub const _SC_HOST_NAME_MAX: ::c_int = 0x006f; -pub const _SC_IPV6: ::c_int = 0x0070; -pub const _SC_RAW_SOCKETS: ::c_int = 0x0071; -pub const _SC_READER_WRITER_LOCKS: ::c_int = 0x0072; -pub const _SC_REGEXP: ::c_int = 0x0073; -pub const _SC_SHELL: ::c_int = 0x0074; -pub const _SC_SPAWN: ::c_int = 0x0075; -pub const _SC_SPIN_LOCKS: ::c_int = 0x0076; -pub const _SC_SPORADIC_SERVER: ::c_int = 0x0077; -pub const _SC_SS_REPL_MAX: ::c_int = 0x0078; -pub const _SC_SYMLOOP_MAX: ::c_int = 0x0079; -pub const _SC_THREAD_CPUTIME: ::c_int = 0x007a; -pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 0x007b; -pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 0x007c; -pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 0x007d; -pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 0x007e; -pub const _SC_TIMEOUTS: ::c_int = 0x007f; -pub const _SC_TRACE: ::c_int = 0x0080; -pub const _SC_TRACE_EVENT_FILTER: ::c_int = 0x0081; -pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 0x0082; -pub const _SC_TRACE_INHERIT: ::c_int = 0x0083; -pub const _SC_TRACE_LOG: ::c_int = 0x0084; -pub const _SC_TRACE_NAME_MAX: ::c_int = 0x0085; -pub const _SC_TRACE_SYS_MAX: ::c_int = 0x0086; -pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 0x0087; -pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 0x0088; -pub const _SC_V7_ILP32_OFF32: ::c_int = 0x0089; -pub const _SC_V7_ILP32_OFFBIG: ::c_int = 0x008a; -pub const _SC_V7_LP64_OFF64: ::c_int = 0x008b; -pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 0x008c; -pub const _SC_XOPEN_STREAMS: ::c_int = 0x008d; -pub const _SC_XOPEN_UUCP: ::c_int = 0x008e; -pub const _SC_LEVEL1_ICACHE_SIZE: ::c_int = 0x008f; -pub const _SC_LEVEL1_ICACHE_ASSOC: ::c_int = 0x0090; -pub const _SC_LEVEL1_ICACHE_LINESIZE: ::c_int = 0x0091; -pub const _SC_LEVEL1_DCACHE_SIZE: ::c_int = 0x0092; -pub const _SC_LEVEL1_DCACHE_ASSOC: ::c_int = 0x0093; -pub const _SC_LEVEL1_DCACHE_LINESIZE: ::c_int = 0x0094; -pub const _SC_LEVEL2_CACHE_SIZE: ::c_int = 0x0095; -pub const _SC_LEVEL2_CACHE_ASSOC: ::c_int = 0x0096; -pub const _SC_LEVEL2_CACHE_LINESIZE: ::c_int = 0x0097; -pub const _SC_LEVEL3_CACHE_SIZE: ::c_int = 0x0098; -pub const _SC_LEVEL3_CACHE_ASSOC: ::c_int = 0x0099; -pub const _SC_LEVEL3_CACHE_LINESIZE: ::c_int = 0x009a; -pub const _SC_LEVEL4_CACHE_SIZE: ::c_int = 0x009b; -pub const _SC_LEVEL4_CACHE_ASSOC: ::c_int = 0x009c; -pub const _SC_LEVEL4_CACHE_LINESIZE: ::c_int = 0x009d; +pub const _SC_ARG_MAX: ::c_int = 0; +pub const _SC_BC_BASE_MAX: ::c_int = 1; +pub const _SC_BC_DIM_MAX: ::c_int = 2; +pub const _SC_BC_SCALE_MAX: ::c_int = 3; +pub const _SC_BC_STRING_MAX: ::c_int = 4; +pub const _SC_CHILD_MAX: ::c_int = 5; +pub const _SC_CLK_TCK: ::c_int = 6; +pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 7; +pub const _SC_EXPR_NEST_MAX: ::c_int = 8; +pub const _SC_LINE_MAX: ::c_int = 9; +pub const _SC_NGROUPS_MAX: ::c_int = 10; +pub const _SC_OPEN_MAX: ::c_int = 11; +pub const _SC_PASS_MAX: ::c_int = 12; +pub const _SC_2_C_BIND: ::c_int = 13; +pub const _SC_2_C_DEV: ::c_int = 14; +pub const _SC_2_C_VERSION: ::c_int = 15; +pub const _SC_2_CHAR_TERM: ::c_int = 16; +pub const _SC_2_FORT_DEV: ::c_int = 17; +pub const _SC_2_FORT_RUN: ::c_int = 18; +pub const _SC_2_LOCALEDEF: ::c_int = 19; +pub const _SC_2_SW_DEV: ::c_int = 20; +pub const _SC_2_UPE: ::c_int = 21; +pub const _SC_2_VERSION: ::c_int = 22; +pub const _SC_JOB_CONTROL: ::c_int = 23; +pub const _SC_SAVED_IDS: ::c_int = 24; +pub const _SC_VERSION: ::c_int = 25; +pub const _SC_RE_DUP_MAX: ::c_int = 26; +pub const _SC_STREAM_MAX: ::c_int = 27; +pub const _SC_TZNAME_MAX: ::c_int = 28; +pub const _SC_XOPEN_CRYPT: ::c_int = 29; +pub const _SC_XOPEN_ENH_I18N: ::c_int = 30; +pub const _SC_XOPEN_SHM: ::c_int = 31; +pub const _SC_XOPEN_VERSION: ::c_int = 32; +pub const _SC_XOPEN_XCU_VERSION: ::c_int = 33; +pub const _SC_XOPEN_REALTIME: ::c_int = 34; +pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 35; +pub const _SC_XOPEN_LEGACY: ::c_int = 36; +pub const _SC_ATEXIT_MAX: ::c_int = 37; +pub const _SC_IOV_MAX: ::c_int = 38; +pub const _SC_PAGESIZE: ::c_int = 39; +pub const _SC_PAGE_SIZE: ::c_int = 40; +pub const _SC_XOPEN_UNIX: ::c_int = 41; +pub const _SC_XBS5_ILP32_OFF32: ::c_int = 42; +pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 43; +pub const _SC_XBS5_LP64_OFF64: ::c_int = 44; +pub const _SC_XBS5_LPBIG_OFFBIG: ::c_int = 45; +pub const _SC_AIO_LISTIO_MAX: ::c_int = 46; +pub const _SC_AIO_MAX: ::c_int = 47; +pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 48; +pub const _SC_DELAYTIMER_MAX: ::c_int = 49; +pub const _SC_MQ_OPEN_MAX: ::c_int = 50; +pub const _SC_MQ_PRIO_MAX: ::c_int = 51; +pub const _SC_RTSIG_MAX: ::c_int = 52; +pub const _SC_SEM_NSEMS_MAX: ::c_int = 53; +pub const _SC_SEM_VALUE_MAX: ::c_int = 54; +pub const _SC_SIGQUEUE_MAX: ::c_int = 55; +pub const _SC_TIMER_MAX: ::c_int = 56; +pub const _SC_ASYNCHRONOUS_IO: ::c_int = 57; +pub const _SC_FSYNC: ::c_int = 58; +pub const _SC_MAPPED_FILES: ::c_int = 59; +pub const _SC_MEMLOCK: ::c_int = 60; +pub const _SC_MEMLOCK_RANGE: ::c_int = 61; +pub const _SC_MEMORY_PROTECTION: ::c_int = 62; +pub const _SC_MESSAGE_PASSING: ::c_int = 63; +pub const _SC_PRIORITIZED_IO: ::c_int = 64; +pub const _SC_PRIORITY_SCHEDULING: ::c_int = 65; +pub const _SC_REALTIME_SIGNALS: ::c_int = 66; +pub const _SC_SEMAPHORES: ::c_int = 67; +pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 68; +pub const _SC_SYNCHRONIZED_IO: ::c_int = 69; +pub const _SC_TIMERS: ::c_int = 70; +pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 71; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 72; +pub const _SC_LOGIN_NAME_MAX: ::c_int = 73; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 74; +pub const _SC_THREAD_KEYS_MAX: ::c_int = 75; +pub const _SC_THREAD_STACK_MIN: ::c_int = 76; +pub const _SC_THREAD_THREADS_MAX: ::c_int = 77; +pub const _SC_TTY_NAME_MAX: ::c_int = 78; +pub const _SC_THREADS: ::c_int = 79; +pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 80; +pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 81; +pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 82; +pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 83; +pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 84; +pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 85; +pub const _SC_NPROCESSORS_CONF: ::c_int = 96; +pub const _SC_NPROCESSORS_ONLN: ::c_int = 97; +pub const _SC_PHYS_PAGES: ::c_int = 98; +pub const _SC_AVPHYS_PAGES: ::c_int = 99; +pub const _SC_MONOTONIC_CLOCK: ::c_int = 100; + +pub const _SC_2_PBS: ::c_int = 101; +pub const _SC_2_PBS_ACCOUNTING: ::c_int = 102; +pub const _SC_2_PBS_CHECKPOINT: ::c_int = 103; +pub const _SC_2_PBS_LOCATE: ::c_int = 104; +pub const _SC_2_PBS_MESSAGE: ::c_int = 105; +pub const _SC_2_PBS_TRACK: ::c_int = 106; +pub const _SC_ADVISORY_INFO: ::c_int = 107; +pub const _SC_BARRIERS: ::c_int = 108; +pub const _SC_CLOCK_SELECTION: ::c_int = 109; +pub const _SC_CPUTIME: ::c_int = 110; +pub const _SC_HOST_NAME_MAX: ::c_int = 111; +pub const _SC_IPV6: ::c_int = 112; +pub const _SC_RAW_SOCKETS: ::c_int = 113; +pub const _SC_READER_WRITER_LOCKS: ::c_int = 114; +pub const _SC_REGEXP: ::c_int = 115; +pub const _SC_SHELL: ::c_int = 116; +pub const _SC_SPAWN: ::c_int = 117; +pub const _SC_SPIN_LOCKS: ::c_int = 118; +pub const _SC_SPORADIC_SERVER: ::c_int = 119; +pub const _SC_SS_REPL_MAX: ::c_int = 120; +pub const _SC_SYMLOOP_MAX: ::c_int = 121; +pub const _SC_THREAD_CPUTIME: ::c_int = 122; +pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 123; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 124; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 125; +pub const _SC_THREAD_SPORADIC_SERVER: ::c_int = 126; +pub const _SC_TIMEOUTS: ::c_int = 127; +pub const _SC_TRACE: ::c_int = 128; +pub const _SC_TRACE_EVENT_FILTER: ::c_int = 129; +pub const _SC_TRACE_EVENT_NAME_MAX: ::c_int = 130; +pub const _SC_TRACE_INHERIT: ::c_int = 131; +pub const _SC_TRACE_LOG: ::c_int = 132; +pub const _SC_TRACE_NAME_MAX: ::c_int = 133; +pub const _SC_TRACE_SYS_MAX: ::c_int = 134; +pub const _SC_TRACE_USER_EVENT_MAX: ::c_int = 135; +pub const _SC_TYPED_MEMORY_OBJECTS: ::c_int = 136; +pub const _SC_V7_ILP32_OFF32: ::c_int = 137; +pub const _SC_V7_ILP32_OFFBIG: ::c_int = 138; +pub const _SC_V7_LP64_OFF64: ::c_int = 139; +pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 140; +pub const _SC_XOPEN_STREAMS: ::c_int = 141; +pub const _SC_XOPEN_UUCP: ::c_int = 142; pub const F_LOCK: ::c_int = 1; pub const F_TEST: ::c_int = 3; @@ -1760,6 +1716,7 @@ pub const ST_NODIRATIME: ::c_ulong = 2048; pub const ST_RELATIME: ::c_ulong = 4096; pub const RTLD_NOLOAD: ::c_int = 0x4; +pub const RTLD_NODELETE: ::c_int = 0x1000; pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; @@ -2294,8 +2251,6 @@ 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_NOEXEC_SEAL: ::c_uint = 0x0008; -pub const MFD_EXEC: ::c_uint = 0x0010; pub const MFD_HUGE_64KB: ::c_uint = 0x40000000; pub const MFD_HUGE_512KB: ::c_uint = 0x4c000000; pub const MFD_HUGE_1MB: ::c_uint = 0x50000000; @@ -2357,9 +2312,11 @@ pub const NF_INET_FORWARD: ::c_int = 2; pub const NF_INET_LOCAL_OUT: ::c_int = 3; pub const NF_INET_POST_ROUTING: ::c_int = 4; pub const NF_INET_NUMHOOKS: ::c_int = 5; +pub const NF_INET_INGRESS: ::c_int = NF_INET_NUMHOOKS; pub const NF_NETDEV_INGRESS: ::c_int = 0; -pub const NF_NETDEV_NUMHOOKS: ::c_int = 1; +pub const NF_NETDEV_EGRESS: ::c_int = 1; +pub const NF_NETDEV_NUMHOOKS: ::c_int = 2; pub const NFPROTO_UNSPEC: ::c_int = 0; pub const NFPROTO_INET: ::c_int = 1; @@ -2371,6 +2328,31 @@ pub const NFPROTO_IPV6: ::c_int = 10; pub const NFPROTO_DECNET: ::c_int = 12; pub const NFPROTO_NUMPROTO: ::c_int = 13; +// linux/netfilter_arp.h +pub const NF_ARP: ::c_int = 0; +pub const NF_ARP_IN: ::c_int = 0; +pub const NF_ARP_OUT: ::c_int = 1; +pub const NF_ARP_FORWARD: ::c_int = 2; +pub const NF_ARP_NUMHOOKS: ::c_int = 3; + +// linux/netfilter_bridge.h +pub const NF_BR_PRE_ROUTING: ::c_int = 0; +pub const NF_BR_LOCAL_IN: ::c_int = 1; +pub const NF_BR_FORWARD: ::c_int = 2; +pub const NF_BR_LOCAL_OUT: ::c_int = 3; +pub const NF_BR_POST_ROUTING: ::c_int = 4; +pub const NF_BR_BROUTING: ::c_int = 5; +pub const NF_BR_NUMHOOKS: ::c_int = 6; + +pub const NF_BR_PRI_FIRST: ::c_int = ::INT_MIN; +pub const NF_BR_PRI_NAT_DST_BRIDGED: ::c_int = -300; +pub const NF_BR_PRI_FILTER_BRIDGED: ::c_int = -200; +pub const NF_BR_PRI_BRNF: ::c_int = 0; +pub const NF_BR_PRI_NAT_DST_OTHER: ::c_int = 100; +pub const NF_BR_PRI_FILTER_OTHER: ::c_int = 200; +pub const NF_BR_PRI_NAT_SRC: ::c_int = 300; +pub const NF_BR_PRI_LAST: ::c_int = ::INT_MAX; + // linux/netfilter_ipv4.h pub const NF_IP_PRE_ROUTING: ::c_int = 0; pub const NF_IP_LOCAL_IN: ::c_int = 1; @@ -2380,6 +2362,7 @@ pub const NF_IP_POST_ROUTING: ::c_int = 4; pub const NF_IP_NUMHOOKS: ::c_int = 5; pub const NF_IP_PRI_FIRST: ::c_int = ::INT_MIN; +pub const NF_IP_PRI_RAW_BEFORE_DEFRAG: ::c_int = -450; pub const NF_IP_PRI_CONNTRACK_DEFRAG: ::c_int = -400; pub const NF_IP_PRI_RAW: ::c_int = -300; pub const NF_IP_PRI_SELINUX_FIRST: ::c_int = -225; @@ -2403,6 +2386,7 @@ pub const NF_IP6_POST_ROUTING: ::c_int = 4; pub const NF_IP6_NUMHOOKS: ::c_int = 5; pub const NF_IP6_PRI_FIRST: ::c_int = ::INT_MIN; +pub const NF_IP6_PRI_RAW_BEFORE_DEFRAG: ::c_int = -450; pub const NF_IP6_PRI_CONNTRACK_DEFRAG: ::c_int = -400; pub const NF_IP6_PRI_RAW: ::c_int = -300; pub const NF_IP6_PRI_SELINUX_FIRST: ::c_int = -225; @@ -3021,7 +3005,6 @@ pub const FUTEX_WAIT_BITSET: ::c_int = 9; pub const FUTEX_WAKE_BITSET: ::c_int = 10; pub const FUTEX_WAIT_REQUEUE_PI: ::c_int = 11; pub const FUTEX_CMP_REQUEUE_PI: ::c_int = 12; -pub const FUTEX_LOCK_PI2: ::c_int = 13; pub const FUTEX_PRIVATE_FLAG: ::c_int = 128; pub const FUTEX_CLOCK_REALTIME: ::c_int = 256; @@ -4093,6 +4076,22 @@ extern "C" { ) -> ::size_t; pub fn fflush_unlocked(stream: *mut ::FILE) -> ::c_int; pub fn fgets_unlocked(buf: *mut ::c_char, size: ::c_int, stream: *mut ::FILE) -> *mut ::c_char; + + pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int; + pub fn renameat2( + olddirfd: ::c_int, + oldpath: *const ::c_char, + newdirfd: ::c_int, + newpath: *const ::c_char, + flags: ::c_uint, + ) -> ::c_int; + pub fn statx( + dirfd: ::c_int, + pathname: *const c_char, + flags: ::c_int, + mask: ::c_uint, + statxbuf: *mut statx, + ) -> ::c_int; } cfg_if! { @@ -4133,64 +4132,60 @@ impl siginfo_t { } } -cfg_if! { - if #[cfg(libc_union)] { - // Internal, for casts to access union fields - #[repr(C)] - struct sifields_sigchld { - si_pid: ::pid_t, - si_uid: ::uid_t, - si_status: ::c_int, - si_utime: ::c_long, - si_stime: ::c_long, - } - impl ::Copy for sifields_sigchld {} - impl ::Clone for sifields_sigchld { - fn clone(&self) -> sifields_sigchld { - *self - } - } +// Internal, for casts to access union fields +#[repr(C)] +struct sifields_sigchld { + si_pid: ::pid_t, + si_uid: ::uid_t, + si_status: ::c_int, + si_utime: ::c_long, + si_stime: ::c_long, +} +impl ::Copy for sifields_sigchld {} +impl ::Clone for sifields_sigchld { + fn clone(&self) -> sifields_sigchld { + *self + } +} - // Internal, for casts to access union fields - #[repr(C)] - union sifields { - _align_pointer: *mut ::c_void, - sigchld: sifields_sigchld, - } +// Internal, for casts to access union fields +#[repr(C)] +union sifields { + _align_pointer: *mut ::c_void, + sigchld: sifields_sigchld, +} - // Internal, for casts to access union fields. Note that some variants - // of sifields start with a pointer, which makes the alignment of - // sifields vary on 32-bit and 64-bit architectures. - #[repr(C)] - struct siginfo_f { - _siginfo_base: [::c_int; 3], - sifields: sifields, - } +// Internal, for casts to access union fields. Note that some variants +// of sifields start with a pointer, which makes the alignment of +// sifields vary on 32-bit and 64-bit architectures. +#[repr(C)] +struct siginfo_f { + _siginfo_base: [::c_int; 3], + sifields: sifields, +} - impl siginfo_t { - unsafe fn sifields(&self) -> &sifields { - &(*(self as *const siginfo_t as *const siginfo_f)).sifields - } +impl siginfo_t { + unsafe fn sifields(&self) -> &sifields { + &(*(self as *const siginfo_t as *const siginfo_f)).sifields + } - pub unsafe fn si_pid(&self) -> ::pid_t { - self.sifields().sigchld.si_pid - } + pub unsafe fn si_pid(&self) -> ::pid_t { + self.sifields().sigchld.si_pid + } - pub unsafe fn si_uid(&self) -> ::uid_t { - self.sifields().sigchld.si_uid - } + pub unsafe fn si_uid(&self) -> ::uid_t { + self.sifields().sigchld.si_uid + } - pub unsafe fn si_status(&self) -> ::c_int { - self.sifields().sigchld.si_status - } + pub unsafe fn si_status(&self) -> ::c_int { + self.sifields().sigchld.si_status + } - pub unsafe fn si_utime(&self) -> ::c_long { - self.sifields().sigchld.si_utime - } + pub unsafe fn si_utime(&self) -> ::c_long { + self.sifields().sigchld.si_utime + } - pub unsafe fn si_stime(&self) -> ::c_long { - self.sifields().sigchld.si_stime - } - } + pub unsafe fn si_stime(&self) -> ::c_long { + self.sifields().sigchld.si_stime } } diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 1dc607496a2ad..8014060890963 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -775,9 +775,9 @@ 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 S_IEXEC: mode_t = 64; -pub const S_IWRITE: mode_t = 128; -pub const S_IREAD: mode_t = 256; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IREAD: mode_t = 0o0400; pub const F_LOCK: ::c_int = 1; pub const F_TEST: ::c_int = 3; @@ -801,17 +801,15 @@ pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; pub const RTLD_NODELETE: ::c_int = 0x1000; pub const RTLD_NOW: ::c_int = 0x2; -align_const! { - pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - size: [0; __SIZEOF_PTHREAD_MUTEX_T], - }; - pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - size: [0; __SIZEOF_PTHREAD_COND_T], - }; - pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - size: [0; __SIZEOF_PTHREAD_RWLOCK_T], - }; -} +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], +}; pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; @@ -1782,13 +1780,6 @@ extern "C" { mod lfs64; pub use self::lfs64::*; -cfg_if! { - if #[cfg(libc_align)] { - #[macro_use] - mod align; - } else { - #[macro_use] - mod no_align; - } -} +#[macro_use] +mod align; expand_align!(); 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 89c93aba8818e..e689441213de0 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -22,7 +22,8 @@ s! { pub f_namelen: ::__fsword_t, pub f_frsize: ::__fsword_t, - f_spare: [::__fsword_t; 5], + pub f_flags: ::__fsword_t, + f_spare: [::__fsword_t; 4], } pub struct flock { @@ -856,9 +857,5 @@ 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; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs index 5e92e30073bee..16b2f9b84034e 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -733,9 +733,5 @@ 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; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; 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 fa2707500dbe4..6f9560334c164 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -37,7 +37,8 @@ s! { pub f_fsid: ::fsid_t, pub f_namelen: ::c_long, - f_spare: [::c_long; 6], + pub f_flags: ::c_long, + f_spare: [::c_long; 5], } pub struct statfs64 { @@ -811,9 +812,5 @@ pub const B4000000: ::speed_t = 0o010017; pub const EHWPOISON: ::c_int = 168; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/gnu/b32/mod.rs b/src/unix/linux_like/linux/gnu/b32/mod.rs index d5b11347eb8b7..54c84fa617c86 100644 --- a/src/unix/linux_like/linux/gnu/b32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -263,56 +263,42 @@ cfg_if! { } } -align_const! { - #[cfg(target_endian = "little")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, - 0, 0, 0, - ], - }; -} +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; pub const PTRACE_GETFPREGS: ::c_uint = 14; pub const PTRACE_SETFPREGS: ::c_uint = 15; diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index dd5732e0dcc14..0b0c779c4d7c7 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -22,7 +22,8 @@ s! { pub f_namelen: ::__fsword_t, pub f_frsize: ::__fsword_t, - f_spare: [::__fsword_t; 5], + pub f_flags: ::__fsword_t, + f_spare: [::__fsword_t; 4], } pub struct flock { 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 65b7aaa783559..8a75e6d42b32b 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -805,9 +805,5 @@ 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; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::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 da9cf29c48668..16b836f7e6128 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -849,9 +849,5 @@ 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; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; 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 27f477bb48f85..8e206b114cd3a 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -23,7 +23,8 @@ s! { pub f_namelen: ::__fsword_t, pub f_frsize: ::__fsword_t, - f_spare: [::__fsword_t; 5], + pub f_flags: ::__fsword_t, + f_spare: [::__fsword_t; 4], } pub struct flock { @@ -1044,6 +1045,7 @@ pub const SYS_memfd_secret: ::c_long = 447; 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; +pub const SYS_fchmodat2: ::c_long = 452; // offsets in user_regs_structs, from sys/reg.h pub const EBX: ::c_int = 0; @@ -1092,9 +1094,5 @@ extern "C" { pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> ::c_int; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs index 0848fb5880138..5a0785c13c7a8 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs @@ -10,55 +10,47 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 48; pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20; -align_const! { - #[cfg(target_endian = "little")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; -} +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; pub const SYS_sync_file_range2: ::c_long = 84; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs index 3802caf644fbe..efe3cc57e8a2f 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs @@ -10,62 +10,48 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 8; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; -align_const! { - #[cfg(target_endian = "little")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - ], - }; -} +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; pub const SYS_renameat: ::c_long = 38; pub const SYS_sync_file_range: ::c_long = 84; 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 284a1788f4409..2d73c68389728 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -917,21 +917,8 @@ cfg_if! { } } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } - - -} +mod align; +pub use self::align::*; -cfg_if! { - if #[cfg(libc_int128)] { - mod int128; - pub use self::int128::*; - } else if #[cfg(libc_align)] { - mod fallback; - pub use self::fallback::*; - } -} +mod int128; +pub use self::int128::*; diff --git a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs index ac3f88905f38e..eccbeff79f6c6 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -213,56 +213,48 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; -align_const! { - #[cfg(target_endian = "little")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; -} +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; pub const HWCAP_LOONGARCH_CPUCFG: ::c_ulong = 1 << 0; pub const HWCAP_LOONGARCH_LAM: ::c_ulong = 1 << 1; @@ -892,9 +884,5 @@ pub const EPOLL_CLOEXEC: ::c_int = 0x80000; pub const EFD_CLOEXEC: ::c_int = 0x80000; pub const EFD_NONBLOCK: ::c_int = 0x800; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; 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 f7b52be805cab..ac4d205c7f7a2 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -193,56 +193,48 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; -align_const! { - #[cfg(target_endian = "little")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; -} +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; pub const SYS_read: ::c_long = 5000 + 0; pub const SYS_write: ::c_long = 5000 + 1; @@ -926,9 +918,5 @@ extern "C" { ) -> ::c_int; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; 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 3088c25a2646f..3a06d26143a2b 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -405,56 +405,48 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; -align_const! { - #[cfg(target_endian = "little")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; -} +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; pub const O_DIRECTORY: ::c_int = 0x4000; pub const O_NOFOLLOW: ::c_int = 0x8000; @@ -971,9 +963,5 @@ extern "C" { ) -> ::c_int; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; 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 64f5cf10f8583..750ee8f8436e8 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -852,9 +852,5 @@ 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; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::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 61ee2dcc9b50a..deeb23f9ed8e9 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -294,29 +294,24 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; -align_const! { - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; -} +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; pub const EUCLEAN: ::c_int = 117; pub const ENOTNAM: ::c_int = 118; 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 de2f0d6e470f6..4ea00510f0aa1 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -404,29 +404,24 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; -align_const! { - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; -} +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; pub const O_DIRECTORY: ::c_int = 0o200000; pub const O_NOFOLLOW: ::c_int = 0o400000; @@ -923,9 +918,5 @@ extern "C" { ) -> ::c_int; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; 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 609c74429c5bc..86536f185750f 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 @@ -816,9 +816,5 @@ cfg_if! { } } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs index 3831dfad9d414..f6b748254872f 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs @@ -24,56 +24,48 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; -align_const! { - #[cfg(target_endian = "little")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "little")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - #[cfg(target_endian = "big")] - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; -} +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; // Syscall table @@ -438,6 +430,7 @@ pub const SYS_memfd_secret: ::c_long = 447; 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; +pub const SYS_fchmodat2: ::c_long = 452; extern "C" { pub fn sysctl( diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs index 06aa0da2d74aa..55b85e9626807 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs @@ -24,29 +24,24 @@ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 32; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 44; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20; -align_const! { - pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; - pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = - pthread_mutex_t { - size: [ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ], - }; -} +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; // Syscall table @@ -366,6 +361,7 @@ pub const SYS_memfd_secret: ::c_long = __X32_SYSCALL_BIT + 447; pub const SYS_process_mrelease: ::c_long = __X32_SYSCALL_BIT + 448; pub const SYS_futex_waitv: ::c_long = __X32_SYSCALL_BIT + 449; pub const SYS_set_mempolicy_home_node: ::c_long = __X32_SYSCALL_BIT + 450; +pub const SYS_fchmodat2: ::c_long = __X32_SYSCALL_BIT + 452; pub const SYS_rt_sigaction: ::c_long = __X32_SYSCALL_BIT + 512; pub const SYS_rt_sigreturn: ::c_long = __X32_SYSCALL_BIT + 513; pub const SYS_ioctl: ::c_long = __X32_SYSCALL_BIT + 514; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 4b3ee5a15ce34..6d5deb6b24abd 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -353,7 +353,6 @@ s! { pub arch: ::__u32, pub instruction_pointer: ::__u64, pub stack_pointer: ::__u64, - #[cfg(libc_union)] pub u: __c_anonymous_ptrace_syscall_info_data, } @@ -482,77 +481,73 @@ impl siginfo_t { } } -cfg_if! { - if #[cfg(libc_union)] { - // Internal, for casts to access union fields - #[repr(C)] - struct sifields_sigchld { - si_pid: ::pid_t, - si_uid: ::uid_t, - si_status: ::c_int, - si_utime: ::c_long, - si_stime: ::c_long, - } - impl ::Copy for sifields_sigchld {} - impl ::Clone for sifields_sigchld { - fn clone(&self) -> sifields_sigchld { - *self - } - } +// Internal, for casts to access union fields +#[repr(C)] +struct sifields_sigchld { + si_pid: ::pid_t, + si_uid: ::uid_t, + si_status: ::c_int, + si_utime: ::c_long, + si_stime: ::c_long, +} +impl ::Copy for sifields_sigchld {} +impl ::Clone for sifields_sigchld { + fn clone(&self) -> sifields_sigchld { + *self + } +} - // Internal, for casts to access union fields - #[repr(C)] - union sifields { - _align_pointer: *mut ::c_void, - sigchld: sifields_sigchld, - } +// Internal, for casts to access union fields +#[repr(C)] +union sifields { + _align_pointer: *mut ::c_void, + sigchld: sifields_sigchld, +} - // Internal, for casts to access union fields. Note that some variants - // of sifields start with a pointer, which makes the alignment of - // sifields vary on 32-bit and 64-bit architectures. - #[repr(C)] - struct siginfo_f { - _siginfo_base: [::c_int; 3], - sifields: sifields, - } +// Internal, for casts to access union fields. Note that some variants +// of sifields start with a pointer, which makes the alignment of +// sifields vary on 32-bit and 64-bit architectures. +#[repr(C)] +struct siginfo_f { + _siginfo_base: [::c_int; 3], + sifields: sifields, +} - impl siginfo_t { - unsafe fn sifields(&self) -> &sifields { - &(*(self as *const siginfo_t as *const siginfo_f)).sifields - } +impl siginfo_t { + unsafe fn sifields(&self) -> &sifields { + &(*(self as *const siginfo_t as *const siginfo_f)).sifields + } - pub unsafe fn si_pid(&self) -> ::pid_t { - self.sifields().sigchld.si_pid - } + pub unsafe fn si_pid(&self) -> ::pid_t { + self.sifields().sigchld.si_pid + } - pub unsafe fn si_uid(&self) -> ::uid_t { - self.sifields().sigchld.si_uid - } + pub unsafe fn si_uid(&self) -> ::uid_t { + self.sifields().sigchld.si_uid + } - pub unsafe fn si_status(&self) -> ::c_int { - self.sifields().sigchld.si_status - } + pub unsafe fn si_status(&self) -> ::c_int { + self.sifields().sigchld.si_status + } - pub unsafe fn si_utime(&self) -> ::c_long { - self.sifields().sigchld.si_utime - } + pub unsafe fn si_utime(&self) -> ::c_long { + self.sifields().sigchld.si_utime + } - pub unsafe fn si_stime(&self) -> ::c_long { - self.sifields().sigchld.si_stime - } - } + pub unsafe fn si_stime(&self) -> ::c_long { + 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 - } - } +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 } } @@ -656,7 +651,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for __c_anonymous_ptrace_syscall_info_data { fn eq(&self, other: &__c_anonymous_ptrace_syscall_info_data) -> bool { unsafe { @@ -667,10 +661,8 @@ cfg_if! { } } - #[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 { @@ -683,7 +675,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for __c_anonymous_ptrace_syscall_info_data { fn hash(&self, state: &mut H) { unsafe { @@ -835,6 +826,9 @@ pub const TMP_MAX: ::c_uint = 238328; pub const FOPEN_MAX: ::c_uint = 16; pub const FILENAME_MAX: ::c_uint = 4096; pub const POSIX_MADV_DONTNEED: ::c_int = 4; +pub const _CS_GNU_LIBC_VERSION: ::c_int = 2; +pub const _CS_GNU_LIBPTHREAD_VERSION: ::c_int = 3; +pub const _CS_PATH: ::c_int = 0; pub const _SC_EQUIV_CLASS_MAX: ::c_int = 41; pub const _SC_CHARCLASS_NAME_MAX: ::c_int = 45; pub const _SC_PII: ::c_int = 53; @@ -1074,8 +1068,8 @@ pub const ELFOSABI_ARM_AEABI: u8 = 64; // linux/sched.h pub const CLONE_NEWTIME: ::c_int = 0x80; -pub const CLONE_CLEAR_SIGHAND: ::c_int = 0x100000000; -pub const CLONE_INTO_CGROUP: ::c_int = 0x200000000; +pub const CLONE_CLEAR_SIGHAND: ::c_ulonglong = 0x100000000; +pub const CLONE_INTO_CGROUP: ::c_ulonglong = 0x200000000; // linux/keyctl.h pub const KEYCTL_DH_COMPUTE: u32 = 23; @@ -1435,6 +1429,7 @@ extern "C" { pub fn pthread_sigqueue(thread: ::pthread_t, sig: ::c_int, value: ::sigval) -> ::c_int; pub fn mallinfo() -> ::mallinfo; pub fn mallinfo2() -> ::mallinfo2; + pub fn malloc_stats(); pub fn malloc_info(options: ::c_int, stream: *mut ::FILE) -> ::c_int; pub fn malloc_usable_size(ptr: *mut ::c_void) -> ::size_t; pub fn getpwent_r( @@ -1478,6 +1473,22 @@ extern "C" { pub fn asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char; pub fn ctime_r(timep: *const time_t, buf: *mut ::c_char) -> *mut ::c_char; + pub fn strftime( + s: *mut ::c_char, + max: ::size_t, + format: *const ::c_char, + tm: *const ::tm, + ) -> ::size_t; + pub fn strftime_l( + s: *mut ::c_char, + max: ::size_t, + format: *const ::c_char, + tm: *const ::tm, + locale: ::locale_t, + ) -> ::size_t; + pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char; + + pub fn confstr(name: ::c_int, buf: *mut ::c_char, len: ::size_t) -> ::size_t; pub fn dirname(path: *mut ::c_char) -> *mut ::c_char; /// POSIX version of `basename(3)`, defined in `libgen.h`. #[link_name = "__xpg_basename"] @@ -1567,12 +1578,5 @@ cfg_if! { } } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } else { - mod no_align; - pub use self::no_align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index dc0d3eaca5335..d526bcb1d2243 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -27,6 +27,8 @@ pub type Elf32_Half = u16; pub type Elf32_Word = u32; pub type Elf32_Off = u32; pub type Elf32_Addr = u32; +pub type Elf32_Xword = u64; +pub type Elf32_Sword = i32; pub type Elf64_Half = u16; pub type Elf64_Word = u32; @@ -34,10 +36,23 @@ pub type Elf64_Off = u64; pub type Elf64_Addr = u64; pub type Elf64_Xword = u64; pub type Elf64_Sxword = i64; +pub type Elf64_Sword = i32; pub type Elf32_Section = u16; pub type Elf64_Section = u16; +pub type Elf32_Relr = Elf32_Word; +pub type Elf64_Relr = Elf32_Xword; +pub type Elf32_Rel = __c_anonymous_elf32_rel; +pub type Elf64_Rel = __c_anonymous_elf64_rel; + +cfg_if! { + if #[cfg(not(target_arch = "sparc64"))] { + pub type Elf32_Rela = __c_anonymous_elf32_rela; + pub type Elf64_Rela = __c_anonymous_elf64_rela; + } +} + // linux/can.h pub type canid_t = u32; @@ -58,6 +73,14 @@ missing! { pub enum fpos64_t {} // FIXME: fill this out with a struct } +e! { + pub enum tpacket_versions { + TPACKET_V1, + TPACKET_V2, + TPACKET_V3, + } +} + s! { pub struct glob_t { pub gl_pathc: ::size_t, @@ -140,6 +163,15 @@ s! { __val: [::c_int; 2], } + pub struct fanout_args { + #[cfg(target_endian = "little")] + pub id: ::__u16, + pub type_flags: ::__u16, + #[cfg(target_endian = "big")] + pub id: ::__u16, + pub max_num_members: ::__u32, + } + pub struct packet_mreq { pub mr_ifindex: ::c_int, pub mr_type: ::c_ushort, @@ -147,6 +179,116 @@ s! { pub mr_address: [::c_uchar; 8], } + pub struct sockaddr_pkt { + pub spkt_family: ::c_ushort, + pub spkt_device: [::c_uchar; 14], + pub spkt_protocol: ::c_ushort, + } + + pub struct tpacket_auxdata { + pub tp_status: ::__u32, + pub tp_len: ::__u32, + pub tp_snaplen: ::__u32, + pub tp_mac: ::__u16, + pub tp_net: ::__u16, + pub tp_vlan_tci: ::__u16, + pub tp_vlan_tpid: ::__u16, + } + + pub struct tpacket_hdr { + pub tp_status: ::c_ulong, + pub tp_len: ::c_uint, + pub tp_snaplen: ::c_uint, + pub tp_mac: ::c_ushort, + pub tp_net: ::c_ushort, + pub tp_sec: ::c_uint, + pub tp_usec: ::c_uint, + } + + pub struct tpacket_hdr_variant1 { + pub tp_rxhash: ::__u32, + pub tp_vlan_tci: ::__u32, + pub tp_vlan_tpid: ::__u16, + pub tp_padding: ::__u16, + } + + pub struct tpacket2_hdr { + pub tp_status: ::__u32, + pub tp_len: ::__u32, + pub tp_snaplen: ::__u32, + pub tp_mac: ::__u16, + pub tp_net: ::__u16, + pub tp_sec: ::__u32, + pub tp_nsec: ::__u32, + pub tp_vlan_tci: ::__u16, + pub tp_vlan_tpid: ::__u16, + pub tp_padding: [::__u8; 4], + } + + pub struct tpacket_req { + pub tp_block_size: ::c_uint, + pub tp_block_nr: ::c_uint, + pub tp_frame_size: ::c_uint, + pub tp_frame_nr: ::c_uint, + } + + pub struct tpacket_req3 { + pub tp_block_size: ::c_uint, + pub tp_block_nr: ::c_uint, + pub tp_frame_size: ::c_uint, + pub tp_frame_nr: ::c_uint, + pub tp_retire_blk_tov: ::c_uint, + pub tp_sizeof_priv: ::c_uint, + pub tp_feature_req_word: ::c_uint, + } + + #[repr(align(8))] + pub struct tpacket_rollover_stats { + pub tp_all: ::__u64, + pub tp_huge: ::__u64, + pub tp_failed: ::__u64, + } + + pub struct tpacket_stats { + pub tp_packets: ::c_uint, + pub tp_drops: ::c_uint, + } + + pub struct tpacket_stats_v3 { + pub tp_packets: ::c_uint, + pub tp_drops: ::c_uint, + pub tp_freeze_q_cnt: ::c_uint, + } + + pub struct tpacket3_hdr { + pub tp_next_offset: ::__u32, + pub tp_sec: ::__u32, + pub tp_nsec: ::__u32, + pub tp_snaplen: ::__u32, + pub tp_len: ::__u32, + pub tp_status: ::__u32, + pub tp_mac: ::__u16, + pub tp_net: ::__u16, + pub hv1: ::tpacket_hdr_variant1, + pub tp_padding: [::__u8; 8], + } + + pub struct tpacket_bd_ts { + pub ts_sec: ::c_uint, + pub ts_usec: ::c_uint, + } + + #[repr(align(8))] + pub struct tpacket_hdr_v1 { + pub block_status: ::__u32, + pub num_pkts: ::__u32, + pub offset_to_first_pkt: ::__u32, + pub blk_len: ::__u32, + pub seq_num: ::__u64, + pub ts_first_pkt: ::tpacket_bd_ts, + pub ts_last_pkt: ::tpacket_bd_ts, + } + pub struct cpu_set_t { #[cfg(all(target_pointer_width = "32", not(target_arch = "x86_64")))] @@ -437,6 +579,16 @@ s! { pub sh_entsize: Elf64_Xword, } + pub struct __c_anonymous_elf32_rel { + pub r_offset: Elf32_Addr, + pub r_info: Elf32_Word, + } + + pub struct __c_anonymous_elf64_rel { + pub r_offset: Elf64_Addr, + pub r_info: Elf64_Xword, + } + pub struct ucred { pub pid: ::pid_t, pub uid: ::uid_t, @@ -509,7 +661,8 @@ s! { pub svm_reserved1: ::c_ushort, pub svm_port: ::c_uint, pub svm_cid: ::c_uint, - pub svm_zero: [u8; 4] + pub svm_flags: u8, + pub svm_zero: [u8; 3] } pub struct regmatch_t { @@ -742,8 +895,164 @@ s! { pub salt: [::c_uchar; TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE], pub rec_seq: [::c_uchar; TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE], } + + // linux/wireless.h + + pub struct iw_param { + pub value: __s32, + pub fixed: __u8, + pub disabled: __u8, + pub flags: __u16, + } + pub struct iw_point { + pub pointer: *mut ::c_void, + pub length: __u16, + pub flags: __u16, + } + pub struct iw_freq { + pub m: __s32, + pub e: __s16, + pub i: __u8, + pub flags: __u8, + } + pub struct iw_quality { + pub qual: __u8, + pub level: __u8, + pub noise: __u8, + pub updated: __u8, + } + pub struct iw_discarded { + pub nwid: __u32, + pub code: __u32, + pub fragment: __u32, + pub retries: __u32, + pubmisc: __u32, + } + pub struct iw_missed { + pub beacon: __u32, + } + pub struct iw_scan_req { + pub scan_type: __u8, + pub essid_len: __u8, + pub num_channels: __u8, + pub flags: __u8, + pub bssid: ::sockaddr, + pub essid: [__u8; IW_ESSID_MAX_SIZE], + pub min_channel_time: __u32, + pub max_channel_time: __u32, + pub channel_list: [iw_freq; IW_MAX_FREQUENCIES], + } + pub struct iw_encode_ext { + pub ext_flags: __u32, + pub tx_seq: [__u8; IW_ENCODE_SEQ_MAX_SIZE], + pub rx_seq: [__u8; IW_ENCODE_SEQ_MAX_SIZE], + pub addr: ::sockaddr, + pub alg: __u16, + pub key_len: __u16, + pub key: [__u8;0], + } + pub struct iw_pmksa { + pub cmd: __u32, + pub bssid: ::sockaddr, + pub pmkid: [__u8; IW_PMKID_LEN], + } + pub struct iw_pmkid_cand { + pub flags: __u32, + pub index: __u32, + pub bssid: ::sockaddr, + } + pub struct iw_statistics { + pub status: __u16, + pub qual: iw_quality, + pub discard: iw_discarded, + pub miss: iw_missed, + } + pub struct iw_range { + pub throughput: __u32, + pub min_nwid: __u32, + pub max_nwid: __u32, + pub old_num_channels: __u16, + pub old_num_frequency: __u8, + pub scan_capa: __u8, + pub event_capa: [__u32; 6], + pub sensitivity: __s32, + pub max_qual: iw_quality, + pub avg_qual: iw_quality, + pub num_bitrates: __u8, + pub bitrate: [__s32; IW_MAX_BITRATES], + pub min_rts: __s32, + pub max_rts: __s32, + pub min_frag: __s32, + pub max_frag: __s32, + pub min_pmp: __s32, + pub max_pmp: __s32, + pub min_pmt: __s32, + pub max_pmt: __s32, + pub pmp_flags: __u16, + pub pmt_flags: __u16, + pub pm_capa: __u16, + pub encoding_size: [__u16; IW_MAX_ENCODING_SIZES], + pub num_encoding_sizes: __u8, + pub max_encoding_tokens: __u8, + pub encoding_login_index: __u8, + pub txpower_capa: __u16, + pub num_txpower: __u8, + pub txpower: [__s32;IW_MAX_TXPOWER], + pub we_version_compiled: __u8, + pub we_version_source: __u8, + pub retry_capa: __u16, + pub retry_flags: __u16, + pub r_time_flags: __u16, + pub min_retry: __s32, + pub max_retry: __s32, + pub min_r_time: __s32, + pub max_r_time: __s32, + pub num_channels: __u16, + pub num_frequency: __u8, + pub freq: [iw_freq; IW_MAX_FREQUENCIES], + pub enc_capa: __u32, + } + pub struct iw_priv_args { + pub cmd: __u32, + pub set_args: __u16, + pub get_args: __u16, + pub name: [c_char; ::IFNAMSIZ], + } } +cfg_if! { + if #[cfg(not(target_arch = "sparc64"))] { + s!{ + pub struct iw_thrspy { + pub addr: ::sockaddr, + pub qual: iw_quality, + pub low: iw_quality, + pub high: iw_quality, + } + pub struct iw_mlme { + pub cmd: __u16, + pub reason_code: __u16, + pub addr: ::sockaddr, + } + pub struct iw_michaelmicfailure { + pub flags: __u32, + pub src_addr: ::sockaddr, + pub tsc: [__u8; IW_ENCODE_SEQ_MAX_SIZE], + } + pub struct __c_anonymous_elf32_rela { + pub r_offset: Elf32_Addr, + pub r_info: Elf32_Word, + pub r_addend: Elf32_Sword, + } + + pub struct __c_anonymous_elf64_rela { + pub r_offset: Elf64_Addr, + pub r_info: Elf64_Xword, + pub r_addend: Elf64_Sxword, + } + } + } +} s_no_extra_traits! { pub struct sockaddr_nl { pub nl_family: ::sa_family_t, @@ -784,13 +1093,7 @@ s_no_extra_traits! { pub absflat: [::__s32; ABS_CNT], } - /// WARNING: The `PartialEq`, `Eq` and `Hash` implementations of this - /// type are unsound and will be removed in the future. - #[deprecated( - note = "this struct has unsafe trait implementations that will be \ - removed in the future", - since = "0.2.80" - )] + #[allow(missing_debug_implementations)] pub struct af_alg_iv { pub ivlen: u32, pub iv: [::c_uchar; 0], @@ -822,7 +1125,6 @@ s_no_extra_traits! { pad: [::c_long; 4], } - #[cfg(libc_union)] pub union __c_anonymous_ifr_ifru { pub ifru_addr: ::sockaddr, pub ifru_dstaddr: ::sockaddr, @@ -842,27 +1144,17 @@ s_no_extra_traits! { pub struct ifreq { /// interface 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: *mut ::c_char, pub ifcu_req: *mut ::ifreq, } - /* Structure used in SIOCGIFCONF request. Used to retrieve interface - configuration for machine (useful for programs which must know all - networks accessible). */ pub struct ifconf { - pub ifc_len: ::c_int, /* Size of buffer. */ - #[cfg(libc_union)] + pub ifc_len: ::c_int, pub ifc_ifcu: __c_anonymous_ifc_ifcu, - #[cfg(not(libc_union))] - pub ifc_ifcu: *mut ::ifreq, } pub struct hwtstamp_config { @@ -889,6 +1181,21 @@ s_no_extra_traits! { pub sched_deadline: ::__u64, pub sched_period: ::__u64, } + + pub union tpacket_req_u { + pub req: ::tpacket_req, + pub req3: ::tpacket_req3, + } + + pub union tpacket_bd_header_u { + pub bh1: ::tpacket_hdr_v1, + } + + pub struct tpacket_block_desc { + pub version: ::__u32, + pub offset_to_priv: ::__u32, + pub hdr: ::tpacket_bd_header_u, + } } s_no_extra_traits! { @@ -900,23 +1207,58 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(libc_union)] { - s_no_extra_traits! { - // linux/can.h - #[allow(missing_debug_implementations)] - pub union __c_anonymous_sockaddr_can_can_addr { - pub tp: __c_anonymous_sockaddr_can_tp, - pub j1939: __c_anonymous_sockaddr_can_j1939, - } +s_no_extra_traits! { + // linux/can.h + #[allow(missing_debug_implementations)] + pub union __c_anonymous_sockaddr_can_can_addr { + pub tp: __c_anonymous_sockaddr_can_tp, + pub j1939: __c_anonymous_sockaddr_can_j1939, + } - #[allow(missing_debug_implementations)] - pub struct sockaddr_can { - pub can_family: ::sa_family_t, - pub can_ifindex: ::c_int, - pub can_addr: __c_anonymous_sockaddr_can_can_addr, - } - } + #[allow(missing_debug_implementations)] + pub struct sockaddr_can { + pub can_family: ::sa_family_t, + pub can_ifindex: ::c_int, + pub can_addr: __c_anonymous_sockaddr_can_can_addr, + } +} + +s_no_extra_traits! { + // linux/wireless.h + pub union iwreq_data { + pub name: [c_char; ::IFNAMSIZ], + pub essid: iw_point, + pub nwid: iw_param, + pub freq: iw_freq, + pub sens: iw_param, + pub bitrate: iw_param, + pub txpower: iw_param, + pub rts: iw_param, + pub frag: iw_param, + pub mode: __u32, + pub retry: iw_param, + pub encoding: iw_point, + pub power: iw_param, + pub qual: iw_quality, + pub ap_addr: ::sockaddr, + pub addr: ::sockaddr, + pub param: iw_param, + pub data: iw_point, + } + + pub struct iw_event { + pub len: __u16, + pub cmd: __u16, + pub u: iwreq_data, + } + + pub union __c_anonymous_iwreq { + pub ifrn_name: [c_char; ::IFNAMSIZ], + } + + pub struct iwreq { + pub ifr_ifrn: __c_anonymous_iwreq, + pub u: iwreq_data, } } @@ -1219,44 +1561,6 @@ cfg_if! { } } - #[allow(deprecated)] - impl af_alg_iv { - fn as_slice(&self) -> &[u8] { - unsafe { - ::core::slice::from_raw_parts( - self.iv.as_ptr(), - self.ivlen as usize - ) - } - } - } - - #[allow(deprecated)] - impl PartialEq for af_alg_iv { - fn eq(&self, other: &af_alg_iv) -> bool { - *self.as_slice() == *other.as_slice() - } - } - - #[allow(deprecated)] - impl Eq for af_alg_iv {} - - #[allow(deprecated)] - impl ::fmt::Debug for af_alg_iv { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("af_alg_iv") - .field("ivlen", &self.ivlen) - .finish() - } - } - - #[allow(deprecated)] - impl ::hash::Hash for af_alg_iv { - fn hash(&self, state: &mut H) { - self.as_slice().hash(state); - } - } - impl PartialEq for mq_attr { fn eq(&self, other: &mq_attr) -> bool { self.mq_flags == other.mq_flags && @@ -1284,7 +1588,6 @@ cfg_if! { self.mq_curmsgs.hash(state); } } - #[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") @@ -1313,7 +1616,32 @@ cfg_if! { } } - #[cfg(libc_union)] + impl ::fmt::Debug for tpacket_req_u { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("tpacket_req_u") + .field("req3", unsafe { &self.req3 }) + .finish() + } + } + + impl ::fmt::Debug for tpacket_bd_header_u { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("tpacket_bd_header_u") + .field("bh1", unsafe { &self.bh1 }) + .finish() + } + } + + impl ::fmt::Debug for tpacket_block_desc { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("tpacket_bd_header_u") + .field("version", &self.version) + .field("offset_to_priv", &self.offset_to_priv) + .field("hdr", &self.hdr) + .finish() + } + } + impl ::fmt::Debug for __c_anonymous_ifc_ifcu { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("ifr_ifru") @@ -1394,6 +1722,57 @@ cfg_if! { self.sched_period.hash(state); } } + impl ::fmt::Debug for iwreq_data { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("iwreq_data") + .field("name", unsafe { &self.name }) + .field("essid", unsafe { &self.essid }) + .field("nwid", unsafe { &self.nwid }) + .field("freq", unsafe { &self.freq }) + .field("sens", unsafe { &self.sens }) + .field("bitrate", unsafe { &self.bitrate }) + .field("txpower", unsafe { &self.txpower }) + .field("rts", unsafe { &self.rts }) + .field("frag", unsafe { &self.frag }) + .field("mode", unsafe { &self.mode }) + .field("retry", unsafe { &self.retry }) + .field("encoding", unsafe { &self.encoding }) + .field("power", unsafe { &self.power }) + .field("qual", unsafe { &self.qual }) + .field("ap_addr", unsafe { &self.ap_addr }) + .field("addr", unsafe { &self.addr }) + .field("param", unsafe { &self.param }) + .field("data", unsafe { &self.data }) + .finish() + } + } + + impl ::fmt::Debug for iw_event { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("iw_event") + .field("len", &self.len ) + .field("cmd", &self.cmd ) + .field("u", &self.u ) + .finish() + } + } + + impl ::fmt::Debug for __c_anonymous_iwreq { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("__c_anonymous_iwreq") + .field("ifrn_name", unsafe { &self.ifrn_name }) + .finish() + } + } + + impl ::fmt::Debug for iwreq { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("iwreq") + .field("ifr_ifrn", &self.ifr_ifrn ) + .field("u", &self.u ) + .finish() + } + } } } @@ -1859,12 +2238,12 @@ 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 POSIX_SPAWN_SETSID: ::c_int = 128; +pub const POSIX_SPAWN_USEVFORK: ::c_short = 64; +pub const POSIX_SPAWN_SETSID: ::c_short = 128; -pub const S_IEXEC: mode_t = 64; -pub const S_IWRITE: mode_t = 128; -pub const S_IREAD: mode_t = 256; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IREAD: mode_t = 0o0400; pub const F_LOCK: ::c_int = 1; pub const F_TEST: ::c_int = 3; @@ -2053,17 +2432,15 @@ pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE: ::c_int = 1 << 6; pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ: ::c_int = 1 << 7; pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ: ::c_int = 1 << 8; -align_const! { - pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - size: [0; __SIZEOF_PTHREAD_MUTEX_T], - }; - pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - size: [0; __SIZEOF_PTHREAD_COND_T], - }; - pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - size: [0; __SIZEOF_PTHREAD_RWLOCK_T], - }; -} +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], +}; pub const PTHREAD_ONCE_INIT: pthread_once_t = 0; pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; @@ -2434,8 +2811,6 @@ 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_NOEXEC_SEAL: ::c_uint = 0x0008; -pub const MFD_EXEC: ::c_uint = 0x0010; pub const MFD_HUGE_64KB: ::c_uint = 0x40000000; pub const MFD_HUGE_512KB: ::c_uint = 0x4c000000; pub const MFD_HUGE_1MB: ::c_uint = 0x50000000; @@ -2618,12 +2993,12 @@ pub const ETH_P_PHONET: ::c_int = 0x00F5; pub const ETH_P_IEEE802154: ::c_int = 0x00F6; pub const ETH_P_CAIF: ::c_int = 0x00F7; -pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01; -pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02; -pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x04; -pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x08; -pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_int = 0x10; -pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x20; +pub const POSIX_SPAWN_RESETIDS: ::c_short = 0x01; +pub const POSIX_SPAWN_SETPGROUP: ::c_short = 0x02; +pub const POSIX_SPAWN_SETSIGDEF: ::c_short = 0x04; +pub const POSIX_SPAWN_SETSIGMASK: ::c_short = 0x08; +pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_short = 0x10; +pub const POSIX_SPAWN_SETSCHEDULER: ::c_short = 0x20; pub const NLMSG_NOOP: ::c_int = 0x1; pub const NLMSG_ERROR: ::c_int = 0x2; @@ -2823,13 +3198,74 @@ pub const CTRL_ATTR_MCAST_GRP_NAME: ::c_int = 1; pub const CTRL_ATTR_MCAST_GRP_ID: ::c_int = 2; // linux/if_packet.h +pub const PACKET_HOST: ::c_uchar = 0; +pub const PACKET_BROADCAST: ::c_uchar = 1; +pub const PACKET_MULTICAST: ::c_uchar = 2; +pub const PACKET_OTHERHOST: ::c_uchar = 3; +pub const PACKET_OUTGOING: ::c_uchar = 4; +pub const PACKET_LOOPBACK: ::c_uchar = 5; +pub const PACKET_USER: ::c_uchar = 6; +pub const PACKET_KERNEL: ::c_uchar = 7; + pub const PACKET_ADD_MEMBERSHIP: ::c_int = 1; pub const PACKET_DROP_MEMBERSHIP: ::c_int = 2; +pub const PACKET_RX_RING: ::c_int = 5; +pub const PACKET_STATISTICS: ::c_int = 6; +pub const PACKET_AUXDATA: ::c_int = 8; +pub const PACKET_VERSION: ::c_int = 10; +pub const PACKET_RESERVE: ::c_int = 12; +pub const PACKET_TX_RING: ::c_int = 13; +pub const PACKET_LOSS: ::c_int = 14; +pub const PACKET_TIMESTAMP: ::c_int = 17; +pub const PACKET_FANOUT: ::c_int = 18; +pub const PACKET_QDISC_BYPASS: ::c_int = 20; + +pub const PACKET_FANOUT_HASH: ::c_uint = 0; +pub const PACKET_FANOUT_LB: ::c_uint = 1; +pub const PACKET_FANOUT_CPU: ::c_uint = 2; +pub const PACKET_FANOUT_ROLLOVER: ::c_uint = 3; +pub const PACKET_FANOUT_RND: ::c_uint = 4; +pub const PACKET_FANOUT_QM: ::c_uint = 5; +pub const PACKET_FANOUT_CBPF: ::c_uint = 6; +pub const PACKET_FANOUT_EBPF: ::c_uint = 7; +pub const PACKET_FANOUT_FLAG_ROLLOVER: ::c_uint = 0x1000; +pub const PACKET_FANOUT_FLAG_UNIQUEID: ::c_uint = 0x2000; +pub const PACKET_FANOUT_FLAG_DEFRAG: ::c_uint = 0x8000; pub const PACKET_MR_MULTICAST: ::c_int = 0; pub const PACKET_MR_PROMISC: ::c_int = 1; pub const PACKET_MR_ALLMULTI: ::c_int = 2; +pub const TP_STATUS_KERNEL: ::__u32 = 0; +pub const TP_STATUS_USER: ::__u32 = 1 << 0; +pub const TP_STATUS_COPY: ::__u32 = 1 << 1; +pub const TP_STATUS_LOSING: ::__u32 = 1 << 2; +pub const TP_STATUS_CSUMNOTREADY: ::__u32 = 1 << 3; +pub const TP_STATUS_VLAN_VALID: ::__u32 = 1 << 4; +pub const TP_STATUS_BLK_TMO: ::__u32 = 1 << 5; +pub const TP_STATUS_VLAN_TPID_VALID: ::__u32 = 1 << 6; +pub const TP_STATUS_CSUM_VALID: ::__u32 = 1 << 7; + +pub const TP_STATUS_AVAILABLE: ::__u32 = 0; +pub const TP_STATUS_SEND_REQUEST: ::__u32 = 1 << 0; +pub const TP_STATUS_SENDING: ::__u32 = 1 << 1; +pub const TP_STATUS_WRONG_FORMAT: ::__u32 = 1 << 2; + +pub const TP_STATUS_TS_SOFTWARE: ::__u32 = 1 << 29; +pub const TP_STATUS_TS_SYS_HARDWARE: ::__u32 = 1 << 30; +pub const TP_STATUS_TS_RAW_HARDWARE: ::__u32 = 1 << 31; + +pub const TPACKET_ALIGNMENT: usize = 16; +pub const TPACKET_HDRLEN: usize = ((core::mem::size_of::<::tpacket_hdr>() + TPACKET_ALIGNMENT - 1) + & !(TPACKET_ALIGNMENT - 1)) + + core::mem::size_of::<::sockaddr_ll>(); +pub const TPACKET2_HDRLEN: usize = + ((core::mem::size_of::<::tpacket2_hdr>() + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1)) + + core::mem::size_of::<::sockaddr_ll>(); +pub const TPACKET3_HDRLEN: usize = + ((core::mem::size_of::<::tpacket3_hdr>() + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1)) + + core::mem::size_of::<::sockaddr_ll>(); + // linux/netfilter.h pub const NF_DROP: ::c_int = 0; pub const NF_ACCEPT: ::c_int = 1; @@ -2853,20 +3289,47 @@ pub const NF_INET_FORWARD: ::c_int = 2; pub const NF_INET_LOCAL_OUT: ::c_int = 3; pub const NF_INET_POST_ROUTING: ::c_int = 4; pub const NF_INET_NUMHOOKS: ::c_int = 5; +pub const NF_INET_INGRESS: ::c_int = NF_INET_NUMHOOKS; + +pub const NF_NETDEV_INGRESS: ::c_int = 0; +pub const NF_NETDEV_EGRESS: ::c_int = 1; +pub const NF_NETDEV_NUMHOOKS: ::c_int = 2; // Some NFPROTO are not compatible with musl and are defined in submodules. pub const NFPROTO_UNSPEC: ::c_int = 0; +pub const NFPROTO_INET: ::c_int = 1; pub const NFPROTO_IPV4: ::c_int = 2; pub const NFPROTO_ARP: ::c_int = 3; +pub const NFPROTO_NETDEV: ::c_int = 5; pub const NFPROTO_BRIDGE: ::c_int = 7; pub const NFPROTO_IPV6: ::c_int = 10; pub const NFPROTO_DECNET: ::c_int = 12; pub const NFPROTO_NUMPROTO: ::c_int = 13; -pub const NFPROTO_INET: ::c_int = 1; -pub const NFPROTO_NETDEV: ::c_int = 5; -pub const NF_NETDEV_INGRESS: ::c_int = 0; -pub const NF_NETDEV_NUMHOOKS: ::c_int = 1; +// linux/netfilter_arp.h +pub const NF_ARP: ::c_int = 0; +pub const NF_ARP_IN: ::c_int = 0; +pub const NF_ARP_OUT: ::c_int = 1; +pub const NF_ARP_FORWARD: ::c_int = 2; +pub const NF_ARP_NUMHOOKS: ::c_int = 3; + +// linux/netfilter_bridge.h +pub const NF_BR_PRE_ROUTING: ::c_int = 0; +pub const NF_BR_LOCAL_IN: ::c_int = 1; +pub const NF_BR_FORWARD: ::c_int = 2; +pub const NF_BR_LOCAL_OUT: ::c_int = 3; +pub const NF_BR_POST_ROUTING: ::c_int = 4; +pub const NF_BR_BROUTING: ::c_int = 5; +pub const NF_BR_NUMHOOKS: ::c_int = 6; + +pub const NF_BR_PRI_FIRST: ::c_int = ::INT_MIN; +pub const NF_BR_PRI_NAT_DST_BRIDGED: ::c_int = -300; +pub const NF_BR_PRI_FILTER_BRIDGED: ::c_int = -200; +pub const NF_BR_PRI_BRNF: ::c_int = 0; +pub const NF_BR_PRI_NAT_DST_OTHER: ::c_int = 100; +pub const NF_BR_PRI_FILTER_OTHER: ::c_int = 200; +pub const NF_BR_PRI_NAT_SRC: ::c_int = 300; +pub const NF_BR_PRI_LAST: ::c_int = ::INT_MAX; // linux/netfilter_ipv4.h pub const NF_IP_PRE_ROUTING: ::c_int = 0; @@ -2877,6 +3340,7 @@ pub const NF_IP_POST_ROUTING: ::c_int = 4; pub const NF_IP_NUMHOOKS: ::c_int = 5; pub const NF_IP_PRI_FIRST: ::c_int = ::INT_MIN; +pub const NF_IP_PRI_RAW_BEFORE_DEFRAG: ::c_int = -450; pub const NF_IP_PRI_CONNTRACK_DEFRAG: ::c_int = -400; pub const NF_IP_PRI_RAW: ::c_int = -300; pub const NF_IP_PRI_SELINUX_FIRST: ::c_int = -225; @@ -2900,6 +3364,7 @@ pub const NF_IP6_POST_ROUTING: ::c_int = 4; pub const NF_IP6_NUMHOOKS: ::c_int = 5; pub const NF_IP6_PRI_FIRST: ::c_int = ::INT_MIN; +pub const NF_IP6_PRI_RAW_BEFORE_DEFRAG: ::c_int = -450; pub const NF_IP6_PRI_CONNTRACK_DEFRAG: ::c_int = -400; pub const NF_IP6_PRI_RAW: ::c_int = -300; pub const NF_IP6_PRI_SELINUX_FIRST: ::c_int = -225; @@ -3249,6 +3714,9 @@ pub const IW_ENC_CAPA_CIPHER_TKIP: ::c_ulong = 0x00000004; pub const IW_ENC_CAPA_CIPHER_CCMP: ::c_ulong = 0x00000008; pub const IW_ENC_CAPA_4WAY_HANDSHAKE: ::c_ulong = 0x00000010; +pub const IW_EVENT_CAPA_K_0: c_ulong = 0x4000050; // IW_EVENT_CAPA_MASK(0x8B04) | IW_EVENT_CAPA_MASK(0x8B06) | IW_EVENT_CAPA_MASK(0x8B1A); +pub const IW_EVENT_CAPA_K_1: c_ulong = 0x400; // W_EVENT_CAPA_MASK(0x8B2A); + pub const IW_PMKSA_ADD: usize = 1; pub const IW_PMKSA_REMOVE: usize = 2; pub const IW_PMKSA_FLUSH: usize = 3; @@ -3259,8 +3727,13 @@ pub const IW_PMKID_CAND_PREAUTH: ::c_ulong = 0x00000001; pub const IW_EV_LCP_PK_LEN: usize = 4; -pub const IW_EV_CHAR_PK_LEN: usize = IW_EV_LCP_PK_LEN + ::IFNAMSIZ; -pub const IW_EV_POINT_PK_LEN: usize = IW_EV_LCP_PK_LEN + 4; +pub const IW_EV_CHAR_PK_LEN: usize = 20; // IW_EV_LCP_PK_LEN + ::IFNAMSIZ; +pub const IW_EV_UINT_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + ::mem::size_of::(); +pub const IW_EV_FREQ_PK_LEN: usize = 12; // IW_EV_LCP_PK_LEN + ::mem::size_of::(); +pub const IW_EV_PARAM_PK_LEN: usize = 12; // IW_EV_LCP_PK_LEN + ::mem::size_of::(); +pub const IW_EV_ADDR_PK_LEN: usize = 20; // IW_EV_LCP_PK_LEN + ::mem::size_of::<::sockaddr>(); +pub const IW_EV_QUAL_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + ::mem::size_of::(); +pub const IW_EV_POINT_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + 4; pub const IPTOS_TOS_MASK: u8 = 0x1E; pub const IPTOS_PREC_MASK: u8 = 0xE0; @@ -4103,7 +4576,7 @@ pub const FAN_MARK_IGNORED_MASK: ::c_uint = 0x0000_0020; pub const FAN_MARK_IGNORED_SURV_MODIFY: ::c_uint = 0x0000_0040; pub const FAN_MARK_FLUSH: ::c_uint = 0x0000_0080; pub const FAN_MARK_EVICTABLE: ::c_uint = 0x0000_0200; -pub const FAN_MARK_IGNORE: ::c_uint = 0x0000_0400; +pub const FAN_MARK_IGNORE: ::c_uint = 0x0000_0100; pub const FAN_MARK_INODE: ::c_uint = 0x0000_0000; pub const FAN_MARK_MOUNT: ::c_uint = 0x0000_0010; @@ -4296,19 +4769,15 @@ pub const CANXL_MAX_DLEN: usize = 2048; pub const CANXL_XLF: ::c_int = 0x80; pub const CANXL_SEC: ::c_int = 0x01; -cfg_if! { - if #[cfg(libc_align)] { - pub const CAN_MTU: usize = ::mem::size_of::(); - pub const CANFD_MTU: usize = ::mem::size_of::(); - pub const CANXL_MTU: usize = ::mem::size_of::(); - // FIXME: use `core::mem::offset_of!` once that is available - // https://github.com/rust-lang/rfcs/pull/3308 - // pub const CANXL_HDR_SIZE: usize = core::mem::offset_of!(canxl_frame, data); - pub const CANXL_HDR_SIZE: usize = 12; - pub const CANXL_MIN_MTU: usize = CANXL_HDR_SIZE + 64; - pub const CANXL_MAX_MTU: usize = CANXL_MTU; - } -} +pub const CAN_MTU: usize = ::mem::size_of::(); +pub const CANFD_MTU: usize = ::mem::size_of::(); +pub const CANXL_MTU: usize = ::mem::size_of::(); +// FIXME: use `core::mem::offset_of!` once that is available +// https://github.com/rust-lang/rfcs/pull/3308 +// pub const CANXL_HDR_SIZE: usize = core::mem::offset_of!(canxl_frame, data); +pub const CANXL_HDR_SIZE: usize = 12; +pub const CANXL_MIN_MTU: usize = CANXL_HDR_SIZE + 64; +pub const CANXL_MAX_MTU: usize = CANXL_MTU; pub const CAN_RAW: ::c_int = 1; pub const CAN_BCM: ::c_int = 2; @@ -4679,7 +5148,7 @@ f! { as *mut cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; - if (next.wrapping_offset(1)) as usize > max || + if (next.offset(1)) as usize > max || next as usize + super::CMSG_ALIGN((*next).cmsg_len as usize) > max { 0 as *mut cmsghdr @@ -4791,6 +5260,11 @@ f! { ee.offset(1) as *mut ::sockaddr } + pub fn TPACKET_ALIGN(x: usize) -> usize { + (x + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1) + } + + pub fn BPF_RVAL(code: ::__u32) -> ::__u32 { code & 0x18 } @@ -4806,6 +5280,30 @@ f! { pub fn BPF_JUMP(code: ::__u16, k: ::__u32, jt: ::__u8, jf: ::__u8) -> sock_filter { sock_filter{code: code, jt: jt, jf: jf, k: k} } + + pub fn ELF32_R_SYM(val: Elf32_Word) -> Elf32_Word { + val >> 8 + } + + pub fn ELF32_R_TYPE(val: Elf32_Word) -> Elf32_Word { + val & 0xff + } + + pub fn ELF32_R_INFO(sym: Elf32_Word, t: Elf32_Word) -> Elf32_Word { + sym << 8 + t & 0xff + } + + pub fn ELF64_R_SYM(val: Elf64_Xword) -> Elf64_Xword { + val >> 32 + } + + pub fn ELF64_R_TYPE(val: Elf64_Xword) -> Elf64_Xword { + val & 0xffffffff + } + + pub fn ELF64_R_INFO(sym: Elf64_Xword, t: Elf64_Xword) -> Elf64_Xword { + sym << 32 + t + } } safe_f! { @@ -4924,9 +5422,6 @@ cfg_if! { spbufp: *mut *mut spwd, ) -> ::c_int; - pub fn shm_open(name: *const c_char, oflag: ::c_int, mode: mode_t) -> ::c_int; - pub fn shm_unlink(name: *const ::c_char) -> ::c_int; - pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; pub fn mq_close(mqd: ::mqd_t) -> ::c_int; pub fn mq_unlink(name: *const ::c_char) -> ::c_int; @@ -5013,6 +5508,9 @@ extern "C" { pub fn getspnam(name: *const ::c_char) -> *mut spwd; + pub fn shm_open(name: *const c_char, oflag: ::c_int, mode: mode_t) -> ::c_int; + pub fn shm_unlink(name: *const ::c_char) -> ::c_int; + // System V IPC pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; pub fn shmat(shmid: ::c_int, shmaddr: *const ::c_void, shmflg: ::c_int) -> *mut ::c_void; @@ -5671,20 +6169,9 @@ cfg_if! { mod arch; pub use self::arch::*; -cfg_if! { - if #[cfg(libc_align)] { - #[macro_use] - mod align; - } else { - #[macro_use] - mod no_align; - } -} +#[macro_use] +mod align; expand_align!(); -cfg_if! { - if #[cfg(libc_non_exhaustive)] { - mod non_exhaustive; - pub use self::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 8225f26adb474..3f41f8990a09f 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -845,9 +845,5 @@ extern "C" { pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; 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 2fb405bbc6ceb..ab7a55b754c5e 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -780,9 +780,5 @@ pub const SYS_process_mrelease: ::c_long = 4000 + 448; pub const SYS_futex_waitv: ::c_long = 4000 + 449; pub const SYS_set_mempolicy_home_node: ::c_long = 4000 + 450; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs index f963f645a9f10..8568f2f338094 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -790,9 +790,5 @@ 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::*; - } -} +mod align; +pub use self::align::*; 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 12280851e7471..f43c7ea60f8c7 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -936,6 +936,7 @@ pub const SYS_memfd_secret: ::c_long = 447; 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; +pub const SYS_fchmodat2: ::c_long = 452; // offsets in user_regs_structs, from sys/reg.h pub const EBX: ::c_int = 0; @@ -960,9 +961,5 @@ extern "C" { pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; 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 54e072b314a84..0d66884445421 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -643,16 +643,8 @@ pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; -cfg_if! { - if #[cfg(libc_int128)] { - mod int128; - pub use self::int128::*; - } -} +mod int128; +pub use self::int128::*; diff --git a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs index 393f54d3ff773..2a37bd976bc7c 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -719,9 +719,5 @@ 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::*; - } -} +mod align; +pub use self::align::*; 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 4d17868000ebd..f1c9f5af90c0f 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 @@ -608,6 +608,7 @@ pub const SYS_memfd_secret: ::c_long = 447; 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; +pub const SYS_fchmodat2: ::c_long = 452; // offsets in user_regs_structs, from sys/reg.h pub const R15: ::c_int = 0; @@ -907,9 +908,5 @@ pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 36d8c20381432..f8a7a62b17d79 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -58,65 +58,61 @@ impl siginfo_t { } } -cfg_if! { - if #[cfg(libc_union)] { - // Internal, for casts to access union fields - #[repr(C)] - struct sifields_sigchld { - si_pid: ::pid_t, - si_uid: ::uid_t, - si_status: ::c_int, - si_utime: ::c_long, - si_stime: ::c_long, - } - impl ::Copy for sifields_sigchld {} - impl ::Clone for sifields_sigchld { - fn clone(&self) -> sifields_sigchld { - *self - } - } +// Internal, for casts to access union fields +#[repr(C)] +struct sifields_sigchld { + si_pid: ::pid_t, + si_uid: ::uid_t, + si_status: ::c_int, + si_utime: ::c_long, + si_stime: ::c_long, +} +impl ::Copy for sifields_sigchld {} +impl ::Clone for sifields_sigchld { + fn clone(&self) -> sifields_sigchld { + *self + } +} - // Internal, for casts to access union fields - #[repr(C)] - union sifields { - _align_pointer: *mut ::c_void, - sigchld: sifields_sigchld, - } +// Internal, for casts to access union fields +#[repr(C)] +union sifields { + _align_pointer: *mut ::c_void, + sigchld: sifields_sigchld, +} - // Internal, for casts to access union fields. Note that some variants - // of sifields start with a pointer, which makes the alignment of - // sifields vary on 32-bit and 64-bit architectures. - #[repr(C)] - struct siginfo_f { - _siginfo_base: [::c_int; 3], - sifields: sifields, - } +// Internal, for casts to access union fields. Note that some variants +// of sifields start with a pointer, which makes the alignment of +// sifields vary on 32-bit and 64-bit architectures. +#[repr(C)] +struct siginfo_f { + _siginfo_base: [::c_int; 3], + sifields: sifields, +} - impl siginfo_t { - unsafe fn sifields(&self) -> &sifields { - &(*(self as *const siginfo_t as *const siginfo_f)).sifields - } +impl siginfo_t { + unsafe fn sifields(&self) -> &sifields { + &(*(self as *const siginfo_t as *const siginfo_f)).sifields + } - pub unsafe fn si_pid(&self) -> ::pid_t { - self.sifields().sigchld.si_pid - } + pub unsafe fn si_pid(&self) -> ::pid_t { + self.sifields().sigchld.si_pid + } - pub unsafe fn si_uid(&self) -> ::uid_t { - self.sifields().sigchld.si_uid - } + pub unsafe fn si_uid(&self) -> ::uid_t { + self.sifields().sigchld.si_uid + } - pub unsafe fn si_status(&self) -> ::c_int { - self.sifields().sigchld.si_status - } + pub unsafe fn si_status(&self) -> ::c_int { + self.sifields().sigchld.si_status + } - pub unsafe fn si_utime(&self) -> ::c_long { - self.sifields().sigchld.si_utime - } + pub unsafe fn si_utime(&self) -> ::c_long { + self.sifields().sigchld.si_utime + } - pub unsafe fn si_stime(&self) -> ::c_long { - self.sifields().sigchld.si_stime - } - } + pub unsafe fn si_stime(&self) -> ::c_long { + self.sifields().sigchld.si_stime } } @@ -883,8 +879,30 @@ extern "C" { pub fn asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char; + pub fn strftime( + s: *mut ::c_char, + max: ::size_t, + format: *const ::c_char, + tm: *const ::tm, + ) -> ::size_t; + pub fn strftime_l( + s: *mut ::c_char, + max: ::size_t, + format: *const ::c_char, + tm: *const ::tm, + locale: ::locale_t, + ) -> ::size_t; + pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char; + pub fn dirname(path: *mut ::c_char) -> *mut ::c_char; pub fn basename(path: *mut ::c_char) -> *mut ::c_char; + + 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(); } // Alias to 64 to mimic glibc's LFS64 support diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index cff82f005acee..69187670587d6 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -914,12 +914,5 @@ 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; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } else { - mod no_align; - pub use self::no_align::*; - } -} +mod align; +pub use self::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 a5aca85a3a741..9e5765e9568f1 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -681,12 +681,5 @@ extern "C" { ) -> ::c_int; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } else { - mod no_align; - pub use self::no_align::*; - } -} +mod align; +pub use self::align::*; 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 8ca100fcd268f..4ac13f5c77866 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs @@ -196,12 +196,5 @@ pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; pub const SYS_gettid: ::c_long = 5178; // Valid for n64 -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } else { - mod no_align; - pub use self::no_align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 48b03e9ee43fa..b3c126963e090 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -107,6 +107,64 @@ impl siginfo_t { } } +// Internal, for casts to access union fields +#[repr(C)] +struct sifields_sigchld { + si_pid: ::pid_t, + si_uid: ::uid_t, + si_status: ::c_int, + si_utime: ::c_long, + si_stime: ::c_long, +} +impl ::Copy for sifields_sigchld {} +impl ::Clone for sifields_sigchld { + fn clone(&self) -> sifields_sigchld { + *self + } +} + +// Internal, for casts to access union fields +#[repr(C)] +union sifields { + _align_pointer: *mut ::c_void, + sigchld: sifields_sigchld, +} + +// Internal, for casts to access union fields. Note that some variants +// of sifields start with a pointer, which makes the alignment of +// sifields vary on 32-bit and 64-bit architectures. +#[repr(C)] +struct siginfo_f { + _siginfo_base: [::c_int; 3], + sifields: sifields, +} + +impl siginfo_t { + unsafe fn sifields(&self) -> &sifields { + &(*(self as *const siginfo_t as *const siginfo_f)).sifields + } + + pub unsafe fn si_pid(&self) -> ::pid_t { + self.sifields().sigchld.si_pid + } + + pub unsafe fn si_uid(&self) -> ::uid_t { + self.sifields().sigchld.si_uid + } + + pub unsafe fn si_status(&self) -> ::c_int { + self.sifields().sigchld.si_status + } + + pub unsafe fn si_utime(&self) -> ::c_long { + self.sifields().sigchld.si_utime + } + + pub unsafe fn si_stime(&self) -> ::c_long { + self.sifields().sigchld.si_stime + } +} + pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; pub const MCL_ONFAULT: ::c_int = 0x0004; 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 390119e3b5091..384566c5bf379 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -109,18 +109,6 @@ s! { pub sin6_scope_id: u32, } - // ------------------------------------------------------------ - // definitions below are *unverified* and might **break** the software -// pub struct in_addr { -// pub s_addr: in_addr_t, -// } -// -// pub struct in6_addr { -// pub s6_addr: [u8; 16], -// #[cfg(not(libc_align))] -// __align: [u32; 0], -// } - pub struct stat { pub st_dev: ::c_ulong, pub st_ino: ::ino_t, diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 749c8a16d0148..bdbec9c651fc5 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -85,7 +85,7 @@ s! { } pub struct fd_set { - fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE], + fds_bits: [::c_ulong; FD_SETSIZE as usize / ULONG_SIZE], } pub struct tm { @@ -505,26 +505,26 @@ pub const O_RDWR: ::c_int = 2; pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC; -pub const S_IFIFO: ::mode_t = 4096; -pub const S_IFCHR: ::mode_t = 8192; -pub const S_IFBLK: ::mode_t = 24576; -pub const S_IFDIR: ::mode_t = 16384; -pub const S_IFREG: ::mode_t = 32768; -pub const S_IFLNK: ::mode_t = 40960; -pub const S_IFSOCK: ::mode_t = 49152; -pub const S_IFMT: ::mode_t = 61440; -pub const S_IRWXU: ::mode_t = 448; -pub const S_IXUSR: ::mode_t = 64; -pub const S_IWUSR: ::mode_t = 128; -pub const S_IRUSR: ::mode_t = 256; -pub const S_IRWXG: ::mode_t = 56; -pub const S_IXGRP: ::mode_t = 8; -pub const S_IWGRP: ::mode_t = 16; -pub const S_IRGRP: ::mode_t = 32; -pub const S_IRWXO: ::mode_t = 7; -pub const S_IXOTH: ::mode_t = 1; -pub const S_IWOTH: ::mode_t = 2; -pub const S_IROTH: ::mode_t = 4; +pub const S_IFIFO: ::mode_t = 0o1_0000; +pub const S_IFCHR: ::mode_t = 0o2_0000; +pub const S_IFBLK: ::mode_t = 0o6_0000; +pub const S_IFDIR: ::mode_t = 0o4_0000; +pub const S_IFREG: ::mode_t = 0o10_0000; +pub const S_IFLNK: ::mode_t = 0o12_0000; +pub const S_IFSOCK: ::mode_t = 0o14_0000; +pub const S_IFMT: ::mode_t = 0o17_0000; +pub const S_IRWXU: ::mode_t = 0o0700; +pub const S_IXUSR: ::mode_t = 0o0100; +pub const S_IWUSR: ::mode_t = 0o0200; +pub const S_IRUSR: ::mode_t = 0o0400; +pub const S_IRWXG: ::mode_t = 0o0070; +pub const S_IXGRP: ::mode_t = 0o0010; +pub const S_IWGRP: ::mode_t = 0o0020; +pub const S_IRGRP: ::mode_t = 0o0040; +pub const S_IRWXO: ::mode_t = 0o0007; +pub const S_IXOTH: ::mode_t = 0o0001; +pub const S_IWOTH: ::mode_t = 0o0002; +pub const S_IROTH: ::mode_t = 0o0004; pub const F_OK: ::c_int = 0; pub const R_OK: ::c_int = 4; pub const W_OK: ::c_int = 2; @@ -1065,23 +1065,23 @@ pub const PATH_MAX: ::c_int = 4096; pub const UIO_MAXIOV: ::c_int = 1024; -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 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 FD_SETSIZE: ::c_int = 1024; + +pub const EPOLLIN: u32 = 0x1; +pub const EPOLLPRI: u32 = 0x2; +pub const EPOLLOUT: u32 = 0x4; +pub const EPOLLERR: u32 = 0x8; +pub const EPOLLHUP: u32 = 0x10; +pub const EPOLLRDNORM: u32 = 0x40; +pub const EPOLLRDBAND: u32 = 0x80; +pub const EPOLLWRNORM: u32 = 0x100; +pub const EPOLLWRBAND: u32 = 0x200; +pub const EPOLLMSG: u32 = 0x400; +pub const EPOLLRDHUP: u32 = 0x2000; +pub const EPOLLEXCLUSIVE: u32 = 0x10000000; +pub const EPOLLWAKEUP: u32 = 0x20000000; +pub const EPOLLONESHOT: u32 = 0x40000000; +pub const EPOLLET: u32 = 0x80000000; pub const EPOLL_CTL_ADD: ::c_int = 1; pub const EPOLL_CTL_MOD: ::c_int = 3; @@ -1739,11 +1739,6 @@ extern "C" { pub fn acct(filename: *const ::c_char) -> ::c_int; pub fn brk(addr: *mut ::c_void) -> ::c_int; pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void; - #[deprecated( - since = "0.2.66", - note = "causes memory corruption, see rust-lang/libc#1596" - )] - pub fn vfork() -> ::pid_t; 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 wait4( @@ -1755,14 +1750,10 @@ extern "C" { pub fn login_tty(fd: ::c_int) -> ::c_int; pub fn execvpe( file: *const ::c_char, - argv: *const *const ::c_char, - envp: *const *const ::c_char, - ) -> ::c_int; - pub fn fexecve( - fd: ::c_int, - argv: *const *const ::c_char, - envp: *const *const ::c_char, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char, ) -> ::c_int; + pub fn fexecve(fd: ::c_int, argv: *const *mut ::c_char, envp: *const *mut ::c_char) -> ::c_int; pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; pub fn freeifaddrs(ifa: *mut ::ifaddrs); pub fn bind(socket: ::c_int, address: *const ::sockaddr, address_len: ::socklen_t) -> ::c_int; @@ -1775,21 +1766,6 @@ extern "C" { pub fn uname(buf: *mut ::utsname) -> ::c_int; pub fn strchrnul(s: *const ::c_char, c: ::c_int) -> *mut ::c_char; - - pub fn strftime( - s: *mut ::c_char, - max: ::size_t, - format: *const ::c_char, - tm: *const ::tm, - ) -> ::size_t; - pub fn strftime_l( - s: *mut ::c_char, - max: ::size_t, - format: *const ::c_char, - tm: *const ::tm, - locale: ::locale_t, - ) -> ::size_t; - pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char; } // LFS64 extensions diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 49984d3f00c65..b67b5a93e3541 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -235,9 +235,9 @@ cfg_if! { } pub const SIGIOT: ::c_int = 6; -pub const S_ISUID: ::mode_t = 0x800; -pub const S_ISGID: ::mode_t = 0x400; -pub const S_ISVTX: ::mode_t = 0x200; +pub const S_ISUID: ::mode_t = 0o4000; +pub const S_ISGID: ::mode_t = 0o2000; +pub const S_ISVTX: ::mode_t = 0o1000; cfg_if! { if #[cfg(not(any(target_os = "haiku", target_os = "illumos", @@ -369,7 +369,6 @@ cfg_if! { target_os = "ios", target_os = "tvos", target_os = "watchos", - target_os = "visionos", target_os = "android", target_os = "openbsd", target_os = "nto", @@ -396,7 +395,7 @@ cfg_if! { #[cfg_attr(feature = "rustc-dep-of-std", link(name = "c", cfg(not(target_feature = "crt-static"))))] extern {} - } else if #[cfg(target_env = "aix")] { + } else if #[cfg(target_os = "aix")] { #[link(name = "c")] #[link(name = "m")] #[link(name = "bsd")] @@ -589,20 +588,12 @@ extern "C" { pub fn getchar_unlocked() -> ::c_int; pub fn putchar_unlocked(c: ::c_int) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr(target_os = "netbsd", link_name = "__socket30")] #[cfg_attr(target_os = "illumos", link_name = "__xnet_socket")] #[cfg_attr(target_os = "espidf", link_name = "lwip_socket")] pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "connect$UNIX2003" @@ -616,22 +607,14 @@ extern "C" { )] #[cfg_attr(target_os = "espidf", link_name = "lwip_listen")] pub fn listen(socket: ::c_int, backlog: ::c_int) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "accept$UNIX2003" )] #[cfg_attr(target_os = "espidf", link_name = "lwip_accept")] pub fn accept(socket: ::c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "getpeername$UNIX2003" @@ -642,11 +625,7 @@ extern "C" { address: *mut sockaddr, address_len: *mut socklen_t, ) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "getsockname$UNIX2003" @@ -676,11 +655,7 @@ extern "C" { protocol: ::c_int, socket_vector: *mut ::c_int, ) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "sendto$UNIX2003" @@ -865,13 +840,13 @@ extern "C" { pub fn execl(path: *const c_char, arg0: *const c_char, ...) -> ::c_int; pub fn execle(path: *const ::c_char, arg0: *const ::c_char, ...) -> ::c_int; pub fn execlp(file: *const ::c_char, arg0: *const ::c_char, ...) -> ::c_int; - pub fn execv(prog: *const c_char, argv: *const *const c_char) -> ::c_int; + pub fn execv(prog: *const c_char, argv: *const *mut c_char) -> ::c_int; pub fn execve( prog: *const c_char, - argv: *const *const c_char, - envp: *const *const c_char, + argv: *const *mut c_char, + envp: *const *mut c_char, ) -> ::c_int; - pub fn execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int; + pub fn execvp(c: *const c_char, argv: *const *mut c_char) -> ::c_int; pub fn fork() -> pid_t; pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long; pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char; @@ -1043,8 +1018,7 @@ extern "C" { target_os = "macos", target_os = "ios", target_os = "tvos", - target_os = "watchos", - target_os = "visionos" + target_os = "watchos" ), link_name = "realpath$DARWIN_EXTSN" )] @@ -1181,11 +1155,7 @@ extern "C" { pub fn dlsym(handle: *mut ::c_void, symbol: *const ::c_char) -> *mut ::c_void; pub fn dlclose(handle: *mut ::c_void) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr(target_os = "illumos", link_name = "__xnet_getaddrinfo")] #[cfg_attr(target_os = "espidf", link_name = "lwip_getaddrinfo")] pub fn getaddrinfo( @@ -1194,11 +1164,7 @@ extern "C" { hints: *const addrinfo, res: *mut *mut addrinfo, ) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr(target_os = "espidf", link_name = "lwip_freeaddrinfo")] pub fn freeaddrinfo(res: *mut addrinfo); pub fn hstrerror(errcode: ::c_int) -> *const ::c_char; @@ -1220,8 +1186,7 @@ extern "C" { target_os = "macos", target_os = "ios", target_os = "tvos", - target_os = "watchos", - target_os = "visionos" + target_os = "watchos" ), link_name = "res_9_init" )] @@ -1567,7 +1532,6 @@ cfg_if! { target_os = "ios", target_os = "tvos", target_os = "watchos", - target_os = "visionos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", @@ -1598,32 +1562,7 @@ cfg_if! { } } -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, - } - } -} +pub use ffi::c_void; -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } else { - mod no_align; - pub use self::no_align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/unix/newlib/espidf/mod.rs b/src/unix/newlib/espidf/mod.rs index e2e98ee9c394a..409d7ad9bd784 100644 --- a/src/unix/newlib/espidf/mod.rs +++ b/src/unix/newlib/espidf/mod.rs @@ -89,16 +89,6 @@ pub const MSG_EOR: ::c_int = 0x08; pub const PTHREAD_STACK_MIN: ::size_t = 768; -pub const SIGABRT: ::size_t = 1; -pub const SIGFPE: ::size_t = 1; -pub const SIGILL: ::size_t = 1; -pub const SIGINT: ::size_t = 1; -pub const SIGSEGV: ::size_t = 1; -pub const SIGTERM: ::size_t = 1; -pub const SIGHUP: ::size_t = 1; -pub const SIGQUIT: ::size_t = 1; -pub const NSIG: ::size_t = 2; - extern "C" { pub fn pthread_create( native: *mut ::pthread_t, diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index a572cc38bfda9..45a2668aac71a 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -70,7 +70,7 @@ s! { #[cfg(not(any( target_os = "espidf", - all(libc_cfg_target_vendor, target_arch = "powerpc", target_vendor = "nintendo"))))] + all(target_arch = "powerpc", target_vendor = "nintendo"))))] pub ai_addr: *mut sockaddr, pub ai_next: *mut addrinfo, @@ -171,7 +171,7 @@ s! { } pub struct fd_set { // Unverified - fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE], + fds_bits: [::c_ulong; FD_SETSIZE as usize / ULONG_SIZE], } pub struct passwd { // Unverified @@ -226,18 +226,15 @@ s! { } } -// unverified constants -align_const! { - pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_MUTEX_T], - }; - pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_COND_T], - }; - pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_RWLOCK_T], - }; -} +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_MUTEX_T], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_COND_T], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_RWLOCK_T], +}; pub const NCCS: usize = 32; cfg_if! { @@ -283,11 +280,11 @@ pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; cfg_if! { if #[cfg(any(target_os = "horizon", target_os = "espidf"))] { - pub const FD_SETSIZE: usize = 64; + pub const FD_SETSIZE: ::c_int = 64; } else if #[cfg(target_os = "vita")] { - pub const FD_SETSIZE: usize = 256; + pub const FD_SETSIZE: ::c_int = 256; } else { - pub const FD_SETSIZE: usize = 1024; + pub const FD_SETSIZE: ::c_int = 1024; } } // intentionally not public, only used for fd_set @@ -423,27 +420,27 @@ pub const FIOCLEX: ::c_ulong = 0x20006601; pub const FIONCLEX: ::c_ulong = 0x20006602; pub const S_BLKSIZE: ::mode_t = 1024; -pub const S_IREAD: ::mode_t = 256; -pub const S_IWRITE: ::mode_t = 128; -pub const S_IEXEC: ::mode_t = 64; -pub const S_ENFMT: ::mode_t = 1024; -pub const S_IFMT: ::mode_t = 61440; -pub const S_IFDIR: ::mode_t = 16384; -pub const S_IFCHR: ::mode_t = 8192; -pub const S_IFBLK: ::mode_t = 24576; -pub const S_IFREG: ::mode_t = 32768; -pub const S_IFLNK: ::mode_t = 40960; -pub const S_IFSOCK: ::mode_t = 49152; -pub const S_IFIFO: ::mode_t = 4096; -pub const S_IRUSR: ::mode_t = 256; -pub const S_IWUSR: ::mode_t = 128; -pub const S_IXUSR: ::mode_t = 64; -pub const S_IRGRP: ::mode_t = 32; -pub const S_IWGRP: ::mode_t = 16; -pub const S_IXGRP: ::mode_t = 8; -pub const S_IROTH: ::mode_t = 4; -pub const S_IWOTH: ::mode_t = 2; -pub const S_IXOTH: ::mode_t = 1; +pub const S_IREAD: ::mode_t = 0o0400; +pub const S_IWRITE: ::mode_t = 0o0200; +pub const S_IEXEC: ::mode_t = 0o0100; +pub const S_ENFMT: ::mode_t = 0o2000; +pub const S_IFMT: ::mode_t = 0o17_0000; +pub const S_IFDIR: ::mode_t = 0o4_0000; +pub const S_IFCHR: ::mode_t = 0o2_0000; +pub const S_IFBLK: ::mode_t = 0o6_0000; +pub const S_IFREG: ::mode_t = 0o10_0000; +pub const S_IFLNK: ::mode_t = 0o12_0000; +pub const S_IFSOCK: ::mode_t = 0o14_0000; +pub const S_IFIFO: ::mode_t = 0o1_0000; +pub const S_IRUSR: ::mode_t = 0o0400; +pub const S_IWUSR: ::mode_t = 0o0200; +pub const S_IXUSR: ::mode_t = 0o0100; +pub const S_IRGRP: ::mode_t = 0o0040; +pub const S_IWGRP: ::mode_t = 0o0020; +pub const S_IXGRP: ::mode_t = 0o0010; +pub const S_IROTH: ::mode_t = 0o0004; +pub const S_IWOTH: ::mode_t = 0o0002; +pub const S_IXOTH: ::mode_t = 0o0001; pub const SOL_TCP: ::c_int = 6; @@ -662,11 +659,7 @@ extern "C" { pub fn rand() -> ::c_int; pub fn srand(seed: ::c_uint); - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr(target_os = "espidf", link_name = "lwip_bind")] pub fn bind(fd: ::c_int, addr: *const sockaddr, len: socklen_t) -> ::c_int; pub fn clock_settime(clock_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; @@ -675,11 +668,7 @@ extern "C" { #[cfg_attr(target_os = "espidf", link_name = "lwip_close")] pub fn closesocket(sockfd: ::c_int) -> ::c_int; pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr(target_os = "espidf", link_name = "lwip_recvfrom")] pub fn recvfrom( fd: ::c_int, @@ -689,11 +678,7 @@ extern "C" { addr: *mut sockaddr, addr_len: *mut socklen_t, ) -> isize; - #[cfg(not(all( - libc_cfg_target_vendor, - target_arch = "powerpc", - target_vendor = "nintendo" - )))] + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] pub fn getnameinfo( sa: *const sockaddr, salen: socklen_t, @@ -704,11 +689,7 @@ extern "C" { flags: ::c_int, ) -> ::c_int; pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; - pub fn fexecve( - fd: ::c_int, - argv: *const *const ::c_char, - envp: *const *const ::c_char, - ) -> ::c_int; + pub fn fexecve(fd: ::c_int, argv: *const *mut ::c_char, envp: *const *mut ::c_char) -> ::c_int; pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; pub fn getgrgid_r( gid: ::gid_t, @@ -786,13 +767,6 @@ cfg_if! { } } -cfg_if! { - if #[cfg(libc_align)] { - #[macro_use] - mod align; - } else { - #[macro_use] - mod no_align; - } -} +#[macro_use] +mod align; expand_align!(); diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 9eef23458d14a..f00d710bbac02 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -154,7 +154,7 @@ s! { } pub struct fd_set { - fds_bits: [::c_uint; 2 * FD_SETSIZE / ULONG_SIZE], + fds_bits: [::c_uint; 2 * FD_SETSIZE as usize / ULONG_SIZE], } pub struct tm { @@ -1383,7 +1383,7 @@ pub const PATH_MAX: ::c_int = 1024; pub const UIO_MAXIOV: ::c_int = 1024; -pub const FD_SETSIZE: usize = 256; +pub const FD_SETSIZE: ::c_int = 256; pub const TCIOFF: ::c_int = 0x0002; pub const TCION: ::c_int = 0x0003; @@ -1609,12 +1609,12 @@ pub const ITIMER_REAL: ::c_int = 0; pub const ITIMER_VIRTUAL: ::c_int = 1; pub const ITIMER_PROF: ::c_int = 2; -pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x00000010; -pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x00000001; -pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x00000004; -pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x00000002; -pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_int = 0x00000400; -pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x00000040; +pub const POSIX_SPAWN_RESETIDS: ::c_short = 0x0010; +pub const POSIX_SPAWN_SETPGROUP: ::c_short = 0x0001; +pub const POSIX_SPAWN_SETSIGDEF: ::c_short = 0x0004; +pub const POSIX_SPAWN_SETSIGMASK: ::c_short = 0x0002; +pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_short = 0x0400; +pub const POSIX_SPAWN_SETSCHEDULER: ::c_short = 0x0040; pub const IPTOS_ECN_NOT_ECT: u8 = 0x00; @@ -2037,27 +2037,27 @@ pub const S_IEXEC: mode_t = ::S_IXUSR; pub const S_IWRITE: mode_t = ::S_IWUSR; pub const S_IREAD: mode_t = ::S_IRUSR; -pub const S_IFIFO: ::mode_t = 0x1000; -pub const S_IFCHR: ::mode_t = 0x2000; -pub const S_IFDIR: ::mode_t = 0x4000; -pub const S_IFBLK: ::mode_t = 0x6000; -pub const S_IFREG: ::mode_t = 0x8000; -pub const S_IFLNK: ::mode_t = 0xA000; -pub const S_IFSOCK: ::mode_t = 0xC000; -pub const S_IFMT: ::mode_t = 0xF000; - -pub const S_IXOTH: ::mode_t = 0o000001; -pub const S_IWOTH: ::mode_t = 0o000002; -pub const S_IROTH: ::mode_t = 0o000004; -pub const S_IRWXO: ::mode_t = 0o000007; -pub const S_IXGRP: ::mode_t = 0o000010; -pub const S_IWGRP: ::mode_t = 0o000020; -pub const S_IRGRP: ::mode_t = 0o000040; -pub const S_IRWXG: ::mode_t = 0o000070; -pub const S_IXUSR: ::mode_t = 0o000100; -pub const S_IWUSR: ::mode_t = 0o000200; -pub const S_IRUSR: ::mode_t = 0o000400; -pub const S_IRWXU: ::mode_t = 0o000700; +pub const S_IFIFO: ::mode_t = 0o1_0000; +pub const S_IFCHR: ::mode_t = 0o2_0000; +pub const S_IFDIR: ::mode_t = 0o4_0000; +pub const S_IFBLK: ::mode_t = 0o6_0000; +pub const S_IFREG: ::mode_t = 0o10_0000; +pub const S_IFLNK: ::mode_t = 0o12_0000; +pub const S_IFSOCK: ::mode_t = 0o14_0000; +pub const S_IFMT: ::mode_t = 0o17_0000; + +pub const S_IXOTH: ::mode_t = 0o0001; +pub const S_IWOTH: ::mode_t = 0o0002; +pub const S_IROTH: ::mode_t = 0o0004; +pub const S_IRWXO: ::mode_t = 0o0007; +pub const S_IXGRP: ::mode_t = 0o0010; +pub const S_IWGRP: ::mode_t = 0o0020; +pub const S_IRGRP: ::mode_t = 0o0040; +pub const S_IRWXG: ::mode_t = 0o0070; +pub const S_IXUSR: ::mode_t = 0o0100; +pub const S_IWUSR: ::mode_t = 0o0200; +pub const S_IRUSR: ::mode_t = 0o0400; +pub const S_IRWXU: ::mode_t = 0o0700; pub const F_LOCK: ::c_int = 1; pub const F_TEST: ::c_int = 3; @@ -2935,8 +2935,8 @@ extern "C" { ) -> ::pid_t; pub fn execvpe( file: *const ::c_char, - argv: *const *const ::c_char, - envp: *const *const ::c_char, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char, ) -> ::c_int; pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; diff --git a/src/unix/nto/x86_64.rs b/src/unix/nto/x86_64.rs index 3a1d230bb98eb..29739ac83a3e9 100644 --- a/src/unix/nto/x86_64.rs +++ b/src/unix/nto/x86_64.rs @@ -34,10 +34,7 @@ s! { #[repr(align(8))] pub struct mcontext_t { pub cpu: x86_64_cpu_registers, - #[cfg(libc_union)] pub fpu: x86_64_fpu_registers, - #[cfg(not(libc_union))] - __reserved: [u8; 1024], } pub struct stack_t { @@ -80,7 +77,6 @@ s! { } s_no_extra_traits! { - #[cfg(libc_union)] pub union x86_64_fpu_registers { pub fsave_area: fsave_area_64, pub fxsave_area: fxsave_area_64, @@ -91,10 +87,8 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - #[cfg(libc_union)] impl Eq for x86_64_fpu_registers {} - #[cfg(libc_union)] impl PartialEq for x86_64_fpu_registers { fn eq(&self, other: &x86_64_fpu_registers) -> bool { unsafe { @@ -105,7 +99,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::fmt::Debug for x86_64_fpu_registers { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { @@ -118,7 +111,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl ::hash::Hash for x86_64_fpu_registers { fn hash(&self, state: &mut H) { unsafe { diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 5036f458067b6..bc6e2a8a93d4e 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -116,7 +116,7 @@ s! { } pub struct fd_set { - fds_bits: [::c_ulong; ::FD_SETSIZE / ULONG_SIZE], + fds_bits: [::c_ulong; ::FD_SETSIZE as usize / ULONG_SIZE], } pub struct in_addr { @@ -585,7 +585,13 @@ pub const IP_MULTICAST_TTL: ::c_int = 33; pub const IP_MULTICAST_LOOP: ::c_int = 34; pub const IP_ADD_MEMBERSHIP: ::c_int = 35; pub const IP_DROP_MEMBERSHIP: ::c_int = 36; +pub const IP_TOS: ::c_int = 1; +pub const IP_RECVTOS: ::c_int = 2; +pub const IPPROTO_IGMP: ::c_int = 2; +pub const IPPROTO_PUP: ::c_int = 12; +pub const IPPROTO_IDP: ::c_int = 22; pub const IPPROTO_RAW: ::c_int = 255; +pub const IPPROTO_MAX: ::c_int = 255; // } // netinet/tcp.h @@ -677,44 +683,44 @@ pub const EPOLL_CLOEXEC: ::c_int = 0x0100_0000; pub const EPOLL_CTL_ADD: ::c_int = 1; pub const EPOLL_CTL_DEL: ::c_int = 2; pub const EPOLL_CTL_MOD: ::c_int = 3; -pub const EPOLLIN: ::c_int = 0x001; -pub const EPOLLPRI: ::c_int = 0x002; -pub const EPOLLOUT: ::c_int = 0x004; -pub const EPOLLERR: ::c_int = 0x008; -pub const EPOLLHUP: ::c_int = 0x010; -pub const EPOLLNVAL: ::c_int = 0x020; -pub const EPOLLRDNORM: ::c_int = 0x040; -pub const EPOLLRDBAND: ::c_int = 0x080; -pub const EPOLLWRNORM: ::c_int = 0x100; -pub const EPOLLWRBAND: ::c_int = 0x200; -pub const EPOLLMSG: ::c_int = 0x400; -pub const EPOLLRDHUP: ::c_int = 0x2000; -pub const EPOLLEXCLUSIVE: ::c_int = 1 << 28; -pub const EPOLLWAKEUP: ::c_int = 1 << 29; -pub const EPOLLONESHOT: ::c_int = 1 << 30; -pub const EPOLLET: ::c_int = 1 << 31; +pub const EPOLLIN: ::c_int = 1; +pub const EPOLLPRI: ::c_int = 0; +pub const EPOLLOUT: ::c_int = 2; +pub const EPOLLRDNORM: ::c_int = 0; +pub const EPOLLNVAL: ::c_int = 0; +pub const EPOLLRDBAND: ::c_int = 0; +pub const EPOLLWRNORM: ::c_int = 0; +pub const EPOLLWRBAND: ::c_int = 0; +pub const EPOLLMSG: ::c_int = 0; +pub const EPOLLERR: ::c_int = 0; +pub const EPOLLHUP: ::c_int = 0; +pub const EPOLLRDHUP: ::c_int = 0; +pub const EPOLLEXCLUSIVE: ::c_int = 0; +pub const EPOLLWAKEUP: ::c_int = 0; +pub const EPOLLONESHOT: ::c_int = 0; +pub const EPOLLET: ::c_int = 0; // sys/stat.h -pub const S_IFMT: ::c_int = 0o0_170_000; -pub const S_IFDIR: ::c_int = 0o040_000; -pub const S_IFCHR: ::c_int = 0o020_000; -pub const S_IFBLK: ::c_int = 0o060_000; -pub const S_IFREG: ::c_int = 0o100_000; -pub const S_IFIFO: ::c_int = 0o010_000; -pub const S_IFLNK: ::c_int = 0o120_000; -pub const S_IFSOCK: ::c_int = 0o140_000; -pub const S_IRWXU: ::c_int = 0o0_700; -pub const S_IRUSR: ::c_int = 0o0_400; -pub const S_IWUSR: ::c_int = 0o0_200; -pub const S_IXUSR: ::c_int = 0o0_100; -pub const S_IRWXG: ::c_int = 0o0_070; -pub const S_IRGRP: ::c_int = 0o0_040; -pub const S_IWGRP: ::c_int = 0o0_020; -pub const S_IXGRP: ::c_int = 0o0_010; -pub const S_IRWXO: ::c_int = 0o0_007; -pub const S_IROTH: ::c_int = 0o0_004; -pub const S_IWOTH: ::c_int = 0o0_002; -pub const S_IXOTH: ::c_int = 0o0_001; +pub const S_IFMT: ::c_int = 0o17_0000; +pub const S_IFDIR: ::c_int = 0o4_0000; +pub const S_IFCHR: ::c_int = 0o2_0000; +pub const S_IFBLK: ::c_int = 0o6_0000; +pub const S_IFREG: ::c_int = 0o10_0000; +pub const S_IFIFO: ::c_int = 0o1_0000; +pub const S_IFLNK: ::c_int = 0o12_0000; +pub const S_IFSOCK: ::c_int = 0o14_0000; +pub const S_IRWXU: ::c_int = 0o0700; +pub const S_IRUSR: ::c_int = 0o0400; +pub const S_IWUSR: ::c_int = 0o0200; +pub const S_IXUSR: ::c_int = 0o0100; +pub const S_IRWXG: ::c_int = 0o0070; +pub const S_IRGRP: ::c_int = 0o0040; +pub const S_IWGRP: ::c_int = 0o0020; +pub const S_IXGRP: ::c_int = 0o0010; +pub const S_IRWXO: ::c_int = 0o0007; +pub const S_IROTH: ::c_int = 0o0004; +pub const S_IWOTH: ::c_int = 0o0002; +pub const S_IXOTH: ::c_int = 0o0001; // stdlib.h pub const EXIT_SUCCESS: ::c_int = 0; @@ -759,7 +765,7 @@ pub const MS_INVALIDATE: ::c_int = 0x0002; pub const MS_SYNC: ::c_int = 0x0004; // sys/select.h -pub const FD_SETSIZE: usize = 1024; +pub const FD_SETSIZE: ::c_int = 1024; // sys/socket.h pub const AF_INET: ::c_int = 2; @@ -810,6 +816,7 @@ pub const SO_PROTOCOL: ::c_int = 38; pub const SO_DOMAIN: ::c_int = 39; pub const SOCK_STREAM: ::c_int = 1; pub const SOCK_DGRAM: ::c_int = 2; +pub const SOCK_RAW: ::c_int = 3; pub const SOCK_NONBLOCK: ::c_int = 0o4_000; pub const SOCK_CLOEXEC: ::c_int = 0o2_000_000; pub const SOCK_SEQPACKET: ::c_int = 5; diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 7ed00413dc7f2..ab8070dd3f077 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -135,7 +135,7 @@ s! { pub struct ifaddrs { pub ifa_next: *mut ifaddrs, pub ifa_name: *mut ::c_char, - pub ifa_flags: ::c_ulong, + pub ifa_flags: u64, pub ifa_addr: *mut ::sockaddr, pub ifa_netmask: *mut ::sockaddr, pub ifa_dstaddr: *mut ::sockaddr, @@ -476,14 +476,10 @@ s! { } s_no_extra_traits! { - #[cfg_attr(all( - any(target_arch = "x86", target_arch = "x86_64"), - libc_packedN - ), repr(packed(4)))] - #[cfg_attr(all( - any(target_arch = "x86", target_arch = "x86_64"), - not(libc_packedN) - ), repr(packed))] + #[cfg_attr(any( + target_arch = "x86", target_arch = "x86_64"), + repr(packed(4)) + )] pub struct epoll_event { pub events: u32, pub u64: u64, @@ -518,9 +514,9 @@ s_no_extra_traits! { pub struct fd_set { #[cfg(target_pointer_width = "64")] - fds_bits: [i64; FD_SETSIZE / 64], + fds_bits: [i64; FD_SETSIZE as usize / 64], #[cfg(target_pointer_width = "32")] - fds_bits: [i32; FD_SETSIZE / 32], + fds_bits: [i32; FD_SETSIZE as usize / 32], } pub struct sockaddr_storage { @@ -530,7 +526,7 @@ s_no_extra_traits! { __ss_pad2: [u8; 240], } - #[cfg_attr(all(target_pointer_width = "64", libc_align), repr(align(8)))] + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] pub struct siginfo_t { pub si_signo: ::c_int, pub si_code: ::c_int, @@ -560,15 +556,13 @@ s_no_extra_traits! { __sigev_pad2: ::c_int, } - #[cfg(libc_union)] - #[cfg_attr(libc_align, repr(align(16)))] + #[repr(align(16))] pub union pad128_t { // 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)))] + #[repr(align(16))] pub union upad128_t { // pub _q in this structure would be a "long double", of 16 bytes pub _l: [u32; 4], @@ -936,7 +930,6 @@ cfg_if! { } } - #[cfg(libc_union)] impl PartialEq for pad128_t { fn eq(&self, other: &pad128_t) -> bool { unsafe { @@ -945,9 +938,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for pad128_t {} - #[cfg(libc_union)] impl ::fmt::Debug for pad128_t { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { @@ -958,7 +949,6 @@ cfg_if! { } } } - #[cfg(libc_union)] impl ::hash::Hash for pad128_t { fn hash(&self, state: &mut H) { unsafe { @@ -967,7 +957,6 @@ cfg_if! { } } } - #[cfg(libc_union)] impl PartialEq for upad128_t { fn eq(&self, other: &upad128_t) -> bool { unsafe { @@ -976,9 +965,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for upad128_t {} - #[cfg(libc_union)] impl ::fmt::Debug for upad128_t { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { @@ -989,7 +976,6 @@ cfg_if! { } } } - #[cfg(libc_union)] impl ::hash::Hash for upad128_t { fn hash(&self, state: &mut H) { unsafe { @@ -1250,9 +1236,9 @@ pub const IPV6_V6ONLY: ::c_int = 0x27; cfg_if! { if #[cfg(target_pointer_width = "64")] { - pub const FD_SETSIZE: usize = 65536; + pub const FD_SETSIZE: ::c_int = 65536; } else { - pub const FD_SETSIZE: usize = 1024; + pub const FD_SETSIZE: ::c_int = 1024; } } @@ -1279,6 +1265,7 @@ pub const FOPEN_MAX: ::c_uint = 20; pub const FILENAME_MAX: ::c_uint = 1024; pub const L_tmpnam: ::c_uint = 25; pub const TMP_MAX: ::c_uint = 17576; +pub const PIPE_BUF: ::c_int = 5120; pub const GRND_NONBLOCK: ::c_uint = 0x0001; pub const GRND_RANDOM: ::c_uint = 0x0002; @@ -1301,29 +1288,29 @@ pub const O_ACCMODE: ::c_int = 0x600003; pub const O_XATTR: ::c_int = 0x4000; pub const O_DIRECTORY: ::c_int = 0x1000000; pub const O_DIRECT: ::c_int = 0x2000000; -pub const S_IFIFO: mode_t = 4096; -pub const S_IFCHR: mode_t = 8192; -pub const S_IFBLK: mode_t = 24576; -pub const S_IFDIR: mode_t = 16384; -pub const S_IFREG: mode_t = 32768; -pub const S_IFLNK: mode_t = 40960; -pub const S_IFSOCK: mode_t = 49152; -pub const S_IFMT: mode_t = 61440; -pub const S_IEXEC: mode_t = 64; -pub const S_IWRITE: mode_t = 128; -pub const S_IREAD: mode_t = 256; -pub const S_IRWXU: mode_t = 448; -pub const S_IXUSR: mode_t = 64; -pub const S_IWUSR: mode_t = 128; -pub const S_IRUSR: mode_t = 256; -pub const S_IRWXG: mode_t = 56; -pub const S_IXGRP: mode_t = 8; -pub const S_IWGRP: mode_t = 16; -pub const S_IRGRP: mode_t = 32; -pub const S_IRWXO: mode_t = 7; -pub const S_IXOTH: mode_t = 1; -pub const S_IWOTH: mode_t = 2; -pub const S_IROTH: mode_t = 4; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IREAD: mode_t = 0o0400; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; pub const F_OK: ::c_int = 0; pub const R_OK: ::c_int = 4; pub const W_OK: ::c_int = 2; diff --git a/src/unix/solarish/solaris.rs b/src/unix/solarish/solaris.rs index 80bad281ea705..5ab67884f6a68 100644 --- a/src/unix/solarish/solaris.rs +++ b/src/unix/solarish/solaris.rs @@ -66,11 +66,7 @@ pub const F_DUP2FD_CLOEXEC: ::c_int = 48; pub const F_DUP2FD_CLOFORK: ::c_int = 50; extern "C" { - pub fn fexecve( - fd: ::c_int, - argv: *const *const ::c_char, - envp: *const *const ::c_char, - ) -> ::c_int; + pub fn fexecve(fd: ::c_int, argv: *const *mut ::c_char, envp: *const *mut ::c_char) -> ::c_int; pub fn mincore(addr: *const ::c_void, len: ::size_t, vec: *mut ::c_char) -> ::c_int; diff --git a/src/unix/solarish/x86_64.rs b/src/unix/solarish/x86_64.rs index bca552f378202..d0e80b5588c46 100644 --- a/src/unix/solarish/x86_64.rs +++ b/src/unix/solarish/x86_64.rs @@ -50,7 +50,6 @@ s! { } s_no_extra_traits! { - #[cfg(libc_union)] pub union __c_anonymous_fp_reg_set { pub fpchip_state: __c_anonymous_fpchip_state, pub f_fpregs: [[u32; 13]; 10], @@ -77,7 +76,6 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - #[cfg(libc_union)] impl PartialEq for __c_anonymous_fp_reg_set { fn eq(&self, other: &__c_anonymous_fp_reg_set) -> bool { unsafe { @@ -90,9 +88,7 @@ cfg_if! { } } } - #[cfg(libc_union)] impl Eq for __c_anonymous_fp_reg_set {} - #[cfg(libc_union)] impl ::fmt::Debug for __c_anonymous_fp_reg_set { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { unsafe { diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 43afbc3e2c23d..def1cccfa58ce 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -91,6 +91,7 @@ pub type SEM_ID_KERNEL = ::OBJ_HANDLE; pub type RTP_ID = ::OBJ_HANDLE; pub type SD_ID = ::OBJ_HANDLE; pub type CONDVAR_ID = ::OBJ_HANDLE; +pub type STATUS = ::OBJ_HANDLE; // From vxTypes.h pub type _Vx_usr_arg_t = isize; @@ -613,6 +614,7 @@ pub const PTHREAD_STACK_MIN: usize = 4096; pub const _PTHREAD_SHARED_SEM_NAME_MAX: usize = 30; // ERRNO STUFF +pub const ERROR: ::c_int = -1; pub const OK: ::c_int = 0; pub const EPERM: ::c_int = 1; /* Not owner */ pub const ENOENT: ::c_int = 2; /* No such file or directory */ @@ -720,6 +722,33 @@ pub const S_nfsLib_NFSERR_SERVERFAULT: ::c_int = EIO; pub const S_nfsLib_NFSERR_BADTYPE: ::c_int = M_nfsStat | nfsstat::NFSERR_BADTYPE as ::c_int; pub const S_nfsLib_NFSERR_JUKEBOX: ::c_int = M_nfsStat | nfsstat::NFSERR_JUKEBOX as ::c_int; +// internal offset values for below constants +const taskErrorBase: ::c_int = 0x00030000; +const semErrorBase: ::c_int = 0x00160000; +const objErrorBase: ::c_int = 0x003d0000; + +// taskLibCommon.h +pub const S_taskLib_NAME_NOT_FOUND: ::c_int = taskErrorBase + 0x0065; +pub const S_taskLib_TASK_HOOK_TABLE_FULL: ::c_int = taskErrorBase + 0x0066; +pub const S_taskLib_TASK_HOOK_NOT_FOUND: ::c_int = taskErrorBase + 0x0067; +pub const S_taskLib_ILLEGAL_PRIORITY: ::c_int = taskErrorBase + 0x0068; + +// FIXME: could also be useful for TASK_DESC type +pub const VX_TASK_NAME_LENGTH: ::c_int = 31; + +// semLibCommon.h +pub const S_semLib_INVALID_STATE: ::c_int = semErrorBase + 0x0065; +pub const S_semLib_INVALID_OPTION: ::c_int = semErrorBase + 0x0066; +pub const S_semLib_INVALID_QUEUE_TYPE: ::c_int = semErrorBase + 0x0067; +pub const S_semLib_INVALID_OPERATION: ::c_int = semErrorBase + 0x0068; + +// objLibCommon.h +pub const S_objLib_OBJ_ID_ERROR: ::c_int = objErrorBase + 0x0001; +pub const S_objLib_OBJ_UNAVAILABLE: ::c_int = objErrorBase + 0x0002; +pub const S_objLib_OBJ_DELETED: ::c_int = objErrorBase + 0x0003; +pub const S_objLib_OBJ_TIMEOUT: ::c_int = objErrorBase + 0x0004; +pub const S_objLib_OBJ_NO_METHOD: ::c_int = objErrorBase + 0x0005; + // in.h pub const IPPROTO_IP: ::c_int = 0; pub const IPPROTO_IPV6: ::c_int = 41; @@ -741,33 +770,35 @@ pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12; pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13; // STAT Stuff -pub const S_IFMT: ::c_int = 0xf000; -pub const S_IFIFO: ::c_int = 0x1000; -pub const S_IFCHR: ::c_int = 0x2000; -pub const S_IFDIR: ::c_int = 0x4000; -pub const S_IFBLK: ::c_int = 0x6000; -pub const S_IFREG: ::c_int = 0x8000; -pub const S_IFLNK: ::c_int = 0xa000; -pub const S_IFSHM: ::c_int = 0xb000; -pub const S_IFSOCK: ::c_int = 0xc000; -pub const S_ISUID: ::c_int = 0x0800; -pub const S_ISGID: ::c_int = 0x0400; -pub const S_ISTXT: ::c_int = 0x0200; -pub const S_IRUSR: ::c_int = 0x0100; -pub const S_IWUSR: ::c_int = 0x0080; -pub const S_IXUSR: ::c_int = 0x0040; -pub const S_IRWXU: ::c_int = 0x01c0; -pub const S_IRGRP: ::c_int = 0x0020; -pub const S_IWGRP: ::c_int = 0x0010; -pub const S_IXGRP: ::c_int = 0x0008; -pub const S_IRWXG: ::c_int = 0x0038; -pub const S_IROTH: ::c_int = 0x0004; -pub const S_IWOTH: ::c_int = 0x0002; -pub const S_IXOTH: ::c_int = 0x0001; -pub const S_IRWXO: ::c_int = 0x0007; +pub const S_IFMT: ::c_int = 0o17_0000; +pub const S_IFIFO: ::c_int = 0o1_0000; +pub const S_IFCHR: ::c_int = 0o2_0000; +pub const S_IFDIR: ::c_int = 0o4_0000; +pub const S_IFBLK: ::c_int = 0o6_0000; +pub const S_IFREG: ::c_int = 0o10_0000; +pub const S_IFLNK: ::c_int = 0o12_0000; +pub const S_IFSHM: ::c_int = 0o13_0000; +pub const S_IFSOCK: ::c_int = 0o14_0000; +pub const S_ISUID: ::c_int = 0o4000; +pub const S_ISGID: ::c_int = 0o2000; +pub const S_ISTXT: ::c_int = 0o1000; +pub const S_ISVTX: mode_t = 0o1000; +pub const S_IRUSR: ::c_int = 0o0400; +pub const S_IWUSR: ::c_int = 0o0200; +pub const S_IXUSR: ::c_int = 0o0100; +pub const S_IRWXU: ::c_int = 0o0700; +pub const S_IRGRP: ::c_int = 0o0040; +pub const S_IWGRP: ::c_int = 0o0020; +pub const S_IXGRP: ::c_int = 0o0010; +pub const S_IRWXG: ::c_int = 0o0070; +pub const S_IROTH: ::c_int = 0o0004; +pub const S_IWOTH: ::c_int = 0o0002; +pub const S_IXOTH: ::c_int = 0o0001; +pub const S_IRWXO: ::c_int = 0o0007; // socket.h pub const SOL_SOCKET: ::c_int = 0xffff; +pub const SOMAXCONN: ::c_int = 128; pub const SO_DEBUG: ::c_int = 0x0001; pub const SO_REUSEADDR: ::c_int = 0x0004; @@ -1867,11 +1898,16 @@ safe_f! { } } -pub fn pread(_fd: ::c_int, _buf: *mut ::c_void, _count: ::size_t, _offset: off64_t) -> ::ssize_t { +pub unsafe fn pread( + _fd: ::c_int, + _buf: *mut ::c_void, + _count: ::size_t, + _offset: off64_t, +) -> ::ssize_t { -1 } -pub fn pwrite( +pub unsafe fn pwrite( _fd: ::c_int, _buf: *const ::c_void, _count: ::size_t, @@ -1879,7 +1915,12 @@ pub fn pwrite( ) -> ::ssize_t { -1 } -pub fn posix_memalign(memptr: *mut *mut ::c_void, align: ::size_t, size: ::size_t) -> ::c_int { + +pub unsafe fn posix_memalign( + memptr: *mut *mut ::c_void, + align: ::size_t, + size: ::size_t, +) -> ::c_int { // check to see if align is a power of 2 and if align is a multiple // of sizeof(void *) if (align & align - 1 != 0) || (align as usize % size_of::<::size_t>() != 0) { @@ -1902,25 +1943,7 @@ pub fn posix_memalign(memptr: *mut *mut ::c_void, align: ::size_t, size: ::size_ } } -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, - } - } -} +pub use ffi::c_void; cfg_if! { if #[cfg(target_arch = "aarch64")] { diff --git a/src/wasi.rs b/src/wasi.rs index ae490bf94d7a2..6b8177aa86cb2 100644 --- a/src/wasi.rs +++ b/src/wasi.rs @@ -1,3 +1,6 @@ +// [wasi-libc](https://github.com/WebAssembly/wasi-libc) definitions. +// `wasi-libc` project provides multiple libraries including emulated features, but we list only basic features with `libc.a` here. + use super::{Send, Sync}; pub use ffi::c_void; @@ -207,7 +210,7 @@ pub const F_SETFD: c_int = 2; pub const F_GETFL: c_int = 3; pub const F_SETFL: c_int = 4; pub const FD_CLOEXEC: c_int = 1; -pub const FD_SETSIZE: size_t = 1024; +pub const FD_SETSIZE: c_int = 1024; pub const O_APPEND: c_int = 0x0001; pub const O_DSYNC: c_int = 0x0002; pub const O_NONBLOCK: c_int = 0x0004; @@ -239,29 +242,29 @@ pub const AT_SYMLINK_FOLLOW: c_int = 0x2; pub const AT_REMOVEDIR: c_int = 0x4; pub const UTIME_OMIT: c_long = 0xfffffffe; pub const UTIME_NOW: c_long = 0xffffffff; -pub const S_IFIFO: mode_t = 49152; -pub const S_IFCHR: mode_t = 8192; -pub const S_IFBLK: mode_t = 24576; -pub const S_IFDIR: mode_t = 16384; -pub const S_IFREG: mode_t = 32768; -pub const S_IFLNK: mode_t = 40960; -pub const S_IFSOCK: mode_t = 49152; -pub const S_IFMT: mode_t = 57344; -pub const S_IRWXO: mode_t = 0x7; -pub const S_IXOTH: mode_t = 0x1; -pub const S_IWOTH: mode_t = 0x2; -pub const S_IROTH: mode_t = 0x4; -pub const S_IRWXG: mode_t = 0x38; -pub const S_IXGRP: mode_t = 0x8; -pub const S_IWGRP: mode_t = 0x10; -pub const S_IRGRP: mode_t = 0x20; -pub const S_IRWXU: mode_t = 0x1c0; -pub const S_IXUSR: mode_t = 0x40; -pub const S_IWUSR: mode_t = 0x80; -pub const S_IRUSR: mode_t = 0x100; -pub const S_ISVTX: mode_t = 0x200; -pub const S_ISGID: mode_t = 0x400; -pub const S_ISUID: mode_t = 0x800; +pub const S_IFIFO: mode_t = 0o14_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o16_0000; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_ISVTX: mode_t = 0o1000; +pub const S_ISGID: mode_t = 0o2000; +pub const S_ISUID: mode_t = 0o4000; pub const DT_UNKNOWN: u8 = 0; pub const DT_BLK: u8 = 1; pub const DT_CHR: u8 = 2; @@ -366,10 +369,15 @@ 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; +// unsafe code here is required in the stable, but not in nightly +#[allow(unused_unsafe)] pub static CLOCK_MONOTONIC: clockid_t = unsafe { clockid_t(ptr_addr_of!(_CLOCK_MONOTONIC)) }; +#[allow(unused_unsafe)] pub static CLOCK_PROCESS_CPUTIME_ID: clockid_t = unsafe { clockid_t(ptr_addr_of!(_CLOCK_PROCESS_CPUTIME_ID)) }; +#[allow(unused_unsafe)] pub static CLOCK_REALTIME: clockid_t = unsafe { clockid_t(ptr_addr_of!(_CLOCK_REALTIME)) }; +#[allow(unused_unsafe)] pub static CLOCK_THREAD_CPUTIME_ID: clockid_t = unsafe { clockid_t(ptr_addr_of!(_CLOCK_THREAD_CPUTIME_ID)) }; diff --git a/src/windows/gnu/mod.rs b/src/windows/gnu/mod.rs index 3e7d38b8e83c6..8923a531e7512 100644 --- a/src/windows/gnu/mod.rs +++ b/src/windows/gnu/mod.rs @@ -15,9 +15,5 @@ extern "C" { pub fn wmemchr(cx: *const ::wchar_t, c: ::wchar_t, n: ::size_t) -> *mut ::wchar_t; } -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} +mod align; +pub use self::align::*; diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 196f1f2e4b743..8fcdfbede0866 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -140,13 +140,13 @@ pub const _O_OBTAIN_DIR: ::c_int = 0x2000; pub const O_SEQUENTIAL: ::c_int = 0x0020; pub const O_RANDOM: ::c_int = 0x0010; -pub const S_IFCHR: ::c_int = 8192; -pub const S_IFDIR: ::c_int = 16384; -pub const S_IFREG: ::c_int = 32768; -pub const S_IFMT: ::c_int = 61440; -pub const S_IEXEC: ::c_int = 64; -pub const S_IWRITE: ::c_int = 128; -pub const S_IREAD: ::c_int = 256; +pub const S_IFCHR: ::c_int = 0o2_0000; +pub const S_IFDIR: ::c_int = 0o4_0000; +pub const S_IFREG: ::c_int = 0o10_0000; +pub const S_IFMT: ::c_int = 0o17_0000; +pub const S_IEXEC: ::c_int = 0o0100; +pub const S_IWRITE: ::c_int = 0o0200; +pub const S_IREAD: ::c_int = 0o0400; pub const LC_ALL: ::c_int = 0; pub const LC_COLLATE: ::c_int = 1; @@ -254,12 +254,6 @@ pub const SIG_GET: ::sighandler_t = 2; pub const SIG_SGE: ::sighandler_t = 3; pub const SIG_ACK: ::sighandler_t = 4; -// inline comment below appeases style checker -#[cfg(all(target_env = "msvc", feature = "rustc-dep-of-std"))] // " if " -#[link(name = "msvcrt", cfg(not(target_feature = "crt-static")))] -#[link(name = "libcmt", cfg(target_feature = "crt-static"))] -extern "C" {} - #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum FILE {} impl ::Copy for FILE {} @@ -460,15 +454,15 @@ extern "C" { prog: *const c_char, argv: *const *const c_char, envp: *const *const c_char, - ) -> ::c_int; + ) -> ::intptr_t; #[link_name = "_execvp"] - pub fn execvp(c: *const c_char, argv: *const *const c_char) -> ::c_int; + pub fn execvp(c: *const c_char, argv: *const *const c_char) -> ::intptr_t; #[link_name = "_execvpe"] pub fn execvpe( c: *const c_char, argv: *const *const c_char, envp: *const *const c_char, - ) -> ::c_int; + ) -> ::intptr_t; #[link_name = "_wexecv"] pub fn wexecv(prog: *const wchar_t, argv: *const *const wchar_t) -> ::intptr_t; #[link_name = "_wexecve"] @@ -518,6 +512,9 @@ extern "C" { pub fn aligned_malloc(size: size_t, alignment: size_t) -> *mut c_void; #[link_name = "_aligned_free"] pub fn aligned_free(ptr: *mut ::c_void); + #[link_name = "_aligned_realloc"] + pub fn aligned_realloc(memblock: *mut ::c_void, size: size_t, alignment: size_t) + -> *mut c_void; #[link_name = "_putenv"] pub fn putenv(envstring: *const ::c_char) -> ::c_int; #[link_name = "_wputenv"] @@ -568,25 +565,7 @@ extern "system" { pub fn socket(af: ::c_int, socket_type: ::c_int, protocol: ::c_int) -> SOCKET; } -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, - } - } -} +pub use ffi::c_void; cfg_if! { if #[cfg(all(target_env = "gnu"))] { diff --git a/src/xous.rs b/src/xous.rs index e6c0c2573d07d..6731a94e20df7 100644 --- a/src/xous.rs +++ b/src/xous.rs @@ -28,22 +28,4 @@ pub type wchar_t = u32; pub const INT_MIN: c_int = -2147483648; pub const INT_MAX: c_int = 2147483647; -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, - } - } -} +pub use ffi::c_void; diff --git a/triagebot.toml b/triagebot.toml index 8b989c8db5058..1fa350bf74cdd 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -1,6 +1,6 @@ [relabel] allow-unauthenticated = [ - "C-*", "O-*", "S-*" + "C-*", "O-*", "S-*", "stable-nominated" ] [autolabel."S-waiting-on-review"]