From e70b031fbd4b10840f58fe84f97cf625d1b58bfd Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 14 Apr 2025 22:46:54 -0400 Subject: [PATCH 01/29] chore: add clippy CI tests run cargo clippy for all targets (backport ) (cherry picked from commit bea4d1b0b893f222a837dcfa2ed1a100f1ed440a) --- Cargo.toml | 22 ++++++++++++++++++++++ ci/style.sh | 3 +++ ci/verify-build.sh | 7 +++++++ libc-test/Cargo.toml | 23 +++++++++++++++++++++++ 4 files changed, 55 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 9e53e45110a7e..8ae40020fad33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -150,3 +150,25 @@ members = [ "ctest", "libc-test", ] + +# +# TODO: These should be renamed as `[workspace.lints.*]` once MSRV is abve 1.64 +# This way all crates can use it with `[lints] workspace=true` section +# + +[lints.rust] +# TODO: make ident usage consistent in each file +unused_qualifications = "allow" + +[lints.clippy] +# TODO: all these are default lints and should probably be fixed +identity_op = "allow" +if_same_then_else = "allow" +missing_safety_doc = "allow" +non_minimal_cfg = "allow" +precedence = "allow" +redundant_field_names = "allow" +redundant_static_lifetimes = "allow" +unnecessary_cast = "allow" +unused_unit = "allow" +zero_ptr = "allow" diff --git a/ci/style.sh b/ci/style.sh index 5b200796a8c53..99fc2f12c089d 100755 --- a/ci/style.sh +++ b/ci/style.sh @@ -4,6 +4,9 @@ set -eux [ -n "${CI:-}" ] && check="--check" +# TODO: for some reason using `--workspace` validates a lot of generated code in ./target/** dir +cargo clippy -p libc@1.0.0-alpha.1 -p ctest --all-targets -- -D warnings + cargo test --manifest-path libc-test/Cargo.toml --test style -- --nocapture command -v rustfmt diff --git a/ci/verify-build.sh b/ci/verify-build.sh index 375a5de1b0a2f..c99d04addfafe 100755 --- a/ci/verify-build.sh +++ b/ci/verify-build.sh @@ -44,9 +44,13 @@ test_target() { # The basic command that is run each time cmd="cargo +$rust build --target $target" + # The basic clippy command + clippy_cmd="cargo +$rust clippy --all-targets --target $target" + if [ "${no_dist}" != "0" ]; then # If we can't download a `core`, we need to build it cmd="$cmd -Zbuild-std=core,alloc" + clippy_cmd="$clippy_cmd -Zbuild-std=core,alloc" # FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings. RUSTFLAGS="${RUSTFLAGS:-} -Aimproper_ctypes_definitions" @@ -67,6 +71,9 @@ test_target() { done fi + # Run cargo clippy first + $clippy_cmd + # Test with expected combinations of features $cmd $cmd --features const-extern-fn diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 9573c3fdb8288..fe8d2866cf324 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -104,3 +104,26 @@ harness = true name = "style_tests" path = "test/style_tests.rs" harness = true + +# +# TODO: These should be moved to the root Cargo.toml as `[workspace.lints.*]` once MSRV is abve 1.64 +# replace it with `[lints] workspace=true` +# + +[lints.rust] +# TODO: make ident usage consistent in each file +unused_qualifications = "allow" + +[lints.clippy] +# TODO: fix these, and enable pedantic lints with needed exceptions +needless_return = "allow" +comparison_to_empty = "allow" +unused_io_amount = "allow" +write_with_newline = "allow" +needless_borrows_for_generic_args = "allow" +only_used_in_recursion = "allow" +match_like_matches_macro = "allow" +useless_format = "allow" +wildcard_in_or_patterns = "allow" +nonminimal_bool = "allow" +match_single_binding = "allow" From 2aba8545d79551f1e7105bfeb1893739262012ab Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 14 Apr 2025 22:57:49 -0400 Subject: [PATCH 02/29] simplify clippy ci (backport ) (cherry picked from commit 5997a8b58b7f348300c839a1bd5b82f7eee459a5) --- .github/workflows/ci.yaml | 12 ++++++++++++ ci/style.sh | 3 --- ci/verify-build.sh | 7 ------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d581b362ebacf..60e4340145c2d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,6 +30,18 @@ jobs: - name: Check style run: ./ci/style.sh + clippy: + name: Clippy check + runs-on: ubuntu-24.04 + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + # Here we use the latest stable Rust toolchain already installed by GitHub + # Ideally we should run it for every target, but we cannot rely on unstable toolchains + # due to Clippy not being consistent between them. + - run: cargo clippy --workspace --exclude libc-test --exclude ctest-test --all-targets -- -D warnings + # This runs `cargo build --target ...` for all T1 and T2 targets` verify_build: name: Verify build diff --git a/ci/style.sh b/ci/style.sh index 99fc2f12c089d..5b200796a8c53 100755 --- a/ci/style.sh +++ b/ci/style.sh @@ -4,9 +4,6 @@ set -eux [ -n "${CI:-}" ] && check="--check" -# TODO: for some reason using `--workspace` validates a lot of generated code in ./target/** dir -cargo clippy -p libc@1.0.0-alpha.1 -p ctest --all-targets -- -D warnings - cargo test --manifest-path libc-test/Cargo.toml --test style -- --nocapture command -v rustfmt diff --git a/ci/verify-build.sh b/ci/verify-build.sh index c99d04addfafe..375a5de1b0a2f 100755 --- a/ci/verify-build.sh +++ b/ci/verify-build.sh @@ -44,13 +44,9 @@ test_target() { # The basic command that is run each time cmd="cargo +$rust build --target $target" - # The basic clippy command - clippy_cmd="cargo +$rust clippy --all-targets --target $target" - if [ "${no_dist}" != "0" ]; then # If we can't download a `core`, we need to build it cmd="$cmd -Zbuild-std=core,alloc" - clippy_cmd="$clippy_cmd -Zbuild-std=core,alloc" # FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings. RUSTFLAGS="${RUSTFLAGS:-} -Aimproper_ctypes_definitions" @@ -71,9 +67,6 @@ test_target() { done fi - # Run cargo clippy first - $clippy_cmd - # Test with expected combinations of features $cmd $cmd --features const-extern-fn From c544ee4d7ad012a4d0b14f2b1c85799331161c8b Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 14 Apr 2025 23:03:23 -0400 Subject: [PATCH 03/29] run clippy on 3 major platforms (backport ) (cherry picked from commit e09683ea3523cde23c36ffe7ada2289b76a18618) --- .github/workflows/ci.yaml | 11 ++++++++--- Cargo.toml | 11 +++++------ libc-test/Cargo.toml | 10 ++++------ 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 60e4340145c2d..9b98d1d83e8e8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -31,11 +31,15 @@ jobs: run: ./ci/style.sh clippy: - name: Clippy check - runs-on: ubuntu-24.04 + name: Clippy on ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-24.04, macos-14, windows-2022] + runs-on: ${{ matrix.os }} timeout-minutes: 10 steps: - uses: actions/checkout@v4 + - run: rustup update stable --no-self-update - uses: Swatinem/rust-cache@v2 # Here we use the latest stable Rust toolchain already installed by GitHub # Ideally we should run it for every target, but we cannot rely on unstable toolchains @@ -270,7 +274,8 @@ jobs: - test_tier2 - test_tier2_vm - verify_build - # Github branch protection is exceedingly silly and treats "jobs skipped because a dependency + - clippy + # GitHub branch protection is exceedingly silly and treats "jobs skipped because a dependency # failed" as success. So we have to do some contortions to ensure the job fails if any of its # dependencies fails. if: always() # make sure this is never "skipped" diff --git a/Cargo.toml b/Cargo.toml index 8ae40020fad33..88d748dc549a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -151,20 +151,19 @@ members = [ "libc-test", ] -# -# TODO: These should be renamed as `[workspace.lints.*]` once MSRV is abve 1.64 +# FIXME(msrv): These should be renamed as `[workspace.lints.*]` once MSRV is above 1.64 # This way all crates can use it with `[lints] workspace=true` section -# [lints.rust] -# TODO: make ident usage consistent in each file +# FIXME(cleanup): make ident usage consistent in each file unused_qualifications = "allow" [lints.clippy] -# TODO: all these are default lints and should probably be fixed +missing_safety_doc = "allow" + +# FIXME(clippy): all these are default lints and should probably be fixed identity_op = "allow" if_same_then_else = "allow" -missing_safety_doc = "allow" non_minimal_cfg = "allow" precedence = "allow" redundant_field_names = "allow" diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index fe8d2866cf324..9e7d176b71be6 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -105,17 +105,15 @@ name = "style_tests" path = "test/style_tests.rs" harness = true -# -# TODO: These should be moved to the root Cargo.toml as `[workspace.lints.*]` once MSRV is abve 1.64 -# replace it with `[lints] workspace=true` -# +# FIXME(msrv): These should be moved to the root Cargo.toml as `[workspace.lints.*]` +# once MSRV is above 1.64 and replaced with `[lints] workspace=true` [lints.rust] -# TODO: make ident usage consistent in each file +# FIXME(cleanup): make ident usage consistent in each file unused_qualifications = "allow" [lints.clippy] -# TODO: fix these, and enable pedantic lints with needed exceptions +# FIXME(clippy): fix these needless_return = "allow" comparison_to_empty = "allow" unused_io_amount = "allow" From d716b809e5e5bba253b069b61930eb5204e18c43 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Tue, 15 Apr 2025 02:55:14 -0400 Subject: [PATCH 04/29] chore: inline format args (backport ) (cherry picked from commit 444d9df5606f5b848f338f03b5be00581cb44f1f) --- build.rs | 12 +-- ci/ios/deploy_and_run_on_ios_simulator.rs | 4 +- ci/runtest-android.rs | 4 +- libc-test/build.rs | 93 +++++++++++------------ 4 files changed, 55 insertions(+), 58 deletions(-) diff --git a/build.rs b/build.rs index ec2c599ca7de0..2fc84aa6b8d33 100644 --- a/build.rs +++ b/build.rs @@ -130,17 +130,17 @@ fn main() { if rustc_minor_ver >= 80 { for cfg in ALLOWED_CFGS { if rustc_minor_ver >= 75 { - println!("cargo:rustc-check-cfg=cfg({})", cfg); + println!("cargo:rustc-check-cfg=cfg({cfg})"); } else { - println!("cargo:rustc-check-cfg=values({})", cfg); + println!("cargo:rustc-check-cfg=values({cfg})"); } } for &(name, values) in CHECK_CFG_EXTRA { let values = values.join("\",\""); if rustc_minor_ver >= 75 { - println!("cargo:rustc-check-cfg=cfg({},values(\"{}\"))", name, values); + println!("cargo:rustc-check-cfg=cfg({name},values(\"{values}\"))"); } else { - println!("cargo:rustc-check-cfg=values({},\"{}\")", name, values); + println!("cargo:rustc-check-cfg=values({name},\"{values}\")"); } } } @@ -267,7 +267,7 @@ fn emcc_version_code() -> Option { fn set_cfg(cfg: &str) { if !ALLOWED_CFGS.contains(&cfg) { - panic!("trying to set cfg {}, but it is not in ALLOWED_CFGS", cfg); + panic!("trying to set cfg {cfg}, but it is not in ALLOWED_CFGS"); } - println!("cargo:rustc-cfg={}", cfg); + println!("cargo:rustc-cfg={cfg}"); } diff --git a/ci/ios/deploy_and_run_on_ios_simulator.rs b/ci/ios/deploy_and_run_on_ios_simulator.rs index aa1034fc749df..7e0b80268ffbc 100644 --- a/ci/ios/deploy_and_run_on_ios_simulator.rs +++ b/ci/ios/deploy_and_run_on_ios_simulator.rs @@ -16,7 +16,7 @@ use std::process::Command; macro_rules! t { ($e:expr) => (match $e { Ok(e) => e, - Err(e) => panic!("{} failed with: {}", stringify!($e), e), + Err(e) => panic!("{} failed with: {e}", stringify!($e)), }) } @@ -143,7 +143,7 @@ trait CheckStatus { impl CheckStatus for Command { fn check_status(&mut self) { - println!("\trunning: {:?}", self); + println!("\trunning: {self:?}"); assert!(t!(self.status()).success()); } } diff --git a/ci/runtest-android.rs b/ci/runtest-android.rs index d422f9c2e8a7e..29b1a82f675c7 100644 --- a/ci/runtest-android.rs +++ b/ci/runtest-android.rs @@ -37,8 +37,8 @@ fn main() { let stderr = String::from_utf8_lossy(&output.stderr); println!( - "status: {}\nstdout ---\n{}\nstderr ---\n{}", - output.status, stdout, stderr + "status: {}\nstdout ---\n{stdout}\nstderr ---\n{stderr}", + output.status, ); if !stderr.lines().any(|l| { diff --git a/libc-test/build.rs b/libc-test/build.rs index 7d6e5fe6d7330..6b5cd9b74d029 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -69,7 +69,7 @@ fn do_ctest() { t if t.contains("windows") => return test_windows(t), t if t.contains("vxworks") => return test_vxworks(t), t if t.contains("nto-qnx") => return test_neutrino(t), - t => panic!("unknown target {}", t), + t => panic!("unknown target {t}"), } } @@ -109,13 +109,13 @@ fn do_semver() { process_semver_file(&mut output, &mut semver_root, &vendor); } process_semver_file(&mut output, &mut semver_root, &os); - let os_arch = format!("{}-{}", os, arch); + let os_arch = format!("{os}-{arch}"); process_semver_file(&mut output, &mut semver_root, &os_arch); if target_env != "" { - let os_env = format!("{}-{}", os, target_env); + let os_env = format!("{os}-{target_env}"); process_semver_file(&mut output, &mut semver_root, &os_env); - let os_env_arch = format!("{}-{}-{}", os, target_env, arch); + let os_env_arch = format!("{os}-{target_env}-{arch}"); process_semver_file(&mut output, &mut semver_root, &os_env_arch); } } @@ -132,7 +132,7 @@ fn process_semver_file>(output: &mut W, path: &mut Path path.pop(); return; } - Err(err) => panic!("unexpected error opening file: {}", err), + Err(err) => panic!("unexpected error opening file: {err}"), }; let input = BufReader::new(input_file); @@ -471,9 +471,9 @@ fn test_apple(target: &str) { // OSX calls this something else "sighandler_t" => "sig_t".to_string(), - t if is_union => format!("union {}", t), + t if is_union => format!("union {t}"), t if t.ends_with("_t") => t.to_string(), - t if is_struct => format!("struct {}", t), + t if is_struct => format!("struct {t}"), t => t.to_string(), } }); @@ -654,9 +654,9 @@ fn test_openbsd(target: &str) { // OSX calls this something else "sighandler_t" => "sig_t".to_string(), - t if is_union => format!("union {}", t), + t if is_union => format!("union {t}"), t if t.ends_with("_t") => t.to_string(), - t if is_struct => format!("struct {}", t), + t if is_struct => format!("struct {t}"), t => t.to_string(), } }); @@ -753,7 +753,7 @@ fn test_cygwin(target: &str) { "Ioctl" => "int".to_string(), - t if is_union => format!("union {}", t), + t if is_union => format!("union {t}"), t if t.ends_with("_t") => t.to_string(), @@ -761,7 +761,7 @@ fn test_cygwin(target: &str) { "sigval" => format!("union sigval"), // put `struct` in front of all structs:. - t if is_struct => format!("struct {}", t), + t if is_struct => format!("struct {t}"), t => t.to_string(), } @@ -905,7 +905,7 @@ fn test_windows(target: &str) { "sighandler_t" if !gnu => "_crt_signal_t".to_string(), "sighandler_t" if gnu => "__p_sig_fn_t".to_string(), - t if is_union => format!("union {}", t), + t if is_union => format!("union {t}"), t if t.ends_with("_t") => t.to_string(), // Windows uppercase structs don't have `struct` in front: @@ -918,7 +918,7 @@ fn test_windows(target: &str) { "struct __utimbuf64".to_string() } else { // put `struct` in front of all structs: - format!("struct {}", t) + format!("struct {t}") } } t => t.to_string(), @@ -1164,8 +1164,8 @@ fn test_solarish(target: &str) { "FILE" => "__FILE".to_string(), "DIR" | "Dl_info" => ty.to_string(), t if t.ends_with("_t") => t.to_string(), - t if is_struct => format!("struct {}", t), - t if is_union => format!("union {}", t), + t if is_struct => format!("struct {t}"), + t if is_union => format!("union {t}"), t => t.to_string(), }); @@ -1434,12 +1434,12 @@ fn test_netbsd(target: &str) { // OSX calls this something else "sighandler_t" => "sig_t".to_string(), - t if is_union => format!("union {}", t), + t if is_union => format!("union {t}"), t if t.ends_with("_t") => t.to_string(), // put `struct` in front of all structs:. - t if is_struct => format!("struct {}", t), + t if is_struct => format!("struct {t}"), t => t.to_string(), } @@ -1650,7 +1650,7 @@ fn test_dragonflybsd(target: &str) { // FIXME(dragonflybsd): OSX calls this something else "sighandler_t" => "sig_t".to_string(), - t if is_union => format!("union {}", t), + t if is_union => format!("union {t}"), t if t.ends_with("_t") => t.to_string(), @@ -1658,7 +1658,7 @@ fn test_dragonflybsd(target: &str) { "sigval" => format!("union sigval"), // put `struct` in front of all structs:. - t if is_struct => format!("struct {}", t), + t if is_struct => format!("struct {t}"), t => t.to_string(), } @@ -1828,11 +1828,11 @@ fn test_wasi(target: &str) { cfg.type_name(move |ty, is_struct, is_union| match ty { "FILE" | "fd_set" | "DIR" => ty.to_string(), - t if is_union => format!("union {}", t), - t if t.starts_with("__wasi") && t.ends_with("_u") => format!("union {}", t), - t if t.starts_with("__wasi") && is_struct => format!("struct {}", t), + t if is_union => format!("union {t}"), + t if t.starts_with("__wasi") && t.ends_with("_u") => format!("union {t}"), + t if t.starts_with("__wasi") && is_struct => format!("struct {t}"), t if t.ends_with("_t") => t.to_string(), - t if is_struct => format!("struct {}", t), + t if is_struct => format!("struct {t}"), t => t.to_string(), }); @@ -1881,7 +1881,7 @@ fn test_android(target: &str) { let target_pointer_width = match target { t if t.contains("aarch64") || t.contains("x86_64") => 64, t if t.contains("i686") || t.contains("arm") => 32, - t => panic!("unsupported target: {}", t), + t => panic!("unsupported target: {t}"), }; let x86 = target.contains("i686") || target.contains("x86_64"); let aarch64 = target.contains("aarch64"); @@ -2040,7 +2040,7 @@ fn test_android(target: &str) { // Just pass all these through, no need for a "struct" prefix "FILE" | "fd_set" | "Dl_info" | "Elf32_Phdr" | "Elf64_Phdr" => ty.to_string(), - t if is_union => format!("union {}", t), + t if is_union => format!("union {t}"), t if t.ends_with("_t") => t.to_string(), @@ -2048,7 +2048,7 @@ fn test_android(target: &str) { "sigval" => format!("union sigval"), // put `struct` in front of all structs:. - t if is_struct => format!("struct {}", t), + t if is_struct => format!("struct {t}"), t => t.to_string(), } @@ -2553,7 +2553,7 @@ fn test_freebsd(target: &str) { // FIXME(freebsd): https://github.com/rust-lang/libc/issues/1273 "sighandler_t" => "sig_t".to_string(), - t if is_union => format!("union {}", t), + t if is_union => format!("union {t}"), t if t.ends_with("_t") => t.to_string(), @@ -2561,7 +2561,7 @@ fn test_freebsd(target: &str) { "sigval" => format!("union sigval"), // put `struct` in front of all structs:. - t if is_struct => format!("struct {}", t), + t if is_struct => format!("struct {t}"), t => t.to_string(), } @@ -3158,10 +3158,10 @@ fn test_emscripten(target: &str) { t if t.ends_with("_t") => t.to_string(), // put `struct` in front of all structs:. - t if is_struct => format!("struct {}", t), + t if is_struct => format!("struct {t}"), // put `union` in front of all unions: - t if is_union => format!("union {}", t), + t if is_union => format!("union {t}"), t => t.to_string(), } @@ -3438,12 +3438,12 @@ fn test_neutrino(target: &str) { "Ioctl" => "int".to_string(), - t if is_union => format!("union {}", t), + t if is_union => format!("union {t}"), t if t.ends_with("_t") => t.to_string(), // put `struct` in front of all structs:. - t if is_struct => format!("struct {}", t), + t if is_struct => format!("struct {t}"), t => t.to_string(), } @@ -3664,9 +3664,9 @@ fn test_vxworks(target: &str) { cfg.type_name(move |ty, is_struct, is_union| match ty { "DIR" | "FILE" | "Dl_info" | "RTP_DESC" => ty.to_string(), - t if is_union => format!("union {}", t), + t if is_union => format!("union {t}"), t if t.ends_with("_t") => t.to_string(), - t if is_struct => format!("struct {}", t), + t if is_struct => format!("struct {t}"), t => t.to_string(), }); @@ -3716,10 +3716,7 @@ fn test_linux(target: &str) { (true, false, false) => (), (false, true, false) => (), (false, false, true) => (), - (_, _, _) => panic!( - "linux target lib is gnu: {}, musl: {}, uclibc: {}", - gnu, musl, uclibc - ), + (_, _, _) => panic!("linux target lib is gnu: {gnu}, musl: {musl}, uclibc: {uclibc}"), } let arm = target.contains("arm"); @@ -3959,9 +3956,9 @@ fn test_linux(target: &str) { // typedefs don't need any keywords t if t.ends_with("_t") => t.to_string(), // put `struct` in front of all structs:. - t if is_struct => format!("struct {}", t), + t if is_struct => format!("struct {t}"), // put `union` in front of all unions: - t if is_union => format!("union {}", t), + t if is_union => format!("union {t}"), t => t.to_string(), } @@ -4990,8 +4987,8 @@ fn test_linux_like_apis(target: &str) { _ => true, }) .type_name(move |ty, is_struct, is_union| match ty { - t if is_struct => format!("struct {}", t), - t if is_union => format!("union {}", t), + t if is_struct => format!("struct {t}"), + t if is_union => format!("union {t}"), t => t.to_string(), }); @@ -5016,8 +5013,8 @@ fn test_linux_like_apis(target: &str) { .type_name(move |ty, is_struct, is_union| match ty { "Ioctl" if gnu => "unsigned long".to_string(), "Ioctl" => "int".to_string(), - t if is_struct => format!("struct {}", t), - t if is_union => format!("union {}", t), + t if is_struct => format!("struct {t}"), + t if is_union => format!("union {t}"), t => t.to_string(), }); cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_termios.rs"); @@ -5045,8 +5042,8 @@ fn test_linux_like_apis(target: &str) { _ => true, }) .type_name(move |ty, is_struct, is_union| match ty { - t if is_struct => format!("struct {}", t), - t if is_union => format!("union {}", t), + t if is_struct => format!("struct {t}"), + t if is_union => format!("union {t}"), t => t.to_string(), }); cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_ipv6.rs"); @@ -5433,9 +5430,9 @@ fn test_haiku(target: &str) { // is actually a union "sigval" => format!("union sigval"), - t if is_union => format!("union {}", t), + t if is_union => format!("union {t}"), t if t.ends_with("_t") => t.to_string(), - t if is_struct => format!("struct {}", t), + t if is_struct => format!("struct {t}"), t => t.to_string(), } }); From b21e075c77d1c47a3142cb3b5afa35a111d47a1a Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 14 Apr 2025 23:20:00 -0400 Subject: [PATCH 05/29] chore: lint `libc-test/build.rs` run `cargo clippy --all-targets` on `libc-test/build.rs`, and fix all default issues. Notes: * `copy_dir_hotfix` had a `replace` parameter that was never used (backport ) [ adjust section heading to avoid ### turning into comment - Trevor ] (cherry picked from commit 8b15e27a1e06ea9484caa75632de63263a3abb5c) --- libc-test/Cargo.toml | 14 ----- libc-test/build.rs | 119 ++++++++++++++++++-------------------- libc-test/test/makedev.rs | 6 +- 3 files changed, 59 insertions(+), 80 deletions(-) diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 9e7d176b71be6..6379029be07a9 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -109,19 +109,5 @@ harness = true # once MSRV is above 1.64 and replaced with `[lints] workspace=true` [lints.rust] -# FIXME(cleanup): make ident usage consistent in each file -unused_qualifications = "allow" [lints.clippy] -# FIXME(clippy): fix these -needless_return = "allow" -comparison_to_empty = "allow" -unused_io_amount = "allow" -write_with_newline = "allow" -needless_borrows_for_generic_args = "allow" -only_used_in_recursion = "allow" -match_like_matches_macro = "allow" -useless_format = "allow" -wildcard_in_or_patterns = "allow" -nonminimal_bool = "allow" -match_single_binding = "allow" diff --git a/libc-test/build.rs b/libc-test/build.rs index 6b5cd9b74d029..bcbe2dc3356f3 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1,4 +1,5 @@ #![deny(warnings)] +#![allow(clippy::match_like_matches_macro)] extern crate ctest2 as ctest; @@ -52,23 +53,23 @@ fn do_cc() { fn do_ctest() { match &env::var("TARGET").unwrap() { - t if t.contains("android") => return test_android(t), - t if t.contains("apple") => return test_apple(t), - t if t.contains("dragonfly") => return test_dragonflybsd(t), - t if t.contains("emscripten") => return test_emscripten(t), - t if t.contains("freebsd") => return test_freebsd(t), - t if t.contains("haiku") => return test_haiku(t), - t if t.contains("linux") => return test_linux(t), - t if t.contains("netbsd") => return test_netbsd(t), - t if t.contains("openbsd") => return test_openbsd(t), - t if t.contains("cygwin") => return test_cygwin(t), - t if t.contains("redox") => return test_redox(t), - t if t.contains("solaris") => return test_solarish(t), - t if t.contains("illumos") => return test_solarish(t), - t if t.contains("wasi") => return test_wasi(t), - t if t.contains("windows") => return test_windows(t), - t if t.contains("vxworks") => return test_vxworks(t), - t if t.contains("nto-qnx") => return test_neutrino(t), + t if t.contains("android") => test_android(t), + t if t.contains("apple") => test_apple(t), + t if t.contains("dragonfly") => test_dragonflybsd(t), + t if t.contains("emscripten") => test_emscripten(t), + t if t.contains("freebsd") => test_freebsd(t), + t if t.contains("haiku") => test_haiku(t), + t if t.contains("linux") => test_linux(t), + t if t.contains("netbsd") => test_netbsd(t), + t if t.contains("openbsd") => test_openbsd(t), + t if t.contains("cygwin") => test_cygwin(t), + t if t.contains("redox") => test_redox(t), + t if t.contains("solaris") => test_solarish(t), + t if t.contains("illumos") => test_solarish(t), + t if t.contains("wasi") => test_wasi(t), + t if t.contains("windows") => test_windows(t), + t if t.contains("vxworks") => test_vxworks(t), + t if t.contains("nto-qnx") => test_neutrino(t), t => panic!("unknown target {t}"), } } @@ -111,7 +112,7 @@ fn do_semver() { process_semver_file(&mut output, &mut semver_root, &os); let os_arch = format!("{os}-{arch}"); process_semver_file(&mut output, &mut semver_root, &os_arch); - if target_env != "" { + if !target_env.is_empty() { let os_env = format!("{os}-{target_env}"); process_semver_file(&mut output, &mut semver_root, &os_env); @@ -136,21 +137,21 @@ fn process_semver_file>(output: &mut W, path: &mut Path }; let input = BufReader::new(input_file); - write!(output, "// Source: {}.\n", path.display()).unwrap(); - output.write(b"use libc::{\n").unwrap(); + writeln!(output, "// Source: {}.", path.display()).unwrap(); + output.write_all(b"use libc::{\n").unwrap(); for line in input.lines() { let line = line.unwrap().into_bytes(); match line.first() { // Ignore comments and empty lines. Some(b'#') | None => continue, _ => { - output.write(b" ").unwrap(); - output.write(&line).unwrap(); - output.write(b",\n").unwrap(); + output.write_all(b" ").unwrap(); + output.write_all(&line).unwrap(); + output.write_all(b",\n").unwrap(); } } } - output.write(b"};\n\n").unwrap(); + output.write_all(b"};\n\n").unwrap(); path.pop(); } @@ -172,8 +173,10 @@ fn main() { do_semver(); } +// FIXME(clippy): removing `replace` somehow fails the `Test tier1 (x86_64-pc-windows-msvc, windows-2022)` CI job +#[allow(clippy::only_used_in_recursion)] fn copy_dir_hotfix(src: &Path, dst: &Path, regex: ®ex::bytes::Regex, replace: &[u8]) { - std::fs::create_dir(&dst).unwrap(); + std::fs::create_dir(dst).unwrap(); for entry in src.read_dir().unwrap() { let entry = entry.unwrap(); let src_path = entry.path(); @@ -758,7 +761,7 @@ fn test_cygwin(target: &str) { t if t.ends_with("_t") => t.to_string(), // sigval is a struct in Rust, but a union in C: - "sigval" => format!("union sigval"), + "sigval" => "union sigval".to_string(), // put `struct` in front of all structs:. t if is_struct => format!("struct {t}"), @@ -1505,6 +1508,7 @@ fn test_netbsd(target: &str) { }); cfg.skip_fn(move |name| { + #[expect(clippy::wildcard_in_or_patterns)] match name { // FIXME(netbsd): https://github.com/rust-lang/libc/issues/1272 "execv" | "execve" | "execvp" => true, @@ -1655,7 +1659,7 @@ fn test_dragonflybsd(target: &str) { t if t.ends_with("_t") => t.to_string(), // sigval is a struct in Rust, but a union in C: - "sigval" => format!("union sigval"), + "sigval" => "union sigval".to_string(), // put `struct` in front of all structs:. t if is_struct => format!("struct {t}"), @@ -2045,7 +2049,7 @@ fn test_android(target: &str) { t if t.ends_with("_t") => t.to_string(), // sigval is a struct in Rust, but a union in C: - "sigval" => format!("union sigval"), + "sigval" => "union sigval".to_string(), // put `struct` in front of all structs:. t if is_struct => format!("struct {t}"), @@ -2404,18 +2408,9 @@ fn test_freebsd(target: &str) { // Required for making freebsd11_stat available in the headers cfg.define("_WANT_FREEBSD11_STAT", None); - let freebsd13 = match freebsd_ver { - Some(n) if n >= 13 => true, - _ => false, - }; - let freebsd14 = match freebsd_ver { - Some(n) if n >= 14 => true, - _ => false, - }; - let freebsd15 = match freebsd_ver { - Some(n) if n >= 15 => true, - _ => false, - }; + let freebsd13 = matches!(freebsd_ver, Some(n) if n >= 13); + let freebsd14 = matches!(freebsd_ver, Some(n) if n >= 14); + let freebsd15 = matches!(freebsd_ver, Some(n) if n >= 15); headers! { cfg: "aio.h", @@ -2558,7 +2553,7 @@ fn test_freebsd(target: &str) { t if t.ends_with("_t") => t.to_string(), // sigval is a struct in Rust, but a union in C: - "sigval" => format!("union sigval"), + "sigval" => "union sigval".to_string(), // put `struct` in front of all structs:. t if is_struct => format!("struct {t}"), @@ -3308,7 +3303,7 @@ fn test_neutrino(target: &str) { let mut cfg = ctest_cfg(); if target.ends_with("_iosock") { - let qnx_target_val = std::env::var("QNX_TARGET") + let qnx_target_val = env::var("QNX_TARGET") .unwrap_or_else(|_| "QNX_TARGET_not_set_please_source_qnxsdp".into()); cfg.include(qnx_target_val + "/usr/include/io-sock"); @@ -3558,17 +3553,17 @@ fn test_neutrino(target: &str) { struct_ == "_idle_hook" && field == "time" }); - cfg.skip_field(move |struct_, field| { - (struct_ == "__sched_param" && field == "reserved") || - (struct_ == "sched_param" && field == "reserved") || - (struct_ == "sigevent" && field == "__padding1") || // ensure alignment - (struct_ == "sigevent" && field == "__padding2") || // union - (struct_ == "sigevent" && field == "__sigev_un2") || // union - // sighandler_t type is super weird - (struct_ == "sigaction" && field == "sa_sigaction") || - // does not exist - (struct_ == "syspage_entry" && field == "__reserved") || - false // keep me for smaller diffs when something is added above + cfg.skip_field(|struct_, field| { + matches!( + (struct_, field), + ("__sched_param", "reserved") + | ("sched_param", "reserved") + | ("sigevent", "__padding1") // ensure alignment + | ("sigevent", "__padding2") // union + | ("sigevent", "__sigev_un2") // union + | ("sigaction", "sa_sigaction") // sighandler_t type is super weird + | ("syspage_entry", "__reserved") // does not exist + ) }); cfg.skip_static(move |name| (name == "__dso_handle")); @@ -3658,9 +3653,7 @@ fn test_vxworks(target: &str) { _ => false, }); - cfg.skip_roundtrip(move |s| match s { - _ => false, - }); + cfg.skip_roundtrip(|_| false); cfg.type_name(move |ty, is_struct, is_union| match ty { "DIR" | "FILE" | "Dl_info" | "RTP_DESC" => ty.to_string(), @@ -4959,8 +4952,8 @@ fn test_linux_like_apis(target: &str) { "strerror_r" => false, _ => true, }) - .skip_const(|_| true) - .skip_struct(|_| true); + .skip_const(|_| true) + .skip_struct(|_| true); cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_strerror_r.rs"); } @@ -5034,10 +5027,10 @@ fn test_linux_like_apis(target: &str) { .skip_const(|_| true) .skip_struct(|_| true) .skip_const(move |name| match name { - "IPV6_FLOWINFO" - | "IPV6_FLOWLABEL_MGR" - | "IPV6_FLOWINFO_SEND" - | "IPV6_FLOWINFO_FLOWLABEL" + "IPV6_FLOWINFO" + | "IPV6_FLOWLABEL_MGR" + | "IPV6_FLOWINFO_SEND" + | "IPV6_FLOWINFO_FLOWLABEL" | "IPV6_FLOWINFO_PRIORITY" => false, _ => true, }) @@ -5429,7 +5422,7 @@ fn test_haiku(target: &str) { } // is actually a union - "sigval" => format!("union sigval"), + "sigval" => "union sigval".to_string(), t if is_union => format!("union {t}"), t if t.ends_with("_t") => t.to_string(), t if is_struct => format!("struct {t}"), diff --git a/libc-test/test/makedev.rs b/libc-test/test/makedev.rs index ea701f6abe94b..6cf180975b8c0 100644 --- a/libc-test/test/makedev.rs +++ b/libc-test/test/makedev.rs @@ -30,8 +30,8 @@ cfg_if::cfg_if! { target_os = "openbsd", target_os = "cygwin", ))] { - pub type MajorRetType = libc::c_uint; - pub type MinorRetType = libc::c_uint; + pub type MajorRetType = c_uint; + pub type MinorRetType = c_uint; } else if #[cfg(any( target_os = "android", target_os = "dragonfly", @@ -129,7 +129,7 @@ fn test_openbsd_like() { ))] #[test] fn test_fbsd12_like() { - if std::mem::size_of::() >= 8 { + if size_of::() >= 8 { for major_exp in [0, 16, 24, 31] { for major in [(1 << major_exp) - 1, (1 << major_exp)] { for minor_exp in [1, 8, 16, 24, 31] { From a598506f0592445b5e98055e3d6c48dd2bb7fa6f Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Mon, 14 Apr 2025 21:33:10 -0400 Subject: [PATCH 06/29] chore: apply some clippy lints (backport ) [ drop changes around the FreeBSD version in build.rs since the logic isn't the same - Trevor ] (cherry picked from commit a283b9e66d4a8e9371b0aa69d8534010a1c7d9e7) --- Cargo.toml | 28 +++++++++------ build.rs | 36 ++++++++++--------- src/fuchsia/mod.rs | 6 ++-- src/unix/aix/mod.rs | 4 +-- src/unix/bsd/apple/mod.rs | 6 ++-- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 2 +- src/unix/bsd/freebsdlike/freebsd/mod.rs | 6 ++-- src/unix/bsd/mod.rs | 4 +-- src/unix/bsd/netbsdlike/netbsd/mod.rs | 4 +-- src/unix/bsd/netbsdlike/openbsd/mod.rs | 2 +- src/unix/haiku/mod.rs | 4 +-- src/unix/hurd/mod.rs | 6 ++-- src/unix/linux_like/android/mod.rs | 2 +- src/unix/linux_like/emscripten/mod.rs | 4 +-- src/unix/linux_like/linux/gnu/b64/mod.rs | 2 +- .../linux_like/linux/gnu/b64/riscv64/mod.rs | 1 + src/unix/linux_like/linux/gnu/mod.rs | 6 ++-- src/unix/linux_like/linux/mod.rs | 32 +++++++---------- src/unix/linux_like/mod.rs | 8 ++--- src/unix/nto/mod.rs | 4 +-- src/unix/solarish/compat.rs | 6 ++-- src/unix/solarish/mod.rs | 4 +-- src/vxworks/mod.rs | 4 +-- 23 files changed, 90 insertions(+), 91 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 88d748dc549a2..0f6a6a7e54b88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -159,15 +159,21 @@ members = [ unused_qualifications = "allow" [lints.clippy] -missing_safety_doc = "allow" +# Enable pedantic lints - use this manually once in a while, but don't enable by default +# pedantic = { level = "warn", priority = -1 } -# FIXME(clippy): all these are default lints and should probably be fixed -identity_op = "allow" -if_same_then_else = "allow" -non_minimal_cfg = "allow" -precedence = "allow" -redundant_field_names = "allow" -redundant_static_lifetimes = "allow" -unnecessary_cast = "allow" -unused_unit = "allow" -zero_ptr = "allow" +# We are okay with the current state of these lints +explicit_iter_loop = "warn" +identity_op = "allow" # some expressions like `0 | x` are clearer for bit ops +manual_assert = "warn" +map_unwrap_or = "warn" +missing_safety_doc = "allow" # safety? in libc? seriously? +non_minimal_cfg = "allow" # for some reason cfg_if! sometimes trigger this +ptr_as_ptr = "warn" +unnecessary_semicolon = "warn" + +# FIXME(clippy): these should be fixed if possible +expl_impl_clone_on_copy = "allow" +uninlined_format_args = "allow" +unnecessary_cast = "allow" # some casts like `as usize` are only needed for some targets +used_underscore_binding = "allow" diff --git a/build.rs b/build.rs index 2fc84aa6b8d33..bcb9495e4502e 100644 --- a/build.rs +++ b/build.rs @@ -4,7 +4,7 @@ use std::{env, 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: &'static [&'static str] = &[ +const ALLOWED_CFGS: &[&str] = &[ "emscripten_old_stat_abi", "espidf_time32", "freebsd10", @@ -25,7 +25,7 @@ const ALLOWED_CFGS: &'static [&'static str] = &[ ]; // Extra values to allow for check-cfg. -const CHECK_CFG_EXTRA: &'static [(&'static str, &'static [&'static str])] = &[ +const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[ ( "target_os", &[ @@ -169,12 +169,11 @@ fn rustc_version_cmd(is_clippy_driver: bool) -> Output { let output = cmd.output().expect("Failed to get rustc version"); - if !output.status.success() { - panic!( - "failed to run rustc: {}", - String::from_utf8_lossy(output.stderr.as_slice()) - ); - } + assert!( + output.status.success(), + "failed to run rustc: {}", + String::from_utf8_lossy(output.stderr.as_slice()) + ); output } @@ -201,9 +200,11 @@ fn rustc_minor_nightly() -> (u32, bool) { let mut pieces = version.split('.'); - if pieces.next() != Some("rustc 1") { - panic!("Failed to get rustc version"); - } + assert_eq!( + pieces.next(), + Some("rustc 1"), + "Failed to get rustc version" + ); let minor = pieces.next(); @@ -213,9 +214,9 @@ fn rustc_minor_nightly() -> (u32, bool) { // since a nightly build should either come from CI // or a git checkout let nightly_raw = otry!(pieces.next()).split('-').nth(1); - let nightly = nightly_raw - .map(|raw| raw.starts_with("dev") || raw.starts_with("nightly")) - .unwrap_or(false); + let nightly = nightly_raw.map_or(false, |raw| { + raw.starts_with("dev") || raw.starts_with("nightly") + }); let minor = otry!(otry!(minor).parse().ok()); (minor, nightly) @@ -266,8 +267,9 @@ fn emcc_version_code() -> Option { } fn set_cfg(cfg: &str) { - if !ALLOWED_CFGS.contains(&cfg) { - panic!("trying to set cfg {cfg}, but it is not in ALLOWED_CFGS"); - } + assert!( + ALLOWED_CFGS.contains(&cfg), + "trying to set cfg {cfg}, but it is not in ALLOWED_CFGS", + ); println!("cargo:rustc-cfg={cfg}"); } diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index f065eaa3aec8b..c09708f71a0f6 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -3429,9 +3429,9 @@ f! { pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if ((*cmsg).cmsg_len as size_t) < mem::size_of::() { - 0 as *mut cmsghdr + core::ptr::null_mut::() } else if __CMSG_NEXT(cmsg).add(mem::size_of::()) >= __MHDR_END(mhdr) { - 0 as *mut cmsghdr + core::ptr::null_mut::() } else { __CMSG_NEXT(cmsg).cast() } @@ -3441,7 +3441,7 @@ f! { if (*mhdr).msg_controllen as size_t >= mem::size_of::() { (*mhdr).msg_control.cast() } else { - 0 as *mut cmsghdr + core::ptr::null_mut::() } } diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 8cca9bb3c20d6..a8bfca7d2266f 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -2442,7 +2442,7 @@ f! { if (*mhdr).msg_controllen as usize >= mem::size_of::() { (*mhdr).msg_control as *mut cmsghdr } else { - 0 as *mut cmsghdr + core::ptr::null_mut::() } } @@ -2453,7 +2453,7 @@ f! { if (cmsg as usize + (*cmsg).cmsg_len as usize + mem::size_of::()) > ((*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize) { - 0 as *mut cmsghdr + core::ptr::null_mut::() } else { // 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 diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 9c76ed7c01cc5..ebc841a99c36e 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -1691,7 +1691,7 @@ impl siginfo_t { si_value: crate::sigval, } - (*(self as *const siginfo_t as *const siginfo_timer)).si_value + (*(self as *const siginfo_t).cast::()).si_value } pub unsafe fn si_pid(&self) -> crate::pid_t { @@ -5635,7 +5635,7 @@ pub const VMADDR_PORT_ANY: c_uint = 0xFFFFFFFF; const fn __DARWIN_ALIGN32(p: usize) -> usize { const __DARWIN_ALIGNBYTES32: usize = mem::size_of::() - 1; - p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32 + (p + __DARWIN_ALIGNBYTES32) & !__DARWIN_ALIGNBYTES32 } pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t = @@ -5710,7 +5710,7 @@ f! { pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if cmsg.is_null() { return crate::CMSG_FIRSTHDR(mhdr); - }; + } let cmsg_len = (*cmsg).cmsg_len as usize; let next = cmsg as usize + __DARWIN_ALIGN32(cmsg_len); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 5dbe69e564b33..5534c1390b911 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1560,7 +1560,7 @@ f! { if next <= max { (cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr } else { - 0 as *mut cmsghdr + core::ptr::null_mut::() } } diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 11830db22ab5a..7d6b876d6a15a 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -4930,7 +4930,7 @@ const_fn! { f! { pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(_ALIGN(mem::size_of::()) as isize) + (cmsg as *mut c_uchar).add(_ALIGN(mem::size_of::())) } pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { @@ -4945,7 +4945,7 @@ f! { cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(mem::size_of::()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { - 0 as *mut cmsghdr + core::ptr::null_mut::() } else { (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr } @@ -4992,14 +4992,12 @@ f! { let bitset_bits = 8 * mem::size_of::(); let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); cpuset.__bits[idx] |= 1 << offset; - () } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpuset_t) -> () { let bitset_bits = 8 * mem::size_of::(); let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); cpuset.__bits[idx] &= !(1 << offset); - () } pub fn CPU_ISSET(cpu: usize, cpuset: &cpuset_t) -> bool { diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 674fdc088d2b9..1f84950fa1945 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -596,7 +596,7 @@ pub const RTAX_BRD: c_int = 7; f! { pub fn CMSG_FIRSTHDR(mhdr: *const crate::msghdr) -> *mut cmsghdr { if (*mhdr).msg_controllen as usize >= mem::size_of::() { - (*mhdr).msg_control as *mut cmsghdr + (*mhdr).msg_control.cast::() } else { core::ptr::null_mut() } @@ -623,7 +623,7 @@ f! { } pub fn FD_ZERO(set: *mut fd_set) -> () { - for slot in (*set).fds_bits.iter_mut() { + for slot in &mut (*set).fds_bits { *slot = 0; } } diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 9f44907a98b7c..8633ee3dd5c08 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -2423,7 +2423,7 @@ const_fn! { f! { pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { - (cmsg as *mut c_uchar).offset(_ALIGN(mem::size_of::()) as isize) + (cmsg as *mut c_uchar).add(_ALIGN(mem::size_of::())) } pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { @@ -2438,7 +2438,7 @@ f! { cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(mem::size_of::()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { - 0 as *mut cmsghdr + core::ptr::null_mut::() } else { (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr } diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index ff3a99fcc7db2..bd18311f5d20b 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1957,7 +1957,7 @@ f! { cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(mem::size_of::()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { - 0 as *mut cmsghdr + core::ptr::null_mut::() } else { (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr } diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index ef48fa6f9be4b..a47aac2a4fa4d 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1572,7 +1572,7 @@ f! { if (*mhdr).msg_controllen as usize >= mem::size_of::() { (*mhdr).msg_control as *mut cmsghdr } else { - 0 as *mut cmsghdr + core::ptr::null_mut::() } } @@ -1597,7 +1597,7 @@ f! { + CMSG_ALIGN(mem::size_of::()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { - 0 as *mut cmsghdr + core::ptr::null_mut::() } else { (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr } diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 961710b5ae76d..f32975bac4544 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -3444,7 +3444,7 @@ f! { if (*mhdr).msg_controllen as usize >= mem::size_of::() { (*mhdr).msg_control as *mut cmsghdr } else { - 0 as *mut cmsghdr + core::ptr::null_mut::() } } @@ -3462,14 +3462,14 @@ f! { pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if ((*cmsg).cmsg_len as usize) < mem::size_of::() { - return 0 as *mut cmsghdr; + return core::ptr::null_mut::(); }; let next = (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if (next.offset(1)) as usize > max || next as usize + CMSG_ALIGN((*next).cmsg_len as usize) > max { - 0 as *mut cmsghdr + core::ptr::null_mut::() } else { next as *mut cmsghdr } diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 3d24d5d8fb73f..2aa47cda07b09 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -3653,7 +3653,7 @@ f! { let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if (next.offset(1)) as usize > max { - 0 as *mut cmsghdr + core::ptr::null_mut::() } else { next as *mut cmsghdr } diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 462a944b1e2b1..46d0d0f007433 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1412,12 +1412,12 @@ pub const SOMAXCONN: c_int = 128; f! { pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if ((*cmsg).cmsg_len as usize) < mem::size_of::() { - return 0 as *mut cmsghdr; + return core::ptr::null_mut::(); }; let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if (next.offset(1)) as usize > max { - 0 as *mut cmsghdr + core::ptr::null_mut::() } else { next as *mut cmsghdr } diff --git a/src/unix/linux_like/linux/gnu/b64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mod.rs index 9d7608f67f132..5927e6c991725 100644 --- a/src/unix/linux_like/linux/gnu/b64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mod.rs @@ -119,7 +119,7 @@ cfg_if! { } else if #[cfg(any(target_arch = "s390x"))] { mod s390x; pub use self::s390x::*; - } else if #[cfg(any(target_arch = "x86_64"))] { + } else if #[cfg(target_arch = "x86_64")] { mod x86_64; pub use self::x86_64::*; } else if #[cfg(any(target_arch = "riscv64"))] { 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 578057ce58ed2..d689bb14c3ebf 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -601,6 +601,7 @@ pub const REG_NARGS: usize = 8; pub const COMPAT_HWCAP_ISA_I: c_ulong = 1 << (b'I' - b'A'); pub const COMPAT_HWCAP_ISA_M: c_ulong = 1 << (b'M' - b'A'); +#[allow(clippy::eq_op)] pub const COMPAT_HWCAP_ISA_A: c_ulong = 1 << (b'A' - b'A'); pub const COMPAT_HWCAP_ISA_F: c_ulong = 1 << (b'F' - b'A'); pub const COMPAT_HWCAP_ISA_D: c_ulong = 1 << (b'D' - b'A'); diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 84d7c24742c37..5ba13dd6fc2c4 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -447,7 +447,7 @@ impl siginfo_t { _si_code: c_int, si_addr: *mut c_void, } - (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr + (*(self as *const siginfo_t).cast::()).si_addr } pub unsafe fn si_value(&self) -> crate::sigval { @@ -460,7 +460,7 @@ impl siginfo_t { _si_overrun: c_int, si_sigval: crate::sigval, } - (*(self as *const siginfo_t as *const siginfo_timer)).si_sigval + (*(self as *const siginfo_t).cast::()).si_sigval } } @@ -498,7 +498,7 @@ struct siginfo_f { impl siginfo_t { unsafe fn sifields(&self) -> &sifields { - &(*(self as *const siginfo_t as *const siginfo_f)).sifields + &(*(self as *const siginfo_t).cast::()).sifields } pub unsafe fn si_pid(&self) -> crate::pid_t { diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index c0989d2d74c7d..2bfe8f7be3be8 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -6080,16 +6080,16 @@ f! { pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { if ((*cmsg).cmsg_len as usize) < size_of::() { - return 0 as *mut cmsghdr; - }; + return core::ptr::null_mut::(); + } let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if (next.wrapping_offset(1)) as usize > max || next as usize + super::CMSG_ALIGN((*next).cmsg_len as usize) > max { - 0 as *mut cmsghdr + core::ptr::null_mut::() } else { - next as *mut cmsghdr + next } } @@ -6100,7 +6100,7 @@ f! { } pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { - for slot in cpuset.bits.iter_mut() { + for slot in &mut cpuset.bits { *slot = 0; } } @@ -6109,14 +6109,12 @@ f! { let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] |= 1 << offset; - () } pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { let size_in_bits = 8 * mem::size_of_val(&cpuset.bits[0]); // 32, 64 etc let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); cpuset.bits[idx] &= !(1 << offset); - () } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { @@ -6128,7 +6126,7 @@ f! { pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { let mut s: u32 = 0; let size_of_mask = mem::size_of_val(&cpuset.bits[0]); - for i in cpuset.bits[..(size / size_of_mask)].iter() { + for i in &cpuset.bits[..(size / size_of_mask)] { s += i.count_ones(); } s as c_int @@ -6143,7 +6141,7 @@ f! { } pub fn SCTP_PR_INDEX(policy: c_int) -> c_int { - policy >> 4 - 1 + policy >> (4 - 1) } pub fn SCTP_PR_POLICY(policy: c_int) -> c_int { @@ -6153,7 +6151,6 @@ f! { pub fn SCTP_PR_SET_POLICY(flags: &mut c_int, policy: c_int) -> () { *flags &= !SCTP_PR_SCTP_MASK; *flags |= policy; - () } pub fn IPTOS_TOS(tos: u8) -> u8 { @@ -6214,20 +6211,15 @@ f! { pub fn BPF_STMT(code: __u16, k: __u32) -> sock_filter { sock_filter { - code: code, + code, jt: 0, jf: 0, - k: k, + k, } } pub fn BPF_JUMP(code: __u16, k: __u32, jt: __u8, jf: __u8) -> sock_filter { - sock_filter { - code: code, - jt: jt, - jf: jf, - k: k, - } + sock_filter { code, jt, jf, k } } pub fn ELF32_R_SYM(val: Elf32_Word) -> Elf32_Word { @@ -6239,7 +6231,7 @@ f! { } pub fn ELF32_R_INFO(sym: Elf32_Word, t: Elf32_Word) -> Elf32_Word { - sym << 8 + t & 0xff + sym << (8 + t) & 0xff } pub fn ELF64_R_SYM(val: Elf64_Xword) -> Elf64_Xword { @@ -6251,7 +6243,7 @@ f! { } pub fn ELF64_R_INFO(sym: Elf64_Xword, t: Elf64_Xword) -> Elf64_Xword { - sym << 32 + t + sym << (32 + t) } } diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 9c7766a1407d1..c730947529fb6 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1700,16 +1700,16 @@ cfg_if! { const_fn! { {const} fn CMSG_ALIGN(len: usize) -> usize { - len + mem::size_of::() - 1 & !(mem::size_of::() - 1) + (len + mem::size_of::() - 1) & !(mem::size_of::() - 1) } } f! { pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { if (*mhdr).msg_controllen as usize >= mem::size_of::() { - (*mhdr).msg_control as *mut cmsghdr + (*mhdr).msg_control.cast::() } else { - 0 as *mut cmsghdr + core::ptr::null_mut::() } } @@ -1746,7 +1746,7 @@ f! { } pub fn FD_ZERO(set: *mut fd_set) -> () { - for slot in (*set).fds_bits.iter_mut() { + for slot in &mut (*set).fds_bits { *slot = 0; } } diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 631972b144676..209fd3b695e99 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -2802,7 +2802,7 @@ f! { if (*mhdr).msg_controllen as usize >= mem::size_of::() { (*mhdr).msg_control as *mut cmsghdr } else { - 0 as *mut cmsghdr + core::ptr::null_mut::() } } @@ -2810,7 +2810,7 @@ f! { let msg = _CMSG_ALIGN((*cmsg).cmsg_len as usize); let next = cmsg as usize + msg + _CMSG_ALIGN(mem::size_of::()); if next > (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize { - 0 as *mut cmsghdr + core::ptr::null_mut::() } else { (cmsg as usize + msg) as *mut cmsghdr } diff --git a/src/unix/solarish/compat.rs b/src/unix/solarish/compat.rs index 649d6ac9a1536..80d2835977f59 100644 --- a/src/unix/solarish/compat.rs +++ b/src/unix/solarish/compat.rs @@ -50,7 +50,7 @@ unsafe fn bail(fdm: c_int, fds: c_int) -> c_int { crate::close(fdm); } *___errno() = e; - return -1; + -1 } #[cfg(target_os = "illumos")] @@ -184,7 +184,7 @@ pub unsafe fn getpwent_r( ) -> c_int { let old_errno = *crate::___errno(); *crate::___errno() = 0; - *result = native_getpwent_r(pwd, buf, min(buflen, c_int::max_value() as size_t) as c_int); + *result = native_getpwent_r(pwd, buf, min(buflen, c_int::MAX as size_t) as c_int); let ret = if (*result).is_null() { *crate::___errno() @@ -204,7 +204,7 @@ pub unsafe fn getgrent_r( ) -> c_int { let old_errno = *crate::___errno(); *crate::___errno() = 0; - *result = native_getgrent_r(grp, buf, min(buflen, c_int::max_value() as size_t) as c_int); + *result = native_getgrent_r(grp, buf, min(buflen, c_int::MAX as size_t) as c_int); let ret = if (*result).is_null() { *crate::___errno() diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 652d5263a5fd0..605e35ca53bf9 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -2483,7 +2483,7 @@ f! { pub fn CMSG_FIRSTHDR(mhdr: *const crate::msghdr) -> *mut cmsghdr { if ((*mhdr).msg_controllen as usize) < size_of::() { - 0 as *mut cmsghdr + core::ptr::null_mut::() } else { (*mhdr).msg_control as *mut cmsghdr } @@ -2497,7 +2497,7 @@ f! { _CMSG_HDR_ALIGN(cmsg as usize + (*cmsg).cmsg_len as usize + size_of::()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next > max { - 0 as *mut cmsghdr + core::ptr::null_mut::() } else { _CMSG_HDR_ALIGN(cmsg as usize + (*cmsg).cmsg_len as usize) as *mut cmsghdr } diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index cdca84e471e55..793379dcdd792 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -1132,7 +1132,7 @@ f! { if next <= max { (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr } else { - 0 as *mut cmsghdr + core::ptr::null_mut::() } } @@ -1140,7 +1140,7 @@ f! { if (*mhdr).msg_controllen as usize > 0 { (*mhdr).msg_control as *mut cmsghdr } else { - 0 as *mut cmsghdr + core::ptr::null_mut::() } } From 2bb4ceaeb89e55cd0398aae1d269a2a1b55603bc Mon Sep 17 00:00:00 2001 From: rusty-snake <41237666+rusty-snake@users.noreply.github.com> Date: Thu, 1 May 2025 11:22:57 +0200 Subject: [PATCH 07/29] Add constants and types for nsfs ioctls (backport ) (cherry picked from commit 0d7f0ceabe7a1b64df519032f1ebdb70faced316) --- libc-test/build.rs | 21 +++++++++++++++------ libc-test/semver/linux.txt | 13 +++++++++++++ src/unix/linux_like/linux/mod.rs | 28 ++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index bcbe2dc3356f3..1ac7baf8ca91f 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3899,6 +3899,7 @@ fn test_linux(target: &str) { "linux/netfilter_ipv6.h", "linux/netfilter_ipv6/ip6_tables.h", "linux/netlink.h", + "linux/nsfs.h", "linux/openat2.h", // FIXME(linux): some items require Linux >= 5.6: "linux/ptp_clock.h", @@ -4192,6 +4193,9 @@ fn test_linux(target: &str) { // FIXME(linux): Requires >= 6.12 kernel headers. "dmabuf_cmsg" | "dmabuf_token" => true, + // FIXME(linux): Requires >= 6.12 kernel headers. + "mnt_ns_info" => true, + // FIXME(linux): Requires >= 6.4 kernel headers. "ptrace_sud_config" => true, @@ -4597,6 +4601,11 @@ fn test_linux(target: &str) { true } + // FIXME(linux): Requires >= 6.11 kernel headers. + "NS_GET_MNTNS_ID" | "NS_GET_PID_FROM_PIDNS" | "NS_GET_TGID_FROM_PIDNS" | "NS_GET_PID_IN_PIDNS" | "NS_GET_TGID_IN_PIDNS" => true, + // FIXME(linux): Requires >= 6.12 kernel headers. + "MNT_NS_INFO_SIZE_VER0" | "NS_MNT_GET_INFO" | "NS_MNT_GET_NEXT" | "NS_MNT_GET_PREV" => true, + // FIXME(linux): Requires >= 6.6 kernel headers. "SYS_fchmodat2" => true, @@ -4952,8 +4961,8 @@ fn test_linux_like_apis(target: &str) { "strerror_r" => false, _ => true, }) - .skip_const(|_| true) - .skip_struct(|_| true); + .skip_const(|_| true) + .skip_struct(|_| true); cfg.generate(src_hotfix_dir().join("lib.rs"), "linux_strerror_r.rs"); } @@ -5027,10 +5036,10 @@ fn test_linux_like_apis(target: &str) { .skip_const(|_| true) .skip_struct(|_| true) .skip_const(move |name| match name { - "IPV6_FLOWINFO" - | "IPV6_FLOWLABEL_MGR" - | "IPV6_FLOWINFO_SEND" - | "IPV6_FLOWINFO_FLOWLABEL" + "IPV6_FLOWINFO" + | "IPV6_FLOWLABEL_MGR" + | "IPV6_FLOWINFO_SEND" + | "IPV6_FLOWINFO_FLOWLABEL" | "IPV6_FLOWINFO_PRIORITY" => false, _ => true, }) diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 011fba0d85b6b..533adc6ebbcae 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -1667,6 +1667,7 @@ MMAP_PAGE_ZERO MNT_DETACH MNT_EXPIRE MNT_FORCE +MNT_NS_INFO_SIZE_VER0 MODULE_INIT_IGNORE_MODVERSIONS MODULE_INIT_IGNORE_VERMAGIC MON_1 @@ -2022,6 +2023,18 @@ NLM_F_REQUEST NLM_F_ROOT NOEXPR NOSTR +NS_GET_MNTNS_ID +NS_GET_NSTYPE +NS_GET_OWNER_UID +NS_GET_PARENT +NS_GET_PID_FROM_PIDNS +NS_GET_PID_IN_PIDNS +NS_GET_TGID_FROM_PIDNS +NS_GET_TGID_IN_PIDNS +NS_GET_USERNS +NS_MNT_GET_INFO +NS_MNT_GET_NEXT +NS_MNT_GET_PREV NTF_PROXY NTF_ROUTER NTF_SELF diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 2bfe8f7be3be8..e224666dd2847 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1376,6 +1376,13 @@ s! { pub userns_fd: crate::__u64, } + // linux/nsfs.h + pub struct mnt_ns_info { + pub size: crate::__u32, + pub nr_mounts: crate::__u32, + pub mnt_ns_id: crate::__u64, + } + // linux/pidfd.h pub struct pidfd_info { @@ -3211,6 +3218,27 @@ pub const MREMAP_MAYMOVE: c_int = 1; pub const MREMAP_FIXED: c_int = 2; pub const MREMAP_DONTUNMAP: c_int = 4; +// linux/nsfs.h +const NSIO: c_uint = 0xb7; + +pub const NS_GET_USERNS: c_uint = _IO(NSIO, 0x1); +pub const NS_GET_PARENT: c_uint = _IO(NSIO, 0x2); +pub const NS_GET_NSTYPE: c_uint = _IO(NSIO, 0x3); +pub const NS_GET_OWNER_UID: c_uint = _IO(NSIO, 0x4); + +pub const NS_GET_MNTNS_ID: c_uint = _IOR::<__u64>(NSIO, 0x5); + +pub const NS_GET_PID_FROM_PIDNS: c_uint = _IOR::(NSIO, 0x6); +pub const NS_GET_TGID_FROM_PIDNS: c_uint = _IOR::(NSIO, 0x7); +pub const NS_GET_PID_IN_PIDNS: c_uint = _IOR::(NSIO, 0x8); +pub const NS_GET_TGID_IN_PIDNS: c_uint = _IOR::(NSIO, 0x9); + +pub const MNT_NS_INFO_SIZE_VER0: c_uint = 16; + +pub const NS_MNT_GET_INFO: c_uint = _IOR::(NSIO, 10); +pub const NS_MNT_GET_NEXT: c_uint = _IOR::(NSIO, 11); +pub const NS_MNT_GET_PREV: c_uint = _IOR::(NSIO, 12); + // linux/pidfd.h pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint; pub const PIDFD_THREAD: c_uint = O_EXCL as c_uint; From e9fc5808c55555e3b3181dea340891d2e87ec086 Mon Sep 17 00:00:00 2001 From: WANG Rui Date: Wed, 7 May 2025 10:30:38 +0800 Subject: [PATCH 08/29] musl: loongarch64: Define MADV_SOFT_OFFLINE constant (backport ) (cherry picked from commit 054c95888c2b20b341166ff49a1252c180041005) --- libc-test/semver/linux-gnu-loongarch64.txt | 1 - libc-test/semver/linux-loongarch64.txt | 1 + src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs | 2 ++ 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libc-test/semver/linux-gnu-loongarch64.txt b/libc-test/semver/linux-gnu-loongarch64.txt index ec6595b79b76f..ccf233e6e09c3 100644 --- a/libc-test/semver/linux-gnu-loongarch64.txt +++ b/libc-test/semver/linux-gnu-loongarch64.txt @@ -10,7 +10,6 @@ KEYCTL_CAPS0_RESTRICT_KEYRING KEYCTL_CAPS1_NS_KEYRING_NAME KEYCTL_CAPS1_NS_KEY_TAG KEYCTL_MOVE -MADV_SOFT_OFFLINE PTRACE_GETFPREGS PTRACE_GETFPXREGS PTRACE_GETREGS diff --git a/libc-test/semver/linux-loongarch64.txt b/libc-test/semver/linux-loongarch64.txt index 1b50e7248b7fe..7f0446c76abd8 100644 --- a/libc-test/semver/linux-loongarch64.txt +++ b/libc-test/semver/linux-loongarch64.txt @@ -48,6 +48,7 @@ BPF_XOR CIBAUD FICLONE FICLONERANGE +MADV_SOFT_OFFLINE MAP_SYNC NFT_MSG_DELOBJ NFT_MSG_GETOBJ diff --git a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs index e96bcbb2788e4..55ffc20c31dbd 100644 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -532,6 +532,8 @@ pub const ENOTRECOVERABLE: c_int = 131; pub const EHWPOISON: c_int = 133; pub const ERFKILL: c_int = 132; +pub const MADV_SOFT_OFFLINE: c_int = 101; + pub const SA_ONSTACK: c_int = 0x08000000; pub const SA_SIGINFO: c_int = 0x00000004; pub const SA_NOCLDWAIT: c_int = 0x00000002; From f1e459f1846fd6266f71aefcfbe9fef7a7abb56d Mon Sep 17 00:00:00 2001 From: Mattias Nissler Date: Tue, 6 May 2025 01:05:23 -0700 Subject: [PATCH 09/29] Add MADV_SOFT_OFFLINE definition for RISC-V musl targets (backport ) (cherry picked from commit 118a904c4e690327d2ca3a633822ac1171cae5fa) --- libc-test/semver/linux-riscv64gc.txt | 1 + src/unix/linux_like/linux/musl/b32/riscv32/mod.rs | 1 + src/unix/linux_like/linux/musl/b64/riscv64/mod.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/libc-test/semver/linux-riscv64gc.txt b/libc-test/semver/linux-riscv64gc.txt index 09519e9dfbe7e..01609e899a709 100644 --- a/libc-test/semver/linux-riscv64gc.txt +++ b/libc-test/semver/linux-riscv64gc.txt @@ -24,6 +24,7 @@ KEYCTL_CAPS0_RESTRICT_KEYRING KEYCTL_CAPS1_NS_KEYRING_NAME KEYCTL_CAPS1_NS_KEY_TAG KEYCTL_MOVE +MADV_SOFT_OFFLINE MAP_SYNC NFT_MSG_DELOBJ NFT_MSG_GETOBJ diff --git a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs index 9c0525cb167b2..9b76105969343 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -246,6 +246,7 @@ pub const O_DIRECT: c_int = 16384; pub const O_DIRECTORY: c_int = 65536; pub const O_LARGEFILE: c_int = 0o0100000; pub const O_NOFOLLOW: c_int = 131072; +pub const MADV_SOFT_OFFLINE: c_int = 101; pub const MAP_HUGETLB: c_int = 262144; pub const MAP_LOCKED: c_int = 8192; pub const MAP_NORESERVE: c_int = 16384; diff --git a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs index 2b9b394d51d17..115ec076f6a53 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -572,6 +572,7 @@ pub const POLLWRBAND: c_short = 0x200; pub const SOCK_STREAM: c_int = 1; pub const SOCK_DGRAM: c_int = 2; +pub const MADV_SOFT_OFFLINE: c_int = 101; pub const MAP_ANON: c_int = 0x0020; pub const MAP_GROWSDOWN: c_int = 0x0100; pub const MAP_DENYWRITE: c_int = 0x0800; From c469a85507fa25c5851f8e3277fad44d51d356b7 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Sun, 4 May 2025 04:50:21 +0000 Subject: [PATCH 10/29] ci: install-musl: upgrade to 1.2.3 This will be chosen based on the RUST_LIBC_UNSTABLE_MUSL_V1_2_3 variable. Co-authored-by: Daniel Frampton (backport ) (cherry picked from commit e7762a8fdba09b1dd59a29b1915c60e862ec6a57) --- .github/workflows/ci.yaml | 12 ++++++++++++ ci/install-musl.sh | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9b98d1d83e8e8..84d8d1a1f436a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -196,6 +196,18 @@ jobs: env: RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS: 64 artifact-tag: offset-bits64 + - target: aarch64-unknown-linux-musl + env: + RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + - target: arm-unknown-linux-musleabihf + env: + RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + - target: i686-unknown-linux-musl + env: + RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + - target: loongarch64-unknown-linux-musl + env: + RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 # FIXME(ppc): SIGILL running tests, see # https://github.com/rust-lang/libc/pull/4254#issuecomment-2636288713 # - target: powerpc-unknown-linux-gnu diff --git a/ci/install-musl.sh b/ci/install-musl.sh index 416874d916f3e..8567c0848675a 100755 --- a/ci/install-musl.sh +++ b/ci/install-musl.sh @@ -10,7 +10,7 @@ case ${1} in musl_version=1.2.5 ;; *) - musl_version=1.1.24 + [ -n "${RUST_LIBC_UNSTABLE_MUSL_V1_2_3:-}" ] && musl_version=1.2.3 || musl_version=1.1.24 ;; esac From a28ee2b2d93927a57dd9860db189b7cad255ce15 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Sat, 3 May 2025 09:18:40 +0000 Subject: [PATCH 11/29] libc-test: update conditions for workarounds for musl <1.2.3 This commit gates various workarounds of older musl versions behind the RUST_LIBC_UNSTABLE_MUSL_V1_2_3 variable. (backport ) (cherry picked from commit 85a7c8536d6d6a56257eb2755b28a1dc41c1cd0f) --- libc-test/build.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 1ac7baf8ca91f..cf432fd19fa51 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3730,6 +3730,9 @@ fn test_linux(target: &str) { let wasm32 = target.contains("wasm32"); let uclibc = target.contains("uclibc"); + let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok(); + let old_musl = musl && !musl_v1_2_3; + let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); // This macro re-defines fscanf,scanf,sscanf to link to the symbols that are @@ -4300,9 +4303,9 @@ fn test_linux(target: &str) { if name == "PR_GET_MDWE" || name == "PR_MDWE_NO_INHERIT" || name == "PR_MDWE_REFUSE_EXEC_GAIN" || name == "PR_SET_MDWE" { return true; } - // FIXME(musl): Requires musl >= 1.2 - if name == "SO_PREFER_BUSY_POLL" - || name == "SO_BUSY_POLL_BUDGET" + // Requires musl >= 1.2 + if old_musl && (name == "SO_PREFER_BUSY_POLL" + || name == "SO_BUSY_POLL_BUDGET") { return true; } @@ -4734,18 +4737,18 @@ fn test_linux(target: &str) { "getnameinfo" if uclibc => true, // FIXME(musl): This needs musl 1.2.2 or later. - "gettid" if musl => true, + "gettid" if old_musl => true, // Needs glibc 2.33 or later. "mallinfo2" => true, - "reallocarray" if musl => true, + "reallocarray" if old_musl => true, // Not defined in uclibc as of 1.0.34 "gettid" if uclibc => true, // Needs musl 1.2.3 or later. - "pthread_getname_np" if musl => true, + "pthread_getname_np" if old_musl => true, // pthread_sigqueue uses sigval, which was initially declared // as a struct but should be defined as a union. However due From b553d1f7e643f9830158d6a66b5647ee3fa4fa85 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Sat, 3 May 2025 10:21:09 +0000 Subject: [PATCH 12/29] musl: Fix O_LARGEFILE constant value. This was accidentally set to 0 in upstream, but fixed in commit b8b729b. If running with prior versions without that commit, this commit effectively backports it. (backport ) (cherry picked from commit 686aa7a3a2ead357a732d018e4295c9a92312132) --- libc-test/build.rs | 4 ++++ src/unix/linux_like/linux/musl/b64/riscv64/mod.rs | 2 +- src/unix/linux_like/linux/musl/b64/x86_64/mod.rs | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index cf432fd19fa51..71758f46432be 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4329,6 +4329,10 @@ fn test_linux(target: &str) { { return true; } + // Values changed in newer musl versions on these arches + if old_musl && (riscv64 || x86_64) && name == "O_LARGEFILE" { + return true; + } } match name { // These constants are not available if gnu headers have been included diff --git a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs index 115ec076f6a53..cf851c4660113 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -432,7 +432,7 @@ pub const SYS_landlock_restrict_self: c_long = 446; pub const O_APPEND: c_int = 1024; pub const O_DIRECT: c_int = 0x4000; pub const O_DIRECTORY: c_int = 0x10000; -pub const O_LARGEFILE: c_int = 0; +pub const O_LARGEFILE: c_int = 0o100000; pub const O_NOFOLLOW: c_int = 0x20000; pub const O_CREAT: c_int = 64; pub const O_EXCL: c_int = 128; diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs index b44b54de65953..a8070cb970755 100644 --- a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -701,7 +701,7 @@ pub const MAP_32BIT: c_int = 0x0040; pub const O_APPEND: c_int = 1024; pub const O_DIRECT: c_int = 0x4000; pub const O_DIRECTORY: c_int = 0x10000; -pub const O_LARGEFILE: c_int = 0; +pub const O_LARGEFILE: c_int = 0o0100000; pub const O_NOFOLLOW: c_int = 0x20000; pub const O_CREAT: c_int = 64; pub const O_EXCL: c_int = 128; From a485516e3b875ec7f35f1dcd1427962bcd8a7623 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Sat, 3 May 2025 10:54:10 +0000 Subject: [PATCH 13/29] Add musl_v1_2_3 feature This feature, controlled by the environment variable RUST_LIBC_UNSTABLE_MUSL_V1_2_3 will control whether breaking changes up to musl v1.2.3 will be reflected (backport ) (cherry picked from commit 2a68f7f9f6139f8930df345ae19697336908e940) --- build.rs | 8 ++++++++ libc-test/build.rs | 3 +++ 2 files changed, 11 insertions(+) diff --git a/build.rs b/build.rs index bcb9495e4502e..2a55a4c07e525 100644 --- a/build.rs +++ b/build.rs @@ -22,6 +22,7 @@ const ALLOWED_CFGS: &[&str] = &[ "libc_ctest", // Corresponds to `__USE_TIME_BITS64` in UAPI "linux_time_bits64", + "musl_v1_2_3" ]; // Extra values to allow for check-cfg. @@ -89,6 +90,13 @@ fn main() { _ => (), } + let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok(); + println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_V1_2_3"); + // loongarch64 and ohos have already updated + if musl_v1_2_3 || target_os == "loongarch64" || target_env == "ohos" { + // FIXME(musl): enable time64 api as well + set_cfg("musl_v1_2_3"); + } let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok(); println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64"); if linux_time_bits64 { diff --git a/libc-test/build.rs b/libc-test/build.rs index 71758f46432be..e75f10060e83b 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3734,6 +3734,9 @@ fn test_linux(target: &str) { let old_musl = musl && !musl_v1_2_3; let mut cfg = ctest_cfg(); + if musl_v1_2_3 { + cfg.cfg("musl_v1_2_3", None); + } cfg.define("_GNU_SOURCE", None); // This macro re-defines fscanf,scanf,sscanf to link to the symbols that are // deprecated since glibc >= 2.29. This allows Rust binaries to link against From d63132d42ce8428b442d28e7afd0eb15813cffb6 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Sat, 3 May 2025 11:27:09 +0000 Subject: [PATCH 14/29] musl: fix utmpx struct layout This ut_session has changed from long to int + padding in newer versions. This was already reflected on loongarch64 and ohos - this commit adds this change, and re-enables the test when musl_v1_2_3 is set. Co-authored-by: Ariadne Conill (backport ) (cherry picked from commit 1038c7f1f4dbd6a39b867263dc5478806744f5a0) --- libc-test/build.rs | 4 +-- src/unix/linux_like/linux/musl/mod.rs | 39 ++++++++++----------------- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index e75f10060e83b..9506da3570a7e 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4897,8 +4897,8 @@ fn test_linux(target: &str) { (struct_ == "statvfs64" && field == "__f_spare") || // the `xsk_tx_metadata_union` field is an anonymous union (struct_ == "xsk_tx_metadata" && field == "xsk_tx_metadata_union") || - // FIXME(musl): After musl 1.2.0, the type becomes `int` instead of `long`. - (struct_ == "utmpx" && field == "ut_session") + // After musl 1.2.0, the type becomes `int` instead of `long`. + (old_musl && struct_ == "utmpx" && field == "ut_session") }); cfg.skip_roundtrip(move |s| match s { diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 5d4d97fafbc8e..efab9deaf6138 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -438,13 +438,6 @@ s_no_extra_traits! { pub __reserved: [c_char; 256], } - // FIXME(musl): musl added paddings and adjusted - // layout in 1.2.0 but our CI is still 1.1.24. - // So, I'm leaving some fields as cfg for now. - // ref. https://github.com/bminor/musl/commit/ - // 1e7f0fcd7ff2096904fd93a2ee6d12a2392be392 - // - // OpenHarmony uses the musl 1.2 layout. pub struct utmpx { pub ut_type: c_short, __ut_pad1: c_short, @@ -455,31 +448,24 @@ s_no_extra_traits! { pub ut_host: [c_char; 256], pub ut_exit: __exit_status, - #[cfg(target_env = "musl")] - #[cfg(not(target_arch = "loongarch64"))] + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "The ABI of this field has changed from c_long to c_int with padding, \ + we'll follow that change in the future release. See #4443 for more info." + )] pub ut_session: c_long, - #[cfg(target_env = "musl")] - #[cfg(target_arch = "loongarch64")] - pub ut_session: c_int, - - #[cfg(target_env = "musl")] - #[cfg(target_arch = "loongarch64")] + #[cfg(musl_v1_2_3)] + #[cfg(not(target_endian = "little"))] __ut_pad2: c_int, - #[cfg(target_env = "ohos")] - #[cfg(target_endian = "little")] + #[cfg(musl_v1_2_3)] pub ut_session: c_int, - #[cfg(target_env = "ohos")] - #[cfg(target_endian = "little")] - __ut_pad2: c_int, - #[cfg(target_env = "ohos")] - #[cfg(not(target_endian = "little"))] + #[cfg(musl_v1_2_3)] + #[cfg(target_endian = "little")] __ut_pad2: c_int, - #[cfg(target_env = "ohos")] - #[cfg(not(target_endian = "little"))] - pub ut_session: c_int, pub ut_tv: crate::timeval, pub ut_addr_v6: [c_uint; 4], @@ -555,6 +541,7 @@ cfg_if! { } impl PartialEq for utmpx { + #[allow(deprecated)] fn eq(&self, other: &utmpx) -> bool { self.ut_type == other.ut_type //&& self.__ut_pad1 == other.__ut_pad1 @@ -579,6 +566,7 @@ cfg_if! { impl Eq for utmpx {} impl fmt::Debug for utmpx { + #[allow(deprecated)] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("utmpx") .field("ut_type", &self.ut_type) @@ -599,6 +587,7 @@ cfg_if! { } impl hash::Hash for utmpx { + #[allow(deprecated)] fn hash(&self, state: &mut H) { self.ut_type.hash(state); //self.__ut_pad1.hash(state); From 37cde5af0a7a52e1aadadcfa38d28514d3bb75a7 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Sat, 3 May 2025 11:46:22 +0000 Subject: [PATCH 15/29] musl: struct tcp_info: add new fields since 1.2.0/1.2.2 This reflects the upstream commits, 5e0c9f2 and d4f2981, which reflect changes in linux 5.4 and 5.5 respectively As mentioned in the comments, this is possible now as the CI musl version has updated and the headers are newer. (backport ) (cherry picked from commit fb4212a6bd14f0378a3c6fcdd6f8bd64cc79a8fb) --- libc-test/build.rs | 3 +++ src/unix/linux_like/linux/musl/mod.rs | 8 -------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 9506da3570a7e..5e6de77549079 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4205,6 +4205,9 @@ fn test_linux(target: &str) { // FIXME(linux): Requires >= 6.4 kernel headers. "ptrace_sud_config" => true, + // Struct has changed for new musl versions + "tcp_info" if old_musl => true, + _ => false, } }); diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index efab9deaf6138..393d46b20cf25 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -323,16 +323,11 @@ s! { pub tcpi_probes: u8, pub tcpi_backoff: u8, pub tcpi_options: u8, - /* - * FIXME(musl): enable on all targets once musl headers are more up to date - */ /// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`. /// Each is 4 bits. - #[cfg(target_arch = "loongarch64")] pub tcpi_snd_rcv_wscale: u8, /// This contains the bitfields `tcpi_delivery_rate_app_limited` (1 bit) and /// `tcpi_fastopen_client_fail` (2 bits). - #[cfg(target_arch = "loongarch64")] pub tcpi_delivery_fastopen_bitfields: u8, pub tcpi_rto: u32, pub tcpi_ato: u32, @@ -378,10 +373,7 @@ s! { pub tcpi_bytes_retrans: u64, pub tcpi_dsack_dups: u32, pub tcpi_reord_seen: u32, - // FIXME(musl): enable on all targets once CI musl is updated - #[cfg(target_arch = "loongarch64")] pub tcpi_rcv_ooopack: u32, - #[cfg(target_arch = "loongarch64")] pub tcpi_snd_wnd: u32, } From f5d4b076c40dc8877c87f5e10dad913c366fa918 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Sat, 3 May 2025 11:57:39 +0000 Subject: [PATCH 16/29] musl: update RLIM_NLIMITS This reflects upstream commit 2507e7f. This should be safe to change as this has been marked deprecated to warn people it will change across OS versions since 0.2.64 (>5 years ago) (backport ) (cherry picked from commit 5d24ad2e30cfe0e8fab14feaeb1c19c7e34101e0) --- libc-test/build.rs | 4 ++++ src/unix/linux_like/linux/arch/generic/mod.rs | 3 --- src/unix/linux_like/linux/arch/mips/mod.rs | 2 +- src/unix/linux_like/linux/arch/powerpc/mod.rs | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 5e6de77549079..351c0cc11af33 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4339,6 +4339,10 @@ fn test_linux(target: &str) { if old_musl && (riscv64 || x86_64) && name == "O_LARGEFILE" { return true; } + // Values changed in newer musl versions + if old_musl && name == "RLIM_NLIMITS" { + return true; + } } match name { // These constants are not available if gnu headers have been included diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs index ec3179b431f97..75cb7e19375d0 100644 --- a/src/unix/linux_like/linux/arch/generic/mod.rs +++ b/src/unix/linux_like/linux/arch/generic/mod.rs @@ -357,9 +357,6 @@ cfg_if! { pub const RLIMIT_RTPRIO: c_int = 14; pub const RLIMIT_RTTIME: c_int = 15; #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] - #[cfg(not(target_arch = "loongarch64"))] - pub const RLIM_NLIMITS: c_int = 15; - #[cfg(target_arch = "loongarch64")] pub const RLIM_NLIMITS: c_int = 16; #[allow(deprecated)] #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] diff --git a/src/unix/linux_like/linux/arch/mips/mod.rs b/src/unix/linux_like/linux/arch/mips/mod.rs index eee7cc81a47e4..1ac2340a27385 100644 --- a/src/unix/linux_like/linux/arch/mips/mod.rs +++ b/src/unix/linux_like/linux/arch/mips/mod.rs @@ -349,7 +349,7 @@ cfg_if! { pub const RLIMIT_RTPRIO: c_int = 14; pub const RLIMIT_RTTIME: c_int = 15; #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] - pub const RLIM_NLIMITS: c_int = 15; + pub const RLIM_NLIMITS: c_int = 16; #[allow(deprecated)] #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] pub const RLIMIT_NLIMITS: c_int = RLIM_NLIMITS; diff --git a/src/unix/linux_like/linux/arch/powerpc/mod.rs b/src/unix/linux_like/linux/arch/powerpc/mod.rs index 588b99a2d0f22..23fac9fba6262 100644 --- a/src/unix/linux_like/linux/arch/powerpc/mod.rs +++ b/src/unix/linux_like/linux/arch/powerpc/mod.rs @@ -330,7 +330,7 @@ cfg_if! { pub const RLIMIT_RTPRIO: c_int = 14; pub const RLIMIT_RTTIME: c_int = 15; #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] - pub const RLIM_NLIMITS: c_int = 15; + pub const RLIM_NLIMITS: c_int = 16; #[allow(deprecated)] #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] pub const RLIMIT_NLIMITS: c_int = RLIM_NLIMITS; From 53a99ed92101a787c87e3e57f121549b9100039d Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Sat, 3 May 2025 12:31:19 +0000 Subject: [PATCH 17/29] musl: struct ipc_perm: rename `__ipc_perm_key` to `__key` This isn't strictly related to musl 1.2.3, however now presents a good time to change it, before the 1.0 release. (backport ) (cherry picked from commit 3f81aadb0f1d1381c78f9b49da5267b3c466b138) --- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 8 ++++++++ src/unix/linux_like/linux/musl/b32/hexagon.rs | 8 ++++++++ src/unix/linux_like/linux/musl/b32/mips/mod.rs | 8 ++++++++ src/unix/linux_like/linux/musl/b32/powerpc.rs | 8 ++++++++ src/unix/linux_like/linux/musl/b32/x86/mod.rs | 8 ++++++++ src/unix/linux_like/linux/musl/b64/aarch64/mod.rs | 8 ++++++++ src/unix/linux_like/linux/musl/b64/mips64.rs | 8 ++++++++ src/unix/linux_like/linux/musl/b64/powerpc64.rs | 8 ++++++++ src/unix/linux_like/linux/musl/b64/s390x.rs | 8 ++++++++ src/unix/linux_like/linux/musl/b64/wasm32/mod.rs | 8 ++++++++ src/unix/linux_like/linux/musl/b64/x86_64/mod.rs | 8 ++++++++ 11 files changed, 88 insertions(+) diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index 292585fc3a77a..a79b3fa3729ed 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -55,6 +55,14 @@ s! { } pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, diff --git a/src/unix/linux_like/linux/musl/b32/hexagon.rs b/src/unix/linux_like/linux/musl/b32/hexagon.rs index 4aab076e1c2d3..b687953554184 100644 --- a/src/unix/linux_like/linux/musl/b32/hexagon.rs +++ b/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -34,6 +34,14 @@ s! { } pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release" + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, diff --git a/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/src/unix/linux_like/linux/musl/b32/mips/mod.rs index e0b35b6c58ea6..3f2b73decbec6 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -57,6 +57,14 @@ s! { } pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 0de40b15094bc..460b2d8fcf0ee 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -53,6 +53,14 @@ s! { } pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 22befbb0b71a5..c42bed66900e4 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -59,6 +59,14 @@ s! { } pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs index e84b9f563c668..aca96f2ece1df 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -60,6 +60,14 @@ s! { } pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index 33afe4e46c0d2..5cef57239fda9 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -57,6 +57,14 @@ s! { } pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index fb9653bc881a0..4f3c081fb633c 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -51,6 +51,14 @@ s! { } pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index 8a274f39dfb77..fe9f798d00863 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -10,6 +10,14 @@ pub type __s64 = i64; s! { pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, diff --git a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs index 3ac15b8a9349d..3f7a6098297f5 100644 --- a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs @@ -53,6 +53,14 @@ s! { } pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs index a8070cb970755..c02744c5183dd 100644 --- a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -112,6 +112,14 @@ s! { } pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, pub gid: crate::gid_t, From a066096ec006e1f68c8aa5c6bb5ccf20c7119329 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Sat, 3 May 2025 13:09:41 +0000 Subject: [PATCH 18/29] musl: aarch64: update type of ipc_perm->__seq to match upstream The architecture-specific definitions was removed in upstream commit 319b2d0, changing the type to the generic definition of int. (backport ) (cherry picked from commit 3f911737768f78469952fe2604b38f4bc52374e1) --- libc-test/build.rs | 5 ++--- src/unix/linux_like/linux/musl/b64/aarch64/mod.rs | 13 +++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 351c0cc11af33..39adfd281d166 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3722,7 +3722,6 @@ fn test_linux(target: &str) { let x32 = target.contains("x32"); let x86_32 = target.contains("i686"); let x86_64 = target.contains("x86_64"); - let aarch64_musl = aarch64 && musl; let gnueabihf = target.contains("gnueabihf"); let x86_64_gnux32 = target.contains("gnux32") && x86_64; let riscv64 = target.contains("riscv64"); @@ -4856,8 +4855,8 @@ fn test_linux(target: &str) { "sched_ss_init_budget", "sched_ss_max_repl", ].contains(&field) && musl) || - // FIXME(musl): After musl 1.1.24, the type becomes `int` instead of `unsigned short`. - (struct_ == "ipc_perm" && field == "__seq" && aarch64_musl) || + // After musl 1.1.24, the type becomes `int` instead of `unsigned short`. + (struct_ == "ipc_perm" && field == "__seq" && old_musl && aarch64) || // glibc uses unnamed fields here and Rust doesn't support that yet (struct_ == "timex" && field.starts_with("__unused")) || // FIXME(linux): It now takes mode_t since glibc 2.31 on some targets. diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs index aca96f2ece1df..243247edafc46 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -74,9 +74,18 @@ s! { pub cuid: crate::uid_t, pub cgid: crate::gid_t, pub mode: crate::mode_t, + + #[cfg(musl_v1_2_3)] + pub __seq: c_int, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "The type of this field has changed from c_ushort to c_int, + we'll follow that change in the future release." + )] pub __seq: c_ushort, - __unused1: c_ulong, - __unused2: c_ulong, + __unused1: c_long, + __unused2: c_long, } pub struct ucontext_t { From 5c17c0d0d1f86cb65f1f95f4e20abfc2f4f2741c Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Mon, 5 May 2025 07:55:39 +0000 Subject: [PATCH 19/29] ci: add quotes to URL in install-musl.sh script This silences shellcheck warnings (backport ) (cherry picked from commit 60f7b3d1841ca463cdfb1af85b713efd0b4d3b29) --- ci/install-musl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/install-musl.sh b/ci/install-musl.sh index 8567c0848675a..d3752a900ba6d 100755 --- a/ci/install-musl.sh +++ b/ci/install-musl.sh @@ -17,7 +17,7 @@ esac musl="musl-${musl_version}" # Download, configure, build, and install musl: -curl --retry 5 https://www.musl-libc.org/releases/${musl}.tar.gz | tar xzf - +curl --retry 5 "https://www.musl-libc.org/releases/${musl}.tar.gz" | tar xzf - cd "$musl" case ${1} in From e3c6d0d80baf9ff327cacee433618abaf3fbfa6b Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 4 May 2025 05:30:57 +0000 Subject: [PATCH 20/29] triagebot: Set `issue-links.check-commits = false` Disable warnings when crosslinking issues, since we do want contributors to do this. Cc: https://github.com/rust-lang/triagebot/pull/1966 (backport ) (cherry picked from commit 6a8609cb5dfcdfcb67078295c425015f71522b98) --- triagebot.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/triagebot.toml b/triagebot.toml index fe3a00af581f7..6aa18772a750e 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -13,6 +13,7 @@ contributing_url = "https://github.com/rust-lang/libc/blob/HEAD/CONTRIBUTING.md" # Ensure issue links link to this repo [issue-links] +check-commits = false # don't forbid links to issues # Prevents mentions in commits to avoid users being spammed [no-mentions] From 3db74e3ccb27d42a45be1577dd9537f7d281648b Mon Sep 17 00:00:00 2001 From: The 8472 Date: Sun, 11 May 2025 16:34:22 +0200 Subject: [PATCH 21/29] linux: add new flags for pwritev2/preadv2 (backport ) (cherry picked from commit 6e7549d34f839aa3b76476df0408a155fec81186) --- libc-test/build.rs | 9 +++++++++ libc-test/semver/linux-gnu.txt | 3 +++ libc-test/semver/linux-musl.txt | 3 +++ src/unix/linux_like/linux/gnu/mod.rs | 9 --------- src/unix/linux_like/linux/mod.rs | 12 ++++++++++++ src/unix/linux_like/linux/musl/mod.rs | 6 ------ 6 files changed, 27 insertions(+), 15 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 39adfd281d166..c0b0517075c7e 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4542,6 +4542,15 @@ fn test_linux(target: &str) { // kernel 6.2 minimum "TUN_F_USO4" | "TUN_F_USO6" | "IFF_NO_CARRIER" => true, + // kernel 6.9 minimum + "RWF_NOAPPEND" => true, + + // kernel 6.11 minimum + "RWF_ATOMIC" => true, + + // kernel 6.14 minimum + "RWF_DONTCACHE" => true, + // FIXME(linux): Requires more recent kernel headers | "IFLA_PARENT_DEV_NAME" // linux v5.13+ | "IFLA_PARENT_DEV_BUS_NAME" // linux v5.13+ diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 7f04169042c14..c88da4fe9bf6e 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -389,8 +389,11 @@ RTM_NEWCACHEREPORT RTM_NEWSTATS RUN_LVL RWF_APPEND +RWF_ATOMIC +RWF_DONTCACHE RWF_DSYNC RWF_HIPRI +RWF_NOAPPEND RWF_NOWAIT RWF_SYNC SECURITYFS_MAGIC diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index 462f45f7d13b0..8497fe9cf529a 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -32,8 +32,11 @@ PR_SET_VMA PR_SET_VMA_ANON_NAME RUN_LVL RWF_APPEND +RWF_ATOMIC +RWF_DONTCACHE RWF_DSYNC RWF_HIPRI +RWF_NOAPPEND RWF_NOWAIT RWF_SYNC USER_PROCESS diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 5ba13dd6fc2c4..49b009470af5a 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -942,15 +942,6 @@ pub const PTRACE_SYSCALL_INFO_SECCOMP: crate::__u8 = 3; pub const PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG: crate::__u8 = 0x4210; pub const PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG: crate::__u8 = 0x4211; -// linux/fs.h - -// Flags for preadv2/pwritev2 -pub const RWF_HIPRI: c_int = 0x00000001; -pub const RWF_DSYNC: c_int = 0x00000002; -pub const RWF_SYNC: c_int = 0x00000004; -pub const RWF_NOWAIT: c_int = 0x00000008; -pub const RWF_APPEND: c_int = 0x00000010; - // linux/rtnetlink.h pub const TCA_PAD: c_ushort = 9; pub const TCA_DUMP_INVISIBLE: c_ushort = 10; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index e224666dd2847..94145420553be 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -2897,6 +2897,18 @@ pub const IFA_F_NOPREFIXROUTE: u32 = 0x200; pub const IFA_F_MCAUTOJOIN: u32 = 0x400; pub const IFA_F_STABLE_PRIVACY: u32 = 0x800; +// linux/fs.h + +// Flags for preadv2/pwritev2 +pub const RWF_HIPRI: c_int = 0x00000001; +pub const RWF_DSYNC: c_int = 0x00000002; +pub const RWF_SYNC: c_int = 0x00000004; +pub const RWF_NOWAIT: c_int = 0x00000008; +pub const RWF_APPEND: c_int = 0x00000010; +pub const RWF_NOAPPEND: c_int = 0x00000020; +pub const RWF_ATOMIC: c_int = 0x00000040; +pub const RWF_DONTCACHE: c_int = 0x00000080; + // linux/if_link.h pub const IFLA_UNSPEC: c_ushort = 0; pub const IFLA_ADDRESS: c_ushort = 1; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 393d46b20cf25..9931847672ad4 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -747,12 +747,6 @@ pub const PTRACE_PEEKSIGINFO: c_int = 0x4209; pub const PTRACE_GETSIGMASK: c_uint = 0x420a; pub const PTRACE_SETSIGMASK: c_uint = 0x420b; -pub const RWF_HIPRI: c_int = 0x00000001; -pub const RWF_DSYNC: c_int = 0x00000002; -pub const RWF_SYNC: c_int = 0x00000004; -pub const RWF_NOWAIT: c_int = 0x00000008; -pub const RWF_APPEND: c_int = 0x00000010; - pub const AF_IB: c_int = 27; pub const AF_MPLS: c_int = 28; pub const AF_NFC: c_int = 39; From 40c1f316ce01031cdd967a065a1c2e4bcde046e4 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 10 May 2025 22:53:18 +0000 Subject: [PATCH 22/29] adding SO_SPLICE socket option support for freebsd >= 14.2 [ref](https://github.com/freebsd/freebsd-src/blob/d3f15bc2a51d1822795135d9ad4627dc1c7f2b18/sys/sys/socket.h#L175) and [ref](https://github.com/freebsd/freebsd-src/blob/d3f15bc2a51d1822795135d9ad4627dc1c7f2b18/sys/sys/socketvar.h#L76) (backport ) (cherry picked from commit 47ac2e75f172de447f3c1205c63ac6afaacd61de) --- libc-test/build.rs | 6 ++++++ libc-test/semver/freebsd.txt | 2 ++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index c0b0517075c7e..4efc1ff7a92dd 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2853,6 +2853,9 @@ fn test_freebsd(target: &str) { // FIXME(freebsd): Removed in FreeBSD 15, deprecated in libc "TCP_PCAP_OUT" | "TCP_PCAP_IN" => true, + // Added in FreeBSD 14.2 + "SO_SPLICE" if Some(14) > freebsd_ver => true, + _ => false, } }); @@ -2904,6 +2907,9 @@ fn test_freebsd(target: &str) { // FIXME(freebsd): Changed in FreeBSD 15 "tcp_info" | "sockstat" if Some(15) >= freebsd_ver => true, + // `splice` introduced in FreeBSD 14.2 + "splice" if Some(14) > freebsd_ver => true, + _ => false, } }); diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 96b4c19b53fb7..d0b64323282c1 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1466,6 +1466,7 @@ SO_PROTOTYPE SO_REUSEPORT SO_REUSEPORT_LB SO_SETFIB +SO_SPLICE SO_TIMESTAMP SO_TS_BINTIME SO_TS_CLOCK @@ -2360,6 +2361,7 @@ sigwait sigwaitinfo sockaddr_dl sockcred +splice srand srand48 stack_t diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 7d6b876d6a15a..c88967e6fce58 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1398,6 +1398,12 @@ s! { tqh_first: *mut c_void, tqh_last: *mut *mut c_void, } + + pub struct splice { + pub sp_fd: c_int, + pub sp_max: off_t, + pub sp_idle: crate::timeval, + } } s_no_extra_traits! { @@ -3193,6 +3199,7 @@ pub const SO_PROTOCOL: c_int = 0x1016; pub const SO_PROTOTYPE: c_int = SO_PROTOCOL; pub const SO_TS_CLOCK: c_int = 0x1017; pub const SO_DOMAIN: c_int = 0x1019; +pub const SO_SPLICE: c_int = 0x1023; pub const SO_VENDOR: c_int = 0x80000000; pub const SO_TS_REALTIME_MICRO: c_int = 0; From 28e6ae297b1bd48789da1f66e4d1390829185fbf Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 13 May 2025 21:14:57 +0000 Subject: [PATCH 23/29] Run `cargo fmt` from the workspace root (backport ) (cherry picked from commit adcb2b8258ab3b2f21678724f342e84fb28dff3e) --- build.rs | 2 +- src/windows/mod.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 2a55a4c07e525..6eafad5429b9b 100644 --- a/build.rs +++ b/build.rs @@ -22,7 +22,7 @@ const ALLOWED_CFGS: &[&str] = &[ "libc_ctest", // Corresponds to `__USE_TIME_BITS64` in UAPI "linux_time_bits64", - "musl_v1_2_3" + "musl_v1_2_3", ]; // Extra values to allow for check-cfg. diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 8490b709bae9e..5cafc855f78a0 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -394,7 +394,12 @@ extern "C" { #[link_name = "_get_timezone"] pub fn get_timezone(seconds: *mut c_long) -> errno_t; #[link_name = "_get_tzname"] - pub fn get_tzname(p_return_value: *mut size_t, time_zone_name: *mut c_char, size_in_bytes: size_t, index: c_int) -> errno_t; + pub fn get_tzname( + p_return_value: *mut size_t, + time_zone_name: *mut c_char, + size_in_bytes: size_t, + index: c_int, + ) -> errno_t; #[link_name = "_localtime64_s"] pub fn localtime_s(tmDest: *mut tm, sourceTime: *const time_t) -> crate::errno_t; #[link_name = "_time64"] From a2189ad2caac97baf19f11f1223893eebfcbd309 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 13 May 2025 21:16:20 +0000 Subject: [PATCH 24/29] ci: Run `cargo fmt` for the entire workspace Currently only `src/` is checked. Add a run that covers everything else. This does mean files in `src/` get formatted twice, but `cargo fmt` doesn't support an `--exclude` option. (backport ) (cherry picked from commit 1ca8b368a84893ab57fcee3ce26066e255d9b8b2) --- ci/style.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ci/style.sh b/ci/style.sh index 5b200796a8c53..2b5ddfc6328da 100755 --- a/ci/style.sh +++ b/ci/style.sh @@ -59,6 +59,10 @@ done < "$tmpfile" rm "$tmpfile" +# Run once from workspace root to get everything that wasn't handled as an +# individual file. +cargo fmt + if shellcheck --version ; then find . -name '*.sh' -print0 | xargs -0 shellcheck else From 3b98e7d82a134530bf7508f8df3661eb2e2f42f1 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 13 May 2025 21:18:48 +0000 Subject: [PATCH 25/29] ci: Don't exclude `ctest/` There are no longer any shell files in `ctest/`, so this FIXME can be resolved. Also move this to the end so missing shellcheck doesn't exit before the sort checks. (backport ) [ note - this backport doesn't do much since `ctest/` was never excluded, but it does keep file structure in sync - Trevor ] (cherry picked from commit 654bf4eb22056d8b343e578c8a299cd789a7cf0f) --- ci/style.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ci/style.sh b/ci/style.sh index 2b5ddfc6328da..0d4a4f953dda1 100755 --- a/ci/style.sh +++ b/ci/style.sh @@ -63,13 +63,6 @@ rm "$tmpfile" # individual file. cargo fmt -if shellcheck --version ; then - find . -name '*.sh' -print0 | xargs -0 shellcheck -else - echo "shellcheck not found" - exit 1 -fi - # Ensure that `sort` output is not locale-dependent export LC_ALL=C @@ -91,3 +84,10 @@ for file in libc-test/semver/*.txt; do exit 1 fi done + +if shellcheck --version ; then + find . -name '*.sh' -print0 | xargs -0 shellcheck +else + echo "shellcheck not found" + exit 1 +fi From 6e353398a6a4fff08c3a8fc0701280b1dde7af46 Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Tue, 18 Mar 2025 16:48:52 -0400 Subject: [PATCH 26/29] Enable libc-test for AIX and fix definitions/declarations. (backport ) (cherry picked from commit c192a5cae31dd84ad17dc3c2dd0a3deaacae452a) --- libc-test/build.rs | 240 +++- libc-test/semver/aix.txt | 2608 +++++++++++++++++++++++++++++++++++++ libc-test/test/cmsg.rs | 6 +- libc-test/test/makedev.rs | 1 - src/unix/aix/mod.rs | 678 ++++++---- src/unix/aix/powerpc64.rs | 358 ++--- src/unix/mod.rs | 28 +- 7 files changed, 3395 insertions(+), 524 deletions(-) create mode 100644 libc-test/semver/aix.txt diff --git a/libc-test/build.rs b/libc-test/build.rs index 4efc1ff7a92dd..74fce84d73765 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -70,6 +70,7 @@ fn do_ctest() { t if t.contains("windows") => test_windows(t), t if t.contains("vxworks") => test_vxworks(t), t if t.contains("nto-qnx") => test_neutrino(t), + t if t.contains("aix") => return test_aix(t), t => panic!("unknown target {t}"), } } @@ -102,7 +103,9 @@ fn do_semver() { // NOTE: Android doesn't include the unix file (or the Linux file) because // there are some many definitions missing it's actually easier just to // maintain a file for Android. - if family != os && os != "android" { + // NOTE: AIX doesn't include the unix file because there are definitions + // missing on AIX. It is easier to maintain a file for AIX. + if family != os && !matches!(os.as_str(), "android" | "aix") { process_semver_file(&mut output, &mut semver_root, &family); } // We don't do semver for unknown targets. @@ -5485,3 +5488,238 @@ fn test_haiku(target: &str) { }); cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); } + +fn test_aix(target: &str) { + assert!(target.contains("aix")); + + // ctest generates arguments supported only by clang, so make sure to + // run with CC=clang. While debugging, "CFLAGS=-ferror-limit=" + // is useful to get more error output. + let mut cfg = ctest_cfg(); + cfg.define("_THREAD_SAFE", None); + + // Avoid the error for definitions such as '{0, 0, 0, 1}' for + // 'IN6ADDR_LOOPBACK_INIT' in netinent/in.h. + cfg.flag("-Wno-missing-braces"); + + headers! { cfg: + "aio.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "errno.h", + "fcntl.h", + "fnmatch.h", + "glob.h", + "grp.h", + "iconv.h", + "langinfo.h", + "libgen.h", + "limits.h", + "locale.h", + "malloc.h", + "mntent.h", + "mqueue.h", + "netinet/in.h", // this needs be before net/if.h + "poll.h", // this needs be before net/if.h + "sys/pollset.h", // this needs to be before net/if.h + "net/if.h", + "net/bpf.h", // this needs to be after net/if.h + "net/if_dl.h", + "netdb.h", + "netinet/tcp.h", + "pthread.h", + "pwd.h", + "rpcsvc/mount.h", + "rpcsvc/rstat.h", + "regex.h", + "resolv.h", + "sched.h", + "search.h", + "semaphore.h", + "signal.h", + "spawn.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "strings.h", + "sys/aacct.h", + "sys/acct.h", + "sys/dr.h", + "sys/file.h", + "sys/io.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/ldr.h", + "sys/mman.h", + "sys/msg.h", + "sys/reg.h", + "sys/resource.h", + "sys/sem.h", + "sys/shm.h", + "sys/socket.h", + "sys/stat.h", + "sys/statfs.h", + "sys/statvfs.h", + "sys/stropts.h", + "sys/termio.h", + "sys/time.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/user.h", + "sys/utsname.h", + "sys/vattr.h", + "sys/vminfo.h", + "sys/wait.h", + "sys/xti.h", + "syslog.h", + "termios.h", + "thread.h", + "time.h", + "ucontext.h", + "unistd.h", + "utime.h", + "utmp.h", + "utmpx.h", + "wchar.h", + } + + cfg.skip_type(move |ty| match ty { + // AIX does not define type 'sighandler_t'. + "sighandler_t" => true, + + // The alignment of 'double' does not agree between C and Rust for AIX. + // We are working on a resolution. + "c_double" => true, + + _ => false, + }); + + cfg.type_name(move |ty, is_struct, is_union| match ty { + "DIR" => ty.to_string(), + "FILE" => ty.to_string(), + "ACTION" => ty.to_string(), + + // 'sigval' is a struct in Rust, but a union in C. + "sigval" => format!("union sigval"), + + t if t.ends_with("_t") => t.to_string(), + t if is_struct => format!("struct {}", t), + t if is_union => format!("union {}", t), + t => t.to_string(), + }); + + cfg.skip_const(move |name| match name { + // Skip 'sighandler_t' assignments. + "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, + + _ => false, + }); + + cfg.skip_struct(move |ty| { + match ty { + // FIXME(union): actually a union. + "sigval" => true, + + // '__poll_ctl_ext_u' and '__pollfd_ext_u' are for unnamed unions. + "__poll_ctl_ext_u" => true, + "__pollfd_ext_u" => true, + + // 'struct fpreg_t' is not defined in AIX headers. It is created to + // allow type 'double' to be used in signal contexts. + "fpreg_t" => true, + + _ => false, + } + }); + + cfg.skip_field_type(move |struct_, field| { + match (struct_, field) { + // AIX does not define 'sighandler_t'. + ("sigaction", "sa_sigaction") => true, + + // The type of 'fpr' is 'fpreg_t' which is created to allow type + // 'double' to be used in signal contexts. + ("__context64", "fpr") => true, + ("__tm_context_t", "fpr") => true, + + _ => false, + } + }); + + cfg.skip_field(move |s, field| { + match s { + // The field 'u' is actually a unnamed union in the AIX header. + "poll_ctl_ext" if field == "u" => true, + + // The field 'data' is actually a unnamed union in the AIX header. + "pollfd_ext" if field == "data" => true, + + _ => false, + } + }); + + cfg.skip_fn(move |name| { + match name { + // 'sighandler_t' is not defined on AIX. + "signal" => true, + + // The function is only available under macro _USE_IRS in 'netdb.h'. + "hstrerror" => true, + + // _ALL_SOURCE signatures for these functions differ from POSIX's + // on AIX. + "poll" => true, + "readlinkat" => true, + "readlink" => true, + "pselect" => true, + + // The AIX signature differs from POSIX's, issue opened. + "gai_strerror" => true, + + // AIX implements POSIX-compliant versions of these functions + // using 'static' wrappers in the headers, which in turn call + // the corresponding system libc functions prefixed with '_posix_' + // (e.g., '_posix_aio_read' for 'aio_read'). + // On the Rust side, these functions resolve directly to the + // POSIX-compliant versions in the system libc. As a result, + // function pointer comparisons between the C and Rust sides + // would fail. + "getpwuid_r" | "getpwnam_r" | "getgrgid_r" | "getgrnam_r" + | "aio_cancel" | "aio_error" | "aio_fsync" | "aio_read" + | "aio_return" | "aio_suspend" | "aio_write" | "select" => true, + + // 'getdtablesize' is a constant in the AIX header but it is + // a real function in libc which the Rust side is resolved to. + // The function pointer comparison test would fail. + "getdtablesize" => true, + + // FIXME(ctest): Our API is unsound. The Rust API allows aliasing + // pointers, but the C API requires pointers not to alias. + // We should probably be at least using '&'/'&mut' here, see: + // https://github.com/gnzlbg/ctest/issues/68. + "lio_listio" => true, + + _ => false, + } + }); + + + cfg.volatile_item(|i| { + use ctest::VolatileItemKind::*; + match i { + // 'aio_buf' is of type 'volatile void**' but since we cannot + // express that in Rust types, we have to explicitly tell the + // checker about it here. + StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => true, + + _ => false, + } + }); + + cfg.generate(src_hotfix_dir().join("lib.rs"), "main.rs"); +} diff --git a/libc-test/semver/aix.txt b/libc-test/semver/aix.txt new file mode 100644 index 0000000000000..3b6417ba3e718 --- /dev/null +++ b/libc-test/semver/aix.txt @@ -0,0 +1,2608 @@ +ABDAY_1 +ABDAY_2 +ABDAY_3 +ABDAY_4 +ABDAY_5 +ABDAY_6 +ABDAY_7 +ABMON_1 +ABMON_10 +ABMON_11 +ABMON_12 +ABMON_2 +ABMON_3 +ABMON_4 +ABMON_5 +ABMON_6 +ABMON_7 +ABMON_8 +ABMON_9 +ACCOUNTING +ACTION +AF_APPLETALK +AF_CCITT +AF_CHAOS +AF_DATAKIT +AF_DECnet +AF_DLI +AF_ECMA +AF_HYLINK +AF_IMPLINK +AF_INET +AF_INET6 +AF_INTF +AF_ISO +AF_LAT +AF_LINK +AF_LOCAL +AF_MAX +AF_NDD +AF_NS +AF_OSI +AF_PUP +AF_RIF +AF_ROUTE +AF_SNA +AF_UNIX +AF_UNSPEC +AIO_ALLDONE +AIO_CANCELED +AIO_LISTIO_MAX +AIO_NOTCANCELED +AI_ADDRCONFIG +AI_ALL +AI_CANONNAME +AI_DEFAULT +AI_EXTFLAGS +AI_NUMERICHOST +AI_NUMERICSERV +AI_PASSIVE +AI_V4MAPPED +ALTWERASE +ALT_DIGITS +AM_STR +ARG_MAX +ARPHRD_802_3 +ARPHRD_802_5 +ARPHRD_ETHER +ARPHRD_FDDI +AT_EACCESS +AT_FDCWD +AT_FLAGS +AT_GID +AT_REMOVEDIR +AT_SYMLINK_FOLLOW +AT_SYMLINK_NOFOLLOW +AT_UID +B0 +B110 +B1200 +B134 +B150 +B1800 +B19200 +B200 +B2400 +B300 +B38400 +B4800 +B50 +B600 +B75 +B9600 +BC_BASE_MAX +BC_DIM_MAX +BC_SCALE_MAX +BC_STRING_MAX +BIG_ENDIAN +BIOCFLUSH +BIOCGBLEN +BIOCGDLT +BIOCGETIF +BIOCGRTIMEOUT +BIOCGSTATS +BIOCIMMEDIATE +BIOCPROMISC +BIOCSBLEN +BIOCSDEVNO +BIOCSETF +BIOCSETIF +BIOCSRTIMEOUT +BIOCVERSION +BOOT_TIME +BPF_ABS +BPF_ADD +BPF_ALIGNMENT +BPF_ALU +BPF_AND +BPF_B +BPF_DIV +BPF_H +BPF_IMM +BPF_IND +BPF_JA +BPF_JEQ +BPF_JGE +BPF_JGT +BPF_JMP +BPF_JSET +BPF_K +BPF_LD +BPF_LDX +BPF_LEN +BPF_LSH +BPF_MAXINSNS +BPF_MEM +BPF_MEMWORDS +BPF_MISC +BPF_MSH +BPF_MUL +BPF_NEG +BPF_OR +BPF_RET +BPF_RSH +BPF_ST +BPF_STX +BPF_SUB +BPF_W +BPF_X +BRKINT +BS0 +BS1 +BSDLY +BUFSIZ +BUS_ADRALN +BUS_ADRERR +BUS_OBJERR +BUS_UEGARD +CBAUD +CBREAK +CHARCLASS_NAME_MAX +CHILD_MAX +CIBAUD +CLD_CONTINUED +CLD_DUMPED +CLD_EXITED +CLD_KILLED +CLD_STOPPED +CLD_TRAPPED +CLOCAL +CLOCK_MONOTONIC +CLOCK_PROCESS_CPUTIME_ID +CLOCK_REALTIME +CLOCK_THREAD_CPUTIME_ID +CMSG_DATA +CMSG_FIRSTHDR +CMSG_NXTHDR +CODESET +COLL_WEIGHTS_MAX +CPUSTATES +CR0 +CR1 +CR2 +CR3 +CRDLY +CREAD +CRNCYSTR +CS5 +CS6 +CS7 +CS8 +CSIZE +CSTART +CSTOP +CSTOPB +DAY_1 +DAY_2 +DAY_3 +DAY_4 +DAY_5 +DAY_6 +DAY_7 +DEAD_PROCESS +DIR +DLT_ARCNET +DLT_ATM +DLT_AX25 +DLT_EN10MB +DLT_EN3MB +DLT_FDDI +DLT_IEEE802 +DLT_IPOIB +DLT_NULL +DLT_PPP +DLT_PRONET +DLT_SLIP +DST_AUST +DST_CAN +DST_EET +DST_MET +DST_NONE +DST_USA +DST_WET +D_FMT +D_T_FMT +E2BIG +EACCES +EADDRINUSE +EADDRNOTAVAIL +EAFNOSUPPORT +EAGAIN +EAI_AGAIN +EAI_BADFLAGS +EAI_FAIL +EAI_FAMILY +EAI_MEMORY +EAI_NODATA +EAI_NONAME +EAI_OVERFLOW +EAI_SERVICE +EAI_SOCKTYPE +EAI_SYSTEM +EALREADY +EBADF +EBADMSG +EBUSY +ECANCELED +ECHILD +ECHO +ECHOCTL +ECHOE +ECHOK +ECHOKE +ECHONL +ECHOPRT +ECHRNG +ECLONEME +ECONNABORTED +ECONNREFUSED +ECONNRESET +ECORRUPT +EDEADLK +EDESTADDREQ +EDESTADDRREQ +EDIST +EDOM +EDQUOT +EEXIST +EFAULT +EFBIG +EFORMAT +EHOSTDOWN +EHOSTUNREACH +EIDRM +EILSEQ +EINPROGRESS +EINTR +EINVAL +EIO +EISCONN +EISDIR +EL2HLT +EL2NSYNC +EL3HLT +EL3RST +ELNRNG +ELOOP +EMEDIA +EMFILE +EMLINK +EMPTY +EMSGSIZE +EMTP_INFO_FORMAT +EMULTIHOP +ENAMETOOLONG +ENERGYSCALE_INFO +ENETDOWN +ENETRESET +ENETUNREACH +ENFILE +ENOATTR +ENOBUFS +ENOCONNECT +ENOCSI +ENODATA +ENODEV +ENOENT +ENOEXEC +ENOLCK +ENOLINK +ENOMEM +ENOMSG +ENOPROTOOPT +ENOSPC +ENOSR +ENOSTR +ENOSYS +ENOTBLK +ENOTCONN +ENOTDIR +ENOTEMPTY +ENOTREADY +ENOTRECOVERABLE +ENOTRUST +ENOTSOCK +ENOTSUP +ENOTTY +ENTER +ENXIO +EOF +EOPNOTSUPP +EOVERFLOW +EOWNERDEAD +EPERM +EPFNOSUPPORT +EPIPE +EPROCLIM +EPROTO +EPROTONOSUPPORT +EPROTOTYPE +ERA +ERANGE +ERA_D_FMT +ERA_D_T_FMT +ERA_T_FMT +EREMOTE +ERESTART +EROFS +ESAD +ESHUTDOWN +ESOCKTNOSUPPORT +ESOFT +ESPIPE +ESRCH +ESTALE +ESYSERROR +ETIME +ETIMEDOUT +ETOOMANYREFS +ETXTBSY +EUNATCH +EUSERS +EWOULDBLOCK +EWRPROTECT +EXDEV +EXIT_FAILURE +EXIT_SUCCESS +EXPR_NEST_MAX +EXTA +EXTB +FASYNC +FD_CLOEXEC +FD_CLR +FD_ISSET +FD_SET +FD_SETSIZE +FD_ZERO +FF0 +FF1 +FFDLY +FILE +FILENAME_MAX +FIND +FIOASYNC +FIOCLEX +FIOGETOWN +FIONBIO +FIONCLEX +FIONREAD +FIOSETOWN +FLUSHO +FNM_NOESCAPE +FNM_NOMATCH +FNM_PATHNAME +FNM_PERIOD +FOPEN_MAX +FPE_FLTDIV +FPE_FLTINV +FPE_FLTOVF +FPE_FLTRES +FPE_FLTSUB +FPE_FLTUND +FPE_INTDIV +FPE_INTOVF +F_CLOSEM +F_DUP2FD +F_DUPFD +F_DUPFD_CLOEXEC +F_GETFD +F_GETFL +F_GETLK +F_GETLK64 +F_GETOWN +F_LOCK +F_OK +F_RDLCK +F_SETFD +F_SETFL +F_SETLK +F_SETLK64 +F_SETLKW +F_SETLKW64 +F_SETOWN +F_TEST +F_TLOCK +F_TSTLK +F_ULOCK +F_UNLCK +F_WRLCK +GETALL +GETNCNT +GETPID +GETVAL +GETZCNT +GLOB_ABORTED +GLOB_APPEND +GLOB_DOOFFS +GLOB_ERR +GLOB_MARK +GLOB_NOCHECK +GLOB_NOESCAPE +GLOB_NOMATCH +GLOB_NOSORT +GLOB_NOSPACE +GLOB_NOSYS +GRPQUOTA +HUPCL +IA64 +IBSHIFT +ICANON +ICRNL +IEXTEN +IFF_ALLMULTI +IFF_BROADCAST +IFF_DEBUG +IFF_LINK0 +IFF_LINK1 +IFF_LINK2 +IFF_LOOPBACK +IFF_MULTICAST +IFF_NOARP +IFF_NOTRAILERS +IFF_OACTIVE +IFF_POINTOPOINT +IFF_PROMISC +IFF_RUNNING +IFF_SIMPLEX +IFF_UP +IFNAMSIZ +IFNET_SLOWHZ +IFQ_MAXLEN +IF_NAMESIZE +IGNBRK +IGNCR +IGNPAR +ILL_BADSTK +ILL_COPROC +ILL_ILLADR +ILL_ILLOPC +ILL_ILLOPN +ILL_ILLTRP +ILL_PRVOPC +ILL_PRVREG +ILL_TMBADTHING +IMAXBEL +IN6ADDR_ANY_INIT +IN6ADDR_LOOPBACK_INIT +INADDR_ANY +INADDR_BROADCAST +INADDR_LOOPBACK +INADDR_NONE +INIT_PROCESS +INLCR +INPCK +INT_MAX +INT_MIN +IOCPARM_MASK +IOC_IN +IOC_INOUT +IOC_OUT +IOC_VOID +IOV_MAX +IPC_ALLOC +IPC_CREAT +IPC_EXCL +IPC_NOERROR +IPC_NOWAIT +IPC_O +IPC_PRIVATE +IPC_R +IPC_RMID +IPC_SET +IPC_STAT +IPC_W +IPDEFTTL +IPOPT_CONTROL +IPOPT_EOL +IPOPT_LSRR +IPOPT_MINOFF +IPOPT_NOP +IPOPT_OFFSET +IPOPT_OLEN +IPOPT_OPTVAL +IPOPT_RESERVED1 +IPOPT_RESERVED2 +IPOPT_RR +IPOPT_SSRR +IPOPT_TS +IPOPT_TS_PRESPEC +IPOPT_TS_TSANDADDR +IPOPT_TS_TSONLY +IPPROTO_AH +IPPROTO_BIP +IPPROTO_DSTOPTS +IPPROTO_EGP +IPPROTO_EON +IPPROTO_ESP +IPPROTO_FRAGMENT +IPPROTO_GGP +IPPROTO_GIF +IPPROTO_GRE +IPPROTO_HOPOPTS +IPPROTO_ICMP +IPPROTO_ICMPV6 +IPPROTO_IDP +IPPROTO_IGMP +IPPROTO_IP +IPPROTO_IPIP +IPPROTO_IPV6 +IPPROTO_LOCAL +IPPROTO_MH +IPPROTO_NONE +IPPROTO_PUP +IPPROTO_QOS +IPPROTO_RAW +IPPROTO_ROUTING +IPPROTO_RSVP +IPPROTO_SCTP +IPPROTO_TCP +IPPROTO_TP +IPPROTO_UDP +IPTOS_LOWDELAY +IPTOS_PREC_CRITIC_ECP +IPTOS_PREC_FLASH +IPTOS_PREC_FLASHOVERRIDE +IPTOS_PREC_IMMEDIATE +IPTOS_PREC_INTERNETCONTROL +IPTOS_PREC_NETCONTROL +IPTOS_PREC_PRIORITY +IPTOS_PREC_ROUTINE +IPTOS_RELIABILITY +IPTOS_THROUGHPUT +IPV6_ADDRFORM +IPV6_ADDR_PREFERENCES +IPV6_ADD_MEMBERSHIP +IPV6_CHECKSUM +IPV6_DONTFRAG +IPV6_DROP_MEMBERSHIP +IPV6_DSTOPTS +IPV6_FLOWINFO_FLOWLABEL +IPV6_FLOWINFO_PRIFLOW +IPV6_FLOWINFO_PRIORITY +IPV6_FLOWINFO_SRFLAG +IPV6_FLOWINFO_VERSION +IPV6_HOPLIMIT +IPV6_HOPOPTS +IPV6_JOIN_GROUP +IPV6_LEAVE_GROUP +IPV6_MULTICAST_HOPS +IPV6_MULTICAST_IF +IPV6_MULTICAST_LOOP +IPV6_NEXTHOP +IPV6_PATHMTU +IPV6_PKTINFO +IPV6_PREFER_SRC_CGA +IPV6_PREFER_SRC_COA +IPV6_PREFER_SRC_HOME +IPV6_PREFER_SRC_NONCGA +IPV6_PREFER_SRC_PUBLIC +IPV6_PREFER_SRC_TMP +IPV6_RECVDSTOPTS +IPV6_RECVHOPLIMIT +IPV6_RECVHOPOPTS +IPV6_RECVPATHMTU +IPV6_RECVPKTINFO +IPV6_RECVRTHDR +IPV6_RECVTCLASS +IPV6_RTHDR +IPV6_RTHDRDSTOPTS +IPV6_TCLASS +IPV6_UNICAST_HOPS +IPV6_V6ONLY +IPVERSION +IP_ADDRFORM +IP_ADD_MEMBERSHIP +IP_ADD_SOURCE_MEMBERSHIP +IP_BLOCK_SOURCE +IP_BROADCAST_IF +IP_DEFAULT_MULTICAST_LOOP +IP_DEFAULT_MULTICAST_TTL +IP_DHCPMODE +IP_DONTFRAG +IP_DROP_MEMBERSHIP +IP_DROP_SOURCE_MEMBERSHIP +IP_FINDPMTU +IP_HDRINCL +IP_INC_MEMBERSHIPS +IP_INIT_MEMBERSHIP +IP_MULTICAST_HOPS +IP_MULTICAST_IF +IP_MULTICAST_LOOP +IP_MULTICAST_TTL +IP_OPTIONS +IP_PMTUAGE +IP_RECVDSTADDR +IP_RECVIF +IP_RECVIFINFO +IP_RECVINTERFACE +IP_RECVMACHDR +IP_RECVOPTS +IP_RECVRETOPTS +IP_RECVTTL +IP_RETOPTS +IP_TOS +IP_TTL +IP_UNBLOCK_SOURCE +IP_UNICAST_HOPS +ISIG +ISTRIP +ITIMER_PROF +ITIMER_REAL +ITIMER_REAL1 +ITIMER_REAL_TH +ITIMER_VIRT +ITIMER_VIRTUAL +IUCLC +IXANY +IXOFF +IXON +I_ATMARK +I_CANPUT +I_CKBAND +I_FDINSERT +I_FIND +I_FLUSH +I_FLUSHBAND +I_GETBAND +I_GETCLTIME +I_GETSIG +I_GRDOPT +I_GWROPT +I_LINK +I_LIST +I_LOOK +I_NREAD +I_PEEK +I_PLINK +I_POP +I_PUNLINK +I_PUSH +I_RECVFD +I_SENDFD +I_SETCLTIME +I_SETSIG +I_SRDOPT +I_STR +I_SWROPT +I_UNLINK +LCASE +LC_ALL +LC_ALL_MASK +LC_COLLATE +LC_COLLATE_MASK +LC_CTYPE +LC_CTYPE_MASK +LC_GLOBAL_LOCALE +LC_MESSAGES +LC_MESSAGES_MASK +LC_MONETARY +LC_MONETARY_MASK +LC_NUMERIC +LC_NUMERIC_MASK +LC_TIME +LC_TIME_MASK +LIO_NOP +LIO_NOWAIT +LIO_READ +LIO_WAIT +LIO_WRITE +LITTLE_ENDIAN +LOCK_EX +LOCK_NB +LOCK_SH +LOCK_UN +LOGIN_PROCESS +LOG_ALERT +LOG_AUTH +LOG_AUTHPRIV +LOG_CONS +LOG_CRIT +LOG_CRON +LOG_DAEMON +LOG_DEBUG +LOG_EMERG +LOG_ERR +LOG_FACMASK +LOG_INFO +LOG_KERN +LOG_LOCAL0 +LOG_LOCAL1 +LOG_LOCAL2 +LOG_LOCAL3 +LOG_LOCAL4 +LOG_LOCAL5 +LOG_LOCAL6 +LOG_LOCAL7 +LOG_LPR +LOG_MAIL +LOG_NDELAY +LOG_NEWS +LOG_NFACILITIES +LOG_NOTICE +LOG_NOWAIT +LOG_ODELAY +LOG_PERROR +LOG_PID +LOG_PRIMASK +LOG_SYSLOG +LOG_USER +LOG_UUCP +LOG_WARNING +LPAR_INFO_FORMAT1 +LPAR_INFO_FORMAT2 +LPAR_INFO_LPM_CAPABILITY +LPAR_INFO_VRME_ALLOW_DESIRED +LPAR_INFO_VRME_LPAR +LPAR_INFO_VRME_NUM_POOLS +LPAR_INFO_VRME_POOLS +LPAR_INFO_VRME_RESET_HWMARKS +L_GETINFO +L_GETKERNINFO +L_GETLIB32INFO +L_GETLIB64INFO +L_GETLIBPATH +L_GETMESSAGES +L_GETPROCINFO +L_GETXINFO +L_tmpnam +MADV_DONTNEED +MADV_NORMAL +MADV_RANDOM +MADV_SEQUENTIAL +MADV_WILLNEED +MAP_ANON +MAP_ANONYMOUS +MAP_FAILED +MAP_FILE +MAP_FIXED +MAP_PRIVATE +MAP_SHARED +MAP_TYPE +MAXCOMLEN +MAXHOSTNAMELEN +MAXPATHLEN +MAXSYMLINKS +MAXTTL +MAXUPRC +MAX_CANON +MAX_INPUT +MCAST_BLOCK_SOURCE +MCAST_EXCLUDE +MCAST_INCLUDE +MCAST_JOIN_GROUP +MCAST_JOIN_SOURCE_GROUP +MCAST_LEAVE_GROUP +MCAST_LEAVE_SOURCE_GROUP +MCAST_UNBLOCK_SOURCE +MCL_CURRENT +MCL_FUTURE +MDMBUF +MINSIGSTKSZ +MON_1 +MON_10 +MON_11 +MON_12 +MON_2 +MON_3 +MON_4 +MON_5 +MON_6 +MON_7 +MON_8 +MON_9 +MSG_ARGEXT +MSG_COMPAT +MSG_CTRUNC +MSG_DONTROUTE +MSG_EOR +MSG_MAXIOVLEN +MSG_MPEG2 +MSG_NOERROR +MSG_NONBLOCK +MSG_NOSIGNAL +MSG_OOB +MSG_PEEK +MSG_TRUNC +MSG_WAITALL +MSG_WAITFORONE +MS_ASYNC +MS_INVALIDATE +MS_SYNC +NCCS +NEW_TIME +NFSMNT_ACDIRMAX +NFSMNT_ACDIRMIN +NFSMNT_ACREGMAX +NFSMNT_ACREGMIN +NFSMNT_HOSTNAME +NFSMNT_INT +NFSMNT_NOAC +NFSMNT_RETRANS +NFSMNT_RSIZE +NFSMNT_SOFT +NFSMNT_TIMEO +NFSMNT_WSIZE +NGROUPS +NGROUPS_MAX +NI_DGRAM +NI_MAXHOST +NI_MAXSERV +NI_NAMEREQD +NI_NOFQDN +NI_NUMERICHOST +NI_NUMERICSCOPE +NI_NUMERICSERV +NL0 +NL1 +NLDLY +NOEXPR +NOFILE +NOFLSH +NOSTR +NUM_PROC_MODULE_TYPES +NZERO +OCRNL +OFDEL +OFILL +OLCUC +OLD_TIME +ONLCR +ONLRET +ONOCR +ONOEOT +OPEN_MAX +OPOST +OXTABS +O_ACCMODE +O_APPEND +O_CLOEXEC +O_CREAT +O_DIRECT +O_DIRECTORY +O_DSYNC +O_EXCL +O_EXEC +O_LARGEFILE +O_NDELAY +O_NOCTTY +O_NOFOLLOW +O_NONBLOCK +O_RDONLY +O_RDWR +O_RSYNC +O_SEARCH +O_SYNC +O_TRUNC +O_TTY_INIT +O_WRONLY +PAGESIZE +PARENB +PAREXT +PARMRK +PARODD +PATH_MAX +PDP_ENDIAN +PENDIN +PF_APPLETALK +PF_CCITT +PF_CHAOS +PF_DATAKIT +PF_DECnet +PF_DLI +PF_ECMA +PF_HYLINK +PF_IMPLINK +PF_INET +PF_INET6 +PF_INTF +PF_ISO +PF_LAT +PF_LINK +PF_MAX +PF_NDD +PF_NS +PF_OSI +PF_PUP +PF_RIF +PF_ROUTE +PF_SNA +PF_UNIX +PF_UNSPEC +PF_XTP +PIPE_BUF +PM_STR +POLLERR +POLLHUP +POLLIN +POLLMSG +POLLNORM +POLLNVAL +POLLOUT +POLLPRI +POLLRDBAND +POLLRDNORM +POLLSYNC +POLLWRBAND +POLLWRNORM +POLL_ERR +POLL_HUP +POLL_IN +POLL_MSG +POLL_OUT +POLL_PRI +POSIX_FADV_DONTNEED +POSIX_FADV_NOREUSE +POSIX_FADV_NORMAL +POSIX_FADV_RANDOM +POSIX_FADV_SEQUENTIAL +POSIX_FADV_WILLNEED +POSIX_MADV_DONTNEED +POSIX_MADV_NORMAL +POSIX_MADV_RANDOM +POSIX_MADV_SEQUENTIAL +POSIX_MADV_WILLNEED +POSIX_SPAWN_FORK_HANDLERS +POSIX_SPAWN_RESETIDS +POSIX_SPAWN_SETPGROUP +POSIX_SPAWN_SETSCHEDPARAM +POSIX_SPAWN_SETSCHEDULER +POSIX_SPAWN_SETSIGDEF +POSIX_SPAWN_SETSIGMASK +POWER_4 +POWER_5 +POWER_6 +POWER_601 +POWER_603 +POWER_604 +POWER_620 +POWER_630 +POWER_7 +POWER_8 +POWER_9 +POWER_A35 +POWER_MPC7450 +POWER_PC +POWER_RS +POWER_RS1 +POWER_RS2 +POWER_RS64II +POWER_RS64III +POWER_RS64IV +POWER_RSC +PRIO_MAX +PRIO_MIN +PRIO_PGRP +PRIO_PROCESS +PRIO_USER +PROC_MODULE_INFO +PROT_EXEC +PROT_NONE +PROT_READ +PROT_WRITE +PS_ADD +PS_DELETE +PS_MOD +PS_REPLACE +PTHREAD_BARRIER_SERIAL_THREAD +PTHREAD_COND_INITIALIZER +PTHREAD_CREATE_DETACHED +PTHREAD_CREATE_JOINABLE +PTHREAD_MUTEX_DEFAULT +PTHREAD_MUTEX_ERRORCHECK +PTHREAD_MUTEX_INITIALIZER +PTHREAD_MUTEX_NORMAL +PTHREAD_MUTEX_RECURSIVE +PTHREAD_MUTEX_ROBUST +PTHREAD_MUTEX_STALLED +PTHREAD_ONCE_INIT +PTHREAD_PRIO_INHERIT +PTHREAD_PRIO_NONE +PTHREAD_PRIO_PROTECT +PTHREAD_PROCESS_PRIVATE +PTHREAD_PROCESS_SHARED +PTHREAD_RWLOCK_INITIALIZER +PTHREAD_STACK_MIN +PTRACE_ATTACH +PTRACE_CONT +PTRACE_DETACH +PTRACE_GETFPREGS +PTRACE_GETREGS +PTRACE_KILL +PTRACE_PEEKDATA +PTRACE_PEEKTEXT +PTRACE_PEEKUSER +PTRACE_POKEDATA +PTRACE_POKETEXT +PTRACE_POKEUSER +PTRACE_SETFPREGS +PTRACE_SETREGS +PTRACE_SINGLESTEP +PTRACE_SYSCALL +PTRACE_TRACEME +PTT_CLEAR_TRAP +PTT_CONTINUE +PTT_READ_FPRS +PTT_READ_FPSCR_HI +PTT_READ_GPRS +PTT_READ_SPRS +PTT_READ_TM +PTT_READ_UKEYSET +PTT_READ_VEC +PTT_READ_VSX +PTT_SET_TRAP +PTT_STEP +PTT_WATCH +PTT_WRITE_FPRS +PTT_WRITE_FPSCR_HI +PTT_WRITE_GPRS +PTT_WRITE_SPRS +PTT_WRITE_VEC +PTT_WRITE_VSX +PT_ATTACH +PT_CLEAR +PT_CONTINUE +PT_DETACH +PT_GET_UKEY +PT_KILL +PT_LDINFO +PT_LDXINFO +PT_MULTI +PT_NEXT +PT_QUERY +PT_READ_BLOCK +PT_READ_D +PT_READ_FPR +PT_READ_GPR +PT_READ_I +PT_REATT +PT_REGSET +PT_SET +PT_STEP +PT_TRACE_ME +PT_WATCH +PT_WRITE_BLOCK +PT_WRITE_D +PT_WRITE_FPR +PT_WRITE_GPR +PT_WRITE_I +P_ALL +P_PGID +P_PID +Q_GETQUOTA +Q_QUOTAOFF +Q_QUOTAON +Q_SETQLIM +Q_SETQUOTA +Q_SETUSE +Q_SYNC +RADIXCHAR +RAND_MAX +REG_BADBR +REG_BADPAT +REG_BADRPT +REG_EBOL +REG_EBRACE +REG_EBRACK +REG_ECHAR +REG_ECOLLATE +REG_ECTYPE +REG_EEOL +REG_EESCAPE +REG_ENOSYS +REG_EPAREN +REG_ERANGE +REG_ESPACE +REG_ESUBREG +REG_EXTENDED +REG_ICASE +REG_NEWLINE +REG_NOMATCH +REG_NOSUB +REG_NOTBOL +REG_NOTEOL +RLIMIT_AS +RLIMIT_CORE +RLIMIT_CPU +RLIMIT_DATA +RLIMIT_FSIZE +RLIMIT_NOFILE +RLIMIT_NPROC +RLIMIT_RSS +RLIMIT_STACK +RLIMIT_THREADS +RLIM_INFINITY +RLIM_NLIMITS +RLIM_SAVED_CUR +RLIM_SAVED_MAX +RTAX_AUTHOR +RTAX_BRD +RTAX_DST +RTAX_GATEWAY +RTAX_GENMASK +RTAX_IFA +RTAX_IFP +RTAX_MAX +RTAX_NETMASK +RTA_AUTHOR +RTA_BRD +RTA_DOWNSTREAM +RTA_DST +RTA_GATEWAY +RTA_GENMASK +RTA_IFA +RTA_IFP +RTA_NETMASK +RTF_ACTIVE_DGD +RTF_BCE +RTF_BLACKHOLE +RTF_BROADCAST +RTF_BUL +RTF_CACHED +RTF_CLONE +RTF_CLONED +RTF_CLONING +RTF_DONE +RTF_DYNAMIC +RTF_FREE_IN_PROG +RTF_GATEWAY +RTF_HOST +RTF_LLINFO +RTF_LOCAL +RTF_MASK +RTF_MODIFIED +RTF_MULTICAST +RTF_PERMANENT6 +RTF_PINNED +RTF_PROTO1 +RTF_PROTO2 +RTF_PROTO3 +RTF_REJECT +RTF_SMALLMTU +RTF_STATIC +RTF_STOPSRCH +RTF_UNREACHABLE +RTF_UP +RTF_XRESOLVE +RTLD_DEFAULT +RTLD_GLOBAL +RTLD_LAZY +RTLD_LOCAL +RTLD_MEMBER +RTLD_MYSELF +RTLD_NEXT +RTLD_NOAUTODEFER +RTLD_NOW +RTM_ADD +RTM_CHANGE +RTM_DELADDR +RTM_DELETE +RTM_EXPIRE +RTM_GET +RTM_GETNEXT +RTM_IFINFO +RTM_LOCK +RTM_LOSING +RTM_MISS +RTM_NEWADDR +RTM_OLDADD +RTM_OLDDEL +RTM_REDIRECT +RTM_RESOLVE +RTM_RTLOST +RTM_SAMEADDR +RTM_SET +RTV_EXPIRE +RTV_HOPCOUNT +RTV_MTU +RTV_RPIPE +RTV_RTT +RTV_RTTVAR +RTV_SPIPE +RTV_SSTHRESH +RUN_LVL +RUSAGE_CHILDREN +RUSAGE_SELF +RUSAGE_THREAD +R_OK +SA_NOCLDSTOP +SA_NOCLDWAIT +SA_NODEFER +SA_ONSTACK +SA_RESETHAND +SA_RESTART +SA_SIGINFO +SCHED_FIFO +SCHED_FIFO2 +SCHED_FIFO3 +SCHED_FIFO4 +SCHED_GLOBAL +SCHED_LOCAL +SCHED_OTHER +SCHED_RR +SCM_RIGHTS +SC_AME_STAT +SC_ARCH +SC_CAC_CONG +SC_CAPINC +SC_DFP_VER +SC_DISP_WHE +SC_DTLB_ATT +SC_DTLB_SZ +SC_ECO_STAT +SC_EC_LVL +SC_ENT_CAP +SC_IMPL +SC_ITLB_ATT +SC_ITLB_SZ +SC_KRN_ATTR +SC_L1C_ATTR +SC_L1C_DBS +SC_L1C_DCA +SC_L1C_DLS +SC_L1C_DSZ +SC_L1C_IBS +SC_L1C_ICA +SC_L1C_ILS +SC_L1C_ISZ +SC_L2C_AS +SC_L2C_SZ +SC_LMB_SZ +SC_MAX_NCPUS +SC_MAX_REALADDR +SC_MAX_XCPU +SC_MMA_VER +SC_MOD_ARCH +SC_MOD_IMPL +SC_NCPUS +SC_NX_CAP +SC_ORIG_ENT_CAP +SC_PHYSMEM +SC_PHYS_IMP +SC_PHYS_VER +SC_PKS_STATE +SC_PRI_LC +SC_PRO_LC +SC_RESRV_SZ +SC_RTC_TYPE +SC_SLB_ATTR +SC_SLB_SZ +SC_SMT_STAT +SC_SMT_TC +SC_SPCM_MAX +SC_SPCM_STATUS +SC_SPLP_STAT +SC_TLB_ATTR +SC_TM_VER +SC_VCAPW +SC_VERS +SC_VIRT_AL +SC_VMX_VER +SC_VRM_STAT +SC_WIDTH +SC_XFRAC +SC_XINT +SEEK_CUR +SEEK_END +SEEK_SET +SEGV_ACCERR +SEGV_KEYERR +SEGV_MAPERR +SEM_FAILED +SEM_UNDO +SETALL +SETVAL +SF_CLOSE +SF_DONT_CACHE +SF_REUSE +SF_SYNC_CACHE +SHMLBA +SHMLBA_EXTSHM +SHM_CLEAR +SHM_COPY +SHM_DEST +SHM_FMAP +SHM_HGSEG +SHM_LGPAGE +SHM_LOCK +SHM_MAP +SHM_PIN +SHM_R +SHM_RDONLY +SHM_RND +SHM_SHMAT +SHM_UNLOCK +SHM_W +SHUT_RD +SHUT_RDWR +SHUT_WR +SIGABRT +SIGALRM +SIGBUS +SIGCHLD +SIGCLD +SIGCONT +SIGEMT +SIGEV_NONE +SIGEV_SIGNAL +SIGEV_THREAD +SIGFPE +SIGHUP +SIGILL +SIGINT +SIGIO +SIGIOT +SIGKILL +SIGPIPE +SIGPOLL +SIGPROF +SIGPWR +SIGQUIT +SIGRTMAX +SIGRTMIN +SIGSEGV +SIGSTKSZ +SIGSTOP +SIGSYS +SIGTERM +SIGTRAP +SIGTSTP +SIGTTIN +SIGTTOU +SIGURG +SIGUSR1 +SIGUSR2 +SIGVTALRM +SIGWINCH +SIGXCPU +SIGXFSZ +SIG_BLOCK +SIG_DFL +SIG_ERR +SIG_IGN +SIG_SETMASK +SIG_UNBLOCK +SIOCADDMULTI +SIOCADDRT +SIOCDARP +SIOCDELMULTI +SIOCDELRT +SIOCDIFADDR +SIOCGARP +SIOCGIFADDR +SIOCGIFBRDADDR +SIOCGIFCONF +SIOCGIFDSTADDR +SIOCGIFFLAGS +SIOCGIFHWADDR +SIOCGIFMETRIC +SIOCGIFMTU +SIOCGIFNETMASK +SIOCSARP +SIOCSIFADDR +SIOCSIFBRDADDR +SIOCSIFDSTADDR +SIOCSIFFLAGS +SIOCSIFMETRIC +SIOCSIFMTU +SIOCSIFNETMASK +SI_ASYNCIO +SI_EMPTY +SI_MESGQ +SI_QUEUE +SI_TIMER +SI_UNDEFINED +SI_USER +SOCK_DGRAM +SOCK_RAW +SOCK_RDM +SOCK_SEQPACKET +SOCK_STREAM +SOL_SOCKET +SOMAXCONN +SO_ACCEPTCONN +SO_AUDIT +SO_BROADCAST +SO_CKSUMRECV +SO_DEBUG +SO_DONTROUTE +SO_ERROR +SO_KEEPALIVE +SO_KERNACCEPT +SO_LINGER +SO_NOMULTIPATH +SO_NOREUSEADDR +SO_OOBINLINE +SO_RCVBUF +SO_RCVLOWAT +SO_RCVTIMEO +SO_REUSEADDR +SO_REUSEPORT +SO_SNDBUF +SO_SNDLOWAT +SO_SNDTIMEO +SO_TIMESTAMPNS +SO_TYPE +SO_USELOOPBACK +SO_USE_IFBUFS +SS_DISABLE +SS_ONSTACK +STDERR_FILENO +STDIN_FILENO +STDOUT_FILENO +ST_NODEV +ST_NOSUID +ST_RDONLY +S_IEXEC +S_IFBLK +S_IFCHR +S_IFDIR +S_IFIFO +S_IFLNK +S_IFMT +S_IFREG +S_IFSOCK +S_IREAD +S_IRGRP +S_IROTH +S_IRUSR +S_IRWXG +S_IRWXO +S_IRWXU +S_ISGID +S_ISUID +S_ISVTX +S_IWGRP +S_IWOTH +S_IWRITE +S_IWUSR +S_IXGRP +S_IXOTH +S_IXUSR +TAB0 +TAB1 +TAB2 +TAB3 +TABDLY +TANDEM +TCFLSH +TCGETA +TCGETS +TCIFLUSH +TCIOFF +TCIOFLUSH +TCION +TCOFLUSH +TCOOFF +TCOON +TCP_KEEPALIVE +TCP_KEEPCNT +TCP_KEEPIDLE +TCP_KEEPINTVL +TCP_MAXSEG +TCP_NODELAY +TCP_NODELAYACK +TCP_RFC1323 +TCSADRAIN +TCSAFLUSH +TCSANOW +TCSBRK +TCSETA +TCSETAF +TCSETAW +TCSETS +TCSETSF +TCSETSW +TCXONC +THOUSEP +TIMEOFDAY +TIMER_ABSTIME +TIOC +TIOCCBRK +TIOCCDTR +TIOCCONS +TIOCEXCL +TIOCFLUSH +TIOCGETC +TIOCGETD +TIOCGETP +TIOCGLTC +TIOCGPGRP +TIOCGSID +TIOCGWINSZ +TIOCHPCL +TIOCLBIC +TIOCLBIS +TIOCLGET +TIOCLSET +TIOCMBIC +TIOCMBIS +TIOCMGET +TIOCMODG +TIOCMODS +TIOCMSET +TIOCM_CAR +TIOCM_CD +TIOCM_CTS +TIOCM_DSR +TIOCM_DTR +TIOCM_LE +TIOCM_RI +TIOCM_RNG +TIOCM_RTS +TIOCM_SR +TIOCM_ST +TIOCNOTTY +TIOCNXCL +TIOCOUTQ +TIOCPKT +TIOCPKT_DATA +TIOCPKT_DOSTOP +TIOCPKT_FLUSHREAD +TIOCPKT_FLUSHWRITE +TIOCPKT_NOSTOP +TIOCPKT_START +TIOCPKT_STOP +TIOCREMOTE +TIOCSBRK +TIOCSDTR +TIOCSETC +TIOCSETD +TIOCSETN +TIOCSETP +TIOCSLTC +TIOCSPGRP +TIOCSTART +TIOCSTI +TIOCSTOP +TIOCSWINSZ +TIOCUCNTL +TMP_MAX +TOSTOP +TRAP_BRKPT +TRAP_TRACE +T_FMT +T_FMT_AMPM +UF_SYSTEM +UIO_MAXIOV +USER_PROCESS +USRQUOTA +UTIME_NOW +UTIME_OMIT +VDISCRD +VDSUSP +VEOF +VEOL +VEOL2 +VERASE +VINTR +VKILL +VLNEXT +VMIN +VQUIT +VREPRINT +VSTART +VSTOP +VSUSP +VT0 +VT1 +VTDLY +VTIME +VWERSE +WCONTINUED +WCOREDUMP +WEXITED +WEXITSTATUS +WIFCONTINUED +WIFEXITED +WIFSIGNALED +WIFSTOPPED +WNOHANG +WNOWAIT +WPAR_INFO_FORMAT +WSTOPPED +WSTOPSIG +WTERMSIG +WUNTRACED +W_OK +XCASE +XTABS +X_OK +YESEXPR +YESSTR +_Errno +_IOFBF +_IOLBF +_IONBF +_PC_2_SYMLINKS +_PC_ALLOC_SIZE_MIN +_PC_ASYNC_IO +_PC_CHOWN_RESTRICTED +_PC_FILESIZEBITS +_PC_LINK_MAX +_PC_MAX_CANON +_PC_MAX_INPUT +_PC_NAME_MAX +_PC_NO_TRUNC +_PC_PATH_MAX +_PC_PIPE_BUF +_PC_PRIO_IO +_PC_REC_INCR_XFER_SIZE +_PC_REC_MAX_XFER_SIZE +_PC_REC_MIN_XFER_SIZE +_PC_REC_XFER_ALIGN +_PC_SYMLINK_MAX +_PC_SYNC_IO +_PC_TIMESTAMP_RESOLUTION +_PC_VDISABLE +_POSIX_VDISABLE +_SC_2_CHAR_TERM +_SC_2_C_BIND +_SC_2_C_DEV +_SC_2_C_VERSION +_SC_2_FORT_DEV +_SC_2_FORT_RUN +_SC_2_LOCALEDEF +_SC_2_PBS +_SC_2_PBS_ACCOUNTING +_SC_2_PBS_CHECKPOINT +_SC_2_PBS_LOCATE +_SC_2_PBS_MESSAGE +_SC_2_PBS_TRACK +_SC_2_SW_DEV +_SC_2_UPE +_SC_2_VERSION +_SC_ADVISORY_INFO +_SC_AIO_LISTIO_MAX +_SC_AIO_MAX +_SC_AIO_PRIO_DELTA_MAX +_SC_ARG_MAX +_SC_ASYNCHRONOUS_IO +_SC_ATEXIT_MAX +_SC_AVPHYS_PAGES +_SC_BARRIERS +_SC_BC_BASE_MAX +_SC_BC_DIM_MAX +_SC_BC_SCALE_MAX +_SC_BC_STRING_MAX +_SC_CHILD_MAX +_SC_CLK_TCK +_SC_CLOCK_SELECTION +_SC_COLL_WEIGHTS_MAX +_SC_CPUTIME +_SC_DELAYTIMER_MAX +_SC_EXPR_NEST_MAX +_SC_FSYNC +_SC_GETGR_R_SIZE_MAX +_SC_GETPW_R_SIZE_MAX +_SC_HOST_NAME_MAX +_SC_IOV_MAX +_SC_IPV6 +_SC_JOB_CONTROL +_SC_LINE_MAX +_SC_LOGIN_NAME_MAX +_SC_MAPPED_FILES +_SC_MEMLOCK +_SC_MEMLOCK_RANGE +_SC_MEMORY_PROTECTION +_SC_MESSAGE_PASSING +_SC_MONOTONIC_CLOCK +_SC_MQ_OPEN_MAX +_SC_MQ_PRIO_MAX +_SC_NGROUPS_MAX +_SC_NPROCESSORS_CONF +_SC_NPROCESSORS_ONLN +_SC_OPEN_MAX +_SC_PAGESIZE +_SC_PAGE_SIZE +_SC_PASS_MAX +_SC_PHYS_PAGES +_SC_PRIORITIZED_IO +_SC_PRIORITY_SCHEDULING +_SC_RAW_SOCKETS +_SC_READER_WRITER_LOCKS +_SC_REALTIME_SIGNALS +_SC_REGEXP +_SC_RE_DUP_MAX +_SC_RTSIG_MAX +_SC_SAVED_IDS +_SC_SEMAPHORES +_SC_SEM_NSEMS_MAX +_SC_SEM_VALUE_MAX +_SC_SHARED_MEMORY_OBJECTS +_SC_SHELL +_SC_SIGQUEUE_MAX +_SC_SPAWN +_SC_SPIN_LOCKS +_SC_SPORADIC_SERVER +_SC_SS_REPL_MAX +_SC_STREAM_MAX +_SC_SYMLOOP_MAX +_SC_SYNCHRONIZED_IO +_SC_THREADS +_SC_THREAD_ATTR_STACKADDR +_SC_THREAD_ATTR_STACKSIZE +_SC_THREAD_CPUTIME +_SC_THREAD_DESTRUCTOR_ITERATIONS +_SC_THREAD_KEYS_MAX +_SC_THREAD_PRIORITY_SCHEDULING +_SC_THREAD_PRIO_INHERIT +_SC_THREAD_PRIO_PROTECT +_SC_THREAD_PROCESS_SHARED +_SC_THREAD_SAFE_FUNCTIONS +_SC_THREAD_SPORADIC_SERVER +_SC_THREAD_STACK_MIN +_SC_THREAD_THREADS_MAX +_SC_TIMEOUTS +_SC_TIMERS +_SC_TIMER_MAX +_SC_TRACE +_SC_TRACE_EVENT_FILTER +_SC_TRACE_EVENT_NAME_MAX +_SC_TRACE_INHERIT +_SC_TRACE_LOG +_SC_TRACE_NAME_MAX +_SC_TRACE_SYS_MAX +_SC_TRACE_USER_EVENT_MAX +_SC_TTY_NAME_MAX +_SC_TYPED_MEMORY_OBJECTS +_SC_TZNAME_MAX +_SC_T_IOV_MAX +_SC_V6_ILP32_OFF32 +_SC_V6_ILP32_OFFBIG +_SC_V6_LP64_OFF64 +_SC_V6_LPBIG_OFFBIG +_SC_VERSION +_SC_XBS5_ILP32_OFF32 +_SC_XBS5_ILP32_OFFBIG +_SC_XBS5_LP64_OFF64 +_SC_XBS5_LPBIG_OFFBIG +_SC_XOPEN_CRYPT +_SC_XOPEN_ENH_I18N +_SC_XOPEN_LEGACY +_SC_XOPEN_REALTIME +_SC_XOPEN_REALTIME_THREADS +_SC_XOPEN_SHM +_SC_XOPEN_STREAMS +_SC_XOPEN_UNIX +_SC_XOPEN_VERSION +_SC_XOPEN_XCU_VERSION +_W_SEWTED +_W_SFWTED +_W_SLWTED +_W_STOPPED +_W_STRC +__context64 +__extctx_t +__pollfd_ext_u +__tm_context_t +__vmx_context_t +__vmxreg_t +__vsx_context_t +_exit +abort +accept +access +acct +addrinfo +aio_cancel +aio_error +aio_fsync +aio_read +aio_return +aio_suspend +aio_write +aiocb +alarm +aligned_alloc +atexit +atof +atoi +atol +atoll +basename +bind +blkcnt_t +blksize_t +brk +c_char +c_double +c_float +c_int +c_long +c_longlong +c_schar +c_short +c_uchar +c_uint +c_ulong +c_ulonglong +c_ushort +c_void +calloc +cc_t +cfgetispeed +cfgetospeed +cfmakeraw +cfsetispeed +cfsetospeed +cfsetspeed +chdir +chmod +chown +clearenv +clock_getcpuclockid +clock_getres +clock_gettime +clock_nanosleep +clock_settime +clock_t +clockid_t +close +closedir +closelog +cmsghdr +confstr +connect +creat +creat64 +ctermid +dev_t +dirent +dirfd +dirname +dlclose +dlerror +dlopen +dlsym +drand48 +dup +dup2 +duplocale +endgrent +endmntent +endpwent +endutent +endutxent +entry +erand48 +execl +execle +execlp +execv +execve +execvp +exit +exit_status +faccessat +fattach +fchmod +fchmodat +fchown +fchownat +fclose +fcntl +fd_set +fdatasync +fdopen +feof +ferror +fexecve +fflush +ffs +ffsl +ffsll +fgetc +fgetgrent +fgetpos +fgetpos64 +fgetpwent +fgets +fileno +flock +flock64 +fnmatch +fopen +fopen64 +fork +fpathconf +fpos_t +fpreg_t +fprintf +fputc +fputs +fread +free +freeaddrinfo +freelocale +freopen +freopen64 +fsblkcnt_t +fscanf +fseek +fseeko +fseeko64 +fsetpos +fsetpos64 +fsfilcnt_t +fsid64_t +fsid_t +fstat +fstat64 +fstatat +fstatfs +fstatfs64 +fstatvfs +fstatvfs64 +fsync +ftell +ftello +ftello64 +ftok +ftruncate +ftruncate64 +futimens +fwrite +gai_strerror +getaddrinfo +getchar +getchar_unlocked +getcontext +getcwd +getdomainname +getdtablesize +getegid +getenv +geteuid +getgid +getgrent +getgrgid +getgrgid_r +getgrnam +getgrnam_r +getgroups +getgrset +gethostid +gethostname +getitimer +getlogin +getmntent +getnameinfo +getopt +getpagesize +getpeername +getpgid +getpgrp +getpid +getppid +getpriority +getprotobyname +getprotobynumber +getpwent +getpwnam +getpwnam_r +getpwuid +getpwuid_r +getrlimit +getrlimit64 +getservbyname +getsockname +getsockopt +getsystemcfg +gettimeofday +getuid +getutent +getutid +getutline +getutxent +getutxid +getutxline +gid_t +glob +glob_t +globfree +gmtime +gmtime_r +grantpt +group +hasmntopt +hcreate +hdestroy +hostent +hsearch +hstrerror +htonl +htons +iconv +iconv_close +iconv_open +idtype_t +if_freenameindex +if_indextoname +if_nameindex +if_nametoindex +in6_addr +in6addr_any +in6addr_loopback +in_addr +in_addr_t +in_port_t +initgroups +ino_t +int16_t +int32_t +int64_t +int8_t +intmax_t +intptr_t +ioctl +iovec +ip_mreq +ip_mreq_source +ipc_perm +ipv6_mreq +isalnum +isalpha +isatty +isblank +iscntrl +isdigit +isgraph +islower +isprint +ispunct +isspace +isupper +isxdigit +itimerspec +itimerval +jrand48 +kill +lchown +lcong48 +lconv +lfind +linger +link +linkat +lio_listio +listen +loadquery +locale_t +localeconv +localtime +localtime_r +lpar_get_info +lpar_set_resources +lrand48 +lsearch +lseek +lseek64 +lstat +lstat64 +madvise +makecontext +mallinfo +malloc +mallopt +mcontext_t +memccpy +memchr +memcmp +memcpy +memmem +memmove +memset +memset_s +mincore +mkdir +mkdtemp +mkfifo +mkfifoat +mknod +mknodat +mkstemp +mktime +mlock +mlockall +mmap +mmsghdr +mntent +mode_t +mprotect +mq_attr +mq_close +mq_getattr +mq_notify +mq_open +mq_receive +mq_send +mq_setattr +mq_timedreceive +mq_timedsend +mq_unlink +mrand48 +msgctl +msgget +msghdr +msgrcv +msgsnd +msqid_ds +msync +munlock +munlockall +munmap +nanosleep +newlocale +nfds_t +nl_langinfo +nl_langinfo_l +nlink_t +nrand48 +ntohl +ntohs +off_t +open +open64 +opendir +openlog +osigevent +passwd +pathconf +pclose +perror +pid_t +pipe +poll +poll_ctl +poll_ctl_ext +pollfd +pollfd_ext +pollset_create +pollset_ctl +pollset_destroy +pollset_poll +pollset_query +popen +posix_fadvise +posix_fadvise64 +posix_fallocate +posix_fallocate64 +posix_madvise +posix_memalign +posix_openpt +posix_spawn +posix_spawn_file_actions_addclose +posix_spawn_file_actions_adddup2 +posix_spawn_file_actions_addopen +posix_spawn_file_actions_destroy +posix_spawn_file_actions_init +posix_spawnattr_destroy +posix_spawnattr_getflags +posix_spawnattr_getpgroup +posix_spawnattr_getschedparam +posix_spawnattr_getschedpolicy +posix_spawnattr_getsigdefault +posix_spawnattr_getsigmask +posix_spawnattr_init +posix_spawnattr_setflags +posix_spawnattr_setpgroup +posix_spawnattr_setschedparam +posix_spawnattr_setschedpolicy +posix_spawnattr_setsigdefault +posix_spawnattr_setsigmask +posix_spawnattr_t +posix_spawnp +pread +pread64 +preadv +printf +protoent +pselect +pseudo_AF_XTP +pthread_atfork +pthread_attr_destroy +pthread_attr_getdetachstate +pthread_attr_getguardsize +pthread_attr_getinheritsched +pthread_attr_getschedparam +pthread_attr_getschedpolicy +pthread_attr_getscope +pthread_attr_getstack +pthread_attr_getstackaddr +pthread_attr_getstacksize +pthread_attr_init +pthread_attr_setdetachstate +pthread_attr_setguardsize +pthread_attr_setinheritsched +pthread_attr_setschedparam +pthread_attr_setschedpolicy +pthread_attr_setscope +pthread_attr_setstack +pthread_attr_setstackaddr +pthread_attr_setstacksize +pthread_attr_t +pthread_barrier_destroy +pthread_barrier_init +pthread_barrier_t +pthread_barrier_wait +pthread_barrierattr_destroy +pthread_barrierattr_getpshared +pthread_barrierattr_init +pthread_barrierattr_setpshared +pthread_cancel +pthread_cleanup_pop +pthread_cleanup_push +pthread_cond_broadcast +pthread_cond_destroy +pthread_cond_init +pthread_cond_signal +pthread_cond_t +pthread_cond_timedwait +pthread_cond_wait +pthread_condattr_destroy +pthread_condattr_getclock +pthread_condattr_getpshared +pthread_condattr_init +pthread_condattr_setclock +pthread_condattr_setpshared +pthread_condattr_t +pthread_create +pthread_detach +pthread_equal +pthread_exit +pthread_getconcurrency +pthread_getcpuclockid +pthread_getschedparam +pthread_getspecific +pthread_join +pthread_key_create +pthread_key_delete +pthread_key_t +pthread_kill +pthread_mutex_consistent +pthread_mutex_destroy +pthread_mutex_getprioceiling +pthread_mutex_init +pthread_mutex_lock +pthread_mutex_setprioceiling +pthread_mutex_t +pthread_mutex_timedlock +pthread_mutex_trylock +pthread_mutex_unlock +pthread_mutexattr_destroy +pthread_mutexattr_getprioceiling +pthread_mutexattr_getprotocol +pthread_mutexattr_getpshared +pthread_mutexattr_getrobust +pthread_mutexattr_gettype +pthread_mutexattr_init +pthread_mutexattr_setprioceiling +pthread_mutexattr_setprotocol +pthread_mutexattr_setpshared +pthread_mutexattr_setrobust +pthread_mutexattr_settype +pthread_mutexattr_t +pthread_once +pthread_once_t +pthread_rwlock_destroy +pthread_rwlock_init +pthread_rwlock_rdlock +pthread_rwlock_t +pthread_rwlock_timedrdlock +pthread_rwlock_timedwrlock +pthread_rwlock_tryrdlock +pthread_rwlock_trywrlock +pthread_rwlock_unlock +pthread_rwlock_wrlock +pthread_rwlockattr_destroy +pthread_rwlockattr_getpshared +pthread_rwlockattr_init +pthread_rwlockattr_setpshared +pthread_rwlockattr_t +pthread_self +pthread_setcancelstate +pthread_setcanceltype +pthread_setconcurrency +pthread_setschedparam +pthread_setschedprio +pthread_setspecific +pthread_sigmask +pthread_spin_destroy +pthread_spin_init +pthread_spin_lock +pthread_spin_trylock +pthread_spin_unlock +pthread_spinlock_t +pthread_t +pthread_testcancel +ptrace64 +ptrdiff_t +ptsname +putchar +putchar_unlocked +putenv +puts +pututline +pututxline +pwrite +pwrite64 +pwritev +quotactl +raise +rand +read +readdir +readlink +readv +realloc +realpath +recv +recvfrom +recvmsg +regcomp +regerror +regex_t +regexec +regfree +regmatch_t +remove +rename +renameat +res_init +rewind +rewinddir +rlim_t +rlimit +rlimit64 +rmdir +rusage +sa_family_t +sbrk +scanf +sched_get_priority_max +sched_get_priority_min +sched_getparam +sched_getscheduler +sched_param +sched_rr_get_interval +sched_setparam +sched_setscheduler +sched_yield +seed48 +seekdir +select +sem_close +sem_destroy +sem_getvalue +sem_init +sem_open +sem_post +sem_t +sem_timedwait +sem_trywait +sem_unlink +sem_wait +sembuf +semctl +semget +semop +send +send_file +sendmsg +sendto +servent +setbuf +setcontext +setdomainname +setegid +setenv +seteuid +setgid +setgrent +setgroups +setitimer +setlocale +setlogmask +setmntent +setpgid +setpriority +setpwent +setregid +setreuid +setrlimit +setrlimit64 +setsid +setsockopt +settimeofday +setuid +setutent +setutxent +setvbuf +sf_parms +shm_open +shm_unlink +shmat +shmctl +shmdt +shmget +shmid_ds +shutdown +sigaction +sigaddset +sigaltstack +sigdelset +sigemptyset +sigevent +sigfillset +sighandler_t +siginfo_t +sigismember +signal +sigpending +sigprocmask +sigset_t +sigsuspend +sigtimedwait +sigval +sigwait +sigwaitinfo +size_t +sleep +snprintf +sockaddr +sockaddr_dl +sockaddr_in +sockaddr_in6 +sockaddr_storage +sockaddr_un +socket +socketpair +socklen_t +speed_t +sprintf +srand +srand48 +sscanf +ssize_t +st_timespec +stack_t +stat +stat64 +stat64at +statfs +statfs64 +statvfs +statvfs64 +statx +strcasecmp_l +strcat +strchr +strcmp +strcoll +strcpy +strcspn +strdup +strerror +strerror_r +strftime +strlen +strncasecmp_l +strncat +strncmp +strncpy +strnlen +strpbrk +strptime +strrchr +strsep +strspn +strstr +strtod +strtof +strtok +strtol +strtoll +strtoul +strtoull +strxfrm +suseconds_t +swapcontext +swapoff +swapon +symlink +symlinkat +sync +sysconf +syslog +system +tcdrain +tcflag_t +tcflow +tcflush +tcgetattr +tcgetpgrp +tcgetsid +tcsendbreak +tcsetattr +tcsetpgrp +telldir +termios +thr_kill +thr_self +time +time_t +timer_create +timer_delete +timer_getoverrun +timer_gettime +timer_settime +times +timespec +timeval +timezone +tm +tmpfile +tmpnam +tms +tolower +toupper +truncate64 +ttyname +ucontext_t +uid_t +uint16_t +uint32_t +uint64_t +uint8_t +uintmax_t +uintptr_t +uio_rw +umask +uname +ungetc +unlink +unlinkat +unlockpt +unsetenv +updwtmp +uselocale +usleep +utimbuf +utime +utimensat +utimes +utmp +utmpname +utmpx +utsname +wait +wait4 +waitid +waitpid +wchar_t +wcslen +wcstombs +wmemchr +write +writev +xutsname diff --git a/libc-test/test/cmsg.rs b/libc-test/test/cmsg.rs index 130b143cf9dbd..15f4fed1e30ec 100644 --- a/libc-test/test/cmsg.rs +++ b/libc-test/test/cmsg.rs @@ -68,10 +68,14 @@ mod t { mhdr.msg_control = pcmsghdr as *mut c_void; mhdr.msg_controllen = (160 - start_ofs) as _; for cmsg_len in 0..64 { + // Address must be a multiple of 0x4 for testing on AIX. + if cfg!(target_os = "aix") && cmsg_len % std::mem::size_of::() != 0 { + continue; + } for next_cmsg_len in 0..32 { unsafe { pcmsghdr.cast::().write_bytes(0, CAPACITY); - (*pcmsghdr).cmsg_len = cmsg_len; + (*pcmsghdr).cmsg_len = cmsg_len as _; let libc_next = libc::CMSG_NXTHDR(&mhdr, pcmsghdr); let next = cmsg_nxthdr(&mhdr, pcmsghdr); assert_eq!(libc_next, next); diff --git a/libc-test/test/makedev.rs b/libc-test/test/makedev.rs index 6cf180975b8c0..1c08776d7260f 100644 --- a/libc-test/test/makedev.rs +++ b/libc-test/test/makedev.rs @@ -24,7 +24,6 @@ cfg_if::cfg_if! { target_os = "l4re", target_os = "emscripten", target_os = "fuchsia", - target_os = "aix", target_os = "nto", target_os = "hurd", target_os = "openbsd", diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index a8bfca7d2266f..f06d475565cfd 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -1,4 +1,5 @@ use crate::prelude::*; +use crate::{in_addr_t, in_port_t}; pub type caddr_t = *mut c_char; pub type clockid_t = c_longlong; @@ -9,7 +10,6 @@ pub type dev_t = c_ulong; pub type fpos64_t = c_longlong; pub type fsblkcnt_t = c_ulong; pub type fsfilcnt_t = c_ulong; -pub type idtype_t = c_int; pub type ino_t = c_ulong; pub type key_t = c_int; pub type mode_t = c_uint; @@ -18,25 +18,23 @@ pub type rlim_t = c_ulong; pub type speed_t = c_uint; pub type tcflag_t = c_uint; pub type time_t = c_long; -pub type time64_t = crate::int64_t; +pub type time64_t = i64; pub type timer_t = c_long; pub type wchar_t = c_uint; -pub type nfds_t = c_int; +pub type nfds_t = c_uint; pub type projid_t = c_int; pub type id_t = c_uint; pub type blksize64_t = c_ulonglong; pub type blkcnt64_t = c_ulonglong; -pub type sctp_assoc_t = crate::uint32_t; - pub type suseconds_t = c_int; pub type useconds_t = c_uint; pub type off_t = c_long; +pub type offset_t = c_longlong; pub type off64_t = c_longlong; +pub type idtype_t = c_uint; pub type socklen_t = c_uint; pub type sa_family_t = c_uchar; -pub type in_port_t = c_ushort; -pub type in_addr_t = c_uint; pub type signal_t = c_int; pub type pthread_t = c_uint; @@ -69,6 +67,11 @@ e! { UIO_WRITE_NO_MOVE, UIO_PWRITE, } + #[repr(u32)] + pub enum ACTION { + FIND = 0, + ENTER, + } } s! { @@ -228,7 +231,7 @@ s! { pub sin_family: sa_family_t, pub sin_port: in_port_t, pub sin_addr: in_addr, - pub sin_zero: [c_char; 8], + pub sin_zero: [c_uchar; 8], } pub struct sockaddr_in6 { @@ -318,19 +321,6 @@ s! { pub sigev_notify_attributes: *mut pthread_attr_t, } - // Should be union with another 'sival_int' - pub struct sigval64 { - pub sival_ptr: c_ulonglong, - } - - pub struct sigevent64 { - pub sigev_value: sigval64, - pub sigev_signo: c_int, - pub sigev_notify: c_int, - pub sigev_notify_function: c_ulonglong, - pub sigev_notify_attributes: c_ulonglong, - } - pub struct osigevent { pub sevt_value: *mut c_void, pub sevt_signo: signal_t, @@ -402,7 +392,7 @@ s! { pub keepcost: c_int, } - pub struct utmp_exit_status { + pub struct exit_status { pub e_termination: c_short, pub e_exit: c_short, } @@ -414,7 +404,7 @@ s! { pub ut_pid: crate::pid_t, pub ut_type: c_short, pub ut_time: time64_t, - pub ut_exit: utmp_exit_status, + pub ut_exit: exit_status, pub ut_host: [c_char; 256], pub __dbl_word_pad: c_int, pub __reservedA: [c_int; 2], @@ -459,7 +449,7 @@ s! { pub shm_extshm: c_int, pub shm_pagesize: crate::int64_t, pub shm_lba: crate::uint64_t, - pub shm_reserved: crate::int64_t, + pub shm_reserved0: crate::int64_t, pub shm_reserved1: crate::int64_t, } @@ -554,7 +544,7 @@ s_no_extra_traits! { pub events: c_short, pub fd: c_int, pub u: __poll_ctl_ext_u, - pub reversed64: [u64; 6], + pub reserved64: [u64; 6], } } @@ -586,7 +576,7 @@ cfg_if! { && self.command == other.command && self.events == other.events && self.fd == other.fd - && self.reversed64 == other.reversed64 + && self.reserved64 == other.reserved64 && self.u == other.u } } @@ -599,7 +589,7 @@ cfg_if! { .field("events", &self.events) .field("fd", &self.fd) .field("u", &self.u) - .field("reversed64", &self.reversed64) + .field("reserved64", &self.reserved64) .finish() } } @@ -610,7 +600,7 @@ cfg_if! { self.events.hash(state); self.fd.hash(state); self.u.hash(state); - self.reversed64.hash(state); + self.reserved64.hash(state); } } } @@ -643,33 +633,33 @@ pub const O_DIRECTORY: c_int = 0x80000; pub const O_SEARCH: c_int = 0x20; pub const O_EXEC: c_int = 0x20; pub const O_CLOEXEC: c_int = 0x800000; -pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR; +pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH; pub const O_DIRECT: c_int = 0x8000000; pub const O_TTY_INIT: c_int = 0; pub const O_RSYNC: c_int = 0x200000; pub const O_LARGEFILE: c_int = 0x4000000; -pub const F_CLOSEM: c_int = 10; +pub const F_DUPFD: c_int = 0; pub const F_DUPFD_CLOEXEC: c_int = 16; -pub const F_GETLK64: c_int = 11; -pub const F_SETLK64: c_int = 12; -pub const F_SETLKW64: c_int = 13; -pub const F_DUP2FD: c_int = 14; -pub const F_TSTLK: c_int = 15; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; pub const F_GETLK: c_int = F_GETLK64; pub const F_SETLK: c_int = F_SETLK64; pub const F_SETLKW: c_int = F_SETLKW64; pub const F_GETOWN: c_int = 8; pub const F_SETOWN: c_int = 9; +pub const F_CLOSEM: c_int = 10; +pub const F_GETLK64: c_int = 11; +pub const F_SETLK64: c_int = 12; +pub const F_SETLKW64: c_int = 13; +pub const F_DUP2FD: c_int = 14; +pub const F_TSTLK: c_int = 15; pub const AT_FDCWD: c_int = -2; pub const AT_SYMLINK_NOFOLLOW: c_int = 1; pub const AT_SYMLINK_FOLLOW: c_int = 2; pub const AT_REMOVEDIR: c_int = 1; pub const AT_EACCESS: c_int = 1; -pub const F_DUPFD: c_int = 0; -pub const F_GETFD: c_int = 1; -pub const F_SETFD: c_int = 2; -pub const F_GETFL: c_int = 3; -pub const F_SETFL: c_int = 4; pub const O_SYNC: c_int = 16; pub const O_NONBLOCK: c_int = 4; pub const FASYNC: c_int = 0x20000; @@ -754,25 +744,25 @@ pub const NOEXPR: crate::nl_item = 62; // locale.h pub const LC_GLOBAL_LOCALE: crate::locale_t = -1isize as crate::locale_t; +pub const LC_COLLATE: c_int = 0; pub const LC_CTYPE: c_int = 1; +pub const LC_MONETARY: c_int = 2; pub const LC_NUMERIC: c_int = 3; pub const LC_TIME: c_int = 4; -pub const LC_COLLATE: c_int = 0; -pub const LC_MONETARY: c_int = 2; -pub const LC_MESSAGES: c_int = 4; +pub const LC_MESSAGES: c_int = 5; pub const LC_ALL: c_int = -1; +pub const LC_COLLATE_MASK: c_int = 1; pub const LC_CTYPE_MASK: c_int = 2; +pub const LC_MESSAGES_MASK: c_int = 4; +pub const LC_MONETARY_MASK: c_int = 8; pub const LC_NUMERIC_MASK: c_int = 16; pub const LC_TIME_MASK: c_int = 32; -pub const LC_COLLATE_MASK: c_int = 1; -pub const LC_MONETARY_MASK: c_int = 8; -pub const LC_MESSAGES_MASK: c_int = 4; -pub const LC_ALL_MASK: c_int = LC_CTYPE_MASK - | LC_NUMERIC_MASK - | LC_TIME_MASK - | LC_COLLATE_MASK +pub const LC_ALL_MASK: c_int = LC_COLLATE_MASK + | LC_CTYPE_MASK + | LC_MESSAGES_MASK | LC_MONETARY_MASK - | LC_MESSAGES_MASK; + | LC_NUMERIC_MASK + | LC_TIME_MASK; // netdb.h pub const NI_MAXHOST: crate::socklen_t = 1025; @@ -808,8 +798,11 @@ pub const IPV6_ADDR_PREFERENCES: c_int = 74; pub const IPV6_CHECKSUM: c_int = 39; pub const IPV6_DONTFRAG: c_int = 45; pub const IPV6_DSTOPTS: c_int = 54; -pub const IPV6_FLOWINFO_FLOWLABEL: c_int = 16777215; -pub const IPV6_FLOWINFO_PRIORITY: c_int = 251658240; +pub const IPV6_FLOWINFO_FLOWLABEL: c_int = 0x00ffffff; +pub const IPV6_FLOWINFO_PRIORITY: c_int = 0x0f000000; +pub const IPV6_FLOWINFO_PRIFLOW: c_int = 0x0fffffff; +pub const IPV6_FLOWINFO_SRFLAG: c_int = 0x10000000; +pub const IPV6_FLOWINFO_VERSION: c_int = 0xf0000000; pub const IPV6_HOPLIMIT: c_int = 40; pub const IPV6_HOPOPTS: c_int = 52; pub const IPV6_NEXTHOP: c_int = 48; @@ -844,20 +837,20 @@ pub const DLT_PPP: c_int = 0x17; pub const DLT_FDDI: c_int = 0xf; pub const DLT_ATM: c_int = 0x25; pub const DLT_IPOIB: c_int = 0xc7; -pub const BIOCSETF: c_ulong = 0x80104267; -pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; -pub const BIOCGBLEN: c_int = 0x40044266; -pub const BIOCSBLEN: c_int = 0xc0044266; -pub const BIOCFLUSH: c_int = 0x20004268; -pub const BIOCPROMISC: c_int = 0x20004269; -pub const BIOCGDLT: c_int = 0x4004426a; -pub const BIOCSRTIMEOUT: c_int = 0x8010426d; -pub const BIOCGSTATS: c_int = 0x4008426f; -pub const BIOCIMMEDIATE: c_int = 0x80044270; -pub const BIOCVERSION: c_int = 0x40044271; -pub const BIOCSDEVNO: c_int = 0x20004272; -pub const BIOCGETIF: c_ulong = 0x4020426b; -pub const BIOCSETIF: c_ulong = 0xffffffff8020426c; +pub const BIOCSETF: c_long = -2146418073; +pub const BIOCGRTIMEOUT: c_long = 1074807406; +pub const BIOCGBLEN: c_long = 1074020966; +pub const BIOCSBLEN: c_long = -1073462682; +pub const BIOCFLUSH: c_long = 536887912; +pub const BIOCPROMISC: c_long = 536887913; +pub const BIOCGDLT: c_long = 1074020970; +pub const BIOCSRTIMEOUT: c_long = -2146418067; +pub const BIOCGSTATS: c_long = 1074283119; +pub const BIOCIMMEDIATE: c_long = -2147204496; +pub const BIOCVERSION: c_long = 1074020977; +pub const BIOCSDEVNO: c_long = 536887922; +pub const BIOCGETIF: c_long = 1075855979; +pub const BIOCSETIF: c_long = -2145369492; pub const BPF_ABS: c_int = 32; pub const BPF_ADD: c_int = 0; pub const BPF_ALIGNMENT: c_ulong = 4; @@ -1024,7 +1017,6 @@ pub const IPPROTO_SCTP: c_int = 132; pub const IPPROTO_MH: c_int = 135; pub const IPPROTO_GIF: c_int = 140; pub const IPPROTO_RAW: c_int = 255; -pub const IPPROTO_MAX: c_int = 256; pub const IP_OPTIONS: c_int = 1; pub const IP_HDRINCL: c_int = 2; pub const IP_TOS: c_int = 3; @@ -1121,7 +1113,7 @@ pub const TCP_KEEPCNT: c_int = 0x13; pub const TCP_NODELAYACK: c_int = 0x14; // pthread.h -pub const PTHREAD_BARRIER_SERIAL_THREAD: c_int = -1; +pub const PTHREAD_BARRIER_SERIAL_THREAD: c_int = 2; pub const PTHREAD_CREATE_JOINABLE: c_int = 0; pub const PTHREAD_CREATE_DETACHED: c_int = 1; pub const PTHREAD_PROCESS_SHARED: c_int = 0; @@ -1163,17 +1155,18 @@ pub const REG_EEOL: c_int = 16; pub const REG_ENOSYS: c_int = 17; // rpcsvc/mount.h -pub const NFSMNT_ACDIRMAX: c_int = 2048; -pub const NFSMNT_ACDIRMIN: c_int = 1024; -pub const NFSMNT_ACREGMAX: c_int = 512; -pub const NFSMNT_ACREGMIN: c_int = 256; -pub const NFSMNT_INT: c_int = 64; -pub const NFSMNT_NOAC: c_int = 128; -pub const NFSMNT_RETRANS: c_int = 16; -pub const NFSMNT_RSIZE: c_int = 4; -pub const NFSMNT_SOFT: c_int = 1; -pub const NFSMNT_TIMEO: c_int = 8; -pub const NFSMNT_WSIZE: c_int = 2; +pub const NFSMNT_SOFT: c_int = 0x001; +pub const NFSMNT_WSIZE: c_int = 0x002; +pub const NFSMNT_RSIZE: c_int = 0x004; +pub const NFSMNT_TIMEO: c_int = 0x008; +pub const NFSMNT_RETRANS: c_int = 0x010; +pub const NFSMNT_HOSTNAME: c_int = 0x020; +pub const NFSMNT_INT: c_int = 0x040; +pub const NFSMNT_NOAC: c_int = 0x080; +pub const NFSMNT_ACREGMIN: c_int = 0x0100; +pub const NFSMNT_ACREGMAX: c_int = 0x0200; +pub const NFSMNT_ACDIRMIN: c_int = 0x0400; +pub const NFSMNT_ACDIRMAX: c_int = 0x0800; // rpcsvc/rstat.h pub const CPUSTATES: c_int = 4; @@ -1276,35 +1269,19 @@ pub const EUNATCH: c_int = 42; pub const ENOCSI: c_int = 43; pub const EL2HLT: c_int = 44; pub const EDEADLK: c_int = 45; +pub const ENOTREADY: c_int = 46; +pub const EWRPROTECT: c_int = 47; +pub const EFORMAT: c_int = 48; pub const ENOLCK: c_int = 49; -pub const ECANCELED: c_int = 117; -pub const ENOTSUP: c_int = 124; -pub const EPROCLIM: c_int = 83; -pub const EDQUOT: c_int = 88; -pub const EOWNERDEAD: c_int = 95; -pub const ENOTRECOVERABLE: c_int = 94; -pub const ENOSTR: c_int = 123; -pub const ENODATA: c_int = 122; -pub const ETIME: c_int = 119; -pub const ENOSR: c_int = 118; -pub const EREMOTE: c_int = 93; -pub const ENOATTR: c_int = 112; -pub const ESAD: c_int = 113; -pub const ENOTRUST: c_int = 114; -pub const ENOLINK: c_int = 126; -pub const EPROTO: c_int = 121; -pub const EMULTIHOP: c_int = 125; -pub const EBADMSG: c_int = 120; -pub const ENAMETOOLONG: c_int = 86; -pub const EOVERFLOW: c_int = 127; -pub const EILSEQ: c_int = 116; -pub const ENOSYS: c_int = 109; -pub const ELOOP: c_int = 85; -pub const ERESTART: c_int = 82; -pub const ENOTEMPTY: c_int = 87; -pub const EUSERS: c_int = 84; +pub const ENOCONNECT: c_int = 50; +pub const ESTALE: c_int = 52; +pub const EDIST: c_int = 53; +pub const EWOULDBLOCK: c_int = EAGAIN; +pub const EINPROGRESS: c_int = 55; +pub const EALREADY: c_int = 56; pub const ENOTSOCK: c_int = 57; pub const EDESTADDRREQ: c_int = 58; +pub const EDESTADDREQ: c_int = EDESTADDRREQ; pub const EMSGSIZE: c_int = 59; pub const EPROTOTYPE: c_int = 60; pub const ENOPROTOOPT: c_int = 61; @@ -1324,15 +1301,43 @@ pub const ENOBUFS: c_int = 74; pub const EISCONN: c_int = 75; pub const ENOTCONN: c_int = 76; pub const ESHUTDOWN: c_int = 77; -pub const ETOOMANYREFS: c_int = 115; pub const ETIMEDOUT: c_int = 78; pub const ECONNREFUSED: c_int = 79; pub const EHOSTDOWN: c_int = 80; pub const EHOSTUNREACH: c_int = 81; -pub const EWOULDBLOCK: c_int = EAGAIN; -pub const EALREADY: c_int = 56; -pub const EINPROGRESS: c_int = 55; -pub const ESTALE: c_int = 52; +pub const ERESTART: c_int = 82; +pub const EPROCLIM: c_int = 83; +pub const EUSERS: c_int = 84; +pub const ELOOP: c_int = 85; +pub const ENAMETOOLONG: c_int = 86; +pub const ENOTEMPTY: c_int = EEXIST; +pub const EDQUOT: c_int = 88; +pub const ECORRUPT: c_int = 89; +pub const ESYSERROR: c_int = 90; +pub const EREMOTE: c_int = 93; +pub const ENOTRECOVERABLE: c_int = 94; +pub const EOWNERDEAD: c_int = 95; +// errnos 96-108 reserved for future use compatible with AIX PS/2 +pub const ENOSYS: c_int = 109; +pub const EMEDIA: c_int = 110; +pub const ESOFT: c_int = 111; +pub const ENOATTR: c_int = 112; +pub const ESAD: c_int = 113; +pub const ENOTRUST: c_int = 114; +pub const ETOOMANYREFS: c_int = 115; +pub const EILSEQ: c_int = 116; +pub const ECANCELED: c_int = 117; +pub const ENOSR: c_int = 118; +pub const ETIME: c_int = 119; +pub const EBADMSG: c_int = 120; +pub const EPROTO: c_int = 121; +pub const ENODATA: c_int = 122; +pub const ENOSTR: c_int = 123; +pub const ECLONEME: c_int = ERESTART; +pub const ENOTSUP: c_int = 124; +pub const EMULTIHOP: c_int = 125; +pub const ENOLINK: c_int = 126; +pub const EOVERFLOW: c_int = 127; // sys/dr.h pub const LPAR_INFO_FORMAT1: c_int = 1; @@ -1371,22 +1376,22 @@ pub const Q_SETQUOTA: c_int = 0x400; // sys/ioctl.h pub const IOCPARM_MASK: c_int = 0x7f; -pub const IOC_VOID: c_int = 0x20000000; -pub const IOC_OUT: c_int = 0x40000000; -pub const IOC_IN: c_int = 0x40000000 << 1; -pub const IOC_INOUT: c_int = IOC_IN | IOC_OUT; -pub const FIOCLEX: c_int = 536897025; -pub const FIONCLEX: c_int = 536897026; -pub const FIONREAD: c_int = 1074030207; -pub const FIONBIO: c_int = -2147195266; -pub const FIOASYNC: c_int = -2147195267; -pub const FIOSETOWN: c_int = -2147195268; -pub const FIOGETOWN: c_int = 1074030203; -pub const TIOCGETD: c_int = 0x40047400; -pub const TIOCSETD: c_int = 0x80047401; -pub const TIOCHPCL: c_int = 0x20007402; -pub const TIOCMODG: c_int = 0x40047403; -pub const TIOCMODS: c_int = 0x80047404; +pub const IOC_VOID: c_long = 536870912; +pub const IOC_OUT: c_long = 1073741824; +pub const IOC_IN: c_long = -2147483648; +pub const IOC_INOUT: c_long = IOC_IN | IOC_OUT; +pub const FIOCLEX: c_long = 536897025; +pub const FIONCLEX: c_long = 536897026; +pub const FIONREAD: c_long = 1074030207; +pub const FIONBIO: c_long = -2147195266; +pub const FIOASYNC: c_long = -2147195267; +pub const FIOSETOWN: c_long = -2147195268; +pub const FIOGETOWN: c_long = 1074030203; +pub const TIOCGETD: c_long = 1074033664; +pub const TIOCSETD: c_long = -2147191807; +pub const TIOCHPCL: c_long = 536900610; +pub const TIOCMODG: c_long = 1074033667; +pub const TIOCMODS: c_long = -2147191804; pub const TIOCM_LE: c_int = 0x1; pub const TIOCM_DTR: c_int = 0x2; pub const TIOCM_RTS: c_int = 0x4; @@ -1398,46 +1403,46 @@ pub const TIOCM_CD: c_int = 0x40; pub const TIOCM_RNG: c_int = 0x80; pub const TIOCM_RI: c_int = 0x80; pub const TIOCM_DSR: c_int = 0x100; -pub const TIOCGETP: c_int = 0x40067408; -pub const TIOCSETP: c_int = 0x80067409; -pub const TIOCSETN: c_int = 0x8006740a; -pub const TIOCEXCL: c_int = 0x2000740d; -pub const TIOCNXCL: c_int = 0x2000740e; -pub const TIOCFLUSH: c_int = 0x80047410; -pub const TIOCSETC: c_int = 0x80067411; -pub const TIOCGETC: c_int = 0x40067412; +pub const TIOCGETP: c_long = 1074164744; +pub const TIOCSETP: c_long = -2147060727; +pub const TIOCSETN: c_long = -2147060726; +pub const TIOCEXCL: c_long = 536900621; +pub const TIOCNXCL: c_long = 536900622; +pub const TIOCFLUSH: c_long = -2147191792; +pub const TIOCSETC: c_long = -2147060719; +pub const TIOCGETC: c_long = 1074164754; pub const TANDEM: c_int = 0x1; pub const CBREAK: c_int = 0x2; pub const LCASE: c_int = 0x4; pub const MDMBUF: c_int = 0x800000; pub const XTABS: c_int = 0xc00; -pub const SIOCADDMULTI: c_int = -2145359567; -pub const SIOCADDRT: c_int = -2143784438; -pub const SIOCDARP: c_int = -2142476000; -pub const SIOCDELMULTI: c_int = -2145359566; -pub const SIOCDELRT: c_int = -2143784437; -pub const SIOCDIFADDR: c_int = -2144835303; -pub const SIOCGARP: c_int = -1068734170; -pub const SIOCGIFADDR: c_int = -1071093471; -pub const SIOCGIFBRDADDR: c_int = -1071093469; -pub const SIOCGIFCONF: c_int = -1072666299; -pub const SIOCGIFDSTADDR: c_int = -1071093470; -pub const SIOCGIFFLAGS: c_int = -1071093487; -pub const SIOCGIFHWADDR: c_int = -1068209771; -pub const SIOCGIFMETRIC: c_int = -1071093481; -pub const SIOCGIFMTU: c_int = -1071093418; -pub const SIOCGIFNETMASK: c_int = -1071093467; -pub const SIOCSARP: c_int = -2142476002; -pub const SIOCSIFADDR: c_int = -2144835316; -pub const SIOCSIFBRDADDR: c_int = -2144835309; -pub const SIOCSIFDSTADDR: c_int = -2144835314; -pub const SIOCSIFFLAGS: c_int = -2144835312; -pub const SIOCSIFMETRIC: c_int = -2144835304; -pub const SIOCSIFMTU: c_int = -2144835240; -pub const SIOCSIFNETMASK: c_int = -2144835306; -pub const TIOCUCNTL: c_int = -2147191706; -pub const TIOCCONS: c_int = -2147191710; -pub const TIOCPKT: c_int = -2147191696; +pub const SIOCADDMULTI: c_long = -2145359567; +pub const SIOCADDRT: c_long = -2143784438; +pub const SIOCDARP: c_long = -2142476000; +pub const SIOCDELMULTI: c_long = -2145359566; +pub const SIOCDELRT: c_long = -2143784437; +pub const SIOCDIFADDR: c_long = -2144835303; +pub const SIOCGARP: c_long = -1068734170; +pub const SIOCGIFADDR: c_long = -1071093471; +pub const SIOCGIFBRDADDR: c_long = -1071093469; +pub const SIOCGIFCONF: c_long = -1072666299; +pub const SIOCGIFDSTADDR: c_long = -1071093470; +pub const SIOCGIFFLAGS: c_long = -1071093487; +pub const SIOCGIFHWADDR: c_long = -1068209771; +pub const SIOCGIFMETRIC: c_long = -1071093481; +pub const SIOCGIFMTU: c_long = -1071093418; +pub const SIOCGIFNETMASK: c_long = -1071093467; +pub const SIOCSARP: c_long = -2142476002; +pub const SIOCSIFADDR: c_long = -2144835316; +pub const SIOCSIFBRDADDR: c_long = -2144835309; +pub const SIOCSIFDSTADDR: c_long = -2144835314; +pub const SIOCSIFFLAGS: c_long = -2144835312; +pub const SIOCSIFMETRIC: c_long = -2144835304; +pub const SIOCSIFMTU: c_long = -2144835240; +pub const SIOCSIFNETMASK: c_long = -2144835306; +pub const TIOCUCNTL: c_long = -2147191706; +pub const TIOCCONS: c_long = -2147191710; +pub const TIOCPKT: c_long = -2147191696; pub const TIOCPKT_DATA: c_int = 0; pub const TIOCPKT_FLUSHREAD: c_int = 1; pub const TIOCPKT_FLUSHWRITE: c_int = 2; @@ -1463,9 +1468,13 @@ pub const SHM_LOCK: c_int = 201; pub const SHM_UNLOCK: c_int = 202; // sys/ldr.h +pub const L_GETMESSAGES: c_int = 1; pub const L_GETINFO: c_int = 2; -pub const L_GETMESSAGE: c_int = 1; pub const L_GETLIBPATH: c_int = 3; +pub const L_GETKERNINFO: c_int = 4; +pub const L_GETLIB32INFO: c_int = 5; +pub const L_GETLIB64INFO: c_int = 6; +pub const L_GETPROCINFO: c_int = 7; pub const L_GETXINFO: c_int = 8; // sys/limits.h @@ -2097,31 +2106,31 @@ pub const TCOON: c_int = 1; pub const TCIOFF: c_int = 2; pub const TCION: c_int = 3; pub const TIOC: c_int = 0x5400; -pub const TIOCGWINSZ: c_int = 0x40087468; -pub const TIOCSWINSZ: c_int = 0x80087467; -pub const TIOCLBIS: c_int = 0x8004747f; -pub const TIOCLBIC: c_int = 0x8004747e; -pub const TIOCLSET: c_int = 0x8004747d; -pub const TIOCLGET: c_int = 0x4004747c; -pub const TIOCSBRK: c_int = 0x2000747b; -pub const TIOCCBRK: c_int = 0x2000747a; -pub const TIOCSDTR: c_int = 0x20007479; -pub const TIOCCDTR: c_int = 0x20007478; -pub const TIOCSLTC: c_int = 0x80067475; -pub const TIOCGLTC: c_int = 0x40067474; -pub const TIOCOUTQ: c_int = 0x40047473; -pub const TIOCNOTTY: c_int = 0x20007471; -pub const TIOCSTOP: c_int = 0x2000746f; -pub const TIOCSTART: c_int = 0x2000746e; -pub const TIOCGPGRP: c_int = 0x40047477; -pub const TIOCSPGRP: c_int = 0x80047476; -pub const TIOCGSID: c_int = 0x40047448; -pub const TIOCSTI: c_int = 0x80017472; -pub const TIOCMSET: c_int = 0x8004746d; -pub const TIOCMBIS: c_int = 0x8004746c; -pub const TIOCMBIC: c_int = 0x8004746b; -pub const TIOCMGET: c_int = 0x4004746a; -pub const TIOCREMOTE: c_int = 0x80047469; +pub const TIOCGWINSZ: c_long = 1074295912; +pub const TIOCSWINSZ: c_long = -2146929561; +pub const TIOCLBIS: c_long = -2147191681; +pub const TIOCLBIC: c_long = -2147191682; +pub const TIOCLSET: c_long = -2147191683; +pub const TIOCLGET: c_long = 1074033788; +pub const TIOCSBRK: c_long = 536900731; +pub const TIOCCBRK: c_long = 536900730; +pub const TIOCSDTR: c_long = 536900729; +pub const TIOCCDTR: c_long = 536900728; +pub const TIOCSLTC: c_long = -2147060619; +pub const TIOCGLTC: c_long = 1074164852; +pub const TIOCOUTQ: c_long = 1074033779; +pub const TIOCNOTTY: c_long = 536900721; +pub const TIOCSTOP: c_long = 536900719; +pub const TIOCSTART: c_long = 536900718; +pub const TIOCGPGRP: c_long = 1074033783; +pub const TIOCSPGRP: c_long = -2147191690; +pub const TIOCGSID: c_long = 1074033736; +pub const TIOCSTI: c_long = -2147388302; +pub const TIOCMSET: c_long = -2147191699; +pub const TIOCMBIS: c_long = -2147191700; +pub const TIOCMBIC: c_long = -2147191701; +pub const TIOCMGET: c_long = 1074033770; +pub const TIOCREMOTE: c_long = -2147191703; // sys/user.h pub const MAXCOMLEN: c_int = 32; @@ -2133,9 +2142,9 @@ pub const AT_GID: c_int = 8; pub const AT_UID: c_int = 4; // sys/wait.h -pub const P_ALL: c_int = 0; -pub const P_PID: c_int = 1; -pub const P_PGID: c_int = 2; +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 2; pub const WNOHANG: c_int = 0x1; pub const WUNTRACED: c_int = 0x2; pub const WEXITED: c_int = 0x04; @@ -2157,7 +2166,7 @@ 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 = 0x20000; +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; @@ -2173,7 +2182,7 @@ 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 = 0x0001; +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; @@ -2426,7 +2435,7 @@ pub const _SC_IPV6: c_int = 154; pub const _SC_RAW_SOCKETS: c_int = 155; // utmp.h -pub const EMPTY: c_short = -1; +pub const EMPTY: c_short = 0; pub const RUN_LVL: c_short = 1; pub const BOOT_TIME: c_short = 2; pub const OLD_TIME: c_short = 3; @@ -2579,109 +2588,249 @@ extern "C" { parent: Option, child: Option, ) -> c_int; + + pub fn pthread_attr_getdetachstate( + attr: *const crate::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_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int; + + pub fn pthread_attr_getinheritsched( + attr: *const crate::pthread_attr_t, + inheritsched: *mut c_int, + ) -> c_int; + pub fn pthread_attr_getschedparam( attr: *const crate::pthread_attr_t, param: *mut sched_param, ) -> c_int; + + pub fn pthread_attr_getstackaddr( + attr: *const crate::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_getscope( + attr: *const crate::pthread_attr_t, + contentionscope: *mut c_int, + ) -> c_int; + pub fn pthread_attr_getstack( attr: *const crate::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_setinheritsched( + attr: *mut crate::pthread_attr_t, + inheritsched: c_int, + ) -> c_int; + pub fn pthread_attr_setschedparam( attr: *mut crate::pthread_attr_t, param: *const sched_param, ) -> c_int; - pub fn pthread_barrier_destroy(barrier: *mut pthread_barrier_t) -> c_int; - pub fn pthread_barrier_init( - barrier: *mut pthread_barrier_t, - attr: *const crate::pthread_barrierattr_t, - count: c_uint, + + pub fn pthread_attr_setschedpolicy(attr: *mut crate::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_setstack( + attr: *mut crate::pthread_attr_t, + stackaddr: *mut c_void, + stacksize: size_t, ) -> c_int; - pub fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> c_int; + + pub fn pthread_attr_setstackaddr( + attr: *mut crate::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_getpshared( attr: *const crate::pthread_barrierattr_t, - shared: *mut c_int, + pshared: *mut c_int, ) -> c_int; + pub fn pthread_barrierattr_init(attr: *mut crate::pthread_barrierattr_t) -> c_int; + pub fn pthread_barrierattr_setpshared( attr: *mut crate::pthread_barrierattr_t, - shared: c_int, + pshared: c_int, ) -> c_int; + + pub fn pthread_barrier_destroy(barrier: *mut pthread_barrier_t) -> c_int; + + pub fn pthread_barrier_init( + barrier: *mut pthread_barrier_t, + attr: *const crate::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_cleanup_pop(execute: c_int) -> c_void; + + pub fn pthread_cleanup_push( + routine: Option, + arg: *mut c_void, + ) -> c_void; + pub fn pthread_condattr_getclock( attr: *const pthread_condattr_t, clock_id: *mut clockid_t, ) -> c_int; + pub fn pthread_condattr_getpshared( attr: *const pthread_condattr_t, 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_setpshared(attr: *mut pthread_condattr_t, pshared: c_int) -> c_int; + pub fn pthread_create( - native: *mut crate::pthread_t, + thread: *mut crate::pthread_t, attr: *const crate::pthread_attr_t, - f: extern "C" fn(*mut c_void) -> *mut c_void, - value: *mut c_void, + start_routine: extern "C" fn(*mut c_void) -> *mut c_void, + arg: *mut c_void, ) -> c_int; - pub fn pthread_getattr_np(native: crate::pthread_t, attr: *mut crate::pthread_attr_t) -> c_int; - pub fn pthread_getcpuclockid(thread: crate::pthread_t, clk_id: *mut crate::clockid_t) -> 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_getschedparam( thread: crate::pthread_t, policy: *mut c_int, param: *mut sched_param, ) -> c_int; - pub fn pthread_kill(thread: crate::pthread_t, signal: c_int) -> c_int; - pub fn pthread_mutex_consistent(mutex: *mut crate::pthread_mutex_t) -> c_int; - pub fn pthread_mutex_timedlock( - lock: *mut pthread_mutex_t, - abstime: *const crate::timespec, + + pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; + + pub fn pthread_mutexattr_getprioceiling( + attr: *const crate::pthread_mutexattr_t, + prioceiling: *mut c_int, ) -> c_int; + pub fn pthread_mutexattr_getprotocol( attr: *const pthread_mutexattr_t, protocol: *mut c_int, ) -> c_int; + pub fn pthread_mutexattr_getpshared( attr: *const pthread_mutexattr_t, pshared: *mut c_int, ) -> c_int; + pub fn pthread_mutexattr_getrobust( - attr: *mut crate::pthread_mutexattr_t, + attr: *const crate::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_setprioceiling( + attr: *mut crate::pthread_mutexattr_t, + prioceiling: c_int, + ) -> c_int; + pub fn pthread_mutexattr_setprotocol(attr: *mut pthread_mutexattr_t, protocol: c_int) -> c_int; + 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_mutex_consistent(mutex: *mut crate::pthread_mutex_t) -> c_int; + + pub fn pthread_mutex_getprioceiling( + mutex: *const crate::pthread_mutex_t, + prioceiling: *mut c_int, + ) -> c_int; + + pub fn pthread_mutex_setprioceiling( + mutex: *mut crate::pthread_mutex_t, + prioceiling: c_int, + old_ceiling: *mut c_int, + ) -> c_int; + + pub fn pthread_mutex_timedlock( + mutex: *mut pthread_mutex_t, + abstime: *const crate::timespec, + ) -> c_int; + + pub fn pthread_once( + once_control: *mut crate::pthread_once_t, + init_routine: Option, + ) -> c_int; + pub fn pthread_rwlockattr_getpshared( attr: *const pthread_rwlockattr_t, - val: *mut c_int, + pshared: *mut c_int, + ) -> c_int; + + 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, + abstime: *const crate::timespec, + ) -> c_int; + + pub fn pthread_rwlock_timedwrlock( + rwlock: *mut crate::pthread_rwlock_t, + abstime: *const crate::timespec, ) -> c_int; - pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, val: c_int) -> c_int; + + pub fn pthread_setcancelstate(state: c_int, oldstate: *mut c_int) -> c_int; + pub fn pthread_setcanceltype(_type: c_int, oldtype: *mut c_int) -> c_int; + + pub fn pthread_setconcurrency(new_level: c_int) -> c_int; + pub fn pthread_setschedparam( thread: crate::pthread_t, policy: c_int, param: *const sched_param, ) -> c_int; - pub fn pthread_setschedprio(native: crate::pthread_t, priority: c_int) -> c_int; - pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; + + pub fn pthread_setschedprio(thread: crate::pthread_t, prio: c_int) -> c_int; + + pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) -> c_int; + pub fn pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> c_int; pub fn pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: c_int) -> c_int; pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> c_int; pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> c_int; pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> c_int; + + pub fn pthread_testcancel() -> c_void; } #[link(name = "iconv")] @@ -2698,14 +2847,25 @@ extern "C" { } extern "C" { - pub fn acct(filename: *const c_char) -> c_int; + 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_error(aiocbp: *mut crate::aiocb) -> c_int; + #[link_name = "_posix_aio_error"] + pub fn aio_error(aiocbp: *const crate::aiocb) -> c_int; #[link_name = "_posix_aio_fsync"] pub fn aio_fsync(op: c_int, aiocbp: *mut crate::aiocb) -> c_int; + #[link_name = "_posix_aio_read"] pub fn aio_read(aiocbp: *mut crate::aiocb) -> c_int; - // pub fn aio_suspend - // pub fn aio_write + #[link_name = "_posix_aio_return"] + pub fn aio_return(aiocbp: *mut crate::aiocb) -> ssize_t; + #[link_name = "_posix_aio_suspend"] + pub fn aio_suspend( + list: *const *const crate::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 basename(path: *mut c_char) -> *mut c_char; pub fn bind( socket: c_int, @@ -2771,6 +2931,7 @@ extern "C" { pub fn getdtablesize() -> c_int; pub fn getgrent() -> *mut crate::group; pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; + #[link_name = "_posix_getgrgid_r"] pub fn getgrgid_r( gid: crate::gid_t, grp: *mut crate::group, @@ -2779,14 +2940,15 @@ extern "C" { result: *mut *mut crate::group, ) -> c_int; pub fn getgrnam(name: *const c_char) -> *mut crate::group; + #[link_name = "_posix_getgrnam_r"] pub fn getgrnam_r( name: *const c_char, grp: *mut crate::group, buf: *mut c_char, - buflen: size_t, + buflen: c_int, result: *mut *mut crate::group, ) -> c_int; - pub fn getgrset(user: *mut c_char) -> *mut c_char; + 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 getnameinfo( @@ -2799,9 +2961,9 @@ extern "C" { flags: c_int, ) -> 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; + #[link_name = "_posix_getpwnam_r"] pub fn getpwnam_r( name: *const c_char, pwd: *mut passwd, @@ -2809,6 +2971,7 @@ extern "C" { buflen: size_t, result: *mut *mut passwd, ) -> c_int; + #[link_name = "_posix_getpwuid_r"] pub fn getpwuid_r( uid: crate::uid_t, pwd: *mut passwd, @@ -2836,7 +2999,7 @@ extern "C" { pub fn hasmntopt(mnt: *const crate::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: c_int) -> *mut entry; + pub fn hsearch(entry: entry, action: ACTION) -> *mut entry; pub fn if_freenameindex(ptr: *mut if_nameindex); pub fn if_nameindex() -> *mut if_nameindex; pub fn initgroups(name: *const c_char, basegid: crate::gid_t) -> c_int; @@ -2850,13 +3013,14 @@ extern "C" { width: size_t, compar: Option c_int>, ) -> *mut c_void; + #[link_name = "_posix_lio_listio"] pub fn lio_listio( mode: c_int, aiocb_list: *const *mut aiocb, - nitems: c_int, + nent: c_int, sevp: *mut sigevent, ) -> c_int; - pub fn loadquery(flags: c_int, buf: *mut c_char, buflen: c_uint) -> c_int; + pub fn loadquery(flags: c_int, buf: *mut c_void, buflen: c_uint, ...) -> c_int; pub fn lpar_get_info(command: c_int, buf: *mut c_void, bufsize: size_t) -> c_int; pub fn lpar_set_resources(id: c_int, resource: *mut c_void) -> c_int; pub fn lrand48() -> c_long; @@ -2869,7 +3033,7 @@ extern "C" { ) -> *mut c_void; pub fn lseek64(fd: c_int, offset: off64_t, whence: c_int) -> off64_t; pub fn lstat64(path: *const c_char, buf: *mut stat64) -> c_int; - pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> 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 mallopt(param: c_int, value: c_int) -> c_int; @@ -2880,10 +3044,9 @@ extern "C" { needlelen: size_t, ) -> *mut c_void; pub fn memset_s(s: *mut c_void, smax: size_t, c: c_int, n: size_t) -> c_int; - pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) -> c_int; + pub fn mincore(addr: caddr_t, len: size_t, vec: *mut c_char) -> c_int; pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; 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; @@ -3027,7 +3190,7 @@ extern "C" { envp: *const *mut c_char, ) -> c_int; pub fn pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: off64_t) -> ssize_t; - pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: offset_t) -> ssize_t; pub fn ptrace64( request: c_int, id: c_longlong, @@ -3038,11 +3201,13 @@ extern "C" { pub fn pututline(u: *const utmp) -> *mut utmp; pub fn pututxline(ut: *const utmpx) -> *mut utmpx; pub fn pwrite64(fd: c_int, buf: *const c_void, count: size_t, offset: off64_t) -> ssize_t; - pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; - #[link_name = "__linux_quotactl"] - pub fn quotactl(cmd: c_int, special: *const c_char, id: c_int, data: *mut c_char) -> c_int; + pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: offset_t) + -> ssize_t; + pub fn quotactl(cmd: *mut c_char, special: c_int, id: c_int, data: caddr_t) -> c_int; pub fn rand() -> c_int; pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + // AIX header socket.h maps recvfrom() to nrecvfrom() + #[link_name = "nrecvfrom"] pub fn recvfrom( socket: c_int, buf: *mut c_void, @@ -3051,13 +3216,8 @@ extern "C" { addr: *mut crate::sockaddr, addrlen: *mut crate::socklen_t, ) -> ssize_t; - pub fn recvmmsg( - sockfd: c_int, - msgvec: *mut crate::mmsghdr, - vlen: c_uint, - flags: c_int, - timeout: *mut crate::timespec, - ) -> c_int; + // AIX header socket.h maps recvmsg() to nrecvmsg(). + #[link_name = "nrecvmsg"] pub fn recvmsg(sockfd: c_int, msg: *mut msghdr, flags: c_int) -> ssize_t; pub fn regcomp(preg: *mut regex_t, pattern: *const c_char, cflags: c_int) -> c_int; pub fn regerror( @@ -3086,14 +3246,6 @@ extern "C" { policy: c_int, param: *const crate::sched_param, ) -> c_int; - pub fn sctp_opt_info( - sd: c_int, - id: crate::sctp_assoc_t, - opt: c_int, - arg_size: *mut c_void, - size: *mut size_t, - ) -> c_int; - pub fn sctp_peeloff(s: c_int, id: crate::sctp_assoc_t) -> c_int; pub fn seed48(xseed: *mut c_ushort) -> *mut c_ushort; pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); pub fn sem_close(sem: *mut sem_t) -> c_int; @@ -3107,20 +3259,19 @@ extern "C" { pub fn semget(key: crate::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; + // AIX header socket.h maps sendmsg() to nsendmsg(). + #[link_name = "nsendmsg"] pub fn sendmsg(sockfd: c_int, msg: *const msghdr, flags: c_int) -> ssize_t; pub fn setcontext(ucp: *const ucontext_t) -> c_int; - pub fn setdomainname(name: *const c_char, len: c_int) -> c_int; - pub fn setgroups(ngroups: c_int, ptr: *const crate::gid_t) -> c_int; + pub fn setdomainname(name: *mut c_char, len: c_int) -> c_int; + pub fn setgroups(ngroups: c_int, ptr: *mut crate::gid_t) -> c_int; pub fn setgrent(); - pub fn sethostid(hostid: c_int) -> c_int; - pub fn sethostname(name: *const c_char, len: c_int) -> c_int; pub fn setmntent(filename: *const c_char, ty: *const c_char) -> *mut crate::FILE; pub fn setpriority(which: c_int, who: id_t, priority: c_int) -> c_int; pub fn setpwent(); pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; 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: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; pub fn setitimer( which: c_int, new_value: *const crate::itimerval, @@ -3143,15 +3294,14 @@ extern "C" { 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; - pub fn splice(socket1: c_int, socket2: c_int, flags: c_int) -> c_int; pub fn srand(seed: c_uint); pub fn srand48(seed: c_long); pub fn stat64(path: *const c_char, buf: *mut stat64) -> c_int; pub fn stat64at(dirfd: c_int, path: *const c_char, buf: *mut stat64, flags: c_int) -> c_int; - pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; - pub fn statfs64(path: *const c_char, buf: *mut statfs64) -> c_int; + pub fn statfs(path: *mut c_char, buf: *mut statfs) -> c_int; + pub fn statfs64(path: *mut c_char, buf: *mut statfs64) -> c_int; pub fn statvfs64(path: *const c_char, buf: *mut statvfs64) -> c_int; - pub fn statx(path: *const c_char, buf: *mut stat, length: c_int, command: c_int) -> c_int; + pub fn statx(path: *mut c_char, buf: *mut stat, length: c_int, command: c_int) -> c_int; pub fn strcasecmp_l( string1: *const c_char, string2: *const c_char, @@ -3173,8 +3323,8 @@ extern "C" { pub fn strptime(s: *const c_char, format: *const c_char, tm: *mut crate::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(puath: *const c_char) -> c_int; - pub fn swapon(path: *const c_char) -> c_int; + pub fn swapoff(puath: *mut c_char) -> c_int; + pub fn swapon(path: *mut c_char) -> c_int; pub fn sync(); pub fn telldir(dirp: *mut crate::DIR) -> c_long; pub fn timer_create( @@ -3193,9 +3343,9 @@ extern "C" { ) -> c_int; pub fn truncate64(path: *const c_char, length: off64_t) -> c_int; pub fn uname(buf: *mut crate::utsname) -> c_int; - pub fn updwtmp(file: *const c_char, u: *mut utmp); + 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; + pub fn utmpname(file: *mut c_char) -> c_int; pub fn utimensat( dirfd: c_int, path: *const c_char, diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index fcb9e6edfafa7..1bc177841afcd 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -29,7 +29,7 @@ s! { pub f_files: crate::fsfilcnt_t, pub f_ffree: crate::fsfilcnt_t, pub f_favail: crate::fsfilcnt_t, - pub f_fsid: c_ulong, + pub f_fsid: crate::fsid_t, pub f_basetype: [c_char; 16], pub f_flag: c_ulong, pub f_namemax: c_ulong, @@ -49,6 +49,10 @@ s! { __mt_word: [c_long; 8], } + pub struct pthread_once_t { + __on_word: [c_long; 9], + } + pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, @@ -59,9 +63,9 @@ s! { pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, pub st_ssize: c_int, - pub st_atime: crate::st_timespec, - pub st_mtime: crate::st_timespec, - pub st_ctime: crate::st_timespec, + pub st_atim: crate::st_timespec, + pub st_mtim: crate::st_timespec, + pub st_ctim: crate::st_timespec, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, pub st_vfstype: c_int, @@ -112,20 +116,47 @@ s! { pub aio_sigev_tid: c_long, } - pub struct ucontext_t { - pub __sc_onstack: c_int, - pub uc_sigmask: crate::sigset_t, - pub __sc_uerror: c_int, - pub uc_mcontext: crate::mcontext_t, - pub uc_link: *mut ucontext_t, - pub uc_stack: crate::stack_t, - // Should be pointer to __extctx_t - pub __extctx: *mut c_void, - pub __extctx_magic: c_int, - pub __pad: [c_int; 1], + pub struct __vmxreg_t { + __v: [c_uint; 4], } - pub struct mcontext_t { + pub struct __vmx_context_t { + pub __vr: [crate::__vmxreg_t; 32], + pub __pad1: [c_uint; 3], + pub __vscr: c_uint, + pub __vrsave: c_uint, + pub __pad2: [c_uint; 3], + } + + pub struct __vsx_context_t { + pub __vsr_dw1: [c_ulonglong; 32], + } + + pub struct __tm_context_t { + pub vmx: crate::__vmx_context_t, + pub vsx: crate::__vsx_context_t, + pub gpr: [c_ulonglong; 32], + pub lr: c_ulonglong, + pub ctr: c_ulonglong, + pub cr: c_uint, + pub xer: c_uint, + pub amr: c_ulonglong, + pub texasr: c_ulonglong, + pub tfiar: c_ulonglong, + pub tfhar: c_ulonglong, + pub ppr: c_ulonglong, + pub dscr: c_ulonglong, + pub tar: c_ulonglong, + pub fpscr: c_uint, + pub fpscrx: c_uint, + pub fpr: [fpreg_t; 32], + pub tmcontext: c_char, + pub tmstate: c_char, + pub prevowner: c_char, + pub pad: [c_char; 5], + } + + pub struct __context64 { pub gpr: [c_ulonglong; 32], pub msr: c_ulonglong, pub iar: c_ulonglong, @@ -136,8 +167,7 @@ s! { pub fpscr: c_uint, pub fpscrx: c_uint, pub except: [c_ulonglong; 1], - // Should be array of double type - pub fpr: [crate::uint64_t; 32], + pub fpr: [fpreg_t; 32], pub fpeu: c_char, pub fpinfo: c_char, pub fpscr24_31: c_char, @@ -145,6 +175,33 @@ s! { pub excp_type: c_int, } + pub struct mcontext_t { + pub jmp_context: __context64, + } + + pub struct __extctx_t { + pub __flags: c_uint, + pub __rsvd1: [c_uint; 3], + pub __vmx: crate::__vmx_context_t, + pub __ukeys: [c_uint; 2], + pub __vsx: crate::__vsx_context_t, + pub __tm: crate::__tm_context_t, + pub __reserved: [c_char; 1860], + pub __extctx_magic: c_int, + } + + pub struct ucontext_t { + pub __sc_onstack: c_int, + pub uc_sigmask: crate::sigset_t, + pub __sc_uerror: c_int, + pub uc_mcontext: crate::mcontext_t, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub __extctx: *mut crate::__extctx_t, + pub __extctx_magic: c_int, + pub __pad: [c_int; 1], + } + pub struct utmpx { pub ut_user: [c_char; 256], pub ut_id: [c_char; 14], @@ -199,70 +256,6 @@ s_no_extra_traits! { pub __pad: [c_int; 3], } - pub union _kernel_simple_lock { - pub _slock: c_long, - // Should be pointer to 'lock_data_instrumented' - pub _slockp: *mut c_void, - } - - pub struct fileops_t { - pub fo_rw: extern "C" fn( - file: *mut file, - rw: crate::uio_rw, - io: *mut c_void, - ext: c_long, - secattr: *mut c_void, - ) -> c_int, - pub fo_ioctl: extern "C" fn( - file: *mut file, - a: c_long, - b: crate::caddr_t, - c: c_long, - d: c_long, - ) -> c_int, - pub fo_select: - extern "C" fn(file: *mut file, a: c_int, b: *mut c_ushort, c: extern "C" fn()) -> c_int, - pub fo_close: extern "C" fn(file: *mut file) -> c_int, - pub fo_fstat: extern "C" fn(file: *mut file, sstat: *mut crate::stat) -> c_int, - } - - pub struct file { - pub f_flag: c_long, - pub f_count: c_int, - pub f_options: c_short, - pub f_type: c_short, - // Should be pointer to 'vnode' - pub f_data: *mut c_void, - pub f_offset: c_longlong, - pub f_dir_off: c_long, - // Should be pointer to 'cred' - pub f_cred: *mut c_void, - pub f_lock: _kernel_simple_lock, - pub f_offset_lock: _kernel_simple_lock, - pub f_vinfo: crate::caddr_t, - pub f_ops: *mut fileops_t, - pub f_parentp: crate::caddr_t, - pub f_fnamep: crate::caddr_t, - pub f_fdata: [c_char; 160], - } - - pub union __ld_info_file { - pub _ldinfo_fd: c_int, - pub _ldinfo_fp: *mut file, - pub _core_offset: c_long, - } - - pub struct ld_info { - pub ldinfo_next: c_uint, - pub ldinfo_flags: c_uint, - pub _file: __ld_info_file, - pub ldinfo_textorg: *mut c_void, - pub ldinfo_textsize: c_ulong, - pub ldinfo_dataorg: *mut c_void, - pub ldinfo_datasize: c_ulong, - pub ldinfo_filename: [c_char; 2], - } - pub union __pollfd_ext_u { pub addr: *mut c_void, pub data32: u32, @@ -271,10 +264,14 @@ s_no_extra_traits! { pub struct pollfd_ext { pub fd: c_int, - pub events: c_ushort, - pub revents: c_ushort, + pub events: c_short, + pub revents: c_short, pub data: __pollfd_ext_u, } + + pub struct fpreg_t { + pub d: c_double, + } } impl siginfo_t { @@ -346,174 +343,6 @@ cfg_if! { self.__si_flags.hash(state); } } - - impl PartialEq for _kernel_simple_lock { - fn eq(&self, other: &_kernel_simple_lock) -> bool { - unsafe { self._slock == other._slock && self._slockp == other._slockp } - } - } - impl Eq for _kernel_simple_lock {} - impl hash::Hash for _kernel_simple_lock { - fn hash(&self, state: &mut H) { - unsafe { - self._slock.hash(state); - self._slockp.hash(state); - } - } - } - - impl PartialEq for fileops_t { - fn eq(&self, other: &fileops_t) -> bool { - self.fo_rw == other.fo_rw - && self.fo_ioctl == other.fo_ioctl - && self.fo_select == other.fo_select - && self.fo_close == other.fo_close - && self.fo_fstat == other.fo_fstat - } - } - impl Eq for fileops_t {} - impl fmt::Debug for fileops_t { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("fileops_t") - .field("fo_rw", &self.fo_rw) - .field("fo_ioctl", &self.fo_ioctl) - .field("fo_select", &self.fo_select) - .field("fo_close", &self.fo_close) - .field("fo_fstat", &self.fo_fstat) - .finish() - } - } - impl hash::Hash for fileops_t { - fn hash(&self, state: &mut H) { - self.fo_rw.hash(state); - self.fo_ioctl.hash(state); - self.fo_select.hash(state); - self.fo_close.hash(state); - self.fo_fstat.hash(state); - } - } - - impl PartialEq for file { - fn eq(&self, other: &file) -> bool { - self.f_flag == other.f_flag - && self.f_count == other.f_count - && self.f_options == other.f_options - && self.f_type == other.f_type - && self.f_data == other.f_data - && self.f_offset == other.f_offset - && self.f_dir_off == other.f_dir_off - && self.f_cred == other.f_cred - && self.f_vinfo == other.f_vinfo - && self.f_ops == other.f_ops - && self.f_parentp == other.f_parentp - && self.f_fnamep == other.f_fnamep - && self.f_fdata == other.f_fdata - && self.f_lock == other.f_lock - && self.f_offset_lock == other.f_offset_lock - } - } - impl Eq for file {} - impl fmt::Debug for file { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("file") - .field("f_flag", &self.f_flag) - .field("f_count", &self.f_count) - .field("f_options", &self.f_options) - .field("f_type", &self.f_type) - .field("f_data", &self.f_data) - .field("f_offset", &self.f_offset) - .field("f_dir_off", &self.f_dir_off) - .field("f_cred", &self.f_cred) - .field("f_lock", &self.f_lock) - .field("f_offset_lock", &self.f_offset_lock) - .field("f_vinfo", &self.f_vinfo) - .field("f_ops", &self.f_ops) - .field("f_parentp", &self.f_parentp) - .field("f_fnamep", &self.f_fnamep) - .field("f_fdata", &self.f_fdata) - .finish() - } - } - impl hash::Hash for file { - fn hash(&self, state: &mut H) { - self.f_flag.hash(state); - self.f_count.hash(state); - self.f_options.hash(state); - self.f_type.hash(state); - self.f_data.hash(state); - self.f_offset.hash(state); - self.f_dir_off.hash(state); - self.f_cred.hash(state); - self.f_lock.hash(state); - self.f_offset_lock.hash(state); - self.f_vinfo.hash(state); - self.f_ops.hash(state); - self.f_parentp.hash(state); - self.f_fnamep.hash(state); - self.f_fdata.hash(state); - } - } - - impl PartialEq for __ld_info_file { - fn eq(&self, other: &__ld_info_file) -> bool { - unsafe { - self._ldinfo_fd == other._ldinfo_fd - && self._ldinfo_fp == other._ldinfo_fp - && self._core_offset == other._core_offset - } - } - } - impl Eq for __ld_info_file {} - impl hash::Hash for __ld_info_file { - fn hash(&self, state: &mut H) { - unsafe { - self._ldinfo_fd.hash(state); - self._ldinfo_fp.hash(state); - self._core_offset.hash(state); - } - } - } - - impl PartialEq for ld_info { - fn eq(&self, other: &ld_info) -> bool { - self.ldinfo_next == other.ldinfo_next - && self.ldinfo_flags == other.ldinfo_flags - && self.ldinfo_textorg == other.ldinfo_textorg - && self.ldinfo_textsize == other.ldinfo_textsize - && self.ldinfo_dataorg == other.ldinfo_dataorg - && self.ldinfo_datasize == other.ldinfo_datasize - && self.ldinfo_filename == other.ldinfo_filename - && self._file == other._file - } - } - impl Eq for ld_info {} - impl fmt::Debug for ld_info { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("ld_info") - .field("ldinfo_next", &self.ldinfo_next) - .field("ldinfo_flags", &self.ldinfo_flags) - .field("ldinfo_textorg", &self.ldinfo_textorg) - .field("ldinfo_textsize", &self.ldinfo_textsize) - .field("ldinfo_dataorg", &self.ldinfo_dataorg) - .field("ldinfo_datasize", &self.ldinfo_datasize) - .field("ldinfo_filename", &self.ldinfo_filename) - .field("_file", &self._file) - .finish() - } - } - impl hash::Hash for ld_info { - fn hash(&self, state: &mut H) { - self.ldinfo_next.hash(state); - self.ldinfo_flags.hash(state); - self.ldinfo_textorg.hash(state); - self.ldinfo_textsize.hash(state); - self.ldinfo_dataorg.hash(state); - self.ldinfo_datasize.hash(state); - self.ldinfo_filename.hash(state); - self._file.hash(state); - } - } - impl PartialEq for __pollfd_ext_u { fn eq(&self, other: &__pollfd_ext_u) -> bool { unsafe { @@ -561,6 +390,26 @@ cfg_if! { self.data.hash(state); } } + impl PartialEq for fpreg_t { + fn eq(&self, other: &fpreg_t) -> bool { + self.d == other.d + } + } + + impl Eq for fpreg_t {} + + impl fmt::Debug for fpreg_t { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("fpreg_t").field("d", &self.d).finish() + } + } + + impl hash::Hash for fpreg_t { + fn hash(&self, state: &mut H) { + let d: u64 = unsafe { mem::transmute(self.d) }; + d.hash(state); + } + } } } @@ -573,6 +422,11 @@ pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { __rw_word: [2, 0, 0, 0, 0, 0, 0, 0, 0, 0], }; + +pub const PTHREAD_ONCE_INIT: pthread_once_t = pthread_once_t { + __on_word: [0, 0, 0, 0, 0, 2, 0, 0, 0], +}; + pub const RLIM_INFINITY: c_ulong = 0x7fffffffffffffff; extern "C" { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 4fc2afedfc095..d6259ea0f35dd 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -155,6 +155,7 @@ s! { pub revents: c_short, } + #[cfg(not(target_os = "aix"))] pub struct winsize { pub ws_row: c_ushort, pub ws_col: c_ushort, @@ -220,7 +221,7 @@ pub const SIG_IGN: sighandler_t = 1 as sighandler_t; pub const SIG_ERR: sighandler_t = !0 as sighandler_t; cfg_if! { - if #[cfg(not(target_os = "nto"))] { + if #[cfg(all(not(target_os = "nto"), not(target_os = "aix")))] { pub const DT_UNKNOWN: u8 = 0; pub const DT_FIFO: u8 = 1; pub const DT_CHR: u8 = 2; @@ -335,7 +336,7 @@ pub const ATF_PUBL: c_int = 0x08; pub const ATF_USETRAILERS: c_int = 0x10; cfg_if! { - if #[cfg(target_os = "nto")] { + if #[cfg(any(target_os = "nto", target_os = "aix"))] { pub const FNM_PERIOD: c_int = 1 << 1; } else { pub const FNM_PERIOD: c_int = 1 << 2; @@ -346,7 +347,7 @@ pub const FNM_NOMATCH: c_int = 1; cfg_if! { if #[cfg(any(target_os = "illumos", target_os = "solaris",))] { pub const FNM_CASEFOLD: c_int = 1 << 3; - } else { + } else if #[cfg(not(target_os = "aix"))] { pub const FNM_CASEFOLD: c_int = 1 << 4; } } @@ -375,6 +376,8 @@ cfg_if! { pub const FNM_NOESCAPE: c_int = 1 << 0; } else if #[cfg(target_os = "nto")] { pub const FNM_NOESCAPE: c_int = 1 << 2; + } else if #[cfg(target_os = "aix")] { + pub const FNM_NOESCAPE: c_int = 1 << 3; } else { pub const FNM_NOESCAPE: c_int = 1 << 1; } @@ -666,7 +669,9 @@ extern "C" { pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong; pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong; pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong; + #[cfg_attr(target_os = "aix", link_name = "vec_calloc")] pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + #[cfg_attr(target_os = "aix", link_name = "vec_malloc")] pub fn malloc(size: size_t) -> *mut c_void; pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; pub fn free(p: *mut c_void); @@ -778,6 +783,7 @@ extern "C" { link_name = "accept$UNIX2003" )] #[cfg_attr(target_os = "espidf", link_name = "lwip_accept")] + #[cfg_attr(target_os = "aix", link_name = "naccept")] pub fn accept(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int; #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] #[cfg_attr( @@ -785,6 +791,7 @@ extern "C" { link_name = "getpeername$UNIX2003" )] #[cfg_attr(target_os = "espidf", link_name = "lwip_getpeername")] + #[cfg_attr(target_os = "aix", link_name = "ngetpeername")] pub fn getpeername(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int; #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] @@ -793,6 +800,7 @@ extern "C" { link_name = "getsockname$UNIX2003" )] #[cfg_attr(target_os = "espidf", link_name = "lwip_getsockname")] + #[cfg_attr(target_os = "aix", link_name = "ngetsockname")] pub fn getsockname(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int; #[cfg_attr(target_os = "espidf", link_name = "lwip_setsockopt")] @@ -1372,6 +1380,7 @@ extern "C" { ), link_name = "res_9_init" )] + #[cfg_attr(target_os = "aix", link_name = "_res_init")] pub fn res_init() -> c_int; #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")] @@ -1406,6 +1415,7 @@ extern "C" { #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] // FIXME(time): for `time_t` pub fn difftime(time1: time_t, time0: time_t) -> c_double; + #[cfg(not(target_os = "aix"))] #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")] #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] // FIXME(time): for `time_t` @@ -1466,6 +1476,7 @@ extern "C" { link_name = "select$UNIX2003" )] #[cfg_attr(target_os = "netbsd", link_name = "__select50")] + #[cfg_attr(target_os = "aix", link_name = "__fd_select")] pub fn select( nfds: c_int, readfds: *mut fd_set, @@ -1551,6 +1562,7 @@ extern "C" { pub fn ptsname(fd: c_int) -> *mut c_char; pub fn unlockpt(fd: c_int) -> c_int; + #[cfg(not(target_os = "aix"))] pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char; pub fn getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t; @@ -1583,7 +1595,8 @@ cfg_if! { target_os = "haiku", target_os = "nto", target_os = "solaris", - target_os = "cygwin" + target_os = "cygwin", + target_os = "aix", )))] { extern "C" { pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> c_int; @@ -1752,7 +1765,12 @@ cfg_if! { } cfg_if! { - if #[cfg(not(any( + if #[cfg(target_os = "aix")] { + extern "C" { + pub fn cfmakeraw(termios: *mut crate::termios) -> c_int; + pub fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; + } + } else if #[cfg(not(any( target_os = "solaris", target_os = "illumos", target_os = "nto", From b6971335c9b35720351e79ad85cedfbaef091bc6 Mon Sep 17 00:00:00 2001 From: Jakub Janowski Date: Tue, 15 Apr 2025 11:50:59 +0300 Subject: [PATCH 27/29] Cleanup IOCTL definitions in linux_like tree (backport ) (cherry picked from commit 49a6e233a085866dff1a4c410dc21d1cd96e861e) --- libc-test/build.rs | 2 + libc-test/semver/android.txt | 5 + src/unix/linux_like/android/mod.rs | 160 +---------------- src/unix/linux_like/linux/arch/generic/mod.rs | 46 +---- src/unix/linux_like/linux/arch/mips/mod.rs | 65 ------- src/unix/linux_like/linux/arch/powerpc/mod.rs | 65 ------- src/unix/linux_like/linux/arch/sparc/mod.rs | 63 ------- src/unix/linux_like/linux/gnu/mod.rs | 27 --- src/unix/linux_like/linux/mod.rs | 169 +++++------------- src/unix/linux_like/mod.rs | 149 ++++++++++++++- 10 files changed, 202 insertions(+), 549 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 74fce84d73765..a7752f0b36b66 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2054,6 +2054,8 @@ fn test_android(target: &str) { // sigval is a struct in Rust, but a union in C: "sigval" => "union sigval".to_string(), + "Ioctl" => "int".to_string(), + // put `struct` in front of all structs:. t if is_struct => format!("struct {t}"), diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 02705fedbf44d..881ed4378f7ce 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -634,6 +634,8 @@ FF1 FFDLY FF_CNT FF_MAX +FICLONE +FICLONERANGE FILE FILENAME_MAX FIOCLEX @@ -750,6 +752,8 @@ IFF_DYNAMIC IFF_LOOPBACK IFF_MASTER IFF_MULTICAST +IFF_NAPI +IFF_NAPI_FRAGS IFF_NOARP IFF_NOTRAILERS IFF_NO_CARRIER @@ -3321,6 +3325,7 @@ fgetpos fgets fgets_unlocked fgetxattr +file_clone_range fileno flistxattr flock diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 2aa47cda07b09..5915d9dcb631c 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -2,6 +2,15 @@ use crate::prelude::*; +cfg_if! { + if #[cfg(doc)] { + pub(crate) type Ioctl = c_int; + } else { + #[doc(hidden)] + pub type Ioctl = c_int; + } +} + pub type clock_t = c_long; pub type time_t = c_long; pub type suseconds_t = c_long; @@ -337,19 +346,6 @@ s! { pub dlpi_tls_data: *mut c_void, } - // linux/filter.h - pub struct sock_filter { - pub code: crate::__u16, - pub jt: crate::__u8, - pub jf: crate::__u8, - pub k: crate::__u32, - } - - pub struct sock_fprog { - pub len: c_ushort, - pub filter: *mut sock_filter, - } - // linux/seccomp.h pub struct seccomp_data { pub nr: c_int, @@ -1698,27 +1694,6 @@ pub const FIONREAD: c_int = 0x541B; pub const TIOCCONS: c_int = 0x541D; pub const TIOCSBRK: c_int = 0x5427; pub const TIOCCBRK: c_int = 0x5428; -cfg_if! { - if #[cfg(any( - target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64", - target_arch = "riscv64", - target_arch = "s390x" - ))] { - pub const FICLONE: c_int = 0x40049409; - pub const FICLONERANGE: c_int = 0x4020940D; - } else if #[cfg(any( - target_arch = "mips", - target_arch = "mips64", - target_arch = "powerpc", - target_arch = "powerpc64" - ))] { - pub const FICLONE: c_int = 0x80049409; - pub const FICLONERANGE: c_int = 0x8020940D; - } -} pub const ST_RDONLY: c_ulong = 1; pub const ST_NOSUID: c_ulong = 2; @@ -1900,38 +1875,6 @@ pub const BLKIOOPT: c_int = 0x1279; pub const BLKSSZGET: c_int = 0x1268; pub const BLKPBSZGET: c_int = 0x127B; -cfg_if! { - // Those type are constructed using the _IOC macro - // DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN - // where D stands for direction (either None (00), Read (01) or Write (11)) - // where S stands for size (int, long, struct...) - // where T stands for type ('f','v','X'...) - // where N stands for NR (NumbeR) - if #[cfg(any(target_arch = "x86", target_arch = "arm"))] { - pub const FS_IOC_GETFLAGS: c_int = 0x80046601; - pub const FS_IOC_SETFLAGS: c_int = 0x40046602; - pub const FS_IOC_GETVERSION: c_int = 0x80047601; - pub const FS_IOC_SETVERSION: c_int = 0x40047602; - pub const FS_IOC32_GETFLAGS: c_int = 0x80046601; - pub const FS_IOC32_SETFLAGS: c_int = 0x40046602; - pub const FS_IOC32_GETVERSION: c_int = 0x80047601; - pub const FS_IOC32_SETVERSION: c_int = 0x40047602; - } else if #[cfg(any( - target_arch = "x86_64", - target_arch = "riscv64", - target_arch = "aarch64" - ))] { - pub const FS_IOC_GETFLAGS: c_int = 0x80086601; - pub const FS_IOC_SETFLAGS: c_int = 0x40086602; - pub const FS_IOC_GETVERSION: c_int = 0x80087601; - pub const FS_IOC_SETVERSION: c_int = 0x40087602; - pub const FS_IOC32_GETFLAGS: c_int = 0x80046601; - pub const FS_IOC32_SETFLAGS: c_int = 0x40046602; - pub const FS_IOC32_GETVERSION: c_int = 0x80047601; - pub const FS_IOC32_SETVERSION: c_int = 0x40047602; - } -} - pub const EAI_AGAIN: c_int = 2; pub const EAI_BADFLAGS: c_int = 3; pub const EAI_FAIL: c_int = 4; @@ -2666,65 +2609,6 @@ pub const SND_CNT: usize = SND_MAX as usize + 1; pub const UINPUT_VERSION: c_uint = 5; pub const UINPUT_MAX_NAME_SIZE: usize = 80; -// bionic/libc/kernel/uapi/linux/if_tun.h -pub const IFF_TUN: c_int = 0x0001; -pub const IFF_TAP: c_int = 0x0002; -pub const IFF_NAPI: c_int = 0x0010; -pub const IFF_NAPI_FRAGS: c_int = 0x0020; -pub const IFF_NO_CARRIER: c_int = 0x0040; -pub const IFF_NO_PI: c_int = 0x1000; -pub const IFF_ONE_QUEUE: c_int = 0x2000; -pub const IFF_VNET_HDR: c_int = 0x4000; -pub const IFF_TUN_EXCL: c_int = 0x8000; -pub const IFF_MULTI_QUEUE: c_int = 0x0100; -pub const IFF_ATTACH_QUEUE: c_int = 0x0200; -pub const IFF_DETACH_QUEUE: c_int = 0x0400; -pub const IFF_PERSIST: c_int = 0x0800; -pub const IFF_NOFILTER: c_int = 0x1000; -pub const TUN_TX_TIMESTAMP: c_int = 1; -// Features for GSO (TUNSETOFFLOAD) -pub const TUN_F_CSUM: c_uint = 0x01; -pub const TUN_F_TSO4: c_uint = 0x02; -pub const TUN_F_TSO6: c_uint = 0x04; -pub const TUN_F_TSO_ECN: c_uint = 0x08; -pub const TUN_F_UFO: c_uint = 0x10; -pub const TUN_F_USO4: c_uint = 0x20; -pub const TUN_F_USO6: c_uint = 0x40; -// Protocol info prepended to the packets (when IFF_NO_PI is not set) -pub const TUN_PKT_STRIP: c_int = 0x0001; -// Accept all multicast packets -pub const TUN_FLT_ALLMULTI: c_int = 0x0001; -// Ioctl operation codes -const T_TYPE: u32 = b'T' as u32; -pub const TUNSETNOCSUM: c_int = _IOW::(T_TYPE, 200); -pub const TUNSETDEBUG: c_int = _IOW::(T_TYPE, 201); -pub const TUNSETIFF: c_int = _IOW::(T_TYPE, 202); -pub const TUNSETPERSIST: c_int = _IOW::(T_TYPE, 203); -pub const TUNSETOWNER: c_int = _IOW::(T_TYPE, 204); -pub const TUNSETLINK: c_int = _IOW::(T_TYPE, 205); -pub const TUNSETGROUP: c_int = _IOW::(T_TYPE, 206); -pub const TUNGETFEATURES: c_int = _IOR::(T_TYPE, 207); -pub const TUNSETOFFLOAD: c_int = _IOW::(T_TYPE, 208); -pub const TUNSETTXFILTER: c_int = _IOW::(T_TYPE, 209); -pub const TUNGETIFF: c_int = _IOR::(T_TYPE, 210); -pub const TUNGETSNDBUF: c_int = _IOR::(T_TYPE, 211); -pub const TUNSETSNDBUF: c_int = _IOW::(T_TYPE, 212); -pub const TUNATTACHFILTER: c_int = _IOW::(T_TYPE, 213); -pub const TUNDETACHFILTER: c_int = _IOW::(T_TYPE, 214); -pub const TUNGETVNETHDRSZ: c_int = _IOR::(T_TYPE, 215); -pub const TUNSETVNETHDRSZ: c_int = _IOW::(T_TYPE, 216); -pub const TUNSETQUEUE: c_int = _IOW::(T_TYPE, 217); -pub const TUNSETIFINDEX: c_int = _IOW::(T_TYPE, 218); -pub const TUNGETFILTER: c_int = _IOR::(T_TYPE, 219); -pub const TUNSETVNETLE: c_int = _IOW::(T_TYPE, 220); -pub const TUNGETVNETLE: c_int = _IOR::(T_TYPE, 221); -pub const TUNSETVNETBE: c_int = _IOW::(T_TYPE, 222); -pub const TUNGETVNETBE: c_int = _IOR::(T_TYPE, 223); -pub const TUNSETSTEERINGEBPF: c_int = _IOR::(T_TYPE, 224); -pub const TUNSETFILTEREBPF: c_int = _IOR::(T_TYPE, 225); -pub const TUNSETCARRIER: c_int = _IOW::(T_TYPE, 226); -pub const TUNGETDEVNETNS: c_int = _IO(T_TYPE, 227); - // start android/platform/bionic/libc/kernel/uapi/linux/if_ether.h // from https://android.googlesource.com/platform/bionic/+/HEAD/libc/kernel/uapi/linux/if_ether.h pub const ETH_ALEN: c_int = 6; @@ -3758,7 +3642,6 @@ extern "C" { pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; pub fn mlock2(addr: *const c_void, len: size_t, flags: c_int) -> c_int; pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; - pub fn ioctl(fd: c_int, request: c_int, ...) -> c_int; pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; pub fn recvfrom( @@ -4299,28 +4182,3 @@ impl siginfo_t { self.sifields().sigchld.si_stime } } - -/// Build an ioctl number for an argumentless ioctl. -pub const fn _IO(ty: u32, nr: u32) -> c_int { - super::_IOC(super::_IOC_NONE, ty, nr, 0) as c_int -} - -/// Build an ioctl number for an read-only ioctl. -pub const fn _IOR(ty: u32, nr: u32) -> c_int { - super::_IOC(super::_IOC_READ, ty, nr, mem::size_of::()) as c_int -} - -/// Build an ioctl number for an write-only ioctl. -pub const fn _IOW(ty: u32, nr: u32) -> c_int { - super::_IOC(super::_IOC_WRITE, ty, nr, mem::size_of::()) as c_int -} - -/// Build an ioctl number for a read-write ioctl. -pub const fn _IOWR(ty: u32, nr: u32) -> c_int { - super::_IOC( - super::_IOC_READ | super::_IOC_WRITE, - ty, - nr, - mem::size_of::(), - ) as c_int -} diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs index 75cb7e19375d0..33d3cfbd6b436 100644 --- a/src/unix/linux_like/linux/arch/generic/mod.rs +++ b/src/unix/linux_like/linux/arch/generic/mod.rs @@ -1,5 +1,5 @@ use crate::prelude::*; -use crate::{Ioctl, _IOR, _IOW}; +use crate::Ioctl; s! { pub struct termios2 { @@ -158,9 +158,6 @@ pub const SO_DEVMEM_LINEAR: c_int = 78; pub const SO_DEVMEM_DMABUF: c_int = 79; pub const SO_DEVMEM_DONTNEED: c_int = 80; -pub const FICLONE: Ioctl = _IOW::(0x94, 9) as Ioctl; -pub const FICLONERANGE: Ioctl = _IOW::(0x94, 13) as Ioctl; - // Defined in unix/linux_like/mod.rs // pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS; @@ -251,47 +248,6 @@ pub const BLKIOMIN: Ioctl = 0x1278; pub const BLKIOOPT: Ioctl = 0x1279; pub const BLKSSZGET: Ioctl = 0x1268; pub const BLKPBSZGET: Ioctl = 0x127B; -// linux/if_tun.h -pub const TUNSETNOCSUM: Ioctl = 0x400454c8; -pub const TUNSETDEBUG: Ioctl = 0x400454c9; -pub const TUNSETIFF: Ioctl = 0x400454ca; -pub const TUNSETPERSIST: Ioctl = 0x400454cb; -pub const TUNSETOWNER: Ioctl = 0x400454cc; -pub const TUNSETLINK: Ioctl = 0x400454cd; -pub const TUNSETGROUP: Ioctl = 0x400454ce; -pub const TUNGETFEATURES: Ioctl = 0x800454cf; -pub const TUNSETOFFLOAD: Ioctl = 0x400454d0; -pub const TUNSETTXFILTER: Ioctl = 0x400454d1; -pub const TUNGETIFF: Ioctl = 0x800454d2; -pub const TUNGETSNDBUF: Ioctl = 0x800454d3; -pub const TUNSETSNDBUF: Ioctl = 0x400454d4; -pub const TUNGETVNETHDRSZ: Ioctl = 0x800454d7; -pub const TUNSETVNETHDRSZ: Ioctl = 0x400454d8; -pub const TUNSETQUEUE: Ioctl = 0x400454d9; -pub const TUNSETIFINDEX: Ioctl = 0x400454da; -pub const TUNSETVNETLE: Ioctl = 0x400454dc; -pub const TUNGETVNETLE: Ioctl = 0x800454dd; -/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on - * little-endian hosts. Not all kernel configurations support them, but all - * configurations that support SET also support GET. - */ -pub const TUNSETVNETBE: Ioctl = 0x400454de; -pub const TUNGETVNETBE: Ioctl = 0x800454df; -pub const TUNSETSTEERINGEBPF: Ioctl = 0x800454e0; -pub const TUNSETFILTEREBPF: Ioctl = 0x800454e1; - -pub const FS_IOC_GETFLAGS: Ioctl = _IOR::('f' as u32, 1) as Ioctl; -pub const FS_IOC_SETFLAGS: Ioctl = _IOW::('f' as u32, 2) as Ioctl; -pub const FS_IOC_GETVERSION: Ioctl = _IOR::('v' as u32, 1) as Ioctl; -pub const FS_IOC_SETVERSION: Ioctl = _IOW::('v' as u32, 2) as Ioctl; -pub const FS_IOC32_GETFLAGS: Ioctl = _IOR::('f' as u32, 1) as Ioctl; -pub const FS_IOC32_SETFLAGS: Ioctl = _IOW::('f' as u32, 2) as Ioctl; -pub const FS_IOC32_GETVERSION: Ioctl = _IOR::('v' as u32, 1) as Ioctl; -pub const FS_IOC32_SETVERSION: Ioctl = _IOW::('v' as u32, 2) as Ioctl; - -pub const TUNATTACHFILTER: Ioctl = _IOW::('T' as u32, 213) as Ioctl; -pub const TUNDETACHFILTER: Ioctl = _IOW::('T' as u32, 214) as Ioctl; -pub const TUNGETFILTER: Ioctl = _IOR::('T' as u32, 219) as Ioctl; cfg_if! { if #[cfg(any(target_arch = "arm", target_arch = "s390x"))] { diff --git a/src/unix/linux_like/linux/arch/mips/mod.rs b/src/unix/linux_like/linux/arch/mips/mod.rs index 1ac2340a27385..bf58d5a145b82 100644 --- a/src/unix/linux_like/linux/arch/mips/mod.rs +++ b/src/unix/linux_like/linux/arch/mips/mod.rs @@ -131,9 +131,6 @@ pub const SO_DEVMEM_LINEAR: c_int = 78; pub const SO_DEVMEM_DMABUF: c_int = 79; pub const SO_DEVMEM_DONTNEED: c_int = 80; -pub const FICLONE: c_ulong = 0x80049409; -pub const FICLONERANGE: c_ulong = 0x8020940D; - // Defined in unix/linux_like/mod.rs // pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS; @@ -223,68 +220,6 @@ pub const BLKIOMIN: Ioctl = 0x20001278; pub const BLKIOOPT: Ioctl = 0x20001279; pub const BLKSSZGET: Ioctl = 0x20001268; pub const BLKPBSZGET: Ioctl = 0x2000127B; -// linux/if_tun.h -pub const TUNSETNOCSUM: Ioctl = 0x800454c8; -pub const TUNSETDEBUG: Ioctl = 0x800454c9; -pub const TUNSETIFF: Ioctl = 0x800454ca; -pub const TUNSETPERSIST: Ioctl = 0x800454cb; -pub const TUNSETOWNER: Ioctl = 0x800454cc; -pub const TUNSETLINK: Ioctl = 0x800454cd; -pub const TUNSETGROUP: Ioctl = 0x800454ce; -pub const TUNGETFEATURES: Ioctl = 0x400454cf; -pub const TUNSETOFFLOAD: Ioctl = 0x800454d0; -pub const TUNSETTXFILTER: Ioctl = 0x800454d1; -pub const TUNGETIFF: Ioctl = 0x400454d2; -pub const TUNGETSNDBUF: Ioctl = 0x400454d3; -pub const TUNSETSNDBUF: Ioctl = 0x800454d4; -pub const TUNGETVNETHDRSZ: Ioctl = 0x400454d7; -pub const TUNSETVNETHDRSZ: Ioctl = 0x800454d8; -pub const TUNSETQUEUE: Ioctl = 0x800454d9; -pub const TUNSETIFINDEX: Ioctl = 0x800454da; -pub const TUNSETVNETLE: Ioctl = 0x800454dc; -pub const TUNGETVNETLE: Ioctl = 0x400454dd; -/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on - * little-endian hosts. Not all kernel configurations support them, but all - * configurations that support SET also support GET. - */ -pub const TUNSETVNETBE: Ioctl = 0x800454de; -pub const TUNGETVNETBE: Ioctl = 0x400454df; -pub const TUNSETSTEERINGEBPF: Ioctl = 0x400454e0; -pub const TUNSETFILTEREBPF: Ioctl = 0x400454e1; - -cfg_if! { - // Those type are constructed using the _IOC macro - // DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN - // where D stands for direction (either None (00), Read (01) or Write (11)) - // where S stands for size (int, long, struct...) - // where T stands for type ('f','v','X'...) - // where N stands for NR (NumbeR) - if #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] { - pub const FS_IOC_GETFLAGS: Ioctl = 0x40046601; - pub const FS_IOC_SETFLAGS: Ioctl = 0x80046602; - pub const FS_IOC_GETVERSION: Ioctl = 0x40047601; - pub const FS_IOC_SETVERSION: Ioctl = 0x80047602; - pub const FS_IOC32_GETFLAGS: Ioctl = 0x40046601; - pub const FS_IOC32_SETFLAGS: Ioctl = 0x80046602; - pub const FS_IOC32_GETVERSION: Ioctl = 0x40047601; - pub const FS_IOC32_SETVERSION: Ioctl = 0x80047602; - pub const TUNATTACHFILTER: Ioctl = 0x800854d5; - pub const TUNDETACHFILTER: Ioctl = 0x800854d6; - pub const TUNGETFILTER: Ioctl = 0x400854db; - } else if #[cfg(any(target_arch = "mips64", target_arch = "mips64r6"))] { - pub const FS_IOC_GETFLAGS: Ioctl = 0x40086601; - pub const FS_IOC_SETFLAGS: Ioctl = 0x80086602; - pub const FS_IOC_GETVERSION: Ioctl = 0x40087601; - pub const FS_IOC_SETVERSION: Ioctl = 0x80087602; - pub const FS_IOC32_GETFLAGS: Ioctl = 0x40046601; - pub const FS_IOC32_SETFLAGS: Ioctl = 0x80046602; - pub const FS_IOC32_GETVERSION: Ioctl = 0x40047601; - pub const FS_IOC32_SETVERSION: Ioctl = 0x80047602; - pub const TUNATTACHFILTER: Ioctl = 0x801054d5; - pub const TUNDETACHFILTER: Ioctl = 0x801054d6; - pub const TUNGETFILTER: Ioctl = 0x401054db; - } -} cfg_if! { if #[cfg(target_env = "musl")] { diff --git a/src/unix/linux_like/linux/arch/powerpc/mod.rs b/src/unix/linux_like/linux/arch/powerpc/mod.rs index 23fac9fba6262..33a373ce1fa2f 100644 --- a/src/unix/linux_like/linux/arch/powerpc/mod.rs +++ b/src/unix/linux_like/linux/arch/powerpc/mod.rs @@ -113,9 +113,6 @@ pub const SO_DEVMEM_LINEAR: c_int = 78; pub const SO_DEVMEM_DMABUF: c_int = 79; pub const SO_DEVMEM_DONTNEED: c_int = 80; -pub const FICLONE: c_ulong = 0x80049409; -pub const FICLONERANGE: c_ulong = 0x8020940D; - // Defined in unix/linux_like/mod.rs // pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS; @@ -209,68 +206,6 @@ pub const BLKIOOPT: Ioctl = 0x20001279; pub const BLKSSZGET: Ioctl = 0x20001268; pub const BLKPBSZGET: Ioctl = 0x2000127B; //pub const FIOQSIZE: Ioctl = 0x40086680; -// linux/if_tun.h -pub const TUNSETNOCSUM: Ioctl = 0x800454c8; -pub const TUNSETDEBUG: Ioctl = 0x800454c9; -pub const TUNSETIFF: Ioctl = 0x800454ca; -pub const TUNSETPERSIST: Ioctl = 0x800454cb; -pub const TUNSETOWNER: Ioctl = 0x800454cc; -pub const TUNSETLINK: Ioctl = 0x800454cd; -pub const TUNSETGROUP: Ioctl = 0x800454ce; -pub const TUNGETFEATURES: Ioctl = 0x400454cf; -pub const TUNSETOFFLOAD: Ioctl = 0x800454d0; -pub const TUNSETTXFILTER: Ioctl = 0x800454d1; -pub const TUNGETIFF: Ioctl = 0x400454d2; -pub const TUNGETSNDBUF: Ioctl = 0x400454d3; -pub const TUNSETSNDBUF: Ioctl = 0x800454d4; -pub const TUNGETVNETHDRSZ: Ioctl = 0x400454d7; -pub const TUNSETVNETHDRSZ: Ioctl = 0x800454d8; -pub const TUNSETQUEUE: Ioctl = 0x800454d9; -pub const TUNSETIFINDEX: Ioctl = 0x800454da; -pub const TUNSETVNETLE: Ioctl = 0x800454dc; -pub const TUNGETVNETLE: Ioctl = 0x400454dd; -/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on - * little-endian hosts. Not all kernel configurations support them, but all - * configurations that support SET also support GET. - */ -pub const TUNSETVNETBE: Ioctl = 0x800454de; -pub const TUNGETVNETBE: Ioctl = 0x400454df; -pub const TUNSETSTEERINGEBPF: Ioctl = 0x400454e0; -pub const TUNSETFILTEREBPF: Ioctl = 0x400454e1; - -cfg_if! { - // Those type are constructed using the _IOC macro - // DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN - // where D stands for direction (either None (00), Read (01) or Write (11)) - // where S stands for size (int, long, struct...) - // where T stands for type ('f','v','X'...) - // where N stands for NR (NumbeR) - if #[cfg(target_arch = "powerpc")] { - pub const FS_IOC_GETFLAGS: Ioctl = 0x40046601; - pub const FS_IOC_SETFLAGS: Ioctl = 0x80046602; - pub const FS_IOC_GETVERSION: Ioctl = 0x40047601; - pub const FS_IOC_SETVERSION: Ioctl = 0x80047602; - pub const FS_IOC32_GETFLAGS: Ioctl = 0x40046601; - pub const FS_IOC32_SETFLAGS: Ioctl = 0x80046602; - pub const FS_IOC32_GETVERSION: Ioctl = 0x40047601; - pub const FS_IOC32_SETVERSION: Ioctl = 0x80047602; - pub const TUNATTACHFILTER: Ioctl = 0x800854d5; - pub const TUNDETACHFILTER: Ioctl = 0x800854d6; - pub const TUNGETFILTER: Ioctl = 0x400854db; - } else if #[cfg(target_arch = "powerpc64")] { - pub const FS_IOC_GETFLAGS: Ioctl = 0x40086601; - pub const FS_IOC_SETFLAGS: Ioctl = 0x80086602; - pub const FS_IOC_GETVERSION: Ioctl = 0x40087601; - pub const FS_IOC_SETVERSION: Ioctl = 0x80087602; - pub const FS_IOC32_GETFLAGS: Ioctl = 0x40046601; - pub const FS_IOC32_SETFLAGS: Ioctl = 0x80046602; - pub const FS_IOC32_GETVERSION: Ioctl = 0x40047601; - pub const FS_IOC32_SETVERSION: Ioctl = 0x80047602; - pub const TUNATTACHFILTER: Ioctl = 0x801054d5; - pub const TUNDETACHFILTER: Ioctl = 0x801054d6; - pub const TUNGETFILTER: Ioctl = 0x401054db; - } -} pub const TIOCM_LE: c_int = 0x001; pub const TIOCM_DTR: c_int = 0x002; diff --git a/src/unix/linux_like/linux/arch/sparc/mod.rs b/src/unix/linux_like/linux/arch/sparc/mod.rs index 86af2ad14bcd0..4c108ba7b71c1 100644 --- a/src/unix/linux_like/linux/arch/sparc/mod.rs +++ b/src/unix/linux_like/linux/arch/sparc/mod.rs @@ -199,35 +199,6 @@ pub const BLKPBSZGET: Ioctl = 0x2000127B; //pub const TIOCGRS485: Ioctl = 0x40205441; //pub const TIOCSRS485: Ioctl = 0xc0205442; -// linux/if_tun.h -pub const TUNSETNOCSUM: Ioctl = 0x800454c8; -pub const TUNSETDEBUG: Ioctl = 0x800454c9; -pub const TUNSETIFF: Ioctl = 0x800454ca; -pub const TUNSETPERSIST: Ioctl = 0x800454cb; -pub const TUNSETOWNER: Ioctl = 0x800454cc; -pub const TUNSETLINK: Ioctl = 0x800454cd; -pub const TUNSETGROUP: Ioctl = 0x800454ce; -pub const TUNGETFEATURES: Ioctl = 0x400454cf; -pub const TUNSETOFFLOAD: Ioctl = 0x800454d0; -pub const TUNSETTXFILTER: Ioctl = 0x800454d1; -pub const TUNGETIFF: Ioctl = 0x400454d2; -pub const TUNGETSNDBUF: Ioctl = 0x400454d3; -pub const TUNSETSNDBUF: Ioctl = 0x800454d4; -pub const TUNGETVNETHDRSZ: Ioctl = 0x400454d7; -pub const TUNSETVNETHDRSZ: Ioctl = 0x800454d8; -pub const TUNSETQUEUE: Ioctl = 0x800454d9; -pub const TUNSETIFINDEX: Ioctl = 0x800454da; -pub const TUNSETVNETLE: Ioctl = 0x800454dc; -pub const TUNGETVNETLE: Ioctl = 0x400454dd; -/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on - * little-endian hosts. Not all kernel configurations support them, but all - * configurations that support SET also support GET. - */ -pub const TUNSETVNETBE: Ioctl = 0x800454de; -pub const TUNGETVNETBE: Ioctl = 0x400454df; -pub const TUNSETSTEERINGEBPF: Ioctl = 0x400454e0; -pub const TUNSETFILTEREBPF: Ioctl = 0x400454e1; - pub const TIOCM_LE: c_int = 0x001; pub const TIOCM_DTR: c_int = 0x002; pub const TIOCM_RTS: c_int = 0x004; @@ -274,37 +245,3 @@ cfg_if! { pub const RLIM_INFINITY: crate::rlim_t = 0x7fffffff; } } - -cfg_if! { - // Those type are constructed using the _IOC macro - // DD-SS_SSSS_SSSS_SSSS-TTTT_TTTT-NNNN_NNNN - // where D stands for direction (either None (00), Read (01) or Write (11)) - // where S stands for size (int, long, struct...) - // where T stands for type ('f','v','X'...) - // where N stands for NR (NumbeR) - if #[cfg(target_arch = "sparc")] { - pub const FS_IOC_GETFLAGS: Ioctl = 0x40046601; - pub const FS_IOC_SETFLAGS: Ioctl = 0x80046602; - pub const FS_IOC_GETVERSION: Ioctl = 0x40047601; - pub const FS_IOC_SETVERSION: Ioctl = 0x80047602; - pub const FS_IOC32_GETFLAGS: Ioctl = 0x40046601; - pub const FS_IOC32_SETFLAGS: Ioctl = 0x80046602; - pub const FS_IOC32_GETVERSION: Ioctl = 0x40047601; - pub const FS_IOC32_SETVERSION: Ioctl = 0x80047602; - pub const TUNATTACHFILTER: Ioctl = 0x800854d5; - pub const TUNDETACHFILTER: Ioctl = 0x800854d6; - pub const TUNGETFILTER: Ioctl = 0x400854db; - } else if #[cfg(target_arch = "sparc64")] { - pub const FS_IOC_GETFLAGS: Ioctl = 0x40086601; - pub const FS_IOC_SETFLAGS: Ioctl = 0x80086602; - pub const FS_IOC_GETVERSION: Ioctl = 0x40087601; - pub const FS_IOC_SETVERSION: Ioctl = 0x80087602; - pub const FS_IOC32_GETFLAGS: Ioctl = 0x40046601; - pub const FS_IOC32_SETFLAGS: Ioctl = 0x80046602; - pub const FS_IOC32_GETVERSION: Ioctl = 0x40047601; - pub const FS_IOC32_SETVERSION: Ioctl = 0x80047602; - pub const TUNATTACHFILTER: Ioctl = 0x801054d5; - pub const TUNDETACHFILTER: Ioctl = 0x801054d6; - pub const TUNGETFILTER: Ioctl = 0x401054db; - } -} diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 49b009470af5a..5235bce1f4796 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -1149,33 +1149,6 @@ pub const REG_EEND: c_int = 14; pub const REG_ESIZE: c_int = 15; pub const REG_ERPAREN: c_int = 16; -cfg_if! { - if #[cfg(any( - target_arch = "x86", - target_arch = "x86_64", - target_arch = "arm", - target_arch = "aarch64", - target_arch = "loongarch64", - target_arch = "riscv64", - target_arch = "s390x" - ))] { - pub const TUNSETCARRIER: Ioctl = 0x400454e2; - pub const TUNGETDEVNETNS: Ioctl = 0x54e3; - } else if #[cfg(any( - target_arch = "mips", - target_arch = "mips64", - target_arch = "powerpc", - target_arch = "powerpc64", - target_arch = "sparc", - target_arch = "sparc64" - ))] { - pub const TUNSETCARRIER: Ioctl = 0x800454e2; - pub const TUNGETDEVNETNS: Ioctl = 0x200054e3; - } else { - // Unknown target_arch - } -} - extern "C" { pub fn fgetspent_r( fp: *mut crate::FILE, diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 94145420553be..021611af5b52f 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -3,6 +3,7 @@ use core::mem::size_of; use crate::prelude::*; +use crate::{sock_filter, _IO, _IOR, _IOW, _IOWR}; pub type useconds_t = u32; pub type dev_t = u64; @@ -758,19 +759,6 @@ s! { pub addr_mask: u8, } - // linux/filter.h - pub struct sock_filter { - pub code: __u16, - pub jt: __u8, - pub jf: __u8, - pub k: __u32, - } - - pub struct sock_fprog { - pub len: c_ushort, - pub filter: *mut sock_filter, - } - // linux/seccomp.h pub struct seccomp_data { pub nr: c_int, @@ -825,13 +813,6 @@ s! { pub nla_type: u16, } - pub struct file_clone_range { - pub src_fd: crate::__s64, - pub src_offset: crate::__u64, - pub src_length: crate::__u64, - pub dest_offset: crate::__u64, - } - pub struct __c_anonymous_ifru_map { pub mem_start: c_ulong, pub mem_end: c_ulong, @@ -2981,46 +2962,6 @@ pub const IFLA_INFO_XSTATS: c_ushort = 3; pub const IFLA_INFO_SLAVE_KIND: c_ushort = 4; pub const IFLA_INFO_SLAVE_DATA: c_ushort = 5; -// linux/if_tun.h -/* TUNSETIFF ifr flags */ -pub const IFF_TUN: c_int = 0x0001; -pub const IFF_TAP: c_int = 0x0002; -pub const IFF_NAPI: c_int = 0x0010; -pub const IFF_NAPI_FRAGS: c_int = 0x0020; -// Used in TUNSETIFF to bring up tun/tap without carrier -pub const IFF_NO_CARRIER: c_int = 0x0040; -pub const IFF_NO_PI: c_int = 0x1000; -// Read queue size -pub const TUN_READQ_SIZE: c_short = 500; -// TUN device type flags: deprecated. Use IFF_TUN/IFF_TAP instead. -pub const TUN_TUN_DEV: c_short = crate::IFF_TUN as c_short; -pub const TUN_TAP_DEV: c_short = crate::IFF_TAP as c_short; -pub const TUN_TYPE_MASK: c_short = 0x000f; -// This flag has no real effect -pub const IFF_ONE_QUEUE: c_int = 0x2000; -pub const IFF_VNET_HDR: c_int = 0x4000; -pub const IFF_TUN_EXCL: c_int = 0x8000; -pub const IFF_MULTI_QUEUE: c_int = 0x0100; -pub const IFF_ATTACH_QUEUE: c_int = 0x0200; -pub const IFF_DETACH_QUEUE: c_int = 0x0400; -// read-only flag -pub const IFF_PERSIST: c_int = 0x0800; -pub const IFF_NOFILTER: c_int = 0x1000; -// Socket options -pub const TUN_TX_TIMESTAMP: c_int = 1; -// Features for GSO (TUNSETOFFLOAD) -pub const TUN_F_CSUM: c_uint = 0x01; -pub const TUN_F_TSO4: c_uint = 0x02; -pub const TUN_F_TSO6: c_uint = 0x04; -pub const TUN_F_TSO_ECN: c_uint = 0x08; -pub const TUN_F_UFO: c_uint = 0x10; -pub const TUN_F_USO4: c_uint = 0x20; -pub const TUN_F_USO6: c_uint = 0x40; -// Protocol info prepended to the packets (when IFF_NO_PI is not set) -pub const TUN_PKT_STRIP: c_int = 0x0001; -// Accept all multicast packets -pub const TUN_FLT_ALLMULTI: c_int = 0x0001; - // Since Linux 3.1 pub const SEEK_DATA: c_int = 3; pub const SEEK_HOLE: c_int = 4; @@ -3233,23 +3174,23 @@ pub const MREMAP_DONTUNMAP: c_int = 4; // linux/nsfs.h const NSIO: c_uint = 0xb7; -pub const NS_GET_USERNS: c_uint = _IO(NSIO, 0x1); -pub const NS_GET_PARENT: c_uint = _IO(NSIO, 0x2); -pub const NS_GET_NSTYPE: c_uint = _IO(NSIO, 0x3); -pub const NS_GET_OWNER_UID: c_uint = _IO(NSIO, 0x4); +pub const NS_GET_USERNS: Ioctl = _IO(NSIO, 0x1); +pub const NS_GET_PARENT: Ioctl = _IO(NSIO, 0x2); +pub const NS_GET_NSTYPE: Ioctl = _IO(NSIO, 0x3); +pub const NS_GET_OWNER_UID: Ioctl = _IO(NSIO, 0x4); -pub const NS_GET_MNTNS_ID: c_uint = _IOR::<__u64>(NSIO, 0x5); +pub const NS_GET_MNTNS_ID: Ioctl = _IOR::<__u64>(NSIO, 0x5); -pub const NS_GET_PID_FROM_PIDNS: c_uint = _IOR::(NSIO, 0x6); -pub const NS_GET_TGID_FROM_PIDNS: c_uint = _IOR::(NSIO, 0x7); -pub const NS_GET_PID_IN_PIDNS: c_uint = _IOR::(NSIO, 0x8); -pub const NS_GET_TGID_IN_PIDNS: c_uint = _IOR::(NSIO, 0x9); +pub const NS_GET_PID_FROM_PIDNS: Ioctl = _IOR::(NSIO, 0x6); +pub const NS_GET_TGID_FROM_PIDNS: Ioctl = _IOR::(NSIO, 0x7); +pub const NS_GET_PID_IN_PIDNS: Ioctl = _IOR::(NSIO, 0x8); +pub const NS_GET_TGID_IN_PIDNS: Ioctl = _IOR::(NSIO, 0x9); -pub const MNT_NS_INFO_SIZE_VER0: c_uint = 16; +pub const MNT_NS_INFO_SIZE_VER0: Ioctl = 16; -pub const NS_MNT_GET_INFO: c_uint = _IOR::(NSIO, 10); -pub const NS_MNT_GET_NEXT: c_uint = _IOR::(NSIO, 11); -pub const NS_MNT_GET_PREV: c_uint = _IOR::(NSIO, 12); +pub const NS_MNT_GET_INFO: Ioctl = _IOR::(NSIO, 10); +pub const NS_MNT_GET_NEXT: Ioctl = _IOR::(NSIO, 11); +pub const NS_MNT_GET_PREV: Ioctl = _IOR::(NSIO, 12); // linux/pidfd.h pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint; @@ -3267,17 +3208,17 @@ pub const PIDFD_INFO_EXIT: c_uint = 1 << 3; pub const PIDFD_INFO_SIZE_VER0: c_uint = 64; const PIDFS_IOCTL_MAGIC: c_uint = 0xFF; -pub const PIDFD_GET_CGROUP_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 1); -pub const PIDFD_GET_IPC_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 2); -pub const PIDFD_GET_MNT_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 3); -pub const PIDFD_GET_NET_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 4); -pub const PIDFD_GET_PID_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 5); -pub const PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 6); -pub const PIDFD_GET_TIME_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 7); -pub const PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 8); -pub const PIDFD_GET_USER_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 9); -pub const PIDFD_GET_UTS_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 10); -pub const PIDFD_GET_INFO: c_uint = _IOWR::(PIDFS_IOCTL_MAGIC, 11); +pub const PIDFD_GET_CGROUP_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 1); +pub const PIDFD_GET_IPC_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 2); +pub const PIDFD_GET_MNT_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 3); +pub const PIDFD_GET_NET_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 4); +pub const PIDFD_GET_PID_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 5); +pub const PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 6); +pub const PIDFD_GET_TIME_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 7); +pub const PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 8); +pub const PIDFD_GET_USER_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 9); +pub const PIDFD_GET_UTS_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 10); +pub const PIDFD_GET_INFO: Ioctl = _IOWR::(PIDFS_IOCTL_MAGIC, 11); // linux/prctl.h pub const PR_SET_PDEATHSIG: c_int = 1; @@ -4846,25 +4787,25 @@ pub const PTP_MAX_SAMPLES: c_uint = 25; // Maximum allowed offset measurement sa const PTP_CLK_MAGIC: u32 = b'=' as u32; -pub const PTP_CLOCK_GETCAPS: c_uint = _IOR::(PTP_CLK_MAGIC, 1); -pub const PTP_EXTTS_REQUEST: c_uint = _IOW::(PTP_CLK_MAGIC, 2); -pub const PTP_PEROUT_REQUEST: c_uint = _IOW::(PTP_CLK_MAGIC, 3); -pub const PTP_ENABLE_PPS: c_uint = _IOW::(PTP_CLK_MAGIC, 4); -pub const PTP_SYS_OFFSET: c_uint = _IOW::(PTP_CLK_MAGIC, 5); -pub const PTP_PIN_GETFUNC: c_uint = _IOWR::(PTP_CLK_MAGIC, 6); -pub const PTP_PIN_SETFUNC: c_uint = _IOW::(PTP_CLK_MAGIC, 7); -pub const PTP_SYS_OFFSET_PRECISE: c_uint = _IOWR::(PTP_CLK_MAGIC, 8); -pub const PTP_SYS_OFFSET_EXTENDED: c_uint = _IOWR::(PTP_CLK_MAGIC, 9); - -pub const PTP_CLOCK_GETCAPS2: c_uint = _IOR::(PTP_CLK_MAGIC, 10); -pub const PTP_EXTTS_REQUEST2: c_uint = _IOW::(PTP_CLK_MAGIC, 11); -pub const PTP_PEROUT_REQUEST2: c_uint = _IOW::(PTP_CLK_MAGIC, 12); -pub const PTP_ENABLE_PPS2: c_uint = _IOW::(PTP_CLK_MAGIC, 13); -pub const PTP_SYS_OFFSET2: c_uint = _IOW::(PTP_CLK_MAGIC, 14); -pub const PTP_PIN_GETFUNC2: c_uint = _IOWR::(PTP_CLK_MAGIC, 15); -pub const PTP_PIN_SETFUNC2: c_uint = _IOW::(PTP_CLK_MAGIC, 16); -pub const PTP_SYS_OFFSET_PRECISE2: c_uint = _IOWR::(PTP_CLK_MAGIC, 17); -pub const PTP_SYS_OFFSET_EXTENDED2: c_uint = _IOWR::(PTP_CLK_MAGIC, 18); +pub const PTP_CLOCK_GETCAPS: Ioctl = _IOR::(PTP_CLK_MAGIC, 1); +pub const PTP_EXTTS_REQUEST: Ioctl = _IOW::(PTP_CLK_MAGIC, 2); +pub const PTP_PEROUT_REQUEST: Ioctl = _IOW::(PTP_CLK_MAGIC, 3); +pub const PTP_ENABLE_PPS: Ioctl = _IOW::(PTP_CLK_MAGIC, 4); +pub const PTP_SYS_OFFSET: Ioctl = _IOW::(PTP_CLK_MAGIC, 5); +pub const PTP_PIN_GETFUNC: Ioctl = _IOWR::(PTP_CLK_MAGIC, 6); +pub const PTP_PIN_SETFUNC: Ioctl = _IOW::(PTP_CLK_MAGIC, 7); +pub const PTP_SYS_OFFSET_PRECISE: Ioctl = _IOWR::(PTP_CLK_MAGIC, 8); +pub const PTP_SYS_OFFSET_EXTENDED: Ioctl = _IOWR::(PTP_CLK_MAGIC, 9); + +pub const PTP_CLOCK_GETCAPS2: Ioctl = _IOR::(PTP_CLK_MAGIC, 10); +pub const PTP_EXTTS_REQUEST2: Ioctl = _IOW::(PTP_CLK_MAGIC, 11); +pub const PTP_PEROUT_REQUEST2: Ioctl = _IOW::(PTP_CLK_MAGIC, 12); +pub const PTP_ENABLE_PPS2: Ioctl = _IOW::(PTP_CLK_MAGIC, 13); +pub const PTP_SYS_OFFSET2: Ioctl = _IOW::(PTP_CLK_MAGIC, 14); +pub const PTP_PIN_GETFUNC2: Ioctl = _IOWR::(PTP_CLK_MAGIC, 15); +pub const PTP_PIN_SETFUNC2: Ioctl = _IOW::(PTP_CLK_MAGIC, 16); +pub const PTP_SYS_OFFSET_PRECISE2: Ioctl = _IOWR::(PTP_CLK_MAGIC, 17); +pub const PTP_SYS_OFFSET_EXTENDED2: Ioctl = _IOWR::(PTP_CLK_MAGIC, 18); // enum ptp_pin_function pub const PTP_PF_NONE: c_uint = 0; @@ -6093,26 +6034,6 @@ pub const EPIOCGPARAMS: Ioctl = 0x80088a02; pub const SI_DETHREAD: c_int = -7; pub const TRAP_PERF: c_int = 6; -/// Build an ioctl number for an argumentless ioctl. -pub const fn _IO(ty: u32, nr: u32) -> u32 { - super::_IOC(super::_IOC_NONE, ty, nr, 0) -} - -/// Build an ioctl number for an read-only ioctl. -pub const fn _IOR(ty: u32, nr: u32) -> u32 { - super::_IOC(super::_IOC_READ, ty, nr, size_of::()) -} - -/// Build an ioctl number for an write-only ioctl. -pub const fn _IOW(ty: u32, nr: u32) -> u32 { - super::_IOC(super::_IOC_WRITE, ty, nr, size_of::()) -} - -/// Build an ioctl number for a read-write ioctl. -pub const fn _IOWR(ty: u32, nr: u32) -> u32 { - super::_IOC(super::_IOC_READ | super::_IOC_WRITE, ty, nr, size_of::()) -} - f! { pub fn NLA_ALIGN(len: c_int) -> c_int { return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1); @@ -7097,8 +7018,6 @@ extern "C" { ) -> ssize_t; pub fn klogctl(syslog_type: c_int, bufp: *mut c_char, len: c_int) -> c_int; - - pub fn ioctl(fd: c_int, request: Ioctl, ...) -> c_int; } // LFS64 extensions diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index c730947529fb6..aab4cb385e000 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -207,6 +207,32 @@ s! { } } +cfg_if! { + if #[cfg(not(target_os = "emscripten"))] { + s! { + pub struct file_clone_range { + pub src_fd: crate::__s64, + pub src_offset: crate::__u64, + pub src_length: crate::__u64, + pub dest_offset: crate::__u64, + } + + // linux/filter.h + pub struct sock_filter { + pub code: __u16, + pub jt: __u8, + pub jf: __u8, + pub k: __u32, + } + + pub struct sock_fprog { + pub len: c_ushort, + pub filter: *mut sock_filter, + } + } + } +} + cfg_if! { if #[cfg(any(target_env = "gnu", target_os = "android"))] { s! { @@ -1482,6 +1508,93 @@ pub const ARPHRD_IEEE802154: u16 = 804; pub const ARPHRD_VOID: u16 = 0xFFFF; pub const ARPHRD_NONE: u16 = 0xFFFE; +cfg_if! { + if #[cfg(not(target_os = "emscripten"))] { + // linux/if_tun.h + /* TUNSETIFF ifr flags */ + pub const IFF_TUN: c_int = 0x0001; + pub const IFF_TAP: c_int = 0x0002; + pub const IFF_NAPI: c_int = 0x0010; + pub const IFF_NAPI_FRAGS: c_int = 0x0020; + // Used in TUNSETIFF to bring up tun/tap without carrier + pub const IFF_NO_CARRIER: c_int = 0x0040; + pub const IFF_NO_PI: c_int = 0x1000; + // Read queue size + pub const TUN_READQ_SIZE: c_short = 500; + // TUN device type flags: deprecated. Use IFF_TUN/IFF_TAP instead. + pub const TUN_TUN_DEV: c_short = crate::IFF_TUN as c_short; + pub const TUN_TAP_DEV: c_short = crate::IFF_TAP as c_short; + pub const TUN_TYPE_MASK: c_short = 0x000f; + // This flag has no real effect + pub const IFF_ONE_QUEUE: c_int = 0x2000; + pub const IFF_VNET_HDR: c_int = 0x4000; + pub const IFF_TUN_EXCL: c_int = 0x8000; + pub const IFF_MULTI_QUEUE: c_int = 0x0100; + pub const IFF_ATTACH_QUEUE: c_int = 0x0200; + pub const IFF_DETACH_QUEUE: c_int = 0x0400; + // read-only flag + pub const IFF_PERSIST: c_int = 0x0800; + pub const IFF_NOFILTER: c_int = 0x1000; + // Socket options + pub const TUN_TX_TIMESTAMP: c_int = 1; + // Features for GSO (TUNSETOFFLOAD) + pub const TUN_F_CSUM: c_uint = 0x01; + pub const TUN_F_TSO4: c_uint = 0x02; + pub const TUN_F_TSO6: c_uint = 0x04; + pub const TUN_F_TSO_ECN: c_uint = 0x08; + pub const TUN_F_UFO: c_uint = 0x10; + pub const TUN_F_USO4: c_uint = 0x20; + pub const TUN_F_USO6: c_uint = 0x40; + // Protocol info prepended to the packets (when IFF_NO_PI is not set) + pub const TUN_PKT_STRIP: c_int = 0x0001; + // Accept all multicast packets + pub const TUN_FLT_ALLMULTI: c_int = 0x0001; + // Ioctl operation codes + const T_TYPE: u32 = b'T' as u32; + pub const TUNSETNOCSUM: Ioctl = _IOW::(T_TYPE, 200); + pub const TUNSETDEBUG: Ioctl = _IOW::(T_TYPE, 201); + pub const TUNSETIFF: Ioctl = _IOW::(T_TYPE, 202); + pub const TUNSETPERSIST: Ioctl = _IOW::(T_TYPE, 203); + pub const TUNSETOWNER: Ioctl = _IOW::(T_TYPE, 204); + pub const TUNSETLINK: Ioctl = _IOW::(T_TYPE, 205); + pub const TUNSETGROUP: Ioctl = _IOW::(T_TYPE, 206); + pub const TUNGETFEATURES: Ioctl = _IOR::(T_TYPE, 207); + pub const TUNSETOFFLOAD: Ioctl = _IOW::(T_TYPE, 208); + pub const TUNSETTXFILTER: Ioctl = _IOW::(T_TYPE, 209); + pub const TUNGETIFF: Ioctl = _IOR::(T_TYPE, 210); + pub const TUNGETSNDBUF: Ioctl = _IOR::(T_TYPE, 211); + pub const TUNSETSNDBUF: Ioctl = _IOW::(T_TYPE, 212); + pub const TUNATTACHFILTER: Ioctl = _IOW::(T_TYPE, 213); + pub const TUNDETACHFILTER: Ioctl = _IOW::(T_TYPE, 214); + pub const TUNGETVNETHDRSZ: Ioctl = _IOR::(T_TYPE, 215); + pub const TUNSETVNETHDRSZ: Ioctl = _IOW::(T_TYPE, 216); + pub const TUNSETQUEUE: Ioctl = _IOW::(T_TYPE, 217); + pub const TUNSETIFINDEX: Ioctl = _IOW::(T_TYPE, 218); + pub const TUNGETFILTER: Ioctl = _IOR::(T_TYPE, 219); + pub const TUNSETVNETLE: Ioctl = _IOW::(T_TYPE, 220); + pub const TUNGETVNETLE: Ioctl = _IOR::(T_TYPE, 221); + pub const TUNSETVNETBE: Ioctl = _IOW::(T_TYPE, 222); + pub const TUNGETVNETBE: Ioctl = _IOR::(T_TYPE, 223); + pub const TUNSETSTEERINGEBPF: Ioctl = _IOR::(T_TYPE, 224); + pub const TUNSETFILTEREBPF: Ioctl = _IOR::(T_TYPE, 225); + pub const TUNSETCARRIER: Ioctl = _IOW::(T_TYPE, 226); + pub const TUNGETDEVNETNS: Ioctl = _IO(T_TYPE, 227); + + // linux/fs.h + pub const FS_IOC_GETFLAGS: Ioctl = _IOR::('f' as u32, 1); + pub const FS_IOC_SETFLAGS: Ioctl = _IOW::('f' as u32, 2); + pub const FS_IOC_GETVERSION: Ioctl = _IOR::('v' as u32, 1); + pub const FS_IOC_SETVERSION: Ioctl = _IOW::('v' as u32, 2); + pub const FS_IOC32_GETFLAGS: Ioctl = _IOR::('f' as u32, 1); + pub const FS_IOC32_SETFLAGS: Ioctl = _IOW::('f' as u32, 2); + pub const FS_IOC32_GETVERSION: Ioctl = _IOR::('v' as u32, 1); + pub const FS_IOC32_SETVERSION: Ioctl = _IOW::('v' as u32, 2); + + pub const FICLONE: Ioctl = _IOW::(0x94, 9); + pub const FICLONERANGE: Ioctl = _IOW::(0x94, 13); + } +} + cfg_if! { if #[cfg(target_os = "emscripten")] { // Emscripten does not define any `*_SUPER_MAGIC` constants. @@ -1633,11 +1746,7 @@ cfg_if! { // https://github.com/search?q=repo%3Atorvalds%2Flinux+%22%23define+_IOC_NONE%22&type=code cfg_if! { - if #[cfg(any( - target_os = "linux", - target_os = "android", - target_os = "l4re" - ))] { + if #[cfg(not(target_os = "emscripten"))] { const _IOC_NRBITS: u32 = 8; const _IOC_TYPEBITS: u32 = 8; @@ -1681,7 +1790,7 @@ cfg_if! { // adapted from https://github.com/torvalds/linux/blob/8a696a29c6905594e4abf78eaafcb62165ac61f1/rust/kernel/ioctl.rs /// Build an ioctl number, analogous to the C macro of the same name. - const fn _IOC(dir: u32, ty: u32, nr: u32, size: usize) -> u32 { + const fn _IOC(dir: u32, ty: u32, nr: u32, size: usize) -> Ioctl { // FIXME(ctest) the `garando_syntax` crate (used by ctest in the CI test suite) // cannot currently parse these `debug_assert!`s // @@ -1690,10 +1799,34 @@ cfg_if! { // debug_assert!(nr <= _IOC_NRMASK); // debug_assert!(size <= (_IOC_SIZEMASK as usize)); - (dir << _IOC_DIRSHIFT) + ((dir << _IOC_DIRSHIFT) | (ty << _IOC_TYPESHIFT) | (nr << _IOC_NRSHIFT) - | ((size as u32) << _IOC_SIZESHIFT) + | ((size as u32) << _IOC_SIZESHIFT)) as Ioctl + } + + /// Build an ioctl number for an argumentless ioctl. + pub const fn _IO(ty: u32, nr: u32) -> Ioctl { + _IOC(_IOC_NONE, ty, nr, 0) + } + + /// Build an ioctl number for an read-only ioctl. + pub const fn _IOR(ty: u32, nr: u32) -> Ioctl { + _IOC(_IOC_READ, ty, nr, mem::size_of::()) + } + + /// Build an ioctl number for an write-only ioctl. + pub const fn _IOW(ty: u32, nr: u32) -> Ioctl { + _IOC(_IOC_WRITE, ty, nr, mem::size_of::()) + } + + /// Build an ioctl number for a read-write ioctl. + pub const fn _IOWR(ty: u32, nr: u32) -> Ioctl { + _IOC(_IOC_READ | _IOC_WRITE, ty, nr, mem::size_of::()) + } + + extern "C" { + pub fn ioctl(fd: c_int, request: Ioctl, ...) -> c_int; } } } From a64612fcc51ff37a275eff554bf59f0161261af5 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Wed, 28 May 2025 16:47:18 +0800 Subject: [PATCH 28/29] Add arc4random and arc4random_buf to NuttX * Declare `arc4random` and `arc4random_buf` as extern "C" functions in the NuttX module * Enable access to system-provided random number generation for NuttX targets * Aligns NuttX FFI with other Unix platforms that expose these functions This change allows Rust code targeting NuttX to use `arc4random` and `arc4random_buf` for secure random number generation, improving compatibility and feature parity with other targets. (backport ) (cherry picked from commit f8e47462b503fa432ac2b248a53d830b471b5ec1) --- src/unix/nuttx/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index 015a2ba9afbd0..de734f9e0f63d 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -591,4 +591,6 @@ extern "C" { pub fn pthread_setname_np(thread: pthread_t, name: *const c_char) -> i32; pub fn pthread_getname_np(thread: pthread_t, name: *mut c_char, len: usize) -> i32; pub fn getrandom(buf: *mut c_void, buflen: usize, flags: u32) -> isize; + pub fn arc4random() -> u32; + pub fn arc4random_buf(bytes: *mut c_void, nbytes: usize); } From 00c199937c0c7600d7d425a67d9b30b38ac3d2cc Mon Sep 17 00:00:00 2001 From: Bben01 <52465698+Bben01@users.noreply.github.com> Date: Wed, 30 Apr 2025 10:29:29 +0300 Subject: [PATCH 29/29] Add constants from linux/cn_proc.h and linux/connector.h (backport ) (cherry picked from commit abd00f80b61fa48e394fb600f95fee63c78c6537) --- ci/style.sh | 2 +- libc-test/build.rs | 5 ++++ src/unix/linux_like/linux/mod.rs | 45 ++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/ci/style.sh b/ci/style.sh index 0d4a4f953dda1..97a9bc47bc132 100755 --- a/ci/style.sh +++ b/ci/style.sh @@ -26,7 +26,7 @@ while IFS= read -r file; do # Turn all braced macro `foo! { /* ... */ }` invocations into # `fn foo_fmt_tmp() { /* ... */ }`. - perl -pi -e 's/(?!macro_rules)\b(\w+)!\s*\{/fn $1_fmt_tmp() {/g' "$file" + perl -pi -e 's/(?!macro_rules|c_enum)\b(\w+)!\s*\{/fn $1_fmt_tmp() {/g' "$file" # Replace `if #[cfg(...)]` within `cfg_if` with `if cfg_tmp!([...])` which # `rustfmt` will format. We put brackets within the parens so it is easy to diff --git a/libc-test/build.rs b/libc-test/build.rs index a7752f0b36b66..4815715a5c493 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3879,6 +3879,8 @@ fn test_linux(target: &str) { "linux/can.h", "linux/can/raw.h", "linux/can/j1939.h", + "linux/cn_proc.h", + "linux/connector.h", "linux/dccp.h", "linux/errqueue.h", "linux/falloc.h", @@ -4699,6 +4701,9 @@ fn test_linux(target: &str) { // FIXME(linux): Requires >= 6.4 kernel headers. "PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG" | "PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG" => true, + // FIXME(linux): Requires >= 6.6 kernel headers. + "PROC_EVENT_NONZERO_EXIT" => true, + _ => false, } }); diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 021611af5b52f..bfae5592a431c 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -4734,6 +4734,51 @@ pub const RTNLGRP_MCTP_IFADDR: c_uint = 0x22; pub const RTNLGRP_TUNNEL: c_uint = 0x23; pub const RTNLGRP_STATS: c_uint = 0x24; +// linux/cn_proc.h +c_enum! { + proc_cn_mcast_op { + PROC_CN_MCAST_LISTEN = 1, + PROC_CN_MCAST_IGNORE = 2, + } +} + +c_enum! { + proc_cn_event { + PROC_EVENT_NONE = 0x00000000, + PROC_EVENT_FORK = 0x00000001, + PROC_EVENT_EXEC = 0x00000002, + PROC_EVENT_UID = 0x00000004, + PROC_EVENT_GID = 0x00000040, + PROC_EVENT_SID = 0x00000080, + PROC_EVENT_PTRACE = 0x00000100, + PROC_EVENT_COMM = 0x00000200, + PROC_EVENT_NONZERO_EXIT = 0x20000000, + PROC_EVENT_COREDUMP = 0x40000000, + PROC_EVENT_EXIT = 0x80000000, + } +} + +// linux/connector.h +pub const CN_IDX_PROC: c_uint = 0x1; +pub const CN_VAL_PROC: c_uint = 0x1; +pub const CN_IDX_CIFS: c_uint = 0x2; +pub const CN_VAL_CIFS: c_uint = 0x1; +pub const CN_W1_IDX: c_uint = 0x3; +pub const CN_W1_VAL: c_uint = 0x1; +pub const CN_IDX_V86D: c_uint = 0x4; +pub const CN_VAL_V86D_UVESAFB: c_uint = 0x1; +pub const CN_IDX_BB: c_uint = 0x5; +pub const CN_DST_IDX: c_uint = 0x6; +pub const CN_DST_VAL: c_uint = 0x1; +pub const CN_IDX_DM: c_uint = 0x7; +pub const CN_VAL_DM_USERSPACE_LOG: c_uint = 0x1; +pub const CN_IDX_DRBD: c_uint = 0x8; +pub const CN_VAL_DRBD: c_uint = 0x1; +pub const CN_KVP_IDX: c_uint = 0x9; +pub const CN_KVP_VAL: c_uint = 0x1; +pub const CN_VSS_IDX: c_uint = 0xA; +pub const CN_VSS_VAL: c_uint = 0x1; + // linux/module.h pub const MODULE_INIT_IGNORE_MODVERSIONS: c_uint = 0x0001; pub const MODULE_INIT_IGNORE_VERMAGIC: c_uint = 0x0002;