diff --git a/.github/renovate.json5 b/.github/renovate.json5 index 6ce8de556d5b4..0f92d975a3152 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -5,30 +5,41 @@ ":maintainLockFilesMonthly", "helpers:pinGitHubActionDigestsToSemver" ], + baseBranchPatterns: ["main", "libc-0.2"], + lockFileMaintenance: { + enabled: true, + // Every other Monday. Renovate requires a range, hence `* *` rather + // than `0 0`. + schedule: ["* * 1-7,15-21 * 1"] + }, packageRules: [ { - matchCategories: [ - "rust" - ], - matchJsonata: [ - "isBreaking != true" - ], + matchCategories: ["rust"], + matchJsonata: ["isBreaking != true"], // Disable non-breaking change updates because they // are updated periodically with lockfile maintainance. enabled: false, }, { - matchManagers: [ - "github-actions" - ], + matchCategories: ["rust"], + // Separate PRs against main and 0.2 + addLabels: ["stable-declined"], + }, + { + matchManagers: ["github-actions"], // Every month schedule: "* 0 1 * *", groupName: "Github Actions", + // Separate PRs against main and 0.2 + addLabels: ["stable-declined"], }, { // Don't updates such as 23.10 -> mantic-20240530 - "matchDatasources": ["docker"], - "pinDigests": false + matchDatasources: ["docker"], + // Only on main, we backport these + matchBaseBranches: ["main"], + addLabels: ["stable-nominated"], + pinDigests: false } ], // Receive any update that fixes security vulnerabilities. diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 93e39e7fa806e..586b3665eec73 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -135,6 +135,7 @@ jobs: os: ubuntu-26.04-arm - target: i686-pc-windows-msvc os: windows-2025 + host: x86_64-pc-windows-msvc # Tier 1 without host tools - target: i686-unknown-linux-gnu - target: x86_64-pc-windows-gnu os: windows-2025 @@ -144,6 +145,7 @@ jobs: runs-on: ${{ matrix.os && matrix.os || 'ubuntu-26.04' }} timeout-minutes: 25 env: + RUST_HOST: ${{ matrix.host }} TARGET: ${{ matrix.target }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -237,7 +239,7 @@ jobs: - target: x86_64-unknown-linux-musl env: { TEST_MUSL_V1_2: 1 } artifact-tag: new-musl - # FIXME: It seems some items in `src/unix/mod.rs` aren't defined on redox actually. + # FIXME: https://github.com/rust-lang/libc/issues/5520 # - target: x86_64-unknown-redox # FIXME(ppc): SIGILL running tests, see diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a4f3b18e729fa..1425c1e5f7f2e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -132,6 +132,7 @@ Common sources include: (original) * Illumos: (official mirror), (original) +* L4RE: (original) * Linux uapi: (official mirror), (original) * Musl: (unofficial mirror), @@ -141,6 +142,8 @@ Common sources include: * OpenBSD: (official mirror), (original) * RedoxOS: +* Uclibc: (mirror), + (original) * Windows GNU: (unofficial mirror), (original) * Windows MSVC: @@ -171,19 +174,7 @@ are preferred because they become part of history.) Including links to manpages is not required but can also be very helpful to include. Some platforms also publish manpages but not sources. -Common web manuals: - -* AIX: -* Apple: - is the only known official site but it is severly outdated. - or are better options. -* DragonFlyBSD: -* FreeBSD: -* Illumos: -* NetBSD: -* OpenBSD: -* Solaris: -* Windows MSVC: +See documentation in `src/lib.rs` for links to online manuals. ## Breaking change policy diff --git a/Cargo.toml b/Cargo.toml index afc199db5a633..e0629f11f7bf2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,16 +24,18 @@ default-target = "x86_64-unknown-linux-gnu" targets = [ # Note: Keep this in sync with ci/verify-build.py # - # Tier 1 + # Tier 1 with host tools "aarch64-apple-darwin", "aarch64-pc-windows-msvc", "aarch64-unknown-linux-gnu", - "i686-pc-windows-msvc", "i686-unknown-linux-gnu", "x86_64-pc-windows-gnu", "x86_64-pc-windows-msvc", "x86_64-unknown-linux-gnu", # + # Tier 1 without host tools + "i686-pc-windows-msvc", + # # Tier 2 with host tools "aarch64-pc-windows-gnullvm", "aarch64-unknown-linux-musl", diff --git a/build.rs b/build.rs index 28467e7da033f..b3df76b41eda9 100644 --- a/build.rs +++ b/build.rs @@ -7,41 +7,103 @@ use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering::Relaxed; use std::{ env, + fmt, str, }; -// 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 -// make sure to add it to this list as well. -const ALLOWED_CFGS: &[&str] = &[ - "emscripten_old_stat_abi", - // Should be enabled by users if esp-idf (>=6.0) is build with picolibc instead of newlib. - "espidf_picolibc", - "espidf_time32", - "freebsd10", - "freebsd11", - "freebsd12", - "freebsd13", - "freebsd14", - "freebsd15", - // Corresponds to `_FILE_OFFSET_BITS=64` in glibc - "gnu_file_offset_bits64", - // Corresponds to `_TIME_BITS=64` in glibc. Also used in x86 Windows with - // GNU to expose a 64-bit `time_t`. - "gnu_time_bits64", - "libc_deny_warnings", - "libc_elfv2", - // Corresponds to `__USE_TIME_BITS64` in UAPI - "linux_time_bits64", - "musl_v1_2", - // musl v1.2.0+ && 32-bit: time_t is i64, struct layouts change - "musl32_time64", - // Corresponds to `_REDIR_TIME64` in musl: symbol redirects to __*_time64 - "musl_redir_time64", - "vxworks_lt_25_09", - "libc_pauthtest", +/// All possible cfgs that may be set. Used for check-cfg as well as self checks. +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +enum Cfg { + LibcDenyWarnings, + /// MSRV-friendly version of `target_abi = "elfv2"`. + LibcElfv2, + /// MSRV-friendly version of `target_abi = "pauthtest"`. + LibcPauthtest, + + EmscriptenOldStatAbi, + + /// Should be enabled by users if esp-idf (>=6.0) is build with picolibc instead of newlib. Not + /// set by `libc` itself. + EspidfPicolibc, + /// Not set by `libc` itself. + EspidfTime32, + + Freebsd10, + Freebsd11, + Freebsd12, + Freebsd13, + Freebsd14, + Freebsd15, + + VxworksLt25_09, + + /// Corresponds to `__USE_TIME_BITS64` in UAPI. Implies 32-bit Linux target. + LinuxTimeBits64, + /// Corresponds to `_FILE_OFFSET_BITS=64` in glibc. Implies 32-bit GNU target. + GnuFileOffsetBits64, + /// Corresponds to `_TIME_BITS=64` in glibc. Also used in x86 Windows with GNU to expose a + /// 64-bit `time_t`. Implies 32-bit GNU target and, on platforms other than Windows, 64-bit + /// `off_t`. + GnuTimeBits64, + /// Musl 1.2+. Implies `target_env = "musl"` + MuslV1_2, + /// musl v1.2.0+ && 32-bit: time_t is i64, struct layouts change. Implies `musl_v1_2` and + /// 32-bit arch. + Musl32Time64, + /// Corresponds to `_REDIR_TIME64` in musl, i.e. 32-bit platforms that existed prior to the + /// transition to 64-bit `time_t` and thus need `__*_time64` redirects. Implies `musl_v1_2` + /// and 32-bit arch. + MuslRedirTime64, +} + +const ALLOWED_CFGS: &[Cfg] = &[ + Cfg::LibcDenyWarnings, + Cfg::EmscriptenOldStatAbi, + Cfg::EspidfPicolibc, + Cfg::EspidfTime32, + Cfg::Freebsd10, + Cfg::Freebsd11, + Cfg::Freebsd12, + Cfg::Freebsd13, + Cfg::Freebsd14, + Cfg::Freebsd15, + Cfg::LibcElfv2, + Cfg::VxworksLt25_09, + Cfg::LibcPauthtest, + Cfg::GnuFileOffsetBits64, + Cfg::GnuTimeBits64, + Cfg::LinuxTimeBits64, + Cfg::MuslV1_2, + Cfg::Musl32Time64, + Cfg::MuslRedirTime64, ]; +impl fmt::Display for Cfg { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(match self { + Cfg::LibcDenyWarnings => "libc_deny_warnings", + Cfg::EmscriptenOldStatAbi => "emscripten_old_stat_abi", + Cfg::EspidfPicolibc => "espidf_picolibc", + Cfg::EspidfTime32 => "espidf_time32", + Cfg::Freebsd10 => "freebsd10", + Cfg::Freebsd11 => "freebsd11", + Cfg::Freebsd12 => "freebsd12", + Cfg::Freebsd13 => "freebsd13", + Cfg::Freebsd14 => "freebsd14", + Cfg::Freebsd15 => "freebsd15", + Cfg::LibcElfv2 => "libc_elfv2", + Cfg::VxworksLt25_09 => "vxworks_lt_25_09", + Cfg::LibcPauthtest => "libc_pauthtest", + Cfg::GnuFileOffsetBits64 => "gnu_file_offset_bits64", + Cfg::GnuTimeBits64 => "gnu_time_bits64", + Cfg::LinuxTimeBits64 => "linux_time_bits64", + Cfg::MuslV1_2 => "musl_v1_2", + Cfg::Musl32Time64 => "musl32_time64", + Cfg::MuslRedirTime64 => "musl_redir_time64", + }) + } +} + // Extra values to allow for check-cfg. const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[ ( @@ -61,10 +123,6 @@ const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[ ), ]; -/// Musl architectures that define `_REDIR_TIME64` (i.e. those that transitioned -/// from 32-bit to 64-bit `time_t` and need `__*_time64` symbol redirects). -const MUSL_REDIR_TIME64_ARCHES: &[&str] = &["arm", "mips", "powerpc", "x86"]; - /// Read from env, print more debug output via `cargo:warning` if set. static VERBOSE_BUILD: AtomicBool = AtomicBool::new(false); @@ -86,6 +144,8 @@ fn main() { VERBOSE_BUILD.store(true, Relaxed); } + let mut cfgs = Vec::new(); + let (rustc_minor_ver, _is_nightly) = rustc_minor_nightly(); let libc_ci = env_flag("LIBC_CI"); let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default(); @@ -98,10 +158,10 @@ fn main() { // of translating its values. `target_abi` cannot be used directly in cfg // expressions on the current MSRV. if target_abi == "elfv2" { - set_cfg("libc_elfv2"); + cfgs.push(Cfg::LibcElfv2); } if target_abi == "pauthtest" { - set_cfg("libc_pauthtest"); + cfgs.push(Cfg::LibcPauthtest); } // FIXME: this can be removed in 1-2 releases @@ -113,134 +173,150 @@ fn main() { ); } - // 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 12. - // - // On CI, we detect the actual FreeBSD version and match its ABI exactly, - // running tests to ensure that the ABI is correct. - // Allow overriding the default version for testing - let which_freebsd = if let Ok(version) = env::var("CARGO_CFG_LIBC_UNSTABLE_FREEBSD_VERSION") { - let vers = version.parse().unwrap(); - println!("cargo:warning=setting FreeBSD version to {vers}"); - vers - } else if libc_ci { - which_freebsd().unwrap_or(12) - } else { - 12 - }; + if target_os == "freebsd" { + // 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 12. + // + // On CI, we detect the actual FreeBSD version and match its ABI exactly, + // running tests to ensure that the ABI is correct. + // Allow overriding the default version for testing + let which_freebsd = if let Ok(version) = env::var("CARGO_CFG_LIBC_UNSTABLE_FREEBSD_VERSION") + { + let vers = version.parse().unwrap(); + println!("cargo:warning=setting FreeBSD version to {vers}"); + vers + } else if libc_ci { + which_freebsd().unwrap_or(12) + } else { + 12 // regardless of CARGO_FEATURE_RUSTC_DEP_OF_STD env var + }; - 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 which_freebsd { + x if x < 10 => panic!("FreeBSD older than 10 is not supported"), + 10 => cfgs.push(Cfg::Freebsd10), + 11 => cfgs.push(Cfg::Freebsd11), + 12 => cfgs.push(Cfg::Freebsd12), + 13 => cfgs.push(Cfg::Freebsd13), + 14 => cfgs.push(Cfg::Freebsd14), + _ => cfgs.push(Cfg::Freebsd15), + } } - match emcc_version_code() { - Some(v) if (v < 30142) => set_cfg("emscripten_old_stat_abi"), - // Non-Emscripten or version >= 3.1.42. - _ => (), + if target_os == "emscripten" { + match emcc_version_code() { + Some(v) if (v < 30142) => cfgs.push(Cfg::EmscriptenOldStatAbi), + // Non-Emscripten or version >= 3.1.42. + _ => (), + } } - match vxworks_version_code() { - Some(v) if (v < (25, 9)) => set_cfg("vxworks_lt_25_09"), - // VxWorks version >= 25.09 - _ => (), + if target_os == "vxworks" { + match vxworks_version_code() { + Some(v) if (v < (25, 9)) => cfgs.push(Cfg::VxworksLt25_09), + // VxWorks version >= 25.09 + _ => (), + } } - let mut musl_v1_2 = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2"); - if let Ok(old_musl_v1_2_3) = env::var("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3") { - println!( - "cargo:warning=`--cfg=libc_unstable_musl_v1_2_3` will be removed; \ - set `--cfg=libc_unstable_musl_v1_2`instead" - ); - musl_v1_2 |= old_musl_v1_2_3 != "0"; + let mut musl_v1_2_env = env_flag("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2"); + if let Ok(old_musl_v1_2_3_env) = env::var("CARGO_CFG_LIBC_UNSTABLE_MUSL_V1_2_3") { + if !musl_v1_2_env { + println!( + "cargo:warning=`--cfg=libc_unstable_musl_v1_2_3` will be removed; \ + set `--cfg=libc_unstable_musl_v1_2`instead" + ); + } + musl_v1_2_env |= old_musl_v1_2_3_env != "0"; } - if let Ok(old_musl_v1_2_3) = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3") { - println!( - "cargo:warning=RUST_LIBC_UNSTABLE_MUSL_V1_2_3 will be removed; \ - set `--cfg=libc_unstable_musl_v1_2` via RUSTFLAGS instead" - ); - musl_v1_2 |= old_musl_v1_2_3 != "0"; + if let Ok(old_musl_v1_2_3_env) = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3") { + if !musl_v1_2_env { + println!( + "cargo:warning=RUST_LIBC_UNSTABLE_MUSL_V1_2_3 will be removed; \ + set `--cfg=libc_unstable_musl_v1_2` via RUSTFLAGS instead" + ); + } + musl_v1_2_env |= old_musl_v1_2_3_env != "0"; } - // OpenHarmony uses a fork of the musl libc - let musl = target_env == "musl" || target_env == "ohos"; - - // loongarch64, hexagon, ohos and pauthtest only exist with recent musl - if target_arch == "loongarch64" + // Targets that only exist with recent musl. 32-bit targets not in this list need + // `_REDIR_TIME64` for 64-bit `time_t`. + let only_v1_2_on_musl = target_arch == "loongarch64" || target_arch == "hexagon" + || target_arch == "riscv32" || target_env == "ohos" - || target_abi == "pauthtest" - { - musl_v1_2 = true; - } + || target_abi == "pauthtest"; - if musl && musl_v1_2 { - set_cfg("musl_v1_2"); + // OpenHarmony uses a fork of the musl libc + let musl = target_env == "musl" || target_env == "ohos"; + let musl_v1_2 = musl && (musl_v1_2_env || only_v1_2_on_musl); + + if musl_v1_2 { + cfgs.push(Cfg::MuslV1_2); if target_ptr_width == "32" { - set_cfg("musl32_time64"); - set_cfg("linux_time_bits64"); - } - if MUSL_REDIR_TIME64_ARCHES.contains(&target_arch.as_str()) { - set_cfg("musl_redir_time64"); + cfgs.push(Cfg::Musl32Time64); + cfgs.push(Cfg::LinuxTimeBits64); + if !only_v1_2_on_musl { + // Older 32-bit arches need the redirects + cfgs.push(Cfg::MuslRedirTime64); + } } } - let uclibc_use_time64 = env_flag("CARGO_CFG_LIBC_UNSTABLE_UCLIBC_TIME64"); - if target_env == "uclibc" && uclibc_use_time64 { - set_cfg("linux_time_bits64"); + let uclibc_time64_env = env_flag("CARGO_CFG_LIBC_UNSTABLE_UCLIBC_TIME64"); + let uclibc_time64 = target_env == "uclibc" && uclibc_time64_env; + if uclibc_time64 { + cfgs.push(Cfg::LinuxTimeBits64); } - if target_env == "gnu" - && matches!(target_os.as_str(), "linux" | "windows" | "hurd") - && target_ptr_width == "32" - && target_arch != "riscv32" - && target_arch != "x86_64" - { - let defaultbits = "32"; + let mut gnu_tb_env = env::var("CARGO_CFG_LIBC_UNSTABLE_GNU_TIME_BITS"); - let mut tb_env = env::var("CARGO_CFG_LIBC_UNSTABLE_GNU_TIME_BITS"); + // FIXME: remove these fallbacks in a few releases + if let Ok(old_gnu_tb_env) = env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS") { + println!( + "cargo:warning=RUST_LIBC_UNSTABLE_GNU_TIME_BITS will be removed; \ + set `--cfg=libc_unstable_gnu_time_bits=\"...\"` via RUSTFLAGS instead" + ); + gnu_tb_env = gnu_tb_env.or(Ok(old_gnu_tb_env)); + } + if env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS").is_ok() + || env::var("CARGO_CFG_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS").is_ok() + { + println!( + "cargo:warning=glibc file offset can no longer be set independently of \ + `gnu_time_bits`" + ); + } - // FIXME: remove these fallbacks in a few releases - if let Ok(old_tb_env) = env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS") { - println!( - "cargo:warning=RUST_LIBC_UNSTABLE_GNU_TIME_BITS will be removed; \ - set `--cfg=libc_unstable_gnu_time_bits=\"...\"` via RUSTFLAGS instead" - ); - tb_env = tb_env.or(Ok(old_tb_env)); - } - if env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS").is_ok() - || env::var("CARGO_CFG_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS").is_ok() - { - println!( - "cargo:warning=glibc file offset can no longer be set independently of \ - `gnu_time_bits`" - ); + let gnu32_timebits = match gnu_tb_env.as_deref() { + Err(_) => "32", // default to 32 + Ok(tb) if tb == "64" => tb, + Ok(tb) if tb == "32" => tb, + Ok(_) => { + panic!("Invalid value for libc_unstable_gnu_time_bits. Must be 32, 64, or unset.") } + }; - let timebits = match tb_env.as_deref() { - Err(_) => defaultbits, - Ok(tb) if tb == "64" => tb, - Ok(tb) if tb == "32" => tb, - Ok(_) => { - panic!("Invalid value for libc_unstable_gnu_time_bits. Must be 32, 64, or unset.") - } - }; - - if timebits == "64" { - set_cfg("linux_time_bits64"); - set_cfg("gnu_file_offset_bits64"); - set_cfg("gnu_time_bits64"); + // 32-bit arches with 64-bit time_t by default. rv32 is 64-only, `x86_64` covers the x32 arch, + // `!(linux|windows|hurd)` covers vxworks and future platforms. + let gnu32_already_time64 = target_arch == "riscv32" + || target_arch == "x86_64" + || !matches!(target_os.as_str(), "linux" | "windows" | "hurd"); + let gnu = target_env == "gnu"; + let gnu32_time64 = gnu && target_ptr_width == "32" && gnu32_timebits == "64"; + + if gnu32_time64 && !gnu32_already_time64 { + // These configs all set up nonstandard options. They are not needed on platforms like + // riscv32, where 64-bit `time_t` is the default. + if target_os == "linux" { + cfgs.push(Cfg::LinuxTimeBits64); } + cfgs.push(Cfg::GnuFileOffsetBits64); + cfgs.push(Cfg::GnuTimeBits64); } // On CI: deny all warnings if libc_ci { - set_cfg("libc_deny_warnings"); + cfgs.push(Cfg::LibcDenyWarnings); } // Since Rust 1.80, configuration that isn't recognized by default needs to be provided to @@ -254,6 +330,14 @@ fn main() { println!("cargo:rustc-check-cfg=cfg({name},values(\"{values}\"))"); } } + + cfgs.sort_unstable(); + cfgs.dedup(); + validate_cfg(&cfgs, &target_env, &target_os, &target_ptr_width); + + for cfg in cfgs { + set_cfg(cfg); + } } /// Run `rustc --version` and capture the output, adjusting arguments as needed if `clippy-driver` @@ -334,6 +418,84 @@ fn rustc_minor_nightly() -> (u32, bool) { (minor, nightly) } +/// Check that our list of cfg makes sense for the current target. +fn validate_cfg(list: &[Cfg], target_env: &str, target_os: &str, target_ptr_width: &str) { + for cfg in list { + match cfg { + Cfg::LibcDenyWarnings => (), + Cfg::LibcElfv2 => (), + Cfg::LibcPauthtest => (), + Cfg::EspidfPicolibc => (), + Cfg::EspidfTime32 => (), + + Cfg::EmscriptenOldStatAbi => { + assert_eq!( + target_os, "emscripten", + "{cfg:?} set on non-freebsd platform" + ); + } + + Cfg::Freebsd10 + | Cfg::Freebsd11 + | Cfg::Freebsd12 + | Cfg::Freebsd13 + | Cfg::Freebsd14 + | Cfg::Freebsd15 => { + assert_eq!(target_os, "freebsd", "{cfg:?} set on non-freebsd platform"); + } + + Cfg::VxworksLt25_09 => { + assert_eq!(target_os, "vxworks", "{cfg:?} set on non-vxworks platform"); + } + + Cfg::GnuFileOffsetBits64 => { + assert_eq!(target_env, "gnu", "{cfg:?} set on non-gnu platform"); + assert_eq!(target_ptr_width, "32", "{cfg:?} set on non-32-bit platform"); + } + Cfg::GnuTimeBits64 => { + assert_eq!(target_env, "gnu", "{cfg:?} set on non-gnu platform"); + assert_eq!(target_ptr_width, "32", "{cfg:?} set on non-32-bit platform"); + assert!( + list.contains(&Cfg::GnuFileOffsetBits64), + "{cfg:?} set without 64-bit off_t" + ) + } + Cfg::LinuxTimeBits64 => { + assert_eq!(target_os, "linux", "{cfg:?} set on non-linux platform"); + assert_eq!(target_ptr_width, "32", "{cfg:?} set on non-32-bit platform"); + } + Cfg::MuslV1_2 => { + assert!( + matches!(target_env, "musl" | "ohos"), + "{cfg:?} set with env {target_env}" + ); + } + Cfg::Musl32Time64 => { + assert!( + matches!(target_env, "musl" | "ohos"), + "{cfg:?} set with env {target_env}" + ); + assert_eq!(target_ptr_width, "32", "{cfg:?} set on non-32-bit platform"); + assert!( + list.contains(&Cfg::MuslV1_2), + "{cfg:?} set on non-musl1.2 platform" + ) + } + Cfg::MuslRedirTime64 => { + assert!( + matches!(target_env, "musl" | "ohos"), + "{cfg:?} set with env {target_env}" + ); + assert_eq!(target_ptr_width, "32", "{cfg:?} set on non-32-bit platform"); + assert!( + list.contains(&Cfg::MuslV1_2), + "{cfg:?} set on non-musl1.2 platform" + ) + } + } + } +} + fn which_freebsd() -> Option { let output = Command::new("freebsd-version").output().ok()?; if !output.status.success() { @@ -392,11 +554,7 @@ fn vxworks_version_code() -> Option<(u32, u32)> { Some((major, minor)) } -fn set_cfg(cfg: &str) { - assert!( - ALLOWED_CFGS.contains(&cfg), - "trying to set cfg {cfg}, but it is not in ALLOWED_CFGS", - ); +fn set_cfg(cfg: Cfg) { println!("cargo:rustc-cfg={cfg}"); info!("setting config `{cfg}`"); } diff --git a/ci/docker/x86_64-unknown-redox/Dockerfile b/ci/docker/x86_64-unknown-redox/Dockerfile index 91b0cbabdc0b6..17e493bb2432b 100644 --- a/ci/docker/x86_64-unknown-redox/Dockerfile +++ b/ci/docker/x86_64-unknown-redox/Dockerfile @@ -2,7 +2,9 @@ FROM redoxos/redoxer RUN mv /root/.redoxer /.redoxer -ENV PATH=$PATH:/.redoxer/toolchain/bin:/rust/bin \ +RUN ln -sf /root/.redoxer ~/.redoxer + +ENV PATH=$PATH:$HOME/.redoxer/x86_64-unknown-redox/toolchain/bin \ AR_x86_64_unknown_redox="x86_64-unknown-redox-ar" \ CC_x86_64_unknown_redox="x86_64-unknown-redox-gcc" \ CARGO_TARGET_X86_64_UNKNOWN_REDOX_LINKER="x86_64-unknown-redox-gcc" \ diff --git a/ci/install-rust.sh b/ci/install-rust.sh index b40f1df4e7a54..9425d1a694d10 100755 --- a/ci/install-rust.sh +++ b/ci/install-rust.sh @@ -19,7 +19,7 @@ case "$(uname -s)" in esac if [ "$os" = "windows" ] && [ -n "${TARGET:-}" ]; then - toolchain="$toolchain-$TARGET" + toolchain="$toolchain-${RUST_HOST:-$TARGET}" rustup set profile minimal fi diff --git a/ci/style.py b/ci/style.py index ca3afa2bdf2fc..18731281190bc 100755 --- a/ci/style.py +++ b/ci/style.py @@ -26,7 +26,7 @@ def main(): fmt_files.extend(iglob(f"{dir}/**/*.rs", recursive=True)) for file in fmt_files: - if file in IGNORE_FILES: + if Path(file).as_posix() in IGNORE_FILES: continue fmt_one(Path(file), check_only) diff --git a/ci/verify-build.py b/ci/verify-build.py index 83863d0a7e620..89e4e58208cc3 100755 --- a/ci/verify-build.py +++ b/ci/verify-build.py @@ -80,16 +80,18 @@ class TargetResult: FREEBSD_VERSIONS = [11, 12, 13, 14, 15] TARGETS = [ - # Tier 1 + # Tier 1 with host tools Target("aarch64-apple-darwin"), Target("aarch64-pc-windows-msvc"), Target("aarch64-unknown-linux-gnu"), - Target("i686-pc-windows-msvc"), Target("i686-unknown-linux-gnu"), Target("x86_64-pc-windows-gnu"), Target("x86_64-pc-windows-msvc"), Target("x86_64-unknown-linux-gnu"), # + # Tier 1 without host tools + Target("i686-pc-windows-msvc"), + # # Tier 2 with host tools Target("aarch64-pc-windows-gnullvm", min_toolchain=Toolchain.STABLE), Target("aarch64-unknown-linux-musl"), diff --git a/etc/libc-util.py b/etc/libc-util.py index 2181abf264d0b..7be33c39a100b 100755 --- a/etc/libc-util.py +++ b/etc/libc-util.py @@ -1,21 +1,26 @@ #!/usr/bin/env python3 """Helper utilities for common libc tasks.""" +# ruff: noqa: FURB167 allow short regex flags + import argparse import copy import datetime as dt -from enum import StrEnum import functools import json import os import pprint import re +import shlex import subprocess as sp import sys +import time from dataclasses import dataclass +from enum import StrEnum from inspect import cleandoc from multiprocessing import Pool from pathlib import Path +from typing import ClassVar REPO_OWNER = "rust-lang" REPO = "libc" @@ -158,10 +163,10 @@ def execute(self) -> None: if state != "MERGED": print(f'expected MERGED state; got {state} for "{title}" (#{num})') - exit(1) + sys.exit(1) if base != "libc-0.2": print(f'expected libc-0.2 base ref; got {base} for "{title}" (#{num})') - exit(1) + sys.exit(1) print(f'Relabling PRs listed in {num} "{title}"') @@ -337,10 +342,10 @@ class CheckAllTargets: checks: list["CheckInvocation"] failure_limit: int - FREEBSD_VERSIONS = [13, 14, 15] + FREEBSD_VERSIONS: ClassVar = [13, 14, 15] # Targets that don't pass for one reason or another - BROKEN_TARGETS = [ + BROKEN_TARGETS: ClassVar = [ # libc problems ("aarch64-unknown-nto-qnx800", "libc error, unsupported arch"), ("aarch64.*-gnu_ilp32.*time_bits=64", "libc error, time64 mismatches"), @@ -352,16 +357,16 @@ class CheckAllTargets: ("x86_64-lynx-lynxos178", "libc error, unresolved import"), ("x86_64-pc-nto-qnx800", "libc error, unsupported arch"), ("x86_64-unknown-linux-none", "libc error, unresolved import"), + ("m68k-unknown-.*", "libc error, duplicate definition"), # rustc problems ("xtensa-esp32.*", "target string mismatch in rustc"), ("amdgcn-amd-amdhsa", "unsupported instructions with some CPUs"), # llvm problems - ("m68k-unknown-.*", "llvm crash building core"), ("mipsisa32r6(el)?-.*", "llvm crash building core"), ] # Flags that always need to be passed to specific targets - EXTRA_TARGET_FLAGS = { + EXTRA_TARGET_FLAGS: ClassVar = { # Target CPU must be specified "avr-none": ["-Ctarget-cpu=atmega328p"], # Emits a lot of warnings @@ -433,6 +438,15 @@ def prepare() -> "CheckAllTargets": ] new_checks.append(new) + if t.env == "uclibc" and t.bits == 32: + new = copy.deepcopy(base) + new.attributes = base.attributes | {"time_bits": "64"} + new.target_dir = base.target_dir / "time64" + new.extra_rustflags = base.extra_rustflags + [ + "--cfg=libc_unstable_uclibc_time64" + ] + new_checks.append(new) + # Update the name field and check whether there are any targets that we # always need to skip, or that need flags. for check in new_checks: @@ -465,7 +479,7 @@ def check_all_targets( package: str, only: str | None = None, skip: str | None = None, - cargo_args: list[str] = [], + cargo_args: list[str] | None = None, ) -> None: """Run checks from the populated list.""" checks = self.checks @@ -475,6 +489,8 @@ def check_all_targets( failures = [] matched_only_already_skipped = [] + start = time.time() + if only is not None: for t in checks: if t.pattern_matches(only): @@ -534,7 +550,7 @@ def check_all_targets( ] + common_args + extra_args - + cargo_args, + + (cargo_args or []), env=env | {"RUSTFLAGS": " ".join(rustflags)}, ) ok = True @@ -552,8 +568,9 @@ def check_all_targets( if len(failures) > self.failure_limit: break + elapsed = round(time.time() - start, 2) print( - f"finished checking {ran} targets. {passed} passed, " + f"finished checking {ran} targets in {elapsed} seconds. {passed} passed, " f"{len(failures)} failed, {skipped} skipped" ) if len(matched_only_already_skipped) > 0: @@ -569,7 +586,7 @@ def check_all_targets( @staticmethod def get_cache_toolchain() -> str: # Arbitrary but reasonably recent default if unset. - return os.environ.get("RUSTC_CACHE_TOOLCHAIN") or "nightly-2026-06-24" + return os.environ.get("RUSTC_CACHE_TOOLCHAIN") or "nightly-2026-09-01" @dataclass(kw_only=True) @@ -613,7 +630,7 @@ class Backporter: branch: str WORKTREE_DIR = ".libc-backports" - WORKTREE_GIT = ["git", "-C", WORKTREE_DIR] + WORKTREE_GIT: ClassVar = ["git", "-C", WORKTREE_DIR] GQL_QUERY = """ query ($endCursor: String) { repository(name: "libc", owner: "rust-lang") { @@ -702,7 +719,7 @@ def start_backports(self) -> None: delete the branch and start from scratch.{E.RST} """ print("\n" + mstr(msg)) - exit(1) + sys.exit(1) def prepare_rebase_todo(self) -> None: """Create a rebase todo list and cache it, to be picked up by the sequence @@ -722,7 +739,7 @@ def prepare_rebase_todo(self) -> None: # If we have a merge commit, take only the second (incoming) commit. if len(parents) > 2: eprint("Can't backport commits with >1 parent") - exit(1) + sys.exit(1) if len(parents) == 2: last_sha = parents[1] @@ -731,8 +748,7 @@ def prepare_rebase_todo(self) -> None: # "merge" commit is the last commit on `main` from this PR, so we can # work backwards; given N commits, `merge_sha~(N-1)` will be the first PR # from the commit on `main`. - for i in reversed(range(len(pr.commits))): - n_back = len(pr.commits) - i - 1 + for n_back in reversed(range(len(pr.commits))): pick_sha = check_output( ["git", "rev-parse", f"{last_sha}~{n_back}"], quiet=True ).strip() @@ -742,7 +758,7 @@ def prepare_rebase_todo(self) -> None: pick_short = pick_sha[:12] rebase_todo += ( f"exec printf '{E.CY_B.u}picking from PR{pr.number}: {pick_short} " - f'"{subject}"{E.RST.u}\\n\'' + f'"%s"{E.RST.u}\\n\' {shlex.quote(subject)}' "\n" f'pick {pick_short} # pick "{subject}"' "\n" @@ -801,7 +817,7 @@ def fetch_needs_backport_list(self) -> list["PullRequest"]: f"limit reached: {total_commits} total commits but could " f"only fetch {new_commit_count}" ) - exit(1) + sys.exit(1) pull_requests.append(new) @@ -823,7 +839,7 @@ def ensure_local_updated(self) -> None: f"local libc-0.2@{local[:12]} does not match upstream/libc-0.2@{upstream[:12]}!" "Fetch before retrying." ) - exit(1) + sys.exit(1) def ensure_branch(self) -> None: """Create the branch if it doesn't exist.""" @@ -921,7 +937,7 @@ def backport_pr_description(branch: str) -> None: """List all backported commits for a branch, for pasting into the PR body.""" commits = check_output(["git", "log", f"libc-0.2..{branch}", "--format=%b"]) urls = {x[1] for x in re.finditer(r"^\(backport <(.*)>\)", commits, re.M)} - urls = sorted(list(urls)) + urls = sorted(urls) s = "Backport the following:\n\n" for url in urls: diff --git a/libc-test/build/main.rs b/libc-test/build/main.rs index f2d787fdc1f72..f97a0e7d13c5a 100755 --- a/libc-test/build/main.rs +++ b/libc-test/build/main.rs @@ -202,6 +202,7 @@ fn test_apple(t: &Target) { "os/lock.h", "os/signpost.h", "os/os_sync_wait_on_address.h", + "paths.h", "poll.h", "pthread.h", "pthread_spis.h", @@ -430,6 +431,7 @@ fn test_openbsd(t: &Target) { "wchar.h", "ctype.h", "dirent.h", + "sys/sensors.h", "sys/socket.h", (x86_64, "machine/fpu.h"), "net/if.h", @@ -493,6 +495,7 @@ fn test_openbsd(t: &Target) { "sys/shm.h", "sys/param.h", "sys/auxv.h", + "paths.h", ); cfg.rename_type(|ty| match ty { @@ -524,6 +527,10 @@ fn test_openbsd(t: &Target) { "sa_sigaction" if struct_ == "sigaction" => "sa_handler".to_string(), + // Field is named `type` in C but that is a Rust keyword, + // so these fields are translated to `type_` in the bindings. + "type_" if struct_ == "sensor" => "type".to_string(), + _ => return None, }; Some(replacement) @@ -581,6 +588,11 @@ fn test_openbsd(t: &Target) { cfg.rename_struct_ty(|ty| ty.ends_with("_t").then_some(ty.to_string())); cfg.rename_union_ty(|ty| ty.ends_with("_t").then_some(ty.to_string())); + cfg.alias_is_c_enum(move |ty| match ty { + "sensor_type" | "sensor_status" => true, + _ => false, + }); + cfg.skip_struct(move |struct_| { match struct_.ident() { // Extern types @@ -631,6 +643,7 @@ fn test_cygwin(t: &Target) { "net/if.h", "netdb.h", "netinet/tcp.h", + "paths.h", "poll.h", "pthread.h", "pty.h", @@ -944,6 +957,7 @@ fn test_redox(t: &Target) { "netinet/in.h", "netinet/ip.h", "netinet/tcp.h", + "paths.h", "poll.h", "pwd.h", "semaphore.h", @@ -1382,6 +1396,7 @@ fn test_netbsd(t: &Target) { "iconv.h", "utmp.h", "utmpx.h", + "paths.h", ); cfg.rename_type(move |ty| { @@ -1632,6 +1647,7 @@ fn test_dragonflybsd(t: &Target) { "netinet/ip.h", "netinet/tcp.h", "netinet/udp.h", + "paths.h", "poll.h", "pthread.h", "pthread_np.h", @@ -2172,6 +2188,7 @@ fn test_android(t: &Target) { // generate the error 'Your time_t is already 64-bit' (t.p32(), "time64.h"), (x86, "sys/reg.h"), + "paths.h", ); // Include linux headers at the end: @@ -2432,6 +2449,9 @@ fn test_android(t: &Target) { // FIXME(android): Requires >= 6.9 kernel headers. "AT_HWCAP3" | "AT_HWCAP4" | "RWF_NOAPPEND" => true, + // FIXME(android): Requires >= 6.10 kernel headers. + "BCACHEFS_SUPER_MAGIC" => true, + // FIXME(android): Requires >= 6.11 kernel headers. "RWF_ATOMIC" => true, @@ -2661,6 +2681,7 @@ fn test_freebsd(t: &Target) { "netinet/tcp.h", "netinet/udp.h", "netinet6/in6_var.h", + "paths.h", "poll.h", "pthread.h", "pthread_np.h", @@ -3374,6 +3395,7 @@ fn test_emscripten(t: &Target) { "utmp.h", "utmpx.h", "wchar.h", + "paths.h", ); cfg.rename_struct_ty(move |ty| { @@ -4246,6 +4268,7 @@ fn test_linux(t: &Target) { // https://www.openwall.com/lists/musl/2015/04/09/3 // is not present on uclibc. (!(musl || uclibc), "execinfo.h"), + "paths.h", ); // Include linux headers at the end: @@ -4964,6 +4987,7 @@ fn test_linux(t: &Target) { // Recent additions "AT_HWCAP3" | "AT_HWCAP4" if old_musl => true, "AT_HWCAP3" | "AT_HWCAP4" => kernel < (6, 9), + "BCACHEFS_SUPER_MAGIC" => kernel < (6, 10), "PTRACE_SET_SYSCALL_INFO" => kernel < (6, 16), "TLS_INFO_TX_MAX_PAYLOAD_LEN" | "TLS_INFO_MAX" => kernel < (6, 19), @@ -4990,6 +5014,12 @@ fn test_linux(t: &Target) { // eabihf targets are tested using an older version of glibc "AT_HANDLE_FID" if musl || eabihf => true, + // Added in 7.2 + "FUTEX_ROBUST_UNLOCK" => kernel < (7, 2), + "FUTEX_ROBUST_LIST32" => kernel < (7, 2), + // Value changed in 7.2 + "FUTEX_CMD_MASK" => kernel < (7, 2), + _ => false, } }); @@ -5170,9 +5200,6 @@ fn test_linux(t: &Target) { cfg.skip_struct_field(move |struct_, field| { match (struct_.ident(), field.ident()) { - // this is actually a union on linux, so we can't represent it well and - // just insert some padding. - ("siginfo_t", "_pad") => true, // musl names this __dummy1 but it's still there ("glob_t", "gl_flags") if musl => true, // musl seems to define this as an *anonymous* bitfield @@ -5547,6 +5574,7 @@ fn test_haiku(t: &Target) { "netinet6/in6.h", "nl_types.h", "null.h", + "paths.h", "poll.h", "pthread.h", "pwd.h", diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 7ddd3dbb65a11..a29e7ecf7408d 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -3199,6 +3199,8 @@ X_OK _IOFBF _IOLBF _IONBF +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN _PC_ASYNC_IO diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 3ab27db12416f..035e4b8c07ab6 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1720,6 +1720,8 @@ _NSGetArgv _NSGetEnviron _NSGetExecutablePath _NSGetProgname +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN _PC_ASYNC_IO diff --git a/libc-test/semver/cygwin.txt b/libc-test/semver/cygwin.txt index 691271e61ac7b..6fa71843e3084 100644 --- a/libc-test/semver/cygwin.txt +++ b/libc-test/semver/cygwin.txt @@ -472,6 +472,8 @@ WINDOWS_SEND XTABS _CS_PATH _IONBF +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN _PC_ASYNC_IO diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index cef23201ff9c3..ce188075e3536 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -1175,6 +1175,8 @@ _CS_PATH _IOFBF _IOLBF _IONBF +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ACL_EXTENDED _PC_ACL_PATH_MAX diff --git a/libc-test/semver/espidf.txt b/libc-test/semver/espidf.txt index f9f9089b9e371..df8bd8b8037e7 100644 --- a/libc-test/semver/espidf.txt +++ b/libc-test/semver/espidf.txt @@ -32,6 +32,7 @@ SIGSEGV SIGTERM SOL_SOCKET SOMAXCONN +_PATH_BSHELL __errno cmsghdr dirent diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index dd380534a4d35..5db4e7ef57783 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1779,6 +1779,8 @@ _IOR _IOW _IOWINT _IOWR +_PATH_BSHELL +_PATH_DEFPATH _PC_ACL_EXTENDED _PC_ACL_NFS4 _PC_ACL_PATH_MAX diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index d846885a12c82..7bca8b6eba50e 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -25,6 +25,7 @@ AT_STATX_FORCE_SYNC AT_STATX_SYNC_AS_STAT AT_STATX_SYNC_TYPE AUTOFS_SUPER_MAGIC +BCACHEFS_SUPER_MAGIC BINDERFS_SUPER_MAGIC BOOT_TIME BPF_FS_MAGIC diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index ba6693d4d2f6f..57b90559426b9 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -953,6 +953,8 @@ FUTEX_OP_XOR FUTEX_OWNER_DIED FUTEX_PRIVATE_FLAG FUTEX_REQUEUE +FUTEX_ROBUST_LIST32 +FUTEX_ROBUST_UNLOCK FUTEX_TID_MASK FUTEX_TRYLOCK_PI FUTEX_UNLOCK_PI @@ -3871,6 +3873,8 @@ _IONBF _IOR _IOW _IOWR +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN _PC_ASYNC_IO diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 44d9380d1260d..cfec566f3580f 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1132,6 +1132,8 @@ _IONBF _IOR _IOW _IOWR +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ACL_EXTENDED _PC_FILESIZEBITS diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 8e2ca1d9f00b5..330f8da09e068 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -889,6 +889,37 @@ SCHED_RR SCM_RIGHTS SCM_TIMESTAMP SEM_FAILED +SENSOR_ACCEL +SENSOR_AMPHOUR +SENSOR_AMPS +SENSOR_ANGLE +SENSOR_DISTANCE +SENSOR_DRIVE +SENSOR_ENERGY +SENSOR_FANRPM +SENSOR_FINVALID +SENSOR_FREQ +SENSOR_FUNKNOWN +SENSOR_HUMIDITY +SENSOR_INDICATOR +SENSOR_INTEGER +SENSOR_LUX +SENSOR_MAX_TYPES +SENSOR_OHMS +SENSOR_PERCENT +SENSOR_PRESSURE +SENSOR_S_CRIT +SENSOR_S_OK +SENSOR_S_UNKNOWN +SENSOR_S_UNSPEC +SENSOR_S_WARN +SENSOR_TEMP +SENSOR_TIMEDELTA +SENSOR_VELOCITY +SENSOR_VOLTS_AC +SENSOR_VOLTS_DC +SENSOR_WATTHOUR +SENSOR_WATTS SF_APPEND SF_ARCHIVED SF_IMMUTABLE @@ -993,6 +1024,8 @@ _IOR _IOW _IOWR _MAX_PAGE_SHIFT +_PATH_BSHELL +_PATH_DEFPATH _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN _PC_ASYNC_IO @@ -1191,6 +1224,7 @@ futimes getdomainname getdtablesize getentropy +getexecpath getfsstat getgrent getgrgid @@ -1373,6 +1407,7 @@ sem_timedwait sem_unlink sendmmsg sendmsg +sensor setdomainname setgrent setgroups diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index 8753284191f4b..f30f4f9ae6bc6 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -101,6 +101,7 @@ EUCLEAN EUNATCH EUSERS EXFULL +FILENAME_MAX FIONREAD F_DUPFD_CLOEXEC IMAXBEL @@ -258,6 +259,7 @@ _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS _IOFBF _IOLBF _IONBF +_PATH_BSHELL _PC_2_SYMLINKS _PC_ALLOC_SIZE_MIN _PC_ASYNC_IO diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 57ee24142aadc..6fdaf83c9450d 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -3779,6 +3779,10 @@ extern "C" { pub fn mkstemp(template: *mut c_char) -> c_int; pub fn mkdtemp(template: *mut c_char) -> *mut c_char; + #[deprecated( + since = "0.2.190", + note = "function is obsolete; prefer tmpfile, mkstemp, or similar" + )] pub fn tmpnam(ptr: *mut c_char) -> *mut c_char; pub fn openlog(ident: *const c_char, logopt: c_int, facility: c_int); diff --git a/src/lib.rs b/src/lib.rs index 671e2c7dc81be..ee1af1c93e986 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,18 +1,62 @@ //! Raw FFI bindings to platform system libraries. //! +//! # Documentation +//! +//! `libc` only provides the bindings, not instructions on how to use them. For this, please refer +//! to the relevant C documentation. +//! +//! POSIX provides OS-agnostic API definitions, which most platforms aim to comply with. Its +//! specifications are often the best place to look: +//! +//! * POSIX Base Definitions: . +//! Types and structures are defined within the _Headers_ section. +//! * POSIX System Interfaces: . +//! Functions are defined under the _System Interfaces_ section. +//! +//! For platform-specific API and caveats to the standard API, platform-specific manual pages are +//! usually the place to look. Locally you can run commands like `man 2 stat` or `man 3 printf` +//! (2 for kernel interfaces, 3 for standard library) to get documentation, but there are also +//! a number of platforms with manual pages available online: +//! +//! * Apple: Official manpages exist at +//! but are severly outdated. exists but +//! only provides API signatures without documenttion. or +//! are better options. +//! * DragonFlyBSD: +//! * FreeBSD: +//! * IBM AIX: +//! * Illumos: +//! * Linux: +//! * or provide +//! documentation of Linux API as well as the C library, with a focus on glibc. +//! * Glibc-specific documentation is available at +//! . +//! * Musl documentation states to refer to POSIX, linked above, and the C standard, available at +//! (published versions must be +//! purchased but the drafts are free). +//! * NetBSD: +//! * OpenBSD: +//! * Solaris: +//! * Windows MSVC: +//! //! # Usage Guidelines //! //! `libc` exposes non-Rust interfaces in Rust, which makes for some caveats to its use that are //! not present in most Rust libraries. Observing the following guidelines are recommended to help //! avoid soundness and stability pitfalls. //! -//! 1. *Never* construct a `libc` struct with `MaybeUninit::uninit()`, initialize it, then call -//! `assume_init`. Many structures have padding fields or may gain fields in the future, and -//! it is far too easy to end up calling `assume_init` on partially initialized data. +//! 1. *Never* construct a `libc` struct with `MaybeUninit::uninit()`, call a `libc` function with +//! it, then call `assume_init`. Library functions do not always initialize all fields; this +//! includes obvious cases like padding fields, but also less obvious cases like fields present +//! in the `libc` struct but not on older versions of the platform's C library. It is far too +//! easy to end up with a bogus `assume_init` because not all fields have been written. //! //! Instead, use `MaybeUninit::zeroed()` or the `Default` implementations that are slowly being //! added. Alternatively, access fields only via raw pointer without ever using `assume_init`. //! +//! See also the safety docs for `MaybeUninit::assume_init` +//! . +//! //! 2. Avoid relying on the exact value of constants, the exact length of arrays, or the exact //! types of type aliases, as they may change across `libc` versions. That is, if `libc` //! contains code like: diff --git a/src/macros.rs b/src/macros.rs index 587438c5ec869..72dea31b8a515 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -1,11 +1,10 @@ /// A macro for defining #[cfg] if-else statements. /// -/// This is similar to the `if/elif` C preprocessor macro by allowing definition -/// of a cascade of `#[cfg]` cases, emitting the implementation which matches -/// first. +/// This is similar to the `if/elif` C preprocessor macro by allowing definition of a cascade of +/// `#[cfg]` cases, emitting the implementation which matches first. /// -/// This allows you to conveniently provide a long list #[cfg]'d blocks of code -/// without having to rewrite each clause multiple times. +/// This allows you to conveniently provide a long list #[cfg]'d blocks of code without having to +/// rewrite each clause multiple times. macro_rules! cfg_if { // match if/else chains with a final `else` ($( @@ -74,8 +73,15 @@ macro_rules! prelude { #[allow(unused_imports)] pub(crate) use core::clone::Clone; #[allow(unused_imports)] + pub(crate) use core::cmp::{ + Eq, + PartialEq, + }; + #[allow(unused_imports)] pub(crate) use core::default::Default; #[allow(unused_imports)] + pub(crate) use core::iter::Iterator; + #[allow(unused_imports)] pub(crate) use core::marker::{ Copy, Send, @@ -89,12 +95,14 @@ macro_rules! prelude { pub(crate) use core::{ assert, cfg, + compile_error, debug_assert, fmt, hash, iter, mem, ptr, + unimplemented, }; #[allow(unused_imports)] @@ -112,6 +120,7 @@ macro_rules! prelude { pub(crate) use crate::types::u32_cast_ioctl; #[allow(unused_imports)] pub(crate) use crate::types::{ + cstr, replace_array_items, u16_cast_short, u32_cast_int, @@ -152,8 +161,8 @@ macro_rules! prelude { /// /// Also mark the type with `repr(C)`. /// -/// Use [`s_no_extra_traits`] for structs where the `extra_traits` feature does not -/// make sense, and for unions. +/// Use [`s_no_extra_traits`] for structs where the `extra_traits` feature does not make sense, and +/// for unions. macro_rules! s { ($( $(#[$attr:meta])* @@ -175,7 +184,11 @@ macro_rules! s { )] #[cfg_attr( feature = "extra_traits", - ::core::prelude::v1::derive(PartialEq, Eq, Hash) + ::core::prelude::v1::derive( + ::core::cmp::PartialEq, + ::core::cmp::Eq, + ::core::hash::Hash, + ) )] #[allow(deprecated)] $(#[$attr])* @@ -183,8 +196,8 @@ macro_rules! s { ); } -/// Implement `Clone`, `Copy`, and `Debug` for a tuple struct, as well as `PartialEq`, `Eq`, -/// and `Hash` if the `extra_traits` feature is enabled. +/// Implement `Clone`, `Copy`, and `Debug` for a tuple struct, as well as `PartialEq`, `Eq`, and +/// `Hash` if the `extra_traits` feature is enabled. /// /// Unlike `s!`, this does *not* mark the type with `repr(C)`. Users should provide their own /// `repr` attribute via `$attr` as necessary. @@ -200,7 +213,11 @@ macro_rules! s_paren { )] #[cfg_attr( feature = "extra_traits", - ::core::prelude::v1::derive(PartialEq, Eq, Hash) + ::core::prelude::v1::derive( + ::core::cmp::PartialEq, + ::core::cmp::Eq, + ::core::hash::Hash, + ) )] $(#[$attr])* $pub struct $i ( $($field)* ); @@ -239,23 +256,40 @@ macro_rules! s_no_extra_traits { ); } -/// Like [`s`], but also generates a `Default` impl for every struct in the block. -macro_rules! s_with_default { +/// Like [`s`], but (1) generates a `Default` impl for every struct in the block, and (2) adds a +/// private field to the struct to replicate the effects of the `non_exhaustive` attribute while +/// rust-lang/rust#132699 gets sorted out. +/// +/// To opt out of having the private field added, annotate the struct with an `exhaustive` +/// attribute, as in: +/// +/// ```ignore +/// s2! { +/// #[exhaustive] +/// struct Something { +/// ... +/// } +/// } +/// ``` +/// +/// See [`custom_struct`] for details. +macro_rules! s2 { ($( $(#$attr:tt)* $pub:vis $t:ident $i:ident { $($field:tt)* } )*) => ($( - s_with_default!(it: $(#$attr)* $pub $t $i { $($field)* }); + s2!(it: $(#$attr)* $pub $t $i { $($field)* }); )*); (it: $(#$attr:tt)* $pub:vis union $i:ident { $($field:tt)* }) => ( compile_error!( - "unions cannot derive extra traits, use s_no_extra_traits_with_default instead" + "unions cannot derive extra traits, use `s_no_extra_traits2` \ + instead" ); ); (it: $(#$attr:tt)* $pub:vis struct $i:ident { $($field:tt)* }) => ( - struct_with_default! { + custom_struct! { attrs: { #[repr(C)] #[::core::prelude::v1::derive( @@ -265,7 +299,11 @@ macro_rules! s_with_default { )] #[cfg_attr( feature = "extra_traits", - ::core::prelude::v1::derive(PartialEq, Eq, Hash) + ::core::prelude::v1::derive( + ::core::cmp::PartialEq, + ::core::cmp::Eq, + ::core::hash::Hash, + ) )] #[allow(deprecated)] } @@ -274,16 +312,30 @@ macro_rules! s_with_default { ); } -/// Like [`s_no_extra_traits`], but also generates a `Default` impl for every struct in the block. +/// Like [`s_no_extra_traits`], but (1) generates a `Default` impl for every struct in the block, +/// and (2) adds a private field to replicate the effects of the built-in `non_exhaustive` attribute +/// while rust-lang/rust#132699 gets sorted out. /// -/// Unions are emitted just like `s_no_extra_traits!` does, with no `Default`. A struct field of +/// Unions are emitted just like `s_no_extra_traits!` does, with no `Default`. A struct field of /// union type supplies its own default via `#[custom_default(...)]`. -macro_rules! s_no_extra_traits_with_default { +/// +/// To opt out of having the private field added, annotate the struct with an `exhaustive` +/// attribute, as in: +/// +/// ```ignore +/// s_no_extra_traits2! { +/// #[exhaustive] +/// struct Something { +/// ... +/// } +/// } +/// ``` +macro_rules! s_no_extra_traits2 { ($( $(#$attr:tt)* $pub:vis $t:ident $i:ident { $($field:tt)* } )*) => ($( - s_no_extra_traits_with_default!(it: $(#$attr)* $pub $t $i { $($field)* }); + s_no_extra_traits2!(it: $(#$attr)* $pub $t $i { $($field)* }); )*); (it: $(#$attr:tt)* $pub:vis union $i:ident { $($field:tt)* }) => ( @@ -293,7 +345,7 @@ macro_rules! s_no_extra_traits_with_default { ); (it: $(#$attr:tt)* $pub:vis struct $i:ident { $($field:tt)* }) => ( - struct_with_default! { + custom_struct! { attrs: { #[repr(C)] #[::core::prelude::v1::derive( @@ -310,8 +362,8 @@ macro_rules! s_no_extra_traits_with_default { /// Emit a union plus its `Debug` impl. /// /// Unions can't derive `Debug`, so it is written out here. Attributes are split like -/// [`struct_with_default`] does. Everything goes on the union, but only the `cfg`s are repeated -/// on the impl, otherwise a union that is configured out leaves an impl behind. +/// [`custom_struct`] does. Everything goes on the union, but only the `cfg`s are repeated on the +/// impl, otherwise a union that is configured out leaves an impl behind. macro_rules! union_with_debug { ( $(#$attr:tt)* @@ -405,7 +457,9 @@ macro_rules! union_with_debug { }; } -/// Emit a struct with the given derive attributes plus a generated `Default` impl. +/// Emit a struct with the given derive attributes plus a generated `Default` impl. Ensure that the +/// record has an additional private field added to replicate `#[non_exhaustive]`, unless it is +/// annotated with `#[exhaustive]`. /// /// Fields default to `Default::default()`. A field whose default can't be derived must carry /// `#[custom_default(EXPR)]` as its *first* attribute, and `EXPR` is used instead. @@ -414,25 +468,30 @@ macro_rules! union_with_debug { /// attribute's contents are added to `processed_field_defaults` and will be used in the expansion /// for `Default`. If it does not exist, `Default::default()` is used instead. In either case, the /// field is added to `processed_fields` with `#[custom_default]` stripped if necessary, and -/// `struct_with_default` is invoked again with the remaining fields. +/// `custom_struct` is invoked again with the remaining fields. /// -/// Attributes are split into `cfg_attrs` and `other_attrs` before the fields are scanned. Both -/// go on the struct, but only the `cfg`s are repeated on the `Default` impl. A `cfg` decides -/// whether the type exists at all, so without it a configured-out struct leaves an impl behind -/// referring to a type that isn't there. -macro_rules! struct_with_default { - // entry; `attrs` is the attribute block the caller wants on the struct (repr, derives, etc.), - // which is merged with the struct's own attributes. +/// Attributes are split into `cfg_attrs` and `other_attrs` before the fields are scanned. Both go +/// on the struct, but only the `cfg`s are repeated on the `Default` impl. A `cfg` decides whether +/// the type exists at all, so without it a configured-out struct leaves an impl behind referring to +/// a type that isn't there. +/// +/// Out of `other_attrs`, we scan for `#[exhaustive]`. If found, we remove it but take into account +/// that the record should be expanded _without_ an additional private field. The scan for both +/// `cfg` attributes and the (non-existent) `exhaustive` attribute is done in one linear pass. +macro_rules! custom_struct { + // entry; `attrs` is the attribute block the caller wants on the struct + // (repr, derives, etc.), which is merged with the struct's own attributes. ( attrs: { $($attrs:tt)* } $(#$attr:tt)* $vis:vis struct $name:ident { $($body:tt)* } ) => { - struct_with_default! { + custom_struct! { @split_attrs cfg_attrs: { } other_attrs: { } remaining_attrs: { $($attrs)* $(#$attr)* } + found_exhaustive_attr: { false } vis: { $vis } name: { $name } body: { $($body)* } @@ -448,15 +507,44 @@ macro_rules! struct_with_default { #[cfg($($cfg:tt)*)] $($tail:tt)* } + found_exhaustive_attr: { $found_exhaustive:tt } vis: { $vis:vis } name: { $name:ident } body: { $($body:tt)* } ) => { - struct_with_default! { + custom_struct! { @split_attrs cfg_attrs: { $($cfg_attrs)* #[cfg($($cfg)*)] } other_attrs: { $($other_attrs)* } remaining_attrs: { $($tail)* } + found_exhaustive_attr: { $found_exhaustive } + vis: { $vis } + name: { $name } + body: { $($body)* } + } + }; + + // `exhaustive` must be taken into account as many times as it appears, + // though the effect is the same with a single annotation. + ( + @split_attrs + cfg_attrs: { $($cfg_attrs:tt)* } + other_attrs: { $($other_attrs:tt)* } + remaining_attrs: { + #[exhaustive] + $($tail:tt)* + } + found_exhaustive_attr: { $_:tt } + vis: { $vis:vis } + name: { $name:ident } + body: { $($body:tt)* } + ) => { + custom_struct! { + @split_attrs + cfg_attrs: { $($cfg_attrs)* } + other_attrs: { $($other_attrs)* } + remaining_attrs: { $($tail)* } + found_exhaustive_attr: { true } vis: { $vis } name: { $name } body: { $($body)* } @@ -472,15 +560,17 @@ macro_rules! struct_with_default { #$other:tt $($tail:tt)* } + found_exhaustive_attr: { $found_exhaustive:tt } vis: { $vis:vis } name: { $name:ident } body: { $($body:tt)* } ) => { - struct_with_default! { + custom_struct! { @split_attrs cfg_attrs: { $($cfg_attrs)* } other_attrs: { $($other_attrs)* #$other } remaining_attrs: { $($tail)* } + found_exhaustive_attr: { $found_exhaustive } vis: { $vis } name: { $name } body: { $($body)* } @@ -493,14 +583,16 @@ macro_rules! struct_with_default { cfg_attrs: { $($cfg_attrs:tt)* } other_attrs: { $($other_attrs:tt)* } remaining_attrs: { } + found_exhaustive_attr: { $found_exhaustive:tt } vis: { $vis:vis } name: { $name:ident } body: { $($body:tt)* } ) => { - struct_with_default! { + custom_struct! { @struct cfg_attrs: { $($cfg_attrs)* } other_attrs: { $($other_attrs)* } + found_exhaustive_attr: { $found_exhaustive } vis: { $vis } name: { $name } processed_fields: { } @@ -514,6 +606,7 @@ macro_rules! struct_with_default { @struct cfg_attrs: { $($cfg_attrs:tt)* } other_attrs: { $($other_attrs:tt)* } + found_exhaustive_attr: { $found_exhaustive:tt } vis: { $vis:vis } name: { $name:ident } processed_fields: { $($processed_fields:tt)* } @@ -525,10 +618,11 @@ macro_rules! struct_with_default { $($tail:tt)* } ) => { - struct_with_default! { + custom_struct! { @struct cfg_attrs: { $($cfg_attrs)* } other_attrs: { $($other_attrs)* } + found_exhaustive_attr: { $found_exhaustive } vis: { $vis } name: { $name } processed_fields: { $($processed_fields)* $(#[$fattr])* $fvis $fname: $fty, } @@ -545,6 +639,7 @@ macro_rules! struct_with_default { @struct cfg_attrs: { $($cfg_attrs:tt)* } other_attrs: { $($other_attrs:tt)* } + found_exhaustive_attr: { $found_exhaustive:tt } vis: { $vis:vis } name: { $name:ident } processed_fields: { $($processed_fields:tt)* } @@ -555,10 +650,11 @@ macro_rules! struct_with_default { $($tail:tt)* } ) => { - struct_with_default! { + custom_struct! { @struct cfg_attrs: { $($cfg_attrs)* } other_attrs: { $($other_attrs)* } + found_exhaustive_attr: { $found_exhaustive } vis: { $vis } name: { $name } processed_fields: { $($processed_fields)* $(#[$fattr])* $fvis $fname: $fty, } @@ -575,36 +671,85 @@ macro_rules! struct_with_default { @struct cfg_attrs: { $($cfg_attrs:tt)* } other_attrs: { $($other_attrs:tt)* } + found_exhaustive_attr: { $found_exhaustive:tt } vis: { $vis:vis } name: { $name:ident } processed_fields: { $($processed_fields:tt)* } processed_field_defaults: { $($processed_field_defaults:tt)* } remaining_fields: { } ) => { - $($other_attrs)* - $($cfg_attrs)* - $vis struct $name { $($processed_fields)* } + emit_struct_definition! { + found_exhaustive_attr: $found_exhaustive, + body: { + $($other_attrs)* + $($cfg_attrs)* + $vis $name { $($processed_fields)* } + } + } $($cfg_attrs)* - // The impl names the type and its fields, which warns if either is deprecated. + // The impl names the type and its fields, which warns if either is + // deprecated. #[allow(deprecated)] impl ::core::default::Default for $name { - // Field attributes (`#[cfg]`, doc comments) get forwarded to the initializer too. - // Docs are harmless there but trip the lint, so silence it. + // Field attributes (`#[cfg]`, doc comments) get forwarded to the + // initializer too. Docs are harmless there but trip the lint, so + // silence it. #[allow(unused_doc_comments)] fn default() -> Self { - Self { $($processed_field_defaults)* } + emit_struct_default_body! { + found_exhaustive_attr: $found_exhaustive, + body: { $($processed_field_defaults)* } + } } } }; } -/// Create an uninhabited type that can't be constructed. It implements `Debug`, `Clone`, -/// and `Copy`, but these aren't meaningful for extern types so they should eventually -/// be removed. +/// Expands the definition of the record defined at [`custom_struct`], with either one of an +/// additional private field or with its verbatim fields. +macro_rules! emit_struct_definition { + ( + found_exhaustive_attr: false, + body: { $(#[$attr:meta])* $vis:vis $name:ident { $($field:tt)* } } + ) => { + #[allow(clippy::manual_non_exhaustive)] + $(#[$attr])* + $vis struct $name { $($field)* __non_exhaustive: () } + }; + + ( + found_exhaustive_attr: true, + body: { $(#[$attr:meta])* $vis:vis $name:ident { $($field:tt)* } } + ) => { + $(#[$attr])* + $vis struct $name { $($field)* } + }; +} + +/// Expands the `Default` implementation of the record defined at [`custom_struct`], with either one +/// of an additional private field initialized to the unit value, or the record's fields verbatim. +macro_rules! emit_struct_default_body { + ( + found_exhaustive_attr: false, + body: { $($field_default:tt)* } + ) => { + Self { $($field_default)* __non_exhaustive: () } + }; + + ( + found_exhaustive_attr: true, + body: { $($field_default:tt)* } + ) => { + Self { $($field_default)* } + }; +} + +/// Create an uninhabited type that can't be constructed. It implements `Debug`, `Clone`, and +/// `Copy`, but these aren't meaningful for extern types so they should eventually be removed. /// -/// Really what we want here is something that also can't be named without indirection (in -/// ADTs or function signatures), but this doesn't exist. +/// Really what we want here is something that also can't be named without indirection (in ADTs or +/// function signatures), but this doesn't exist. macro_rules! extern_ty { ($( $(#[$attr:meta])* @@ -677,13 +822,19 @@ macro_rules! c_enum { ($( $(#[repr($repr:ty)])? $vis:vis enum $($ty_name:ident)? $(#$anon:ident)? { - $($field_vis:vis $variant:ident $(= $value:expr)?,)+ + $( + $(#[$meta:meta])* + $field_vis:vis $variant:ident $(= $value:expr)?, + )+ } )+) => { $(c_enum!(@single; $(#[repr($repr)])? $vis enum $($ty_name)? $(#$anon)? { - $($field_vis $variant $(= $value)?,)+ + $( + $(#[$meta])* + $field_vis $variant $(= $value)?, + )+ } );)+ }; @@ -692,7 +843,10 @@ macro_rules! c_enum { (@single; $(#[repr($repr:ty)])? $vis:vis enum $ty_name:ident { - $($field_vis:vis $variant:ident $(= $value:expr)?,)+ + $( + $(#[$meta:meta])* + $field_vis:vis $variant:ident $(= $value:expr)?, + )+ } ) => { $vis type $ty_name = c_enum!(@ty $($repr)?); @@ -700,7 +854,10 @@ macro_rules! c_enum { @variant; ty: $ty_name; default: 0; - variants: [$($field_vis $variant $(= $value)?,)+] + variants: [$( + $(#[$meta])* + $field_vis $variant $(= $value)?, + )+] } }; @@ -708,28 +865,41 @@ macro_rules! c_enum { (@single; $(#[repr($repr:ty)])? $vis:vis enum #anon { - $($field_vis:vis $variant:ident $(= $value:expr)?,)+ + $( + $(#[$meta:meta])* + $field_vis:vis $variant:ident $(= $value:expr)?, + )+ } ) => { c_enum! { @variant; ty: c_enum!(@ty $($repr)?); default: 0; - variants: [$($field_vis $variant $(= $value)?,)+] + variants: [$( + $(#[$meta])* + $field_vis $variant $(= $value)?, + )+] } }; // Matcher for variants: eats a single variant then recurses with the rest - (@variant; ty: $_ty_name:ty; default: $_idx:expr; variants: []) => { /* end of the chain */ }; + (@variant; + ty: $_ty_name:ty; + default: $_idx:expr; + variants: [] + ) => { /* end of the chain */ }; ( @variant; ty: $ty_name:ty; default: $default_val:expr; variants: [ + $(#[$meta:meta])* $field_vis:vis $variant:ident $(= $value:expr)?, $($tail:tt)* ] ) => { + $(#[$meta])* + #[allow(deprecated)] $field_vis const $variant: $ty_name = { #[allow(unused_variables)] let r = $default_val; @@ -852,7 +1022,8 @@ macro_rules! offset_of { let ptr = data.as_ptr(); // nested unsafe, see f! #[allow(unused_unsafe)] - // SAFETY: computed address is inbounds since we have a stack alloc for T + // SAFETY: computed address is inbounds since we have a stack alloc for + // T let fptr = unsafe { core::ptr::addr_of!((*ptr).$field) }; let off = (fptr as usize).checked_sub(ptr as usize).unwrap(); core::assert!(off <= core::mem::size_of::<$Ty>()); @@ -863,6 +1034,7 @@ macro_rules! offset_of { #[cfg(test)] mod tests { use core::any::TypeId; + use core::prelude::v1::*; use crate::types::CEnumRepr; @@ -947,8 +1119,8 @@ mod tests { #[test] fn c_enum_multiple_set_value() { - // C enums always take one more than the previous value, unless set to a specific - // value. Duplicates are allowed. + // C enums always take one more than the previous value, unless set to a + // specific value. Duplicates are allowed. c_enum! { pub enum e { VAR0, @@ -999,11 +1171,37 @@ mod tests { assert_eq!(TypeId::of::(), TypeId::of::()); assert_eq!(PUB1, 10u8 * 2); assert_eq!(PUB2, 42u16 * 2); - // Verify that the default is private. If `PRIV_ON_1` was actually public in `priv1`, this - // would be an ambiguous import and/or type mismatch error. + // Verify that the default is private. If `PRIV_ON_1` was actually + // public in `priv1`, this would be an ambiguous import and/or type + // mismatch error. assert_eq!(PRIV_ON_1, 42u16); } + #[test] + fn c_enum_attrs() { + // Note this can't work with `#[cfg]` currently because our expansion uses `previous + 1` + c_enum! { + pub enum e { + VAR0, + WITH_CFG = if cfg!(target_arch = "x86_64") { 86 } else { 1234 }, + #[deprecated] + DEPRECATED, + NOT_DEPRECATED, + } + } + + if cfg!(target_arch = "x86_64") { + assert_eq!(WITH_CFG, 86); + } else { + assert_eq!(WITH_CFG, 1234); + } + + #[expect(deprecated)] + let _ = DEPRECATED; + #[deny(deprecated)] + let _ = NOT_DEPRECATED; + } + #[test] #[deny(unused_unsafe)] fn f_safety() { @@ -1052,9 +1250,60 @@ mod tests { } #[test] - fn s_with_default_uses_custom_default() { - // A non-default value proves `custom_default` is used rather than a derived default. - s_with_default! { + fn s2_is_non_exhaustive() { + // Without `#[exhaustive]`, the record should have an additional field + // added at the end. If this test compiles, it has it. + s2! { + struct Something { + a: u32, + } + } + + let s = Something::default(); + assert_eq!(s.__non_exhaustive, ()); + } + + #[test] + fn s2_uses_exhaustive() { + // With `#[exhaustive]`, the record should be regurgitated as-is. If + // this test compiles, then it works. + s2! { + #[exhaustive] + struct Something { + a: u32, + } + } + + #[allow(unused)] + let s = Something { + a: Default::default(), + }; + } + + #[test] + fn s2_uses_mixed_exhaustive() { + // `#[exhaustive]` should work when sandwiched between attributes. If + // the test compiles, then it works. + s2! { + #[repr(align(8))] + #[exhaustive] + #[repr(align(2))] + struct Something { + a: u32, + } + } + + #[allow(unused)] + let s = Something { + a: Default::default(), + }; + } + + #[test] + fn s2_uses_custom_default() { + // A non-default value proves `custom_default` is used rather than a + // derived default. + s2! { struct CustomDefault { a: u32, #[custom_default([1; 64])] @@ -1068,10 +1317,10 @@ mod tests { } #[test] - fn s_with_default_keeps_field_attrs() { - // If `custom_default` stripping ate the other field attributes, the two `a` fields - // would collide. - s_with_default! { + fn s2_keeps_field_attrs() { + // If `custom_default` stripping ate the other field attributes, the two + // `a` fields would collide. + s2! { struct FieldAttrs { #[cfg(target_arch = "x86_64")] a: u8, @@ -1088,10 +1337,10 @@ mod tests { } #[test] - fn s_with_default_single_cfg_field() { - // this field only exists on x86_64, so its default init needs the same cfg or - // Default won't build on other arches - s_with_default! { + fn s2_single_cfg_field() { + // This field only exists on x86_64, so its default init needs the same + // `cfg` or `Default` won't build on other arches. + s2! { struct SingleCfg { common: u32, #[cfg(target_arch = "x86_64")] @@ -1106,9 +1355,10 @@ mod tests { } #[test] - fn s_no_extra_traits_with_default_zeroes_union() { - // A union field's default is supplied by `custom_default(unsafe { mem::zeroed })`. - s_no_extra_traits_with_default! { + fn s_no_extra_traits2_zeroes_union() { + // A union field's default is supplied by + // `custom_default(unsafe { mem::zeroed })`. + s_no_extra_traits2! { union U { a: u32, b: f32, @@ -1127,10 +1377,11 @@ mod tests { } #[test] - fn s_with_default_keeps_struct_cfg() { - // The opposite of the configured-out types in `macro_checks`. With the `cfg` true the - // type and its `Default` both exist, and the other attributes still apply. - s_with_default! { + fn s2_keeps_struct_cfg() { + // The opposite of the configured-out types in `macro_checks`. With the + // `cfg` true the type and its `Default` both exist, and the other + // attributes still apply. + s2! { #[cfg(true)] #[repr(align(8))] /// a doc comment @@ -1155,6 +1406,8 @@ mod tests { #[cfg(test)] #[allow(unused)] mod macro_checks { + use core::prelude::v1::*; + s! { pub struct S1 { pub a: u32, @@ -1194,7 +1447,7 @@ mod macro_checks { pub type Bar; } - s_with_default! { + s2! { pub struct S3 { pub a: u32, #[custom_default([1; 64])] @@ -1207,7 +1460,7 @@ mod macro_checks { } } - s_no_extra_traits_with_default! { + s_no_extra_traits2! { pub union U3 { pub a: u32, b: f32, @@ -1227,9 +1480,10 @@ mod macro_checks { assert_impls_default::(); } - // Types configured out entirely, checking that the generated impls carry the same `cfg` as - // the type. Without it they fail to compile with "cannot find type". - s_with_default! { + // Types configured out entirely, checking that the generated impls carry + // the same `cfg` as the type. Without it they fail to compile with "cannot + // find type". + s2! { #[cfg(false)] pub struct S5 { pub a: u32, @@ -1246,7 +1500,7 @@ mod macro_checks { } } - s_no_extra_traits_with_default! { + s_no_extra_traits2! { #[cfg(false)] pub union U5 { pub a: u32, @@ -1259,12 +1513,13 @@ mod macro_checks { } } - // The generated impls name the type and its fields, so they need to allow deprecation. - // `deny` turns the warning into an error if that ever stops being the case. + // The generated impls name the type and its fields, so they need to allow + // deprecation. `deny` turns the warning into an error if that ever stops + // being the case. mod deprecated_checks { #![deny(deprecated)] - s_with_default! { + s2! { #[deprecated(since = "0.0.0", note = "check that generated impls don't warn")] pub struct S7 { pub a: u32, @@ -1279,7 +1534,7 @@ mod macro_checks { } } - s_no_extra_traits_with_default! { + s_no_extra_traits2! { #[deprecated(since = "0.0.0", note = "check that generated impls don't warn")] pub union U7 { pub a: u32, diff --git a/src/new/freebsd/net/route.rs b/src/new/freebsd/net/route.rs index a67faeda2e0bf..7d0350f519ca8 100644 --- a/src/new/freebsd/net/route.rs +++ b/src/new/freebsd/net/route.rs @@ -4,7 +4,7 @@ use crate::prelude::*; -s_with_default! { +s2! { pub struct rt_metrics { pub rmx_locks: c_ulong, pub rmx_mtu: c_ulong, diff --git a/src/new/glibc/bits/signum_generic.rs b/src/new/glibc/bits/signum_generic.rs index 4dacf29dc6bc0..a040274595958 100644 --- a/src/new/glibc/bits/signum_generic.rs +++ b/src/new/glibc/bits/signum_generic.rs @@ -16,4 +16,4 @@ pub const SIGKILL: c_int = 9; pub const SIGPIPE: c_int = 13; pub const SIGALRM: c_int = 14; -pub use super::super::sysdeps::unix::linux::bits::signum_arch::*; +pub use crate::new::glibc::bits::signum_arch::*; diff --git a/src/new/glibc/io.rs b/src/new/glibc/io.rs new file mode 100644 index 0000000000000..b2b7afd518bde --- /dev/null +++ b/src/new/glibc/io.rs @@ -0,0 +1,9 @@ +/// Source directory: `io/sys/` +/// +/// +pub(crate) mod sys { + #[cfg(target_os = "linux")] + pub(crate) mod statvfs; + + pub use super::socket::sys::*; +} diff --git a/src/new/glibc/io/sys/mod.rs b/src/new/glibc/io/sys/mod.rs new file mode 100644 index 0000000000000..9bb83fb249fe0 --- /dev/null +++ b/src/new/glibc/io/sys/mod.rs @@ -0,0 +1,6 @@ +//! Source directory: `io/sys/` +//! +//! + +#[cfg(target_os = "linux")] +pub(crate) mod statvfs; diff --git a/src/new/glibc/sys/statvfs.rs b/src/new/glibc/io/sys/statvfs.rs similarity index 90% rename from src/new/glibc/sys/statvfs.rs rename to src/new/glibc/io/sys/statvfs.rs index e1d7cf08e85d0..8efae19a9a68a 100644 --- a/src/new/glibc/sys/statvfs.rs +++ b/src/new/glibc/io/sys/statvfs.rs @@ -1,6 +1,6 @@ //! Header: `io/sys/statvfs.h` -pub use super::super::sysdeps::unix::linux::bits::statvfs::*; +pub use crate::new::glibc::bits::statvfs::*; use crate::prelude::*; extern "C" { diff --git a/src/new/glibc/mod.rs b/src/new/glibc/mod.rs index 15441a20852e7..9fd92101ef154 100644 --- a/src/new/glibc/mod.rs +++ b/src/new/glibc/mod.rs @@ -8,10 +8,24 @@ /// Source directory: `bits/` /// +/// This directory contains default +/// /// mod bits { #[cfg(target_os = "linux")] pub(crate) mod signum_generic; + #[cfg(target_os = "linux")] + pub(crate) use super::sysdeps::unix::linux::bits::{ + sigaction, + signum_arch, + socket, + statvfs, + types, + }; +} + +mod io { + pub(crate) mod sys; } /// Source directory: `posix/` @@ -24,13 +38,11 @@ mod posix { #[cfg(target_os = "linux")] pub(crate) mod signal; -/// Source directory: `io/sys/` +/// Source directory: `socket/` /// -/// -pub(crate) mod sys { - #[cfg(target_os = "linux")] - pub(crate) mod statvfs; -} +/// +#[cfg(target_os = "linux")] +mod socket; /// Source directory: `sysdeps/` /// @@ -45,6 +57,8 @@ mod sysdeps { // `path = "..."` wherever the generic implementation lives. } +pub(crate) mod sys; + pub(crate) use posix::*; // FIXME(pthread): eventually all platforms should use this module #[cfg(target_os = "linux")] diff --git a/src/new/glibc/signal.rs b/src/new/glibc/signal.rs index f91997f45acbd..c05476eb4f723 100644 --- a/src/new/glibc/signal.rs +++ b/src/new/glibc/signal.rs @@ -1,8 +1,8 @@ //! Header: `signal/signal.h` -pub use super::bits::signum_generic::*; -pub use super::sysdeps::unix::linux::bits::sigaction::*; -pub use super::sysdeps::unix::linux::bits::types::siginfo_t::*; +pub use crate::new::glibc::bits::sigaction::*; +pub use crate::new::glibc::bits::signum_generic::*; +pub use crate::new::glibc::bits::types::siginfo_t::*; use crate::prelude::*; extern "C" { diff --git a/src/new/glibc/socket/mod.rs b/src/new/glibc/socket/mod.rs new file mode 100644 index 0000000000000..d34e5d58428fc --- /dev/null +++ b/src/new/glibc/socket/mod.rs @@ -0,0 +1,6 @@ +//! Directory: `socket` + +/// Directory: `socket/sys` +pub(crate) mod sys { + pub(crate) mod socket; +} diff --git a/src/new/glibc/socket/sys/socket.rs b/src/new/glibc/socket/sys/socket.rs new file mode 100644 index 0000000000000..e0a24e548a9a6 --- /dev/null +++ b/src/new/glibc/socket/sys/socket.rs @@ -0,0 +1,20 @@ +//! Header: `socket/sys/socket.h` + +pub use crate::new::glibc::bits::socket::*; +use crate::prelude::*; + +c_enum! { + #[repr(c_int)] + enum #anon { + pub SHUT_RD = 0, + pub SHUT_WR, + pub SHUT_RDWR, + } +} + +s! { + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: c_uint, + } +} diff --git a/src/new/glibc/sys.rs b/src/new/glibc/sys.rs new file mode 100644 index 0000000000000..c575be6fd3225 --- /dev/null +++ b/src/new/glibc/sys.rs @@ -0,0 +1,13 @@ +//! Source directory: `sys/` +//! +//! + +#[cfg(target_os = "linux")] +pub(crate) mod statvfs { + pub use super::super::io::sys::statvfs::*; +} + +#[cfg(target_os = "linux")] +pub(crate) mod socket { + pub use super::super::socket::sys::socket::*; +} diff --git a/src/new/glibc/sysdeps/unix/linux/bits/socket.rs b/src/new/glibc/sysdeps/unix/linux/bits/socket.rs new file mode 100644 index 0000000000000..da2fac5a21e43 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/bits/socket.rs @@ -0,0 +1,3 @@ +//! Header: `sysdeps/unix/sysv/linux/bits/socket.h` + +pub use super::socket_type::*; diff --git a/src/new/glibc/sysdeps/unix/linux/bits/socket_type.rs b/src/new/glibc/sysdeps/unix/linux/bits/socket_type.rs new file mode 100644 index 0000000000000..e0db7f38d963d --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/bits/socket_type.rs @@ -0,0 +1,20 @@ +//! Header: `sysdeps/unix/sysv/linux/bits/socket_type.h` + +use crate::prelude::*; + +c_enum! { + // Actually called __socket_type but that causes test issues + #[repr(c_int)] + enum #anon { + pub SOCK_STREAM = 1, + pub SOCK_DGRAM = 2, + pub SOCK_RAW = 3, + pub SOCK_RDM = 4, + pub SOCK_SEQPACKET = 5, + pub SOCK_DCCP = 6, + #[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] + pub SOCK_PACKET = 10, + pub SOCK_CLOEXEC = 0o2000000, + pub SOCK_NONBLOCK = 0o0004000, + } +} diff --git a/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs b/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs index 03fc1ac847278..a8e36ca11981c 100644 --- a/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs +++ b/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs @@ -37,15 +37,12 @@ s! { pub f_ffree: u64, pub f_favail: u64, pub f_fsid: c_ulong, - // FIXME(riscv32): glibc declares this field on riscv32 too, but we have - // never declared it here. + // Mirrors `_STATVFSBUF_F_UNUSED` in the header. x32 is excluded because + // its `__SYSCALL_WORDSIZE` is 64, aarch64 because glibc always sets + // `__WORDSIZE` to 64. #[cfg(all( target_pointer_width = "32", - not(any( - target_arch = "x86_64", - target_arch = "aarch64", - target_arch = "riscv32" - )) + not(any(target_arch = "x86_64", target_arch = "aarch64")) ))] __f_unused: Padding, pub f_flag: c_ulong, diff --git a/src/new/glibc/sysdeps/unix/linux/mips/bits/socket_type.rs b/src/new/glibc/sysdeps/unix/linux/mips/bits/socket_type.rs new file mode 100644 index 0000000000000..8fb20087da656 --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/mips/bits/socket_type.rs @@ -0,0 +1,20 @@ +//! Header: `sysdeps/unix/sysv/linux/mips/bits/socket_type.h` + +use crate::prelude::*; + +c_enum! { + // Actually called __socket_type but that causes test issues + #[repr(c_int)] + enum #anon { + pub SOCK_DGRAM = 1, + pub SOCK_STREAM = 2, + pub SOCK_RAW = 3, + pub SOCK_RDM = 4, + pub SOCK_SEQPACKET = 5, + pub SOCK_DCCP = 6, + #[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] + pub SOCK_PACKET = 10, + pub SOCK_CLOEXEC = 0o2000000, + pub SOCK_NONBLOCK = 0o0000200, + } +} diff --git a/src/new/glibc/sysdeps/unix/linux/mod.rs b/src/new/glibc/sysdeps/unix/linux/mod.rs index f3d704d63e55d..08304add3d716 100644 --- a/src/new/glibc/sysdeps/unix/linux/mod.rs +++ b/src/new/glibc/sysdeps/unix/linux/mod.rs @@ -35,6 +35,23 @@ pub(crate) mod bits { )] pub(crate) mod signum_arch; + #[cfg_attr( + any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips", + target_arch = "mips32r6", + ), + path = "../mips/bits/socket_type.rs" + )] + #[cfg_attr( + any(target_arch = "sparc", target_arch = "sparc64"), + path = "../sparc/bits/socket_type.rs" + )] + pub(crate) mod socket_type; + + pub(crate) mod socket; + pub(crate) mod statvfs; pub(crate) mod types; diff --git a/src/new/glibc/sysdeps/unix/linux/sparc/bits/socket_type.rs b/src/new/glibc/sysdeps/unix/linux/sparc/bits/socket_type.rs new file mode 100644 index 0000000000000..7a5821a1a6f3e --- /dev/null +++ b/src/new/glibc/sysdeps/unix/linux/sparc/bits/socket_type.rs @@ -0,0 +1,20 @@ +//! Header: `sysdeps/unix/sysv/linux/mips/bits/socket_type.h` + +use crate::prelude::*; + +c_enum! { + // Actually called __socket_type but that causes test issues + #[repr(c_int)] + enum #anon { + pub SOCK_STREAM = 1, + pub SOCK_DGRAM = 2, + pub SOCK_RAW = 3, + pub SOCK_RDM = 4, + pub SOCK_SEQPACKET = 5, + pub SOCK_DCCP = 6, + #[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] + pub SOCK_PACKET = 10, + pub SOCK_CLOEXEC = 0x400000, + pub SOCK_NONBLOCK = 0x004000, + } +} diff --git a/src/new/helenos/bits.rs b/src/new/helenos/bits.rs index bcb704d8cb038..8396c579d0479 100644 --- a/src/new/helenos/bits.rs +++ b/src/new/helenos/bits.rs @@ -2,8 +2,10 @@ //! //! * Headers: +use crate::prelude::*; + // `errno.h` -pub type errno_t = crate::c_int; +pub type errno_t = c_int; // `native.h` -pub type sysarg_t = crate::uintptr_t; +pub type sysarg_t = uintptr_t; diff --git a/src/new/helenos/time.rs b/src/new/helenos/time.rs index 0175af24c0061..daa5c1ee7937b 100644 --- a/src/new/helenos/time.rs +++ b/src/new/helenos/time.rs @@ -7,7 +7,8 @@ use crate::prelude::*; pub type time_t = c_longlong; pub type usec_t = c_longlong; -s_with_default! { +s2! { + #[exhaustive] pub struct timespec { pub tv_sec: time_t, pub tv_nsec: c_long, diff --git a/src/new/linux_uapi/linux/can.rs b/src/new/linux_uapi/linux/can.rs index 989e854c45270..701f9efee3520 100644 --- a/src/new/linux_uapi/linux/can.rs +++ b/src/new/linux_uapi/linux/can.rs @@ -37,7 +37,7 @@ pub const CANXL_MAX_DLC_MASK: c_int = 0x07FF; pub const CANXL_MIN_DLEN: usize = 1; pub const CANXL_MAX_DLEN: usize = 2048; -s_with_default! { +s2! { #[repr(align(8))] pub struct can_frame { pub can_id: canid_t, @@ -54,7 +54,7 @@ pub const CANFD_BRS: c_int = 0x01; pub const CANFD_ESI: c_int = 0x02; pub const CANFD_FDF: c_int = 0x04; -s_with_default! { +s2! { #[repr(align(8))] pub struct canfd_frame { pub can_id: canid_t, @@ -70,7 +70,8 @@ s_with_default! { pub const CANXL_XLF: c_int = 0x80; pub const CANXL_SEC: c_int = 0x01; -s_with_default! { +s2! { + #[exhaustive] pub struct canxl_frame { pub prio: canid_t, pub flags: u8, @@ -103,7 +104,8 @@ pub const CAN_NPROTO: c_int = 8; pub const SOL_CAN_BASE: c_int = 100; -s_no_extra_traits_with_default! { +s_no_extra_traits2! { + #[exhaustive] pub struct sockaddr_can { pub can_family: crate::sa_family_t, pub can_ifindex: c_int, @@ -117,18 +119,21 @@ s_no_extra_traits_with_default! { } } -s! { +s2! { + #[exhaustive] pub struct __c_anonymous_sockaddr_can_tp { pub rx_id: canid_t, pub tx_id: canid_t, } + #[exhaustive] pub struct __c_anonymous_sockaddr_can_j1939 { pub name: u64, pub pgn: u32, pub addr: u8, } + #[exhaustive] pub struct can_filter { pub can_id: canid_t, pub can_mask: canid_t, diff --git a/src/new/linux_uapi/linux/futex.rs b/src/new/linux_uapi/linux/futex.rs index 893dee0e00623..e65977b99bea4 100644 --- a/src/new/linux_uapi/linux/futex.rs +++ b/src/new/linux_uapi/linux/futex.rs @@ -19,8 +19,11 @@ pub const FUTEX_LOCK_PI2: c_int = 13; pub const FUTEX_PRIVATE_FLAG: c_int = 128; pub const FUTEX_CLOCK_REALTIME: c_int = 256; +pub const FUTEX_ROBUST_UNLOCK: c_int = 512; +pub const FUTEX_ROBUST_LIST32: c_int = 1024; -pub const FUTEX_CMD_MASK: c_int = !(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME); +pub const FUTEX_CMD_MASK: c_int = + !(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME | FUTEX_ROBUST_UNLOCK | FUTEX_ROBUST_LIST32); pub const FUTEX2_SIZE_U8: c_int = 0x00; pub const FUTEX2_SIZE_U16: c_int = 0x01; diff --git a/src/new/mod.rs b/src/new/mod.rs index 8f12b20afa993..557717d733b1c 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -197,15 +197,19 @@ cfg_if! { pub use linux::sctp::*; pub use linux::tls::*; pub use linux::types::*; - #[cfg(target_env = "uclibc")] - pub use sysdeps::linux::common::bits::siginfo::*; #[cfg(target_env = "gnu")] pub use self::{ net::route::*, signal::*, + sys::socket::*, sys::statvfs::*, }; + #[cfg(target_env = "uclibc")] + pub use self::{ + socket::*, + sysdeps::linux::common::bits::siginfo::*, + }; } else if #[cfg(target_vendor = "apple")] { #[cfg(target_os = "macos")] pub use net::bpf::*; @@ -235,6 +239,7 @@ cfg_if! { pub use utmpx_::*; } else if #[cfg(target_os = "openbsd")] { pub use sys::ipc::*; + pub use sys::sensors::*; pub use sys::sysctl::*; } else if #[cfg(any(target_os = "nto", target_os = "qnx"))] { pub use net::bpf::*; diff --git a/src/new/musl/arch/mips/bits/socket.rs b/src/new/musl/arch/mips/bits/socket.rs index 77b53e489c3d8..8d4845fea79ca 100644 --- a/src/new/musl/arch/mips/bits/socket.rs +++ b/src/new/musl/arch/mips/bits/socket.rs @@ -2,3 +2,6 @@ use crate::prelude::*; pub const SOCK_STREAM: c_int = 2; pub const SOCK_DGRAM: c_int = 1; + +pub const SOCK_NONBLOCK: c_int = 0o200; +pub const SOCK_CLOEXEC: c_int = 0o2000000; diff --git a/src/new/musl/arch/mips64/bits/socket.rs b/src/new/musl/arch/mips64/bits/socket.rs index 77b53e489c3d8..8d4845fea79ca 100644 --- a/src/new/musl/arch/mips64/bits/socket.rs +++ b/src/new/musl/arch/mips64/bits/socket.rs @@ -2,3 +2,6 @@ use crate::prelude::*; pub const SOCK_STREAM: c_int = 2; pub const SOCK_DGRAM: c_int = 1; + +pub const SOCK_NONBLOCK: c_int = 0o200; +pub const SOCK_CLOEXEC: c_int = 0o2000000; diff --git a/src/new/musl/signal.rs b/src/new/musl/signal.rs index 3fa4fab66eb11..ea440e4da8cd0 100644 --- a/src/new/musl/signal.rs +++ b/src/new/musl/signal.rs @@ -63,17 +63,17 @@ s_no_extra_traits! { si_arch: c_uint, } - struct __c_anonymous___si_common___first { + union __c_anonymous___si_common___first { __piduid: __c_anonymous___first___piduid, __timer: __c_anonymous___first___timer, } - struct __c_anonymous___si_common___second { + union __c_anonymous___si_common___second { si_value: crate::sigval, __sigchld: __c_anonymous___second___sigchld, } - struct __c_anonymous___sigfault___first { + union __c_anonymous___sigfault___first { __addr_band: __c_anonymous___first___addr_band, si_pkey: c_uint, } diff --git a/src/new/musl/sys/socket.rs b/src/new/musl/sys/socket.rs index 8083ddc2a7dc4..1b54c7bfdfa68 100644 --- a/src/new/musl/sys/socket.rs +++ b/src/new/musl/sys/socket.rs @@ -33,6 +33,11 @@ s! { pub cmsg_level: c_int, pub cmsg_type: c_int, } + + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: c_uint, + } } extern "C" { @@ -52,6 +57,10 @@ extern "C" { ) -> c_int; } +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + cfg_if! { if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] { pub use crate::bits::socket::{ @@ -63,3 +72,36 @@ cfg_if! { pub const SOCK_DGRAM: c_int = 2; } } + +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const SOCK_SEQPACKET: c_int = 5; +pub const SOCK_DCCP: c_int = 6; +#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] +pub const SOCK_PACKET: c_int = 10; + +cfg_if! { + if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] { + pub use crate::bits::socket::{ + SOCK_CLOEXEC, + SOCK_NONBLOCK, + }; + } else { + pub const SOCK_CLOEXEC: c_int = 0o2000000; + pub const SOCK_NONBLOCK: c_int = 0o4000; + } +} + +pub const PF_IB: c_int = 27; +pub const PF_MPLS: c_int = 28; + +pub const PF_NFC: c_int = 39; +pub const PF_VSOCK: c_int = 40; + +pub const PF_XDP: c_int = 44; + +pub const AF_IB: c_int = PF_IB; +pub const AF_MPLS: c_int = PF_MPLS; +pub const AF_NFC: c_int = PF_NFC; +pub const AF_VSOCK: c_int = PF_VSOCK; +pub const AF_XDP: c_int = PF_XDP; diff --git a/src/new/openbsd/sys/mod.rs b/src/new/openbsd/sys/mod.rs index 94d4e8db38a29..e292917e15ee9 100644 --- a/src/new/openbsd/sys/mod.rs +++ b/src/new/openbsd/sys/mod.rs @@ -3,4 +3,5 @@ //! pub(crate) mod ipc; +pub(crate) mod sensors; pub(crate) mod sysctl; diff --git a/src/new/openbsd/sys/sensors.rs b/src/new/openbsd/sys/sensors.rs new file mode 100644 index 0000000000000..c6aa7d9ddcbcf --- /dev/null +++ b/src/new/openbsd/sys/sensors.rs @@ -0,0 +1,71 @@ +//! Header: `sys/sensors.h` +//! +//! + +use crate::prelude::*; +use crate::timeval; + +pub const SENSOR_FINVALID: c_int = 0x0001; +pub const SENSOR_FUNKNOWN: c_int = 0x0002; + +c_enum! { + pub enum sensor_status { + pub SENSOR_S_UNSPEC, + pub SENSOR_S_OK, + pub SENSOR_S_WARN, + pub SENSOR_S_CRIT, + pub SENSOR_S_UNKNOWN, + } +} + +c_enum! { + pub enum sensor_type { + pub SENSOR_TEMP, + pub SENSOR_FANRPM, + pub SENSOR_VOLTS_DC, + pub SENSOR_VOLTS_AC, + pub SENSOR_OHMS, + pub SENSOR_WATTS, + pub SENSOR_AMPS, + pub SENSOR_WATTHOUR, + pub SENSOR_AMPHOUR, + pub SENSOR_INDICATOR, + pub SENSOR_INTEGER, + pub SENSOR_PERCENT, + pub SENSOR_LUX, + pub SENSOR_DRIVE, + pub SENSOR_TIMEDELTA, + pub SENSOR_HUMIDITY, + pub SENSOR_FREQ, + pub SENSOR_ANGLE, + pub SENSOR_DISTANCE, + pub SENSOR_PRESSURE, + pub SENSOR_ACCEL, + pub SENSOR_VELOCITY, + pub SENSOR_ENERGY, + pub SENSOR_MAX_TYPES, + } +} + +pub const SENSOR_DRIVE_EMPTY: c_int = 1; +pub const SENSOR_DRIVE_READY: c_int = 2; +pub const SENSOR_DRIVE_POWERUP: c_int = 3; +pub const SENSOR_DRIVE_ONLINE: c_int = 4; +pub const SENSOR_DRIVE_IDLE: c_int = 5; +pub const SENSOR_DRIVE_ACTIVE: c_int = 6; +pub const SENSOR_DRIVE_REBUILD: c_int = 7; +pub const SENSOR_DRIVE_POWERDOWN: c_int = 8; +pub const SENSOR_DRIVE_FAIL: c_int = 9; +pub const SENSOR_DRIVE_PFAIL: c_int = 10; + +s! { + pub struct sensor { + pub desc: [c_char; 32], + pub tv: timeval, + pub value: i64, + pub type_: sensor_type, + pub status: sensor_status, + pub numt: c_int, + pub flags: c_int, + } +} diff --git a/src/new/qurt/stdio.rs b/src/new/qurt/stdio.rs index 7130717764e8a..191bdda3fb4c8 100644 --- a/src/new/qurt/stdio.rs +++ b/src/new/qurt/stdio.rs @@ -65,6 +65,10 @@ extern "C" { pub fn remove(filename: *const c_char) -> c_int; pub fn rename(old: *const c_char, new: *const c_char) -> c_int; pub fn tmpfile() -> *mut FILE; + #[deprecated( + since = "0.2.190", + note = "function is obsolete; prefer tmpfile, mkstemp, or similar" + )] pub fn tmpnam(s: *mut c_char) -> *mut c_char; // Buffer control diff --git a/src/new/uclibc/mod.rs b/src/new/uclibc/mod.rs index 6f99b4e95c0cb..81615dc1941dc 100644 --- a/src/new/uclibc/mod.rs +++ b/src/new/uclibc/mod.rs @@ -5,6 +5,9 @@ pub(crate) mod pthread; +#[cfg(target_os = "linux")] +pub(crate) mod socket; + /// Directory source: `libc/sysdeps` /// /// * Headers: (official) diff --git a/src/new/uclibc/socket.rs b/src/new/uclibc/socket.rs new file mode 100644 index 0000000000000..3001cd7c408c3 --- /dev/null +++ b/src/new/uclibc/socket.rs @@ -0,0 +1,63 @@ +//! Header: `include/sys/socket.h` + +use crate::prelude::*; + +cfg_if! { + if #[cfg(target_arch = "mips")] { + // Header: `libc/sysdeps/linux/mips/bits/socket_type.h` + // + // Inlined for simplicity. + // Actually called __socket_type but that causes test issues + c_enum! { + #[repr(c_int)] + enum #anon { + pub SOCK_DGRAM = 1, + pub SOCK_STREAM = 2, + pub SOCK_RAW = 3, + pub SOCK_RDM = 4, + pub SOCK_SEQPACKET = 5, + pub SOCK_DCCP = 6, + #[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] + pub SOCK_PACKET = 10, + pub SOCK_CLOEXEC = 0o2000000, + pub SOCK_NONBLOCK = 0o0000200, + } + } + } else { + // Header: `libc/sysdeps/linux/common/bits/socket_type.h` + // + // Inlined for simplicity. + // Actually called __socket_type but that causes test issues + c_enum! { + #[repr(c_int)] + enum #anon { + pub SOCK_STREAM = 1, + pub SOCK_DGRAM = 2, + pub SOCK_RAW = 3, + pub SOCK_RDM = 4, + pub SOCK_SEQPACKET = 5, + pub SOCK_DCCP = 6, + #[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] + pub SOCK_PACKET = 10, + pub SOCK_CLOEXEC = 0o2000000, + pub SOCK_NONBLOCK = 0o0004000, + } + } + } +} + +c_enum! { + #[repr(c_int)] + enum #anon { + pub SHUT_RD = 0, + pub SHUT_WR, + pub SHUT_RDWR, + } +} + +s! { + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: c_uint, + } +} diff --git a/src/solid/mod.rs b/src/solid/mod.rs index 7184ccf05719c..2b096231d7aba 100644 --- a/src/solid/mod.rs +++ b/src/solid/mod.rs @@ -461,6 +461,10 @@ extern "C" { pub fn vprintf(arg1: *const c_char, arg2: __va_list) -> c_int; pub fn gets(arg1: *mut c_char) -> *mut c_char; pub fn sprintf(arg1: *mut c_char, arg2: *const c_char, ...) -> c_int; + #[deprecated( + since = "0.2.190", + note = "function is obsolete; prefer tmpfile, mkstemp, or similar" + )] pub fn tmpnam(arg1: *const c_char) -> *mut c_char; pub fn vsprintf(arg1: *mut c_char, arg2: *const c_char, arg3: __va_list) -> c_int; pub fn rename(arg1: *const c_char, arg2: *const c_char) -> c_int; @@ -507,6 +511,10 @@ extern "C" { ) -> c_int; pub fn getw(arg1: *mut FILE) -> c_int; pub fn putw(arg1: c_int, arg2: *mut FILE) -> c_int; + #[deprecated( + since = "0.2.190", + note = "function is obsolete; prefer tmpfile, mkstemp, or similar" + )] pub fn tempnam(arg1: *const c_char, arg2: *const c_char) -> *mut c_char; pub fn fseeko(stream: *mut FILE, offset: off_t, whence: c_int) -> c_int; pub fn ftello(stream: *mut FILE) -> off_t; diff --git a/src/types.rs b/src/types.rs index 02bb2d33ce890..c3036ea39ecdf 100644 --- a/src/types.rs +++ b/src/types.rs @@ -140,3 +140,11 @@ pub const fn replace_array_items( } dst } + +/// Constructs a compile time cstring literal from a byte array +// FIXME(msrv): we can opt to use C-string literals directly in 1.77 +#[allow(dead_code)] +pub(crate) const fn cstr(bytes: &[u8]) -> *const c_char { + assert!(!bytes.is_empty() && bytes[bytes.len() - 1] == 0); + bytes.as_ptr().cast::() +} diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index a0e86fada7a64..efd9c486bd0a5 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -1,8 +1,4 @@ use crate::prelude::*; -use crate::{ - in_addr_t, - in_port_t, -}; pub type caddr_t = *mut c_char; pub type clockid_t = c_longlong; @@ -88,7 +84,7 @@ s! { } pub struct fsid64_t { - pub val: [crate::uint64_t; 2], + pub val: [u64; 2], } pub struct timezone { @@ -103,18 +99,18 @@ s! { pub struct dirent { pub d_offset: c_ulong, - pub d_ino: crate::ino_t, + pub d_ino: ino_t, pub d_reclen: c_ushort, pub d_namlen: c_ushort, pub d_name: [c_char; 256], } pub struct termios { - pub c_iflag: crate::tcflag_t, - pub c_oflag: crate::tcflag_t, - pub c_cflag: crate::tcflag_t, - pub c_lflag: crate::tcflag_t, - pub c_cc: [crate::cc_t; crate::NCCS], + pub c_iflag: tcflag_t, + pub c_oflag: tcflag_t, + pub c_cflag: tcflag_t, + pub c_lflag: tcflag_t, + pub c_cc: [crate::cc_t; NCCS], } // FIXME(1.0,deprecate): lfs binding to be removed @@ -130,7 +126,7 @@ s! { pub struct msghdr { pub msg_name: *mut c_void, - pub msg_namelen: crate::socklen_t, + pub msg_namelen: socklen_t, pub msg_iov: *mut crate::iovec, pub msg_iovlen: c_int, pub msg_control: *mut c_void, @@ -140,14 +136,14 @@ s! { // FIXME(1.0,deprecate,32): lfs binding to be removed. pub struct statvfs64 { - pub f_bsize: crate::blksize64_t, - pub f_frsize: crate::blksize64_t, - pub f_blocks: crate::blkcnt64_t, - pub f_bfree: crate::blkcnt64_t, - pub f_bavail: crate::blkcnt64_t, - pub f_files: crate::blkcnt64_t, - pub f_ffree: crate::blkcnt64_t, - pub f_favail: crate::blkcnt64_t, + pub f_bsize: blksize64_t, + pub f_frsize: blksize64_t, + pub f_blocks: blkcnt64_t, + pub f_bfree: blkcnt64_t, + pub f_bavail: blkcnt64_t, + pub f_files: blkcnt64_t, + pub f_ffree: blkcnt64_t, + pub f_favail: blkcnt64_t, pub f_fsid: fsid64_t, pub f_basetype: [c_char; 16], pub f_flag: c_ulong, @@ -204,13 +200,13 @@ s! { pub ai_protocol: c_int, pub ai_addrlen: c_ulong, pub ai_canonname: *mut c_char, - pub ai_addr: *mut crate::sockaddr, + pub ai_addr: *mut sockaddr, pub ai_next: *mut addrinfo, pub ai_eflags: c_int, } pub struct in_addr { - pub s_addr: in_addr_t, + pub s_addr: crate::in_addr_t, } pub struct ip_mreq_source { @@ -239,7 +235,7 @@ s! { pub struct sockaddr_in { pub sin_len: c_uchar, pub sin_family: sa_family_t, - pub sin_port: in_port_t, + pub sin_port: crate::in_port_t, pub sin_addr: in_addr, pub sin_zero: [c_uchar; 8], } @@ -247,17 +243,17 @@ s! { pub struct sockaddr_in6 { pub sin6_len: c_uchar, pub sin6_family: c_uchar, - pub sin6_port: crate::uint16_t, - pub sin6_flowinfo: crate::uint32_t, + pub sin6_port: u16, + pub sin6_flowinfo: u32, pub sin6_addr: crate::in6_addr, - pub sin6_scope_id: crate::uint32_t, + pub sin6_scope_id: u32, } pub struct sockaddr_storage { pub __ss_len: c_uchar, pub ss_family: sa_family_t, __ss_pad1: Padding<[c_char; 6]>, - __ss_align: crate::int64_t, + __ss_align: i64, __ss_pad2: Padding<[c_char; 1265]>, } @@ -268,7 +264,7 @@ s! { } pub struct st_timespec { - pub tv_sec: crate::time_t, + pub tv_sec: time_t, pub tv_nsec: c_int, } @@ -280,8 +276,8 @@ s! { pub f_blocks: blkcnt64_t, pub f_bfree: blkcnt64_t, pub f_bavail: blkcnt64_t, - pub f_files: crate::uint64_t, - pub f_ffree: crate::uint64_t, + pub f_files: u64, + pub f_ffree: u64, pub f_fsid: fsid64_t, pub f_vfstype: c_int, pub f_fsize: blksize64_t, @@ -319,7 +315,7 @@ s! { } pub struct cmsghdr { - pub cmsg_len: crate::socklen_t, + pub cmsg_len: socklen_t, pub cmsg_level: c_int, pub cmsg_type: c_int, } @@ -349,16 +345,16 @@ s! { pub header_data: *mut c_void, pub header_length: c_uint, pub file_descriptor: c_int, - pub file_size: crate::uint64_t, - pub file_offset: crate::uint64_t, - pub file_bytes: crate::int64_t, + pub file_size: u64, + pub file_offset: u64, + pub file_bytes: i64, pub trailer_data: *mut c_void, pub trailer_length: c_uint, - pub bytes_sent: crate::uint64_t, + pub bytes_sent: u64, } pub struct mmsghdr { - pub msg_hdr: crate::msghdr, + pub msg_hdr: msghdr, pub msg_len: c_uint, } @@ -378,8 +374,8 @@ s! { pub struct posix_spawnattr_t { pub posix_attr_flags: c_short, pub posix_attr_pgroup: crate::pid_t, - pub posix_attr_sigmask: crate::sigset_t, - pub posix_attr_sigdefault: crate::sigset_t, + pub posix_attr_sigmask: sigset_t, + pub posix_attr_sigdefault: sigset_t, pub posix_attr_schedpolicy: c_int, pub posix_attr_schedparam: sched_param, } @@ -435,7 +431,7 @@ s! { pub re_cflags: c_int, pub re_erroff: size_t, pub re_len: size_t, - pub re_ucoll: [crate::wchar_t; 2], + pub re_ucoll: [wchar_t; 2], pub re_lsub: [*mut c_void; 24], pub re_esub: [*mut c_void; 24], pub re_map: *mut c_uchar, @@ -459,12 +455,12 @@ s! { pub shm_atime: time_t, pub shm_dtime: time_t, pub shm_ctime: time_t, - pub shm_handle: crate::uint32_t, + pub shm_handle: u32, pub shm_extshm: c_int, - pub shm_pagesize: crate::int64_t, - pub shm_lba: crate::uint64_t, - shm_reserved0: Padding, - shm_reserved1: Padding, + pub shm_pagesize: i64, + pub shm_lba: u64, + shm_reserved0: Padding, + shm_reserved1: Padding, } // FIXME(1.0,deprecate): lfs binding to be removed @@ -550,13 +546,13 @@ s! { pub command: u8, pub events: c_short, pub fd: c_int, - pub u: __poll_ctl_ext_u, + pub u: __c_anonymous_poll_ctl_ext_u, reserved64: Padding<[u64; 6]>, } } s_no_extra_traits! { - pub union __poll_ctl_ext_u { + pub union __c_anonymous_poll_ctl_ext_u { pub addr: *mut c_void, pub data32: u32, pub data: u64, @@ -565,8 +561,8 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for __poll_ctl_ext_u { - fn eq(&self, other: &__poll_ctl_ext_u) -> bool { + impl PartialEq for __c_anonymous_poll_ctl_ext_u { + fn eq(&self, other: &__c_anonymous_poll_ctl_ext_u) -> bool { unsafe { self.addr == other.addr && self.data32 == other.data32 @@ -574,8 +570,8 @@ cfg_if! { } } } - impl Eq for __poll_ctl_ext_u {} - impl hash::Hash for __poll_ctl_ext_u { + impl Eq for __c_anonymous_poll_ctl_ext_u {} + impl hash::Hash for __c_anonymous_poll_ctl_ext_u { fn hash(&self, state: &mut H) { unsafe { self.addr.hash(state); @@ -665,63 +661,63 @@ pub const GLOB_NOMATCH: c_int = 0x4000; pub const GLOB_NOSYS: c_int = 0x8000; // langinfo.h -pub const DAY_1: crate::nl_item = 13; -pub const DAY_2: crate::nl_item = 14; -pub const DAY_3: crate::nl_item = 15; -pub const DAY_4: crate::nl_item = 16; -pub const DAY_5: crate::nl_item = 17; -pub const DAY_6: crate::nl_item = 18; -pub const DAY_7: crate::nl_item = 19; -pub const ABDAY_1: crate::nl_item = 6; -pub const ABDAY_2: crate::nl_item = 7; -pub const ABDAY_3: crate::nl_item = 8; -pub const ABDAY_4: crate::nl_item = 9; -pub const ABDAY_5: crate::nl_item = 10; -pub const ABDAY_6: crate::nl_item = 11; -pub const ABDAY_7: crate::nl_item = 12; -pub const MON_1: crate::nl_item = 32; -pub const MON_2: crate::nl_item = 33; -pub const MON_3: crate::nl_item = 34; -pub const MON_4: crate::nl_item = 35; -pub const MON_5: crate::nl_item = 36; -pub const MON_6: crate::nl_item = 37; -pub const MON_7: crate::nl_item = 38; -pub const MON_8: crate::nl_item = 39; -pub const MON_9: crate::nl_item = 40; -pub const MON_10: crate::nl_item = 41; -pub const MON_11: crate::nl_item = 42; -pub const MON_12: crate::nl_item = 43; -pub const ABMON_1: crate::nl_item = 20; -pub const ABMON_2: crate::nl_item = 21; -pub const ABMON_3: crate::nl_item = 22; -pub const ABMON_4: crate::nl_item = 23; -pub const ABMON_5: crate::nl_item = 24; -pub const ABMON_6: crate::nl_item = 25; -pub const ABMON_7: crate::nl_item = 26; -pub const ABMON_8: crate::nl_item = 27; -pub const ABMON_9: crate::nl_item = 28; -pub const ABMON_10: crate::nl_item = 29; -pub const ABMON_11: crate::nl_item = 30; -pub const ABMON_12: crate::nl_item = 31; -pub const RADIXCHAR: crate::nl_item = 44; -pub const THOUSEP: crate::nl_item = 45; -pub const YESSTR: crate::nl_item = 46; -pub const NOSTR: crate::nl_item = 47; -pub const CRNCYSTR: crate::nl_item = 48; -pub const D_T_FMT: crate::nl_item = 1; -pub const D_FMT: crate::nl_item = 2; -pub const T_FMT: crate::nl_item = 3; -pub const AM_STR: crate::nl_item = 4; -pub const PM_STR: crate::nl_item = 5; -pub const CODESET: crate::nl_item = 49; -pub const T_FMT_AMPM: crate::nl_item = 55; -pub const ERA: crate::nl_item = 56; -pub const ERA_D_FMT: crate::nl_item = 57; -pub const ERA_D_T_FMT: crate::nl_item = 58; -pub const ERA_T_FMT: crate::nl_item = 59; -pub const ALT_DIGITS: crate::nl_item = 60; -pub const YESEXPR: crate::nl_item = 61; -pub const NOEXPR: crate::nl_item = 62; +pub const DAY_1: nl_item = 13; +pub const DAY_2: nl_item = 14; +pub const DAY_3: nl_item = 15; +pub const DAY_4: nl_item = 16; +pub const DAY_5: nl_item = 17; +pub const DAY_6: nl_item = 18; +pub const DAY_7: nl_item = 19; +pub const ABDAY_1: nl_item = 6; +pub const ABDAY_2: nl_item = 7; +pub const ABDAY_3: nl_item = 8; +pub const ABDAY_4: nl_item = 9; +pub const ABDAY_5: nl_item = 10; +pub const ABDAY_6: nl_item = 11; +pub const ABDAY_7: nl_item = 12; +pub const MON_1: nl_item = 32; +pub const MON_2: nl_item = 33; +pub const MON_3: nl_item = 34; +pub const MON_4: nl_item = 35; +pub const MON_5: nl_item = 36; +pub const MON_6: nl_item = 37; +pub const MON_7: nl_item = 38; +pub const MON_8: nl_item = 39; +pub const MON_9: nl_item = 40; +pub const MON_10: nl_item = 41; +pub const MON_11: nl_item = 42; +pub const MON_12: nl_item = 43; +pub const ABMON_1: nl_item = 20; +pub const ABMON_2: nl_item = 21; +pub const ABMON_3: nl_item = 22; +pub const ABMON_4: nl_item = 23; +pub const ABMON_5: nl_item = 24; +pub const ABMON_6: nl_item = 25; +pub const ABMON_7: nl_item = 26; +pub const ABMON_8: nl_item = 27; +pub const ABMON_9: nl_item = 28; +pub const ABMON_10: nl_item = 29; +pub const ABMON_11: nl_item = 30; +pub const ABMON_12: nl_item = 31; +pub const RADIXCHAR: nl_item = 44; +pub const THOUSEP: nl_item = 45; +pub const YESSTR: nl_item = 46; +pub const NOSTR: nl_item = 47; +pub const CRNCYSTR: nl_item = 48; +pub const D_T_FMT: nl_item = 1; +pub const D_FMT: nl_item = 2; +pub const T_FMT: nl_item = 3; +pub const AM_STR: nl_item = 4; +pub const PM_STR: nl_item = 5; +pub const CODESET: nl_item = 49; +pub const T_FMT_AMPM: nl_item = 55; +pub const ERA: nl_item = 56; +pub const ERA_D_FMT: nl_item = 57; +pub const ERA_D_T_FMT: nl_item = 58; +pub const ERA_T_FMT: nl_item = 59; +pub const ALT_DIGITS: nl_item = 60; +pub const YESEXPR: nl_item = 61; +pub const NOEXPR: nl_item = 62; // locale.h pub const LC_GLOBAL_LOCALE: crate::locale_t = -1isize as crate::locale_t; @@ -746,14 +742,14 @@ pub const LC_ALL_MASK: c_int = LC_COLLATE_MASK | LC_TIME_MASK; // netdb.h -pub const NI_MAXHOST: crate::socklen_t = 1025; -pub const NI_MAXSERV: crate::socklen_t = 32; -pub const NI_NOFQDN: crate::socklen_t = 0x1; -pub const NI_NUMERICHOST: crate::socklen_t = 0x2; -pub const NI_NAMEREQD: crate::socklen_t = 0x4; -pub const NI_NUMERICSERV: crate::socklen_t = 0x8; -pub const NI_DGRAM: crate::socklen_t = 0x10; -pub const NI_NUMERICSCOPE: crate::socklen_t = 0x40; +pub const NI_MAXHOST: socklen_t = 1025; +pub const NI_MAXSERV: socklen_t = 32; +pub const NI_NOFQDN: socklen_t = 0x1; +pub const NI_NUMERICHOST: socklen_t = 0x2; +pub const NI_NAMEREQD: socklen_t = 0x4; +pub const NI_NUMERICSERV: socklen_t = 0x8; +pub const NI_DGRAM: socklen_t = 0x10; +pub const NI_NUMERICSCOPE: socklen_t = 0x40; pub const EAI_AGAIN: c_int = 2; pub const EAI_BADFLAGS: c_int = 3; pub const EAI_FAIL: c_int = 4; @@ -1157,7 +1153,7 @@ pub const NFSMNT_ACDIRMAX: c_int = 0x0800; pub const CPUSTATES: c_int = 4; // semaphore.h -pub const SEM_FAILED: *mut sem_t = -1isize as *mut crate::sem_t; +pub const SEM_FAILED: *mut sem_t = -1isize as *mut sem_t; // spawn.h // DIFF(main): changed to `c_short` in f62eb023ab @@ -1443,7 +1439,7 @@ pub const IPC_W: c_int = 0o0200; pub const IPC_O: c_int = 0o1000; pub const IPC_NOERROR: c_int = 0o10000; pub const IPC_STAT: c_int = 102; -pub const IPC_PRIVATE: crate::key_t = -1; +pub const IPC_PRIVATE: key_t = -1; pub const SHM_LOCK: c_int = 201; pub const SHM_UNLOCK: c_int = 202; @@ -2087,8 +2083,8 @@ pub const POWER_9: c_int = 0x20000; // sys/time.h pub const FD_SETSIZE: usize = 65534; pub const TIMEOFDAY: c_int = 9; -pub const CLOCK_REALTIME: crate::clockid_t = TIMEOFDAY as clockid_t; -pub const CLOCK_MONOTONIC: crate::clockid_t = 10; +pub const CLOCK_REALTIME: clockid_t = TIMEOFDAY as clockid_t; +pub const CLOCK_MONOTONIC: clockid_t = 10; pub const TIMER_ABSTIME: c_int = 999; pub const ITIMER_REAL: c_int = 0; pub const ITIMER_VIRTUAL: c_int = 1; @@ -2105,8 +2101,8 @@ pub const DST_USA: c_int = 1; pub const DST_WET: c_int = 3; // sys/termio.h -pub const CSTART: crate::tcflag_t = 0o21; -pub const CSTOP: crate::tcflag_t = 0o23; +pub const CSTART: tcflag_t = 0o21; +pub const CSTOP: tcflag_t = 0o23; pub const TCGETA: c_int = TIOC | 5; pub const TCSETA: c_int = TIOC | 6; pub const TCSETAW: c_int = TIOC | 7; @@ -2182,44 +2178,44 @@ pub const _W_STRC: c_int = 0x0000007f; // termios.h pub const NCCS: usize = 16; -pub const OLCUC: crate::tcflag_t = 2; -pub const CSIZE: crate::tcflag_t = 0x00000030; -pub const CS5: crate::tcflag_t = 0x00000000; -pub const CS6: crate::tcflag_t = 0x00000010; -pub const CS7: crate::tcflag_t = 0x00000020; -pub const CS8: crate::tcflag_t = 0x00000030; -pub const CSTOPB: crate::tcflag_t = 0x00000040; -pub const ECHO: crate::tcflag_t = 0x00000008; -pub const ECHOE: crate::tcflag_t = 0x00000010; -pub const ECHOK: crate::tcflag_t = 0x00000020; -pub const ECHONL: crate::tcflag_t = 0x00000040; -pub const ECHOCTL: crate::tcflag_t = 0x00020000; -pub const ECHOPRT: crate::tcflag_t = 0x00040000; -pub const ECHOKE: crate::tcflag_t = 0x00080000; -pub const IGNBRK: crate::tcflag_t = 0x00000001; -pub const BRKINT: crate::tcflag_t = 0x00000002; -pub const IGNPAR: crate::tcflag_t = 0x00000004; -pub const PARMRK: crate::tcflag_t = 0x00000008; -pub const INPCK: crate::tcflag_t = 0x00000010; -pub const ISTRIP: crate::tcflag_t = 0x00000020; -pub const INLCR: crate::tcflag_t = 0x00000040; -pub const IGNCR: crate::tcflag_t = 0x00000080; -pub const ICRNL: crate::tcflag_t = 0x00000100; -pub const IXON: crate::tcflag_t = 0x00000200; -pub const IXOFF: crate::tcflag_t = 0x00000400; -pub const IXANY: crate::tcflag_t = 0x00001000; -pub const IMAXBEL: crate::tcflag_t = 0x00010000; -pub const OPOST: crate::tcflag_t = 0x00000001; -pub const ONLCR: crate::tcflag_t = 0x00000004; -pub const OCRNL: crate::tcflag_t = 0x00000008; -pub const ONOCR: crate::tcflag_t = 0x00000010; -pub const ONLRET: crate::tcflag_t = 0x00000020; -pub const CREAD: crate::tcflag_t = 0x00000080; -pub const IEXTEN: crate::tcflag_t = 0x00200000; -pub const TOSTOP: crate::tcflag_t = 0x00010000; -pub const FLUSHO: crate::tcflag_t = 0x00100000; -pub const PENDIN: crate::tcflag_t = 0x20000000; -pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const OLCUC: tcflag_t = 2; +pub const CSIZE: tcflag_t = 0x00000030; +pub const CS5: tcflag_t = 0x00000000; +pub const CS6: tcflag_t = 0x00000010; +pub const CS7: tcflag_t = 0x00000020; +pub const CS8: tcflag_t = 0x00000030; +pub const CSTOPB: tcflag_t = 0x00000040; +pub const ECHO: tcflag_t = 0x00000008; +pub const ECHOE: tcflag_t = 0x00000010; +pub const ECHOK: tcflag_t = 0x00000020; +pub const ECHONL: tcflag_t = 0x00000040; +pub const ECHOCTL: tcflag_t = 0x00020000; +pub const ECHOPRT: tcflag_t = 0x00040000; +pub const ECHOKE: tcflag_t = 0x00080000; +pub const IGNBRK: tcflag_t = 0x00000001; +pub const BRKINT: tcflag_t = 0x00000002; +pub const IGNPAR: tcflag_t = 0x00000004; +pub const PARMRK: tcflag_t = 0x00000008; +pub const INPCK: tcflag_t = 0x00000010; +pub const ISTRIP: tcflag_t = 0x00000020; +pub const INLCR: tcflag_t = 0x00000040; +pub const IGNCR: tcflag_t = 0x00000080; +pub const ICRNL: tcflag_t = 0x00000100; +pub const IXON: tcflag_t = 0x00000200; +pub const IXOFF: tcflag_t = 0x00000400; +pub const IXANY: tcflag_t = 0x00001000; +pub const IMAXBEL: tcflag_t = 0x00010000; +pub const OPOST: tcflag_t = 0x00000001; +pub const ONLCR: tcflag_t = 0x00000004; +pub const OCRNL: tcflag_t = 0x00000008; +pub const ONOCR: tcflag_t = 0x00000010; +pub const ONLRET: tcflag_t = 0x00000020; +pub const CREAD: tcflag_t = 0x00000080; +pub const IEXTEN: tcflag_t = 0x00200000; +pub const TOSTOP: tcflag_t = 0x00010000; +pub const FLUSHO: tcflag_t = 0x00100000; +pub const PENDIN: tcflag_t = 0x20000000; +pub const NOFLSH: tcflag_t = 0x00000080; pub const VINTR: usize = 0; pub const VQUIT: usize = 1; pub const VERASE: usize = 2; @@ -2237,67 +2233,67 @@ pub const VREPRINT: usize = 11; pub const VDISCRD: usize = 12; pub const VWERSE: usize = 13; pub const VLNEXT: usize = 14; -pub const B0: crate::speed_t = 0x0; -pub const B50: crate::speed_t = 0x1; -pub const B75: crate::speed_t = 0x2; -pub const B110: crate::speed_t = 0x3; -pub const B134: crate::speed_t = 0x4; -pub const B150: crate::speed_t = 0x5; -pub const B200: crate::speed_t = 0x6; -pub const B300: crate::speed_t = 0x7; -pub const B600: crate::speed_t = 0x8; -pub const B1200: crate::speed_t = 0x9; -pub const B1800: crate::speed_t = 0xa; -pub const B2400: crate::speed_t = 0xb; -pub const B4800: crate::speed_t = 0xc; -pub const B9600: crate::speed_t = 0xd; -pub const B19200: crate::speed_t = 0xe; -pub const B38400: crate::speed_t = 0xf; -pub const EXTA: crate::speed_t = B19200; -pub const EXTB: crate::speed_t = B38400; -pub const IUCLC: crate::tcflag_t = 0x00000800; -pub const OFILL: crate::tcflag_t = 0x00000040; -pub const OFDEL: crate::tcflag_t = 0x00000080; -pub const CRDLY: crate::tcflag_t = 0x00000300; -pub const CR0: crate::tcflag_t = 0x00000000; -pub const CR1: crate::tcflag_t = 0x00000100; -pub const CR2: crate::tcflag_t = 0x00000200; -pub const CR3: crate::tcflag_t = 0x00000300; -pub const TABDLY: crate::tcflag_t = 0x00000c00; -pub const TAB0: crate::tcflag_t = 0x00000000; -pub const TAB1: crate::tcflag_t = 0x00000400; -pub const TAB2: crate::tcflag_t = 0x00000800; -pub const TAB3: crate::tcflag_t = 0x00000c00; -pub const BSDLY: crate::tcflag_t = 0x00001000; -pub const BS0: crate::tcflag_t = 0x00000000; -pub const BS1: crate::tcflag_t = 0x00001000; -pub const FFDLY: crate::tcflag_t = 0x00002000; -pub const FF0: crate::tcflag_t = 0x00000000; -pub const FF1: crate::tcflag_t = 0x00002000; -pub const NLDLY: crate::tcflag_t = 0x00004000; -pub const NL0: crate::tcflag_t = 0x00000000; -pub const NL1: crate::tcflag_t = 0x00004000; -pub const VTDLY: crate::tcflag_t = 0x00008000; -pub const VT0: crate::tcflag_t = 0x00000000; -pub const VT1: crate::tcflag_t = 0x00008000; -pub const OXTABS: crate::tcflag_t = 0x00040000; -pub const ONOEOT: crate::tcflag_t = 0x00080000; -pub const CBAUD: crate::tcflag_t = 0x0000000f; -pub const PARENB: crate::tcflag_t = 0x00000100; -pub const PARODD: crate::tcflag_t = 0x00000200; -pub const HUPCL: crate::tcflag_t = 0x00000400; -pub const CLOCAL: crate::tcflag_t = 0x00000800; -pub const CIBAUD: crate::tcflag_t = 0x000f0000; -pub const IBSHIFT: crate::tcflag_t = 16; -pub const PAREXT: crate::tcflag_t = 0x00100000; -pub const ISIG: crate::tcflag_t = 0x00000001; -pub const ICANON: crate::tcflag_t = 0x00000002; -pub const XCASE: crate::tcflag_t = 0x00000004; -pub const ALTWERASE: crate::tcflag_t = 0x00400000; +pub const B0: speed_t = 0x0; +pub const B50: speed_t = 0x1; +pub const B75: speed_t = 0x2; +pub const B110: speed_t = 0x3; +pub const B134: speed_t = 0x4; +pub const B150: speed_t = 0x5; +pub const B200: speed_t = 0x6; +pub const B300: speed_t = 0x7; +pub const B600: speed_t = 0x8; +pub const B1200: speed_t = 0x9; +pub const B1800: speed_t = 0xa; +pub const B2400: speed_t = 0xb; +pub const B4800: speed_t = 0xc; +pub const B9600: speed_t = 0xd; +pub const B19200: speed_t = 0xe; +pub const B38400: speed_t = 0xf; +pub const EXTA: speed_t = B19200; +pub const EXTB: speed_t = B38400; +pub const IUCLC: tcflag_t = 0x00000800; +pub const OFILL: tcflag_t = 0x00000040; +pub const OFDEL: tcflag_t = 0x00000080; +pub const CRDLY: tcflag_t = 0x00000300; +pub const CR0: tcflag_t = 0x00000000; +pub const CR1: tcflag_t = 0x00000100; +pub const CR2: tcflag_t = 0x00000200; +pub const CR3: tcflag_t = 0x00000300; +pub const TABDLY: tcflag_t = 0x00000c00; +pub const TAB0: tcflag_t = 0x00000000; +pub const TAB1: tcflag_t = 0x00000400; +pub const TAB2: tcflag_t = 0x00000800; +pub const TAB3: tcflag_t = 0x00000c00; +pub const BSDLY: tcflag_t = 0x00001000; +pub const BS0: tcflag_t = 0x00000000; +pub const BS1: tcflag_t = 0x00001000; +pub const FFDLY: tcflag_t = 0x00002000; +pub const FF0: tcflag_t = 0x00000000; +pub const FF1: tcflag_t = 0x00002000; +pub const NLDLY: tcflag_t = 0x00004000; +pub const NL0: tcflag_t = 0x00000000; +pub const NL1: tcflag_t = 0x00004000; +pub const VTDLY: tcflag_t = 0x00008000; +pub const VT0: tcflag_t = 0x00000000; +pub const VT1: tcflag_t = 0x00008000; +pub const OXTABS: tcflag_t = 0x00040000; +pub const ONOEOT: tcflag_t = 0x00080000; +pub const CBAUD: tcflag_t = 0x0000000f; +pub const PARENB: tcflag_t = 0x00000100; +pub const PARODD: tcflag_t = 0x00000200; +pub const HUPCL: tcflag_t = 0x00000400; +pub const CLOCAL: tcflag_t = 0x00000800; +pub const CIBAUD: tcflag_t = 0x000f0000; +pub const IBSHIFT: tcflag_t = 16; +pub const PAREXT: tcflag_t = 0x00100000; +pub const ISIG: tcflag_t = 0x00000001; +pub const ICANON: tcflag_t = 0x00000002; +pub const XCASE: tcflag_t = 0x00000004; +pub const ALTWERASE: tcflag_t = 0x00400000; // time.h -pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 11; -pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 12; +pub const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 11; +pub const CLOCK_THREAD_CPUTIME_ID: clockid_t = 12; // unistd.h pub const _POSIX_VDISABLE: c_int = 0xff; @@ -2484,7 +2480,8 @@ f! { { ptr::null_mut() } else { - // AIX does not have any alignment/padding for ancillary data, so we don't need _CMSG_ALIGN here. + // AIX does not have any alignment/padding for ancillary data, + // so we don't need _CMSG_ALIGN here. (cmsg as usize + (*cmsg).cmsg_len as usize) as *mut cmsghdr } } @@ -2571,19 +2568,19 @@ f! { false } - pub const safe fn major(dev: crate::dev_t) -> c_uint { + pub const safe fn major(dev: dev_t) -> c_uint { let x = dev >> 16; x as c_uint } - pub const safe fn minor(dev: crate::dev_t) -> c_uint { + pub const safe fn minor(dev: dev_t) -> c_uint { let y = dev & 0xFFFF; y as c_uint } - pub const safe fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { - let major = major as crate::dev_t; - let minor = minor as crate::dev_t; + pub const safe fn makedev(major: c_uint, minor: c_uint) -> dev_t { + let major = major as dev_t; + let minor = minor as dev_t; let mut dev = 0; dev |= major << 16; dev |= minor; @@ -2606,85 +2603,70 @@ extern "C" { ) -> c_int; pub fn pthread_attr_getdetachstate( - attr: *const crate::pthread_attr_t, + attr: *const pthread_attr_t, detachstate: *mut c_int, ) -> c_int; - pub fn pthread_attr_getguardsize( - attr: *const crate::pthread_attr_t, - guardsize: *mut size_t, - ) -> c_int; + pub fn pthread_attr_getguardsize(attr: *const pthread_attr_t, guardsize: *mut size_t) -> c_int; pub fn pthread_attr_getinheritsched( - attr: *const crate::pthread_attr_t, + attr: *const pthread_attr_t, inheritsched: *mut c_int, ) -> c_int; pub fn pthread_attr_getschedparam( - attr: *const crate::pthread_attr_t, + attr: *const pthread_attr_t, param: *mut sched_param, ) -> c_int; pub fn pthread_attr_getstackaddr( - attr: *const crate::pthread_attr_t, + attr: *const pthread_attr_t, stackaddr: *mut *mut c_void, ) -> c_int; - pub fn pthread_attr_getschedpolicy( - attr: *const crate::pthread_attr_t, - policy: *mut c_int, - ) -> c_int; + pub fn pthread_attr_getschedpolicy(attr: *const pthread_attr_t, policy: *mut c_int) -> c_int; - pub fn pthread_attr_getscope( - attr: *const crate::pthread_attr_t, - contentionscope: *mut c_int, - ) -> c_int; + pub fn pthread_attr_getscope(attr: *const pthread_attr_t, contentionscope: *mut c_int) + -> c_int; pub fn pthread_attr_getstack( - attr: *const crate::pthread_attr_t, + attr: *const pthread_attr_t, stackaddr: *mut *mut c_void, stacksize: *mut size_t, ) -> c_int; - pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int; + pub fn pthread_attr_setguardsize(attr: *mut pthread_attr_t, guardsize: size_t) -> c_int; - pub fn pthread_attr_setinheritsched( - attr: *mut crate::pthread_attr_t, - inheritsched: c_int, - ) -> c_int; + pub fn pthread_attr_setinheritsched(attr: *mut pthread_attr_t, inheritsched: c_int) -> c_int; pub fn pthread_attr_setschedparam( - attr: *mut crate::pthread_attr_t, + attr: *mut pthread_attr_t, param: *const sched_param, ) -> c_int; - pub fn pthread_attr_setschedpolicy(attr: *mut crate::pthread_attr_t, policy: c_int) -> c_int; + pub fn pthread_attr_setschedpolicy(attr: *mut pthread_attr_t, policy: c_int) -> c_int; - pub fn pthread_attr_setscope(attr: *mut crate::pthread_attr_t, contentionscope: c_int) - -> c_int; + pub fn pthread_attr_setscope(attr: *mut pthread_attr_t, contentionscope: c_int) -> c_int; pub fn pthread_attr_setstack( - attr: *mut crate::pthread_attr_t, + attr: *mut pthread_attr_t, stackaddr: *mut c_void, stacksize: size_t, ) -> c_int; - pub fn pthread_attr_setstackaddr( - attr: *mut crate::pthread_attr_t, - stackaddr: *mut c_void, - ) -> c_int; + pub fn pthread_attr_setstackaddr(attr: *mut pthread_attr_t, stackaddr: *mut c_void) -> c_int; - pub fn pthread_barrierattr_destroy(attr: *mut crate::pthread_barrierattr_t) -> c_int; + pub fn pthread_barrierattr_destroy(attr: *mut pthread_barrierattr_t) -> c_int; pub fn pthread_barrierattr_getpshared( - attr: *const crate::pthread_barrierattr_t, + attr: *const pthread_barrierattr_t, pshared: *mut c_int, ) -> c_int; - pub fn pthread_barrierattr_init(attr: *mut crate::pthread_barrierattr_t) -> c_int; + pub fn pthread_barrierattr_init(attr: *mut pthread_barrierattr_t) -> c_int; pub fn pthread_barrierattr_setpshared( - attr: *mut crate::pthread_barrierattr_t, + attr: *mut pthread_barrierattr_t, pshared: c_int, ) -> c_int; @@ -2692,13 +2674,13 @@ extern "C" { pub fn pthread_barrier_init( barrier: *mut pthread_barrier_t, - attr: *const crate::pthread_barrierattr_t, + attr: *const pthread_barrierattr_t, count: c_uint, ) -> c_int; pub fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> c_int; - pub fn pthread_cancel(thread: crate::pthread_t) -> c_int; + pub fn pthread_cancel(thread: pthread_t) -> c_int; pub fn pthread_cleanup_pop(execute: c_int); @@ -2717,37 +2699,31 @@ extern "C" { pshared: *mut c_int, ) -> c_int; - pub fn pthread_condattr_setclock( - attr: *mut pthread_condattr_t, - clock_id: crate::clockid_t, - ) -> c_int; + pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, clock_id: clockid_t) -> c_int; pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, pshared: c_int) -> c_int; pub fn pthread_create( - thread: *mut crate::pthread_t, - attr: *const crate::pthread_attr_t, + thread: *mut pthread_t, + attr: *const pthread_attr_t, start_routine: extern "C" fn(*mut c_void) -> *mut c_void, arg: *mut c_void, ) -> c_int; pub fn pthread_getconcurrency() -> c_int; - pub fn pthread_getcpuclockid( - thread_id: crate::pthread_t, - clock_id: *mut crate::clockid_t, - ) -> c_int; + pub fn pthread_getcpuclockid(thread_id: pthread_t, clock_id: *mut clockid_t) -> c_int; pub fn pthread_getschedparam( - thread: crate::pthread_t, + thread: pthread_t, policy: *mut c_int, param: *mut sched_param, ) -> c_int; - pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; + pub fn pthread_kill(thread: pthread_t, sig: c_int) -> c_int; pub fn pthread_mutexattr_getprioceiling( - attr: *const crate::pthread_mutexattr_t, + attr: *const pthread_mutexattr_t, prioceiling: *mut c_int, ) -> c_int; @@ -2762,17 +2738,14 @@ extern "C" { ) -> c_int; pub fn pthread_mutexattr_getrobust( - attr: *const crate::pthread_mutexattr_t, + attr: *const pthread_mutexattr_t, robust: *mut c_int, ) -> c_int; - pub fn pthread_mutexattr_gettype( - attr: *const crate::pthread_mutexattr_t, - _type: *mut c_int, - ) -> c_int; + pub fn pthread_mutexattr_gettype(attr: *const pthread_mutexattr_t, _type: *mut c_int) -> c_int; pub fn pthread_mutexattr_setprioceiling( - attr: *mut crate::pthread_mutexattr_t, + attr: *mut pthread_mutexattr_t, prioceiling: c_int, ) -> c_int; @@ -2780,20 +2753,17 @@ extern "C" { pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, pshared: c_int) -> c_int; - pub fn pthread_mutexattr_setrobust( - attr: *mut crate::pthread_mutexattr_t, - robust: c_int, - ) -> c_int; + pub fn pthread_mutexattr_setrobust(attr: *mut pthread_mutexattr_t, robust: c_int) -> c_int; - pub fn pthread_mutex_consistent(mutex: *mut crate::pthread_mutex_t) -> c_int; + pub fn pthread_mutex_consistent(mutex: *mut pthread_mutex_t) -> c_int; pub fn pthread_mutex_getprioceiling( - mutex: *const crate::pthread_mutex_t, + mutex: *const pthread_mutex_t, prioceiling: *mut c_int, ) -> c_int; pub fn pthread_mutex_setprioceiling( - mutex: *mut crate::pthread_mutex_t, + mutex: *mut pthread_mutex_t, prioceiling: c_int, old_ceiling: *mut c_int, ) -> c_int; @@ -2804,7 +2774,7 @@ extern "C" { ) -> c_int; pub fn pthread_once( - once_control: *mut crate::pthread_once_t, + once_control: *mut pthread_once_t, init_routine: Option, ) -> c_int; @@ -2816,12 +2786,12 @@ extern "C" { pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, pshared: c_int) -> c_int; pub fn pthread_rwlock_timedrdlock( - rwlock: *mut crate::pthread_rwlock_t, + rwlock: *mut pthread_rwlock_t, abstime: *const crate::timespec, ) -> c_int; pub fn pthread_rwlock_timedwrlock( - rwlock: *mut crate::pthread_rwlock_t, + rwlock: *mut pthread_rwlock_t, abstime: *const crate::timespec, ) -> c_int; @@ -2831,12 +2801,12 @@ extern "C" { pub fn pthread_setconcurrency(new_level: c_int) -> c_int; pub fn pthread_setschedparam( - thread: crate::pthread_t, + thread: pthread_t, policy: c_int, param: *const sched_param, ) -> c_int; - pub fn pthread_setschedprio(thread: crate::pthread_t, prio: c_int) -> c_int; + pub fn pthread_setschedprio(thread: pthread_t, prio: c_int) -> c_int; pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) -> c_int; @@ -2865,41 +2835,37 @@ extern "C" { extern "C" { pub fn acct(filename: *mut c_char) -> c_int; #[link_name = "_posix_aio_cancel"] - pub fn aio_cancel(fildes: c_int, aiocbp: *mut crate::aiocb) -> c_int; + pub fn aio_cancel(fildes: c_int, aiocbp: *mut aiocb) -> c_int; #[link_name = "_posix_aio_error"] - pub fn aio_error(aiocbp: *const crate::aiocb) -> c_int; + pub fn aio_error(aiocbp: *const aiocb) -> c_int; #[link_name = "_posix_aio_fsync"] - pub fn aio_fsync(op: c_int, aiocbp: *mut crate::aiocb) -> c_int; + pub fn aio_fsync(op: c_int, aiocbp: *mut aiocb) -> c_int; #[link_name = "_posix_aio_read"] - pub fn aio_read(aiocbp: *mut crate::aiocb) -> c_int; + pub fn aio_read(aiocbp: *mut aiocb) -> c_int; #[link_name = "_posix_aio_return"] - pub fn aio_return(aiocbp: *mut crate::aiocb) -> ssize_t; + pub fn aio_return(aiocbp: *mut aiocb) -> ssize_t; #[link_name = "_posix_aio_suspend"] pub fn aio_suspend( - list: *const *const crate::aiocb, + list: *const *const aiocb, nent: c_int, timeout: *const crate::timespec, ) -> c_int; #[link_name = "_posix_aio_write"] - pub fn aio_write(aiocbp: *mut crate::aiocb) -> c_int; + pub fn aio_write(aiocbp: *mut aiocb) -> c_int; pub fn basename(path: *mut c_char) -> *mut c_char; - pub fn bind( - socket: c_int, - address: *const crate::sockaddr, - address_len: crate::socklen_t, - ) -> c_int; + pub fn bind(socket: c_int, address: *const sockaddr, address_len: socklen_t) -> c_int; pub fn brk(addr: *mut c_void) -> c_int; pub fn clearenv() -> c_int; - pub fn clock_getcpuclockid(pid: crate::pid_t, clk_id: *mut crate::clockid_t) -> c_int; - pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; - pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_getcpuclockid(pid: crate::pid_t, clk_id: *mut clockid_t) -> c_int; + pub fn clock_getres(clk_id: clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_gettime(clk_id: clockid_t, tp: *mut crate::timespec) -> c_int; pub fn clock_nanosleep( - clk_id: crate::clockid_t, + clk_id: clockid_t, flags: c_int, rqtp: *const crate::timespec, rmtp: *mut crate::timespec, ) -> c_int; - pub fn clock_settime(clock_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; + pub fn clock_settime(clock_id: clockid_t, tp: *const crate::timespec) -> c_int; pub fn creat64(path: *const c_char, mode: mode_t) -> c_int; pub fn ctermid(s: *mut c_char) -> *mut c_char; pub fn dirfd(dirp: *mut crate::DIR) -> c_int; @@ -2925,7 +2891,7 @@ extern "C" { pub fn fgetgrent(file: *mut crate::FILE) -> *mut crate::group; // FIXME(1.0,deprecate): lfs binding to be removed pub fn fgetpos64(stream: *mut crate::FILE, ptr: *mut fpos64_t) -> c_int; - pub fn fgetpwent(file: *mut crate::FILE) -> *mut crate::passwd; + pub fn fgetpwent(file: *mut crate::FILE) -> *mut passwd; // FIXME(1.0,deprecate): lfs binding to be removed pub fn fopen64(filename: *const c_char, mode: *const c_char) -> *mut crate::FILE; pub fn freelocale(loc: crate::locale_t); @@ -2948,7 +2914,7 @@ extern "C" { pub fn fstatvfs64(fd: c_int, buf: *mut statvfs64) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed pub fn ftello64(stream: *mut crate::FILE) -> off64_t; - pub fn ftok(path: *const c_char, id: c_int) -> crate::key_t; + pub fn ftok(path: *const c_char, id: c_int) -> key_t; // FIXME(1.0,deprecate): lfs binding to be removed pub fn ftruncate64(fd: c_int, length: off64_t) -> c_int; pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; @@ -2976,9 +2942,9 @@ extern "C" { ) -> c_int; pub fn getgrset(user: *const c_char) -> *mut c_char; pub fn gethostid() -> c_long; - pub fn getmntent(stream: *mut crate::FILE) -> *mut crate::mntent; + pub fn getmntent(stream: *mut crate::FILE) -> *mut mntent; pub fn getnameinfo( - sa: *const crate::sockaddr, + sa: *const sockaddr, salen: size_t, host: *mut c_char, hostlen: size_t, @@ -2988,8 +2954,8 @@ extern "C" { ) -> c_int; pub fn getpagesize() -> c_int; pub fn getpeereid(socket: c_int, euid: *mut crate::uid_t, egid: *mut crate::gid_t) -> c_int; - pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; - pub fn getpwent() -> *mut crate::passwd; + pub fn getpriority(which: c_int, who: id_t) -> c_int; + pub fn getpwent() -> *mut passwd; #[link_name = "_posix_getpwnam_r"] pub fn getpwnam_r( name: *const c_char, @@ -3021,10 +2987,10 @@ extern "C" { pattern: *const c_char, flags: c_int, errfunc: Option c_int>, - pglob: *mut crate::glob_t, + pglob: *mut glob_t, ) -> c_int; - pub fn globfree(pglob: *mut crate::glob_t); - pub fn hasmntopt(mnt: *const crate::mntent, opt: *const c_char) -> *mut c_char; + pub fn globfree(pglob: *mut glob_t); + pub fn hasmntopt(mnt: *const mntent, opt: *const c_char) -> *mut c_char; pub fn hcreate(nelt: size_t) -> c_int; pub fn hdestroy(); pub fn hsearch(entry: entry, action: ACTION) -> *mut entry; @@ -3064,8 +3030,8 @@ extern "C" { // FIXME(1.0,deprecate): lfs binding to be removed pub fn lstat64(path: *const c_char, buf: *mut stat64) -> c_int; pub fn madvise(addr: caddr_t, len: size_t, advice: c_int) -> c_int; - pub fn makecontext(ucp: *mut crate::ucontext_t, func: extern "C" fn(), argc: c_int, ...); - pub fn mallinfo() -> crate::mallinfo; + pub fn makecontext(ucp: *mut ucontext_t, func: extern "C" fn(), argc: c_int, ...); + pub fn mallinfo() -> mallinfo; pub fn mallopt(param: c_int, value: c_int) -> c_int; pub fn memmem( haystack: *const c_void, @@ -3079,36 +3045,27 @@ extern "C" { pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; pub fn mount(device: *const c_char, path: *const c_char, flags: c_int) -> c_int; pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; - pub fn mq_close(mqd: crate::mqd_t) -> c_int; - pub fn mq_getattr(mqd: crate::mqd_t, attr: *mut crate::mq_attr) -> c_int; - pub fn mq_notify(mqd: crate::mqd_t, notification: *const crate::sigevent) -> c_int; - pub fn mq_open(name: *const c_char, oflag: c_int, ...) -> crate::mqd_t; + pub fn mq_close(mqd: mqd_t) -> c_int; + pub fn mq_getattr(mqd: mqd_t, attr: *mut mq_attr) -> c_int; + pub fn mq_notify(mqd: mqd_t, notification: *const sigevent) -> c_int; + pub fn mq_open(name: *const c_char, oflag: c_int, ...) -> mqd_t; pub fn mq_receive( - mqd: crate::mqd_t, + mqd: mqd_t, msg_ptr: *mut c_char, msg_len: size_t, msg_prio: *mut c_uint, ) -> ssize_t; - pub fn mq_send( - mqd: crate::mqd_t, - msg_ptr: *const c_char, - msg_len: size_t, - msg_prio: c_uint, - ) -> c_int; - pub fn mq_setattr( - mqd: crate::mqd_t, - newattr: *const crate::mq_attr, - oldattr: *mut crate::mq_attr, - ) -> c_int; + pub fn mq_send(mqd: mqd_t, msg_ptr: *const c_char, msg_len: size_t, msg_prio: c_uint) -> c_int; + pub fn mq_setattr(mqd: mqd_t, newattr: *const mq_attr, oldattr: *mut mq_attr) -> c_int; pub fn mq_timedreceive( - mqd: crate::mqd_t, + mqd: mqd_t, msg_ptr: *mut c_char, msg_len: size_t, msg_prio: *mut c_uint, abs_timeout: *const crate::timespec, ) -> ssize_t; pub fn mq_timedsend( - mqd: crate::mqd_t, + mqd: mqd_t, msg_ptr: *const c_char, msg_len: size_t, msg_prio: c_uint, @@ -3117,7 +3074,7 @@ extern "C" { pub fn mq_unlink(name: *const c_char) -> c_int; pub fn mrand48() -> c_long; pub fn msgctl(msqid: c_int, cmd: c_int, buf: *mut msqid_ds) -> c_int; - pub fn msgget(key: crate::key_t, msgflg: c_int) -> c_int; + pub fn msgget(key: key_t, msgflg: c_int) -> c_int; pub fn msgrcv( msqid: c_int, msgp: *mut c_void, @@ -3128,8 +3085,8 @@ extern "C" { pub fn msgsnd(msqid: c_int, msgp: *const c_void, msgsz: size_t, msgflg: c_int) -> c_int; pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t; - pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; - pub fn nl_langinfo_l(item: crate::nl_item, loc: crate::locale_t) -> *mut c_char; + pub fn nl_langinfo(item: nl_item) -> *mut c_char; + pub fn nl_langinfo_l(item: nl_item, loc: crate::locale_t) -> *mut c_char; pub fn nrand48(xseed: *mut c_ushort) -> c_long; // FIXME(1.0,deprecate): lfs binding to be removed pub fn open64(path: *const c_char, oflag: c_int, ...) -> c_int; @@ -3146,16 +3103,16 @@ extern "C" { pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE; pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed - pub fn posix_fadvise64(fd: c_int, offset: off64_t, len: off64_t, advise: c_int) -> c_int; + pub fn posix_fadvise64(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed - pub fn posix_fallocate64(fd: c_int, offset: off64_t, len: off64_t) -> c_int; + pub fn posix_fallocate64(fd: c_int, offset: off_t, len: off_t) -> c_int; pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; pub fn posix_spawn( pid: *mut crate::pid_t, path: *const c_char, - file_actions: *const crate::posix_spawn_file_actions_t, - attrp: *const crate::posix_spawnattr_t, + file_actions: *const posix_spawn_file_actions_t, + attrp: *const posix_spawnattr_t, argv: *const *mut c_char, envp: *const *mut c_char, ) -> c_int; @@ -3185,7 +3142,7 @@ extern "C" { ) -> c_int; pub fn posix_spawnattr_getschedparam( attr: *const posix_spawnattr_t, - param: *mut crate::sched_param, + param: *mut sched_param, ) -> c_int; pub fn posix_spawnattr_getschedpolicy( attr: *const posix_spawnattr_t, @@ -3204,22 +3161,22 @@ extern "C" { pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: crate::pid_t) -> c_int; pub fn posix_spawnattr_setschedparam( attr: *mut posix_spawnattr_t, - param: *const crate::sched_param, + param: *const sched_param, ) -> c_int; pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: c_int) -> c_int; pub fn posix_spawnattr_setsigdefault( attr: *mut posix_spawnattr_t, - default: *const crate::sigset_t, + default: *const sigset_t, ) -> c_int; pub fn posix_spawnattr_setsigmask( attr: *mut posix_spawnattr_t, - default: *const crate::sigset_t, + default: *const sigset_t, ) -> c_int; pub fn posix_spawnp( pid: *mut crate::pid_t, file: *const c_char, - file_actions: *const crate::posix_spawn_file_actions_t, - attrp: *const crate::posix_spawnattr_t, + file_actions: *const posix_spawn_file_actions_t, + attrp: *const posix_spawnattr_t, argv: *const *mut c_char, envp: *const *mut c_char, ) -> c_int; @@ -3249,12 +3206,12 @@ extern "C" { buf: *mut c_void, len: size_t, flags: c_int, - addr: *mut crate::sockaddr, - addrlen: *mut crate::socklen_t, + addr: *mut sockaddr, + addrlen: *mut socklen_t, ) -> ssize_t; pub fn recvmmsg( sockfd: c_int, - msgvec: *mut crate::mmsghdr, + msgvec: *mut mmsghdr, vlen: c_uint, flags: c_int, timeout: *mut crate::timespec, @@ -3265,7 +3222,7 @@ extern "C" { pub fn regcomp(preg: *mut regex_t, pattern: *const c_char, cflags: c_int) -> c_int; pub fn regerror( errcode: c_int, - preg: *const crate::regex_t, + preg: *const regex_t, errbuf: *mut c_char, errbuf_size: size_t, ) -> size_t; @@ -3283,15 +3240,12 @@ extern "C" { pub fn sched_get_priority_max(policy: c_int) -> c_int; pub fn sched_get_priority_min(policy: c_int) -> c_int; pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int; - pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int; - pub fn sched_setscheduler( - pid: crate::pid_t, - policy: c_int, - param: *const crate::sched_param, - ) -> c_int; + pub fn sched_setparam(pid: crate::pid_t, param: *const sched_param) -> c_int; + pub fn sched_setscheduler(pid: crate::pid_t, policy: c_int, param: *const sched_param) + -> c_int; pub fn sctp_opt_info( sd: c_int, - id: crate::sctp_assoc_t, + id: sctp_assoc_t, opt: c_int, arg_size: *mut c_void, size: *mut size_t, @@ -3307,7 +3261,7 @@ extern "C" { pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; pub fn sem_unlink(name: *const c_char) -> c_int; pub fn semctl(semid: c_int, semnum: c_int, cmd: c_int, ...) -> c_int; - pub fn semget(key: crate::key_t, nsems: c_int, semflag: c_int) -> c_int; + pub fn semget(key: key_t, nsems: c_int, semflag: c_int) -> c_int; pub fn semop(semid: c_int, sops: *mut sembuf, nsops: size_t) -> c_int; pub fn send_file(socket: *mut c_int, iobuf: *mut sf_parms, flags: c_uint) -> ssize_t; pub fn sendmmsg(sockfd: c_int, msgvec: *mut mmsghdr, vlen: c_uint, flags: c_int) -> c_int; @@ -3326,7 +3280,7 @@ extern "C" { pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed pub fn setrlimit64(resource: c_int, rlim: *const rlimit64) -> c_int; - pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; + pub fn settimeofday(tv: *const crate::timeval, tz: *const timezone) -> c_int; pub fn setitimer( which: c_int, new_value: *const crate::itimerval, @@ -3335,7 +3289,7 @@ extern "C" { pub fn setutent(); pub fn setutxent(); pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; - pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int; + pub fn sigsuspend(mask: *const sigset_t) -> c_int; pub fn sigtimedwait( set: *const sigset_t, info: *mut siginfo_t, @@ -3345,7 +3299,7 @@ extern "C" { pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int; pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void; pub fn shmdt(shmaddr: *const c_void) -> c_int; - pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int; + pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut shmid_ds) -> c_int; pub fn shmget(key: key_t, size: size_t, shmflg: c_int) -> 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; @@ -3380,30 +3334,26 @@ extern "C" { length: size_t, locale: crate::locale_t, ) -> c_int; - pub fn strptime(s: *const c_char, format: *const c_char, tm: *mut crate::tm) -> *mut c_char; + pub fn strptime(s: *const c_char, format: *const c_char, tm: *mut tm) -> *mut c_char; pub fn strsep(string: *mut *mut c_char, delim: *const c_char) -> *mut c_char; pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> c_int; pub fn swapoff(path: *const c_char) -> c_int; pub fn swapon(path: *const c_char) -> c_int; pub fn sync(); pub fn telldir(dirp: *mut crate::DIR) -> c_long; - pub fn timer_create( - clockid: crate::clockid_t, - sevp: *mut crate::sigevent, - timerid: *mut crate::timer_t, - ) -> c_int; + pub fn timer_create(clockid: clockid_t, sevp: *mut sigevent, timerid: *mut timer_t) -> c_int; pub fn timer_delete(timerid: timer_t) -> c_int; pub fn timer_getoverrun(timerid: timer_t) -> c_int; pub fn timer_gettime(timerid: timer_t, value: *mut itimerspec) -> c_int; pub fn timer_settime( - timerid: crate::timer_t, + timerid: timer_t, flags: c_int, - new_value: *const crate::itimerspec, - old_value: *mut crate::itimerspec, + new_value: *const itimerspec, + old_value: *mut itimerspec, ) -> c_int; // FIXME(1.0,deprecate): lfs binding to be removed pub fn truncate64(path: *const c_char, length: off64_t) -> c_int; - pub fn uname(buf: *mut crate::utsname) -> c_int; + pub fn uname(buf: *mut utsname) -> c_int; pub fn updwtmp(file: *const c_char, u: *const utmp); pub fn uselocale(loc: crate::locale_t) -> crate::locale_t; pub fn utmpname(file: *const c_char) -> c_int; @@ -3419,12 +3369,7 @@ extern "C" { options: c_int, rusage: *mut crate::rusage, ) -> crate::pid_t; - pub fn waitid( - idtype: idtype_t, - id: id_t, - infop: *mut crate::siginfo_t, - options: c_int, - ) -> c_int; + pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut siginfo_t, options: c_int) -> c_int; pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; // Use AIX thread-safe version errno. @@ -3435,5 +3380,7 @@ cfg_if! { if #[cfg(target_arch = "powerpc64")] { mod powerpc64; pub use self::powerpc64::*; + } else { + core::compile_error!("unsupported target"); } } diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 2a953eda0b07d..2a2ee82c060d4 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -4307,6 +4307,10 @@ pub const VMADDR_CID_RESERVED: c_uint = 1; pub const VMADDR_CID_HOST: c_uint = 2; pub const VMADDR_PORT_ANY: c_uint = 0xFFFFFFFF; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/bin:/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + const fn __DARWIN_ALIGN32(p: usize) -> usize { const __DARWIN_ALIGNBYTES32: usize = size_of::() - 1; (p + __DARWIN_ALIGNBYTES32) & !__DARWIN_ALIGNBYTES32 diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 95f7e305e4577..ac137c1f5d1c4 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1230,6 +1230,12 @@ pub const RTAX_MPLS3: c_int = 10; /// for details. pub const RTAX_MAX: c_int = 11; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr( + b"/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/pkg/bin:/usr/pkg/sbin\0", +); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + const fn _CMSG_ALIGN(n: usize) -> usize { (n + (size_of::() - 1)) & !(size_of::() - 1) } diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 4a72335df97c2..1ef120c056b7b 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -4413,6 +4413,11 @@ const fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES } +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = + cstr(b"/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { pub unsafe fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { (cmsg as *mut c_uchar).add(_ALIGN(size_of::())) diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 134a4e5fdebbd..fd12e635c791e 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1821,6 +1821,10 @@ const fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES } +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/bin:/bin:/usr/pkg/bin:/usr/local/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { pub unsafe fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { (cmsg as *mut c_uchar).add(_ALIGN(size_of::())) diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 883dbaee0857e..fdf70dffb35ed 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -863,7 +863,7 @@ impl siginfo_t { _uid: crate::uid_t, _utime: crate::clock_t, _stime: crate::clock_t, - _status: crate::c_int, + _status: c_int, } (*(self as *const siginfo_t).cast::())._status } @@ -1854,6 +1854,11 @@ const fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES } +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = + cstr(b"/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { pub unsafe fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { (cmsg as *mut c_uchar).offset(_ALIGN(size_of::()) as isize) @@ -2073,6 +2078,7 @@ extern "C" { pub fn getfsstat(buf: *mut statfs, bufsize: size_t, flags: c_int) -> c_int; pub fn elf_aux_info(aux: c_int, buf: *mut c_void, buflen: c_int) -> c_int; + pub fn getexecpath(buf: *mut c_char, bufsize: size_t) -> c_int; } #[link(name = "execinfo")] diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index 5645bdd2b2dcf..6681080e81d66 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -1678,6 +1678,10 @@ pub const FALLOC_FL_COLLAPSE_RANGE: c_int = 0x0008; pub const FALLOC_FL_INSERT_RANGE: c_int = 0x0010; pub const FALLOC_FL_KEEP_SIZE: c_int = 0x1000; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { pub unsafe fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 72be53de152fa..ca30428a1667b 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1388,6 +1388,10 @@ pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x10; pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x20; pub const POSIX_SPAWN_SETSID: c_int = 0x40; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/bin:/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + const fn CMSG_ALIGN(len: usize) -> usize { len + size_of::() - 1 & !(size_of::() - 1) } diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 7102140a26d3e..fb63c640bf542 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -610,6 +610,11 @@ s! { pub flags: crate::__u32, __reserved: Padding, } + + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: c_uint, + } } s_no_extra_traits! { @@ -686,6 +691,16 @@ s_no_extra_traits! { } } +// socket.h + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; + pub const MADV_SOFT_OFFLINE: c_int = 101; #[allow(overflowing_literals)] // fixed in a future kernel version pub const MS_NOUSER: c_ulong = 0xffffffff80000000; @@ -3414,6 +3429,14 @@ pub const RWF_NOAPPEND: c_int = 0x00000020; pub const RWF_ATOMIC: c_int = 0x00000040; pub const RWF_DONTCACHE: c_int = 0x00000080; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr( + b"/product/bin:/apex/com.android.runtime/bin:\ + /apex/com.android.art/bin:/system_ext/bin:/system/bin:\ + /system/xbin:/odm/bin:/vendor/bin:/vendor/xbin\0", +); +pub const _PATH_BSHELL: *const c_char = cstr(b"/system/bin/sh\0"); + // Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the // following are only available on newer Linux versions than the versions // currently used in CI in some configurations, so we define them here. diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 6d1d9f27d1da2..c4c73bfe2202c 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -392,6 +392,11 @@ s! { pub struct pthread_cond_t { size: [u8; crate::__SIZEOF_PTHREAD_COND_T], } + + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: c_uint, + } } s_no_extra_traits! { @@ -401,6 +406,16 @@ s_no_extra_traits! { } } +// socket.h + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; + pub const MADV_SOFT_OFFLINE: c_int = 101; pub const MS_NOUSER: c_ulong = 0x80000000; pub const MS_RMT_MASK: c_ulong = 0x02800051; @@ -1279,6 +1294,10 @@ pub const PRIO_USER: c_int = 2; pub const SOMAXCONN: c_int = 128; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/local/bin:/bin:/usr/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { pub unsafe fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if ((*cmsg).cmsg_len as usize) < size_of::() { diff --git a/src/unix/linux_like/l4re/mod.rs b/src/unix/linux_like/l4re/mod.rs index b3c768623f7f7..e9bd6104c2d6d 100644 --- a/src/unix/linux_like/l4re/mod.rs +++ b/src/unix/linux_like/l4re/mod.rs @@ -85,8 +85,23 @@ s! { pub affinity: l4_sched_cpu_set_t, pub create_flags: c_uint, } + + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: c_uint, + } } +// socket.h + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; + // L4Re requires a min stack size of 64k; that isn't defined in uClibc, but // somewhere in the core libraries. uClibc wants 16k, but that's not enough. pub const PTHREAD_STACK_MIN: usize = 65536; diff --git a/src/unix/linux_like/l4re/uclibc/mod.rs b/src/unix/linux_like/l4re/uclibc/mod.rs index cced9a7be4408..afb8f64011e2f 100644 --- a/src/unix/linux_like/l4re/uclibc/mod.rs +++ b/src/unix/linux_like/l4re/uclibc/mod.rs @@ -478,6 +478,10 @@ pub const PTHREAD_MUTEX_ADAPTIVE_NP: c_int = 3; pub const __LT_SPINLOCK_INIT: c_int = 0; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/bin:/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + pub const __LOCK_INITIALIZER: _pthread_fastlock = _pthread_fastlock { __status: 0, __spinlock: __LT_SPINLOCK_INIT, 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 bec3d1083093e..5dd589c271c99 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -330,9 +330,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - 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/gnu/b32/csky/mod.rs b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs index c754ec000ea4c..492736e5e394f 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -256,9 +256,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - 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/gnu/b32/m68k/mod.rs b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs index ec5a057cddf55..718a1c142c759 100644 --- a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -256,9 +256,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const F_GETLK: c_int = 5; pub const F_GETOWN: c_int = 9; pub const F_SETOWN: c_int = 8; 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 a4cc330710db7..cf86cd474d978 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -729,9 +729,6 @@ pub const MAP_POPULATE: c_int = 0x10000; pub const MAP_NONBLOCK: c_int = 0x20000; pub const MAP_STACK: c_int = 0x40000; -pub const SOCK_STREAM: c_int = 2; -pub const SOCK_DGRAM: c_int = 1; - pub const POLLWRNORM: c_short = 0x004; pub const POLLWRBAND: c_short = 0x100; diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index 30f85c9fb6885..d2c3e0581c1d2 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -305,9 +305,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const MCL_CURRENT: c_int = 0x2000; pub const MCL_FUTURE: c_int = 0x4000; pub const MCL_ONFAULT: c_int = 0x8000; 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 610fa4065ba6e..8c199bd2c70c0 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -294,8 +294,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; pub const POLLWRNORM: c_short = 256; pub const POLLWRBAND: c_short = 512; pub const O_ASYNC: c_int = 8192; @@ -468,7 +466,6 @@ pub const SYS_shmget: c_long = 194; pub const SYS_shmat: c_long = 196; pub const SYS_shmctl: c_long = 195; pub const SYS_dup: c_long = 23; -pub const SYS_nanosleep: c_long = 101; pub const SYS_getitimer: c_long = 102; pub const SYS_setitimer: c_long = 103; pub const SYS_getpid: c_long = 172; @@ -491,7 +488,6 @@ pub const SYS_getsockopt: c_long = 209; pub const SYS_clone: c_long = 220; pub const SYS_execve: c_long = 221; pub const SYS_exit: c_long = 93; -pub const SYS_wait4: c_long = 260; pub const SYS_kill: c_long = 129; pub const SYS_uname: c_long = 160; pub const SYS_semget: c_long = 190; @@ -514,7 +510,6 @@ pub const SYS_fchdir: c_long = 50; pub const SYS_fchmod: c_long = 52; pub const SYS_fchown: c_long = 55; pub const SYS_umask: c_long = 166; -pub const SYS_gettimeofday: c_long = 169; pub const SYS_getrlimit: c_long = 163; pub const SYS_getrusage: c_long = 165; pub const SYS_sysinfo: c_long = 179; @@ -545,7 +540,7 @@ pub const SYS_getsid: c_long = 156; pub const SYS_capget: c_long = 90; pub const SYS_capset: c_long = 91; pub const SYS_rt_sigpending: c_long = 136; -pub const SYS_rt_sigtimedwait: c_long = 137; +pub const SYS_rt_sigtimedwait_time64: c_long = 421; pub const SYS_rt_sigqueueinfo: c_long = 138; pub const SYS_rt_sigsuspend: c_long = 133; pub const SYS_sigaltstack: c_long = 132; @@ -560,7 +555,7 @@ pub const SYS_sched_setscheduler: c_long = 119; pub const SYS_sched_getscheduler: c_long = 120; pub const SYS_sched_get_priority_max: c_long = 125; pub const SYS_sched_get_priority_min: c_long = 126; -pub const SYS_sched_rr_get_interval: c_long = 127; +pub const SYS_sched_rr_get_interval_time64: c_long = 423; pub const SYS_mlock: c_long = 228; pub const SYS_munlock: c_long = 229; pub const SYS_mlockall: c_long = 230; @@ -568,12 +563,10 @@ pub const SYS_munlockall: c_long = 231; pub const SYS_vhangup: c_long = 58; pub const SYS_pivot_root: c_long = 41; pub const SYS_prctl: c_long = 167; -pub const SYS_adjtimex: c_long = 171; pub const SYS_setrlimit: c_long = 164; pub const SYS_chroot: c_long = 51; pub const SYS_sync: c_long = 81; pub const SYS_acct: c_long = 89; -pub const SYS_settimeofday: c_long = 170; pub const SYS_mount: c_long = 40; pub const SYS_umount2: c_long = 39; pub const SYS_swapon: c_long = 224; @@ -600,12 +593,12 @@ pub const SYS_removexattr: c_long = 14; pub const SYS_lremovexattr: c_long = 15; pub const SYS_fremovexattr: c_long = 16; pub const SYS_tkill: c_long = 130; -pub const SYS_futex: c_long = 98; +pub const SYS_futex_time64: c_long = 422; pub const SYS_sched_setaffinity: c_long = 122; pub const SYS_sched_getaffinity: c_long = 123; pub const SYS_io_setup: c_long = 0; pub const SYS_io_destroy: c_long = 1; -pub const SYS_io_getevents: c_long = 4; +pub const SYS_io_pgetevents_time64: c_long = 416; pub const SYS_io_submit: c_long = 2; pub const SYS_io_cancel: c_long = 3; pub const SYS_lookup_dcookie: c_long = 18; @@ -613,17 +606,17 @@ pub const SYS_remap_file_pages: c_long = 234; pub const SYS_getdents64: c_long = 61; pub const SYS_set_tid_address: c_long = 96; pub const SYS_restart_syscall: c_long = 128; -pub const SYS_semtimedop: c_long = 192; +pub const SYS_semtimedop_time64: c_long = 420; pub const SYS_fadvise64: c_long = 223; pub const SYS_timer_create: c_long = 107; -pub const SYS_timer_settime: c_long = 110; -pub const SYS_timer_gettime: c_long = 108; +pub const SYS_timer_settime64: c_long = 409; +pub const SYS_timer_gettime64: c_long = 408; pub const SYS_timer_getoverrun: c_long = 109; pub const SYS_timer_delete: c_long = 111; -pub const SYS_clock_settime: c_long = 112; -pub const SYS_clock_gettime: c_long = 113; -pub const SYS_clock_getres: c_long = 114; -pub const SYS_clock_nanosleep: c_long = 115; +pub const SYS_clock_settime64: c_long = 404; +pub const SYS_clock_gettime64: c_long = 403; +pub const SYS_clock_getres_time64: c_long = 406; +pub const SYS_clock_nanosleep_time64: c_long = 407; pub const SYS_exit_group: c_long = 94; pub const SYS_epoll_ctl: c_long = 21; pub const SYS_tgkill: c_long = 131; @@ -632,8 +625,8 @@ pub const SYS_set_mempolicy: c_long = 237; pub const SYS_get_mempolicy: c_long = 236; pub const SYS_mq_open: c_long = 180; pub const SYS_mq_unlink: c_long = 181; -pub const SYS_mq_timedsend: c_long = 182; -pub const SYS_mq_timedreceive: c_long = 183; +pub const SYS_mq_timedsend_time64: c_long = 418; +pub const SYS_mq_timedreceive_time64: c_long = 419; pub const SYS_mq_notify: c_long = 184; pub const SYS_mq_getsetattr: c_long = 185; pub const SYS_kexec_load: c_long = 104; @@ -657,8 +650,8 @@ pub const SYS_symlinkat: c_long = 36; pub const SYS_readlinkat: c_long = 78; pub const SYS_fchmodat: c_long = 53; pub const SYS_faccessat: c_long = 48; -pub const SYS_pselect6: c_long = 72; -pub const SYS_ppoll: c_long = 73; +pub const SYS_pselect6_time64: c_long = 413; +pub const SYS_ppoll_time64: c_long = 414; pub const SYS_unshare: c_long = 97; pub const SYS_set_robust_list: c_long = 99; pub const SYS_get_robust_list: c_long = 100; @@ -667,12 +660,12 @@ pub const SYS_tee: c_long = 77; pub const SYS_sync_file_range: c_long = 84; pub const SYS_vmsplice: c_long = 75; pub const SYS_move_pages: c_long = 239; -pub const SYS_utimensat: c_long = 88; +pub const SYS_utimensat_time64: c_long = 412; pub const SYS_epoll_pwait: c_long = 22; pub const SYS_timerfd_create: c_long = 85; pub const SYS_fallocate: c_long = 47; -pub const SYS_timerfd_settime: c_long = 86; -pub const SYS_timerfd_gettime: c_long = 87; +pub const SYS_timerfd_settime64: c_long = 411; +pub const SYS_timerfd_gettime64: c_long = 410; pub const SYS_accept4: c_long = 242; pub const SYS_signalfd4: c_long = 74; pub const SYS_eventfd2: c_long = 19; @@ -684,13 +677,13 @@ pub const SYS_preadv: c_long = 69; pub const SYS_pwritev: c_long = 70; pub const SYS_rt_tgsigqueueinfo: c_long = 240; pub const SYS_perf_event_open: c_long = 241; -pub const SYS_recvmmsg: c_long = 243; +pub const SYS_recvmmsg_time64: c_long = 417; pub const SYS_fanotify_init: c_long = 262; pub const SYS_fanotify_mark: c_long = 263; pub const SYS_prlimit64: c_long = 261; pub const SYS_name_to_handle_at: c_long = 264; pub const SYS_open_by_handle_at: c_long = 265; -pub const SYS_clock_adjtime: c_long = 266; +pub const SYS_clock_adjtime64: c_long = 405; pub const SYS_syncfs: c_long = 267; pub const SYS_sendmmsg: c_long = 269; pub const SYS_setns: c_long = 268; 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 95ad74af2e4c4..eb0f38796c60e 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -280,9 +280,6 @@ pub const ENOTRECOVERABLE: c_int = 133; pub const EHWPOISON: c_int = 135; pub const ERFKILL: c_int = 134; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const POLLWRNORM: c_short = 4; pub const POLLWRBAND: c_short = 0x100; 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 cbfae20a68a97..741a874b23504 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -376,9 +376,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - cfg_if! { if #[cfg(gnu_file_offset_bits64)] { pub const F_GETLK: c_int = 12; 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 714e609b88b6d..26ea52c427dd1 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -302,9 +302,6 @@ pub const ERFKILL: c_int = 132; pub const POSIX_FADV_DONTNEED: c_int = 4; pub const POSIX_FADV_NOREUSE: c_int = 5; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; 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 7cea157c63d16..484c67bfdb20b 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -665,9 +665,6 @@ pub const MCL_CURRENT: c_int = 0x0001; pub const MCL_FUTURE: c_int = 0x0002; pub const MCL_ONFAULT: c_int = 0x0004; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const SFD_NONBLOCK: c_int = 0x800; pub const SFD_CLOEXEC: c_int = 0x080000; 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 07fe19471b76d..668cad4fb1cdf 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -653,9 +653,6 @@ pub const MAP_NONBLOCK: c_int = 0x20000; pub const MAP_STACK: c_int = 0x40000; pub const MAP_HUGETLB: c_int = 0x080000; -pub const SOCK_STREAM: c_int = 2; -pub const SOCK_DGRAM: c_int = 1; - pub const POLLWRNORM: c_short = 0x004; pub const POLLWRBAND: c_short = 0x100; 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 ecccfdb48cd44..5b063fe5de468 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -337,9 +337,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; 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 d58948c951df9..5c552ff2d6f8d 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -336,8 +336,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; pub const POLLWRNORM: c_short = 256; pub const POLLWRBAND: c_short = 512; pub const O_ASYNC: c_int = 8192; diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index 1dcc87aa8d0ae..edd6e12d24cc8 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -262,9 +262,6 @@ pub const O_NONBLOCK: c_int = 2048; pub const SIGSTKSZ: size_t = 0x2000; pub const MINSIGSTKSZ: size_t = 2048; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const O_NOCTTY: c_int = 256; pub const O_SYNC: c_int = 1052672; pub const O_RSYNC: c_int = 1052672; 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 80c5528892b3c..59dbfab935c7f 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -262,9 +262,6 @@ pub const ENOTRECOVERABLE: c_int = 133; pub const EHWPOISON: c_int = 135; pub const ERFKILL: c_int = 134; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const POLLWRNORM: c_short = 4; pub const POLLWRBAND: c_short = 0x100; 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 1f3209f529f5f..89f84f39590a7 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 @@ -382,9 +382,6 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; -pub const SOCK_STREAM: c_int = 1; -pub const SOCK_DGRAM: c_int = 2; - pub const POLLWRNORM: c_short = 0x100; pub const POLLWRBAND: c_short = 0x200; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 297ec8e959bb5..f46adbbcaaa0f 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -549,8 +549,6 @@ pub const RTLD_DI_PROFILEOUT: c_int = 8; pub const RTLD_DI_TLS_MODID: c_int = 9; pub const RTLD_DI_TLS_DATA: c_int = 10; -pub const SOCK_NONBLOCK: c_int = O_NONBLOCK; - pub const SOL_RXRPC: c_int = 272; pub const SOL_PPPOL2TP: c_int = 273; pub const SOL_PNPIPE: c_int = 275; @@ -588,11 +586,6 @@ pub const LC_ALL_MASK: c_int = crate::LC_CTYPE_MASK pub const ENOTSUP: c_int = EOPNOTSUPP; -pub const SOCK_SEQPACKET: c_int = 5; -pub const SOCK_DCCP: c_int = 6; -#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] -pub const SOCK_PACKET: c_int = 10; - pub const AF_IB: c_int = 27; pub const AF_MPLS: c_int = 28; pub const AF_NFC: c_int = 39; @@ -871,6 +864,10 @@ pub const GLOB_TILDE_CHECK: c_int = 1 << 14; pub const MADV_COLLAPSE: c_int = 25; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/bin:/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + cfg_if! { if #[cfg(any( target_arch = "arm", diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 7ed918f41eff7..2c9314778d3ca 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -3312,12 +3312,11 @@ pub const XDP_OPTIONS_ZEROCOPY: crate::__u32 = 1 << 0; pub const XDP_PGOFF_RX_RING: crate::off_t = 0; pub const XDP_PGOFF_TX_RING: crate::off_t = 0x80000000u32 as crate::off_t; -pub const XDP_UMEM_PGOFF_FILL_RING: crate::c_ulonglong = 0x100000000; -pub const XDP_UMEM_PGOFF_COMPLETION_RING: crate::c_ulonglong = 0x180000000; +pub const XDP_UMEM_PGOFF_FILL_RING: c_ulonglong = 0x100000000; +pub const XDP_UMEM_PGOFF_COMPLETION_RING: c_ulonglong = 0x180000000; -pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: crate::c_int = 48; -pub const XSK_UNALIGNED_BUF_ADDR_MASK: crate::c_ulonglong = - (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1; +pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: c_int = 48; +pub const XSK_UNALIGNED_BUF_ADDR_MASK: c_ulonglong = (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1; pub const XDP_PKT_CONTD: crate::__u32 = 1 << 0; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 3641134f1f31c..ba04f8d435891 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -528,12 +528,6 @@ pub const PTHREAD_STACK_MIN: size_t = 2048; pub const MAP_ANONYMOUS: c_int = MAP_ANON; -pub const SOCK_SEQPACKET: c_int = 5; -pub const SOCK_DCCP: c_int = 6; -pub const SOCK_NONBLOCK: c_int = O_NONBLOCK; -#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] -pub const SOCK_PACKET: c_int = 10; - pub const SOMAXCONN: c_int = 128; pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; @@ -576,17 +570,6 @@ pub const PTRACE_PEEKSIGINFO: c_int = 0x4209; pub const PTRACE_GETSIGMASK: c_uint = 0x420a; pub const PTRACE_SETSIGMASK: c_uint = 0x420b; -pub const AF_IB: c_int = 27; -pub const AF_MPLS: c_int = 28; -pub const AF_NFC: c_int = 39; -pub const AF_VSOCK: c_int = 40; -pub const AF_XDP: c_int = 44; -pub const PF_IB: c_int = AF_IB; -pub const PF_MPLS: c_int = AF_MPLS; -pub const PF_NFC: c_int = AF_NFC; -pub const PF_VSOCK: c_int = AF_VSOCK; -pub const PF_XDP: c_int = AF_XDP; - pub const EFD_NONBLOCK: c_int = crate::O_NONBLOCK; pub const SFD_NONBLOCK: c_int = crate::O_NONBLOCK; @@ -692,6 +675,10 @@ pub const UT_HOSTSIZE: usize = 256; pub const UT_LINESIZE: usize = 32; pub const UT_NAMESIZE: usize = 32; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/local/bin:/bin:/usr/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + cfg_if! { if #[cfg(target_arch = "s390x")] { pub const POSIX_FADV_DONTNEED: c_int = 6; diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index 493acf40da090..948f9aeda1331 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -504,10 +504,6 @@ pub const SIGXFSZ: c_int = 0x19; pub const SIG_BLOCK: c_int = 0; pub const SIG_SETMASK: c_int = 0x2; pub const SIG_UNBLOCK: c_int = 0x1; -pub const SOCK_DGRAM: c_int = 0x2; -pub const SOCK_NONBLOCK: c_int = 0o0004000; -pub const SOCK_SEQPACKET: c_int = 0x5; -pub const SOCK_STREAM: c_int = 0x1; pub const TAB1: c_int = 0x800; pub const TAB2: c_int = 0x1000; diff --git a/src/unix/linux_like/linux/uclibc/mips/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mod.rs index 8d17aa8e98e9a..772a6f3326c0a 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mod.rs @@ -56,8 +56,6 @@ pub const O_ASYNC: c_int = 0x1000; pub const O_LARGEFILE: c_int = 0x2000; pub const O_NDELAY: c_int = 0x80; -pub const SOCK_NONBLOCK: c_int = 128; - pub const EDEADLK: c_int = 45; pub const ENAMETOOLONG: c_int = 78; pub const ENOLCK: c_int = 46; @@ -155,10 +153,6 @@ pub const MAP_STACK: c_int = 0x40000; pub const NLDLY: crate::tcflag_t = 0o0000400; -pub const SOCK_STREAM: c_int = 2; -pub const SOCK_DGRAM: c_int = 1; -pub const SOCK_SEQPACKET: c_int = 5; - pub const SA_ONSTACK: c_uint = 0x08000000; pub const SA_SIGINFO: c_uint = 0x00000008; pub const SA_NOCLDWAIT: c_int = 0x00010000; diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 0075bddee94ec..39964530e2f06 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -256,13 +256,14 @@ pub const RTLD_NOLOAD: c_int = 0x00004; pub const RUSAGE_THREAD: c_int = 1; pub const SHM_EXEC: c_int = 0o100000; pub const SIGPOLL: c_int = SIGIO; -pub const SOCK_DCCP: c_int = 6; -#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] -pub const SOCK_PACKET: c_int = 10; pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; pub const UDP_GRO: c_int = 104; pub const UDP_SEGMENT: c_int = 103; +// include/paths.h +pub const _PATH_DEFPATH: *const c_char = cstr(b"/usr/bin:/bin\0"); +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + extern "C" { pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; 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 60e5cfe72500d..093ae1d3d3797 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -300,8 +300,6 @@ pub const NCCS: usize = 32; pub const SIG_SETMASK: c_int = 2; // Set the set of blocked signals pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; -pub const SOCK_DGRAM: c_int = 2; // connectionless, unreliable datagrams -pub const SOCK_STREAM: c_int = 1; // …/common/bits/socket_type.h pub const __SIZEOF_PTHREAD_COND_T: usize = 48; pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index f8a0b45e610cd..dc1f27f7b6c45 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -795,6 +795,7 @@ pub const EM_M32R: u16 = 88; pub const EM_MN10300: u16 = 89; pub const EM_MN10200: u16 = 90; pub const EM_PJ: u16 = 91; +#[cfg(not(target_os = "l4re"))] pub const EM_OPENRISC: u16 = 92; #[cfg(target_env = "uclibc")] pub const EM_OR1K: u16 = 92; @@ -875,6 +876,7 @@ pub const AT_EXECFN: c_ulong = 31; // defined in arch//include/uapi/asm/auxvec.h but has the same value // wherever it is defined. pub const AT_SYSINFO_EHDR: c_ulong = 33; +#[cfg(not(target_os = "l4re"))] pub const AT_MINSIGSTKSZ: c_ulong = 51; pub const GLOB_ERR: c_int = 1 << 0; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 64fea11708e70..8797a0bd354d2 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -206,11 +206,6 @@ s! { pub ar_op: u16, } - pub struct mmsghdr { - pub msg_hdr: crate::msghdr, - pub msg_len: c_uint, - } - pub struct sockaddr_un { pub sun_family: sa_family_t, pub sun_path: [c_char; 108], @@ -453,8 +448,6 @@ pub const O_RDONLY: c_int = 0; pub const O_WRONLY: c_int = 1; pub const O_RDWR: c_int = 2; -pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; - pub const S_IFIFO: mode_t = 0o1_0000; pub const S_IFCHR: mode_t = 0o2_0000; pub const S_IFBLK: mode_t = 0o6_0000; @@ -771,8 +764,6 @@ pub const MSG_CMSG_CLOEXEC: c_int = 0x40000000; pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; -pub const SOCK_RAW: c_int = 3; -pub const SOCK_RDM: c_int = 4; pub const IP_TOS: c_int = 1; pub const IP_TTL: c_int = 2; pub const IP_HDRINCL: c_int = 3; @@ -1024,10 +1015,6 @@ cfg_if! { pub const SO_DEBUG: c_int = 1; -pub const SHUT_RD: c_int = 0; -pub const SHUT_WR: c_int = 1; -pub const SHUT_RDWR: c_int = 2; - pub const LOCK_SH: c_int = 1; pub const LOCK_EX: c_int = 2; pub const LOCK_NB: c_int = 4; @@ -1543,6 +1530,7 @@ cfg_if! { pub const AFFS_SUPER_MAGIC: c_long = 0x0000adff; pub const AFS_SUPER_MAGIC: c_long = 0x5346414f; pub const AUTOFS_SUPER_MAGIC: c_long = 0x0187; + pub const BCACHEFS_SUPER_MAGIC: c_long = u32_cast_long(0xca451a4e); pub const BPF_FS_MAGIC: c_long = u32_cast_long(0xcafe4a11); pub const BTRFS_SUPER_MAGIC: c_long = u32_cast_long(0x9123683e); pub const CGROUP2_SUPER_MAGIC: c_long = 0x63677270; @@ -1597,6 +1585,7 @@ cfg_if! { pub const AFFS_SUPER_MAGIC: c_uint = 0x0000adff; pub const AFS_SUPER_MAGIC: c_uint = 0x5346414f; pub const AUTOFS_SUPER_MAGIC: c_uint = 0x0187; + pub const BCACHEFS_SUPER_MAGIC: c_long = 0xca451a4e; pub const BPF_FS_MAGIC: c_uint = 0xcafe4a11; pub const BTRFS_SUPER_MAGIC: c_uint = 0x9123683e; pub const CGROUP2_SUPER_MAGIC: c_uint = 0x63677270; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index d0bf81b624671..d4823d76bc6ad 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -2131,6 +2131,10 @@ extern "C" { pub fn mkstemp(template: *mut c_char) -> c_int; pub fn mkdtemp(template: *mut c_char) -> *mut c_char; + #[deprecated( + since = "0.2.190", + note = "function is obsolete; prefer tmpfile, mkstemp, or similar" + )] pub fn tmpnam(ptr: *mut c_char) -> *mut c_char; pub fn openlog(ident: *const c_char, logopt: c_int, facility: c_int); diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 933bc2eb8f6f3..5e5fd11c3590f 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -25,7 +25,7 @@ cfg_if! { pub type ino_t = u32; pub type off_t = i64; } else { - core::compile_error!("unsupported target"); + compile_error!("unsupported target"); } } @@ -888,6 +888,9 @@ pub const PRIO_PROCESS: c_int = 0; pub const PRIO_PGRP: c_int = 1; pub const PRIO_USER: c_int = 2; +// include/paths.h from newlib's libc +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { pub unsafe fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let bits = size_of_val(&(*set).fds_bits[0]) * 8; @@ -1027,6 +1030,6 @@ cfg_if! { mod rtems; pub use self::rtems::*; } else { - core::compile_error!("unsupported target"); + compile_error!("unsupported target"); } } diff --git a/src/unix/nto/io_sock/mod.rs b/src/unix/nto/io_sock/mod.rs index 303f5ca4c44b5..5d0e435a65fa6 100644 --- a/src/unix/nto/io_sock/mod.rs +++ b/src/unix/nto/io_sock/mod.rs @@ -50,6 +50,18 @@ s! { pub sdl_slen: c_uchar, pub sdl_data: [c_char; 46], } + + pub struct ip_mreqn { + pub imr_multiaddr: crate::in_addr, + pub imr_address: crate::in_addr, + pub imr_ifindex: c_int, + } + + pub struct ip_mreq_source { + pub imr_multiaddr: crate::in_addr, + pub imr_sourceaddr: crate::in_addr, + pub imr_interface: crate::in_addr, + } } pub const SCM_CREDS: c_int = 0x03; @@ -89,6 +101,12 @@ pub const PF_NATM: c_int = AF_NATM; pub const pseudo_AF_HDRCMPLT: c_int = 31; pub const SIOCGIFADDR: c_int = u32_cast_int(0xc0206921); pub const SO_SETFIB: c_int = 0x1014; +pub const TCP_KEEPIDLE: c_int = 256; +pub const TCP_KEEPINTVL: c_int = 512; +pub const TCP_KEEPCNT: c_int = 1024; +pub const IP_RECVTOS: c_int = 68; +pub const IP_ADD_SOURCE_MEMBERSHIP: c_int = 70; +pub const IP_DROP_SOURCE_MEMBERSHIP: c_int = 71; extern "C" { pub fn sendmmsg( diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index faec373cbec92..7276aaca09b0c 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -771,7 +771,7 @@ s_no_extra_traits! { // form would be bogus and it would potentially change the size of the data type. On QNX SDP 8, this // got fixed and both C and C++ are using the same definition. pub struct max_align_t { - _ll: crate::c_longlong, + _ll: c_longlong, _ld: i128, } } diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 4e21f57b3e187..87f618a8faf4f 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -1018,8 +1018,8 @@ pub const OLCUC: crate::tcflag_t = 0o000_004; pub const OCRNL: crate::tcflag_t = 0o000_010; pub const ONOCR: crate::tcflag_t = 0o000_020; pub const ONLRET: crate::tcflag_t = 0o000_040; -pub const OFILL: crate::tcflag_t = 0o0000_100; -pub const OFDEL: crate::tcflag_t = 0o0000_200; +pub const OFILL: crate::tcflag_t = 0o0_000_100; +pub const OFDEL: crate::tcflag_t = 0o0_000_200; pub const B0: speed_t = 0o000_000; pub const B50: speed_t = 0o000_001; @@ -1190,6 +1190,7 @@ pub const X_OK: c_int = 1; // stdio.h pub const BUFSIZ: c_uint = 1024; +pub const FILENAME_MAX: c_int = 4096; pub const _IOFBF: c_int = 0; pub const _IOLBF: c_int = 1; pub const _IONBF: c_int = 2; @@ -1225,6 +1226,9 @@ pub const PRIO_USER: c_int = 2; pub const RENAME_NOREPLACE: c_uint = 1; +// include/paths.h from relibc +pub const _PATH_BSHELL: *const c_char = cstr(b"/bin/sh\0"); + f! { //sys/socket.h pub const unsafe fn CMSG_ALIGN(len: size_t) -> size_t { diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 07bf8b49ec4dc..83bfb0daaf520 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -1780,6 +1780,10 @@ extern "C" { pub fn ftello(stream: *mut crate::FILE) -> off_t; pub fn mkstemp(template: *mut c_char) -> c_int; + #[deprecated( + since = "0.2.190", + note = "function is obsolete; prefer tmpfile, mkstemp, or similar" + )] pub fn tmpnam(ptr: *mut c_char) -> *mut c_char; pub fn openlog(ident: *const c_char, logopt: c_int, facility: c_int);