diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5e074cbce02d9..70b3fbd1e2cee 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -34,7 +34,7 @@ jobs: name: Clippy on ${{ matrix.os }} strategy: matrix: - os: [ubuntu-24.04, macos-15, windows-2022] + os: [ubuntu-24.04, macos-15, windows-2025] runs-on: ${{ matrix.os }} timeout-minutes: 10 steps: @@ -52,7 +52,7 @@ jobs: strategy: matrix: toolchain: [stable, nightly, 1.63.0] - os: [ubuntu-24.04, macos-15, windows-2022] + os: [ubuntu-24.04, macos-15, windows-2025] include: - toolchain: beta os: ubuntu-24.04 @@ -113,19 +113,19 @@ jobs: - target: aarch64-apple-darwin os: macos-15 - target: x86_64-pc-windows-gnu - os: windows-2022 + os: windows-2025 env: ARCH_BITS: 64 ARCH: x86_64 - target: x86_64-pc-windows-msvc - os: windows-2022 + os: windows-2025 # FIXME: It currently causes segfaults. #- target: i686-pc-windows-gnu # env: # ARCH_BITS: 32 # ARCH: i686 - target: i686-pc-windows-msvc - os: windows-2022 + os: windows-2025 runs-on: ${{ matrix.os }} timeout-minutes: 25 env: @@ -225,6 +225,9 @@ jobs: - target: powerpc64le-unknown-linux-musl env: RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 + - target: x86_64-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/Cargo.lock b/Cargo.lock index 46bd7a6704f01..512d405c94c07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,10 +80,11 @@ dependencies = [ [[package]] name = "cc" -version = "1.2.32" +version = "1.2.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2352e5597e9c544d5e6d9c95190d5d27738ade584fa8db0a16e130e5c2b5296e" +checksum = "37521ac7aabe3d13122dc382493e20c9416f299d2ccd5b3a5340a2570cdeb0f3" dependencies = [ + "find-msvc-tools", "shlex", ] @@ -99,9 +100,9 @@ version = "0.1.0" [[package]] name = "ctest" -version = "0.5.0-beta.0" +version = "0.5.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af3dc06650f831a3845f2493213c01ebe1dc1cd7bea271d26766a38dc6e72a3f" +checksum = "dc1a85629f6b82fee991771a8e3b927a8a082e12e4bb48b64a43e55476d27b10" dependencies = [ "askama", "cc", @@ -111,6 +112,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "find-msvc-tools" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127" + [[package]] name = "glob" version = "0.3.2" @@ -137,7 +144,7 @@ dependencies = [ "annotate-snippets", "cc", "cfg-if", - "ctest 0.5.0-beta.0", + "ctest 0.5.0-beta.1", "glob", "libc", "proc-macro2", @@ -147,9 +154,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.5" +version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" [[package]] name = "percent-encoding" @@ -159,18 +166,18 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" [[package]] name = "proc-macro2" -version = "1.0.101" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.40" +version = "1.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" dependencies = [ "proc-macro2", ] @@ -224,18 +231,27 @@ checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "serde" -version = "1.0.219" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_core" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", @@ -244,14 +260,15 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.142" +version = "1.0.145" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" dependencies = [ "itoa", "memchr", "ryu", "serde", + "serde_core", ] [[package]] @@ -262,9 +279,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "syn" -version = "2.0.104" +version = "2.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" +checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917" dependencies = [ "proc-macro2", "quote", @@ -273,18 +290,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.16" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3467d614147380f2e4e374161426ff399c91084acd2363eaf549172b3d5e60c0" +checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.16" +version = "2.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c5e1be1c48b9172ee610da68fd9cd2770e7a4056cb3fc98710ee6906f0c7960" +checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" dependencies = [ "proc-macro2", "quote", @@ -293,9 +310,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" [[package]] name = "unicode-width" diff --git a/Cargo.toml b/Cargo.toml index a4df1a263ca75..141a77f791ea8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -178,3 +178,7 @@ 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" + +[package.metadata.cargo-semver-checks.lints] +# Alignment is an internal detail that users must not rely upon +repr_align_removed = "warn" diff --git a/build.rs b/build.rs index 802ea7a37def0..0d1cef6440570 100644 --- a/build.rs +++ b/build.rs @@ -18,7 +18,6 @@ const ALLOWED_CFGS: &[&str] = &[ // Corresponds to `_TIME_BITS=64` in glibc "gnu_time_bits64", "libc_deny_warnings", - "libc_thread_local", // Corresponds to `__USE_TIME_BITS64` in UAPI "linux_time_bits64", "musl_v1_2_3", @@ -47,7 +46,6 @@ fn main() { println!("cargo:rerun-if-changed=build.rs"); let (rustc_minor_ver, _is_nightly) = rustc_minor_nightly(); - let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); let libc_ci = env::var("LIBC_CI").is_ok(); let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default(); let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); @@ -143,28 +141,15 @@ fn main() { set_cfg("libc_deny_warnings"); } - // #[thread_local] is currently unstable - if rustc_dep_of_std { - set_cfg("libc_thread_local"); - } - // Since Rust 1.80, configuration that isn't recognized by default needs to be provided to // avoid warnings. if rustc_minor_ver >= 80 { for cfg in ALLOWED_CFGS { - if rustc_minor_ver >= 75 { - println!("cargo:rustc-check-cfg=cfg({cfg})"); - } else { - println!("cargo:rustc-check-cfg=values({cfg})"); - } + println!("cargo:rustc-check-cfg=cfg({cfg})"); } for &(name, values) in CHECK_CFG_EXTRA { let values = values.join("\",\""); - if rustc_minor_ver >= 75 { - println!("cargo:rustc-check-cfg=cfg({name},values(\"{values}\"))"); - } else { - println!("cargo:rustc-check-cfg=values({name},\"{values}\")"); - } + println!("cargo:rustc-check-cfg=cfg({name},values(\"{values}\"))"); } } } diff --git a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile index a91ec3dd25f27..c55d57105a114 100644 --- a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile @@ -7,9 +7,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ qemu-system-sparc64 openbios-sparc seabios ipxe-qemu \ p7zip-full cpio linux-libc-dev-sparc64-cross qemu-user -COPY linux-sparc64.sh / -RUN /linux-sparc64.sh - ENV CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_LINKER=sparc64-linux-gnu-gcc \ CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_RUNNER="qemu-sparc64 -L /usr/sparc64-linux-gnu" \ CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \ diff --git a/ci/linux-sparc64.sh b/ci/linux-sparc64.sh deleted file mode 100755 index b272c42edd9aa..0000000000000 --- a/ci/linux-sparc64.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env sh - -set -eux - -mkdir -m 777 /qemu -cd /qemu - -curl --retry 5 -LO https://cdimage.debian.org/cdimage/ports/snapshots/2024-12-24/debian-12.0.0-sparc64-NETINST-1.iso -7z e debian-12.0.0-sparc64-NETINST-1.iso install/initrd.gz -7z e debian-12.0.0-sparc64-NETINST-1.iso install/vmlinux -mv vmlinux kernel -rm debian-12.0.0-sparc64-NETINST-1.iso - -mkdir init -cd init -gunzip -c ../initrd.gz | cpio -id -rm ../initrd.gz -cp /usr/sparc64-linux-gnu/lib/libgcc_s.so.1 usr/lib/ -chmod a+w . diff --git a/ci/run.sh b/ci/run.sh index 7b4525143d05a..0938b695d403d 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -9,6 +9,9 @@ target="$1" export RUST_BACKTRACE="${RUST_BACKTRACE:-1}" +# For logging +uname -a + cmd="cargo test --target $target ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}" test_flags="--skip check_style" diff --git a/ci/style.sh b/ci/style.sh index 200cc15cfa16a..ef57a5efd0402 100755 --- a/ci/style.sh +++ b/ci/style.sh @@ -31,14 +31,21 @@ while IFS= read -r file; do # wouldn't be correct for something like `all(any(...), ...)`). perl -pi -0777 -e 's/if #\[cfg\((.*?)\)\]/if cfg_tmp!([$1])/gms' "$file" + # The `c_enum!` macro allows anonymous enums without names, which + # isn't valid syntax. Replace it with a dummy name and an indicator + # comment on the preceding line (which is where rustfmt puts it. Also + # rust-lang/rustfmt#5464). + perl -pi -e 's/^(\s*)(.*)enum #anon\b/$1\/\* FMT-ANON-ENUM \*\/\n$1$2enum _fmt_anon/g' "$file" + # Format the file. We need to invoke `rustfmt` directly since `cargo fmt` # can't figure out the module tree with the hacks in place. failed=false - rustfmt --config-path rustfmt.toml "$file" ${check:+"$check"} || failed=true + rustfmt "$file" ${check:+"$check"} || failed=true # Restore all changes to the files. perl -pi -e 's/fn (\w+)_fmt_tmp\(\)/$1!/g' "$file" perl -pi -0777 -e 's/cfg_tmp!\(\[(.*?)\]\)/#[cfg($1)]/gms' "$file" + perl -pi -0777 -e 's/\/\* FMT-ANON-ENUM \*\/(?:\n\s*)?(.*?)enum _fmt_anon/$1enum #anon/gms' "$file" # Defer emitting the failure until after the files get reset if [ "$failed" != "false" ]; then diff --git a/ci/wasi.sh b/ci/wasi.sh index 4928681b0a270..f0d8a5245c99b 100755 --- a/ci/wasi.sh +++ b/ci/wasi.sh @@ -11,8 +11,8 @@ apt-get install -y --no-install-recommends \ # Wasmtime is used to execute tests and wasi-sdk is used to compile tests. # Download appropriate versions here and configure various flags below. -wasmtime=35.0.0 -wasi_sdk=25 +wasmtime=38.0.2 +wasi_sdk=27 curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v$wasmtime/wasmtime-v$wasmtime-x86_64-linux.tar.xz | tar xJf - diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 4ae4a3cd2056f..f761bab3a4dde 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -21,7 +21,7 @@ annotate-snippets = { version = "0.11.5", features = ["testing-colors"] } [build-dependencies] cc = "1.2.29" # Use the in-tree `ctest` from the `main` branch via crates.io -ctest = "0.5.0-beta.0" +ctest = "0.5.0-beta.1" regex = "1.11.1" [features] @@ -32,54 +32,36 @@ extra_traits = ["libc/extra_traits"] [[test]] name = "ctest" -path = "test/ctest.rs" harness = false [[test]] -name = "linux-fcntl" -path = "test/linux_fcntl.rs" +name = "linux_fcntl" harness = false [[test]] -name = "linux-if-arp" -path = "test/linux_if_arp.rs" +name = "linux_if_arp" harness = false [[test]] -name = "linux-ipv6" -path = "test/linux_ipv6.rs" +name = "linux_ipv6" harness = false [[test]] -name = "linux-elf" -path = "test/linux_elf.rs" +name = "linux_elf" harness = false [[test]] -name = "linux-strerror_r" -path = "test/linux_strerror_r.rs" +name = "linux_strerror_r" harness = false [[test]] -name = "linux-termios" -path = "test/linux_termios.rs" +name = "linux_termios" harness = false [[test]] name = "semver" -path = "test/semver.rs" harness = false -[[test]] -name = "style" -path = "test/check_style.rs" -harness = true - -[[test]] -name = "style_tests" -path = "test/style_tests.rs" -harness = 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` diff --git a/libc-test/build.rs b/libc-test/build.rs index 184b5c60443fb..51457f3b4f6e3 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -72,10 +72,16 @@ fn do_ctest() { fn ctest_cfg() -> ctest::TestGenerator { let mut cfg = ctest::TestGenerator::new(); cfg.skip_private(true); - let libc_cfgs = ["libc_thread_local"]; - for f in &libc_cfgs { - cfg.cfg(f, None); - } + + // Skip anonymous unions/structs. + cfg.skip_union(|u| u.ident().starts_with("__c_anonymous_")); + cfg.skip_struct(|s| s.ident().starts_with("__c_anonymous_")); + cfg.skip_alias(|ty| ty.ident().starts_with("__c_anonymous_")); + + // __uint128 is not declared in C, but is an alias we export. + // FIXME(1.0): These aliases will eventually be removed. + cfg.skip_alias(|ty| ty.ident() == "__uint128"); + cfg } @@ -163,22 +169,24 @@ fn main() { } macro_rules! headers { - ($cfg:ident: [$m:expr]: $header:literal) => { - if $m { - $cfg.header($header); - } - }; - ($cfg:ident: $header:literal) => { - $cfg.header($header); - }; - ($($cfg:ident: $([$c:expr]:)* $header:literal,)*) => { - $(headers!($cfg: $([$c]:)* $header);)* - }; - ($cfg:ident: $( $([$c:expr]:)* $header:literal,)*) => { - headers!($($cfg: $([$c]:)* $header,)*); - }; - ($cfg:ident: $( $([$c:expr]:)* $header:literal),*) => { - headers!($($cfg: $([$c]:)* $header,)*); + ( + $cfg:ident, + $( + // Allow a simple header + $($header:literal)? + // As well as a style that is conditionally applied. + $(($pred:expr, $pred_header:literal))? + , + )+ + ) => { + $( + $( $cfg.header($header); )? + $( + if $pred { + $cfg.header($pred_header); + } + )? + )+ }; } @@ -192,7 +200,8 @@ fn test_apple(target: &str) { cfg.flag("-Wno-deprecated-declarations"); cfg.define("__APPLE_USE_RFC_3542", None); - headers! { cfg: + headers!( + cfg, "aio.h", "CommonCrypto/CommonCrypto.h", "CommonCrypto/CommonRandom.h", @@ -244,8 +253,7 @@ fn test_apple(target: &str) { "os/clock.h", "os/lock.h", "os/signpost.h", - // FIXME(macos): Requires the macOS 14.4 SDK. - //"os/os_sync_wait_on_address.h", + "os/os_sync_wait_on_address.h", "poll.h", "pthread.h", "pthread_spis.h", @@ -306,12 +314,8 @@ fn test_apple(target: &str) { "utmpx.h", "wchar.h", "xlocale.h", - [x86_64]: "crt_externs.h", - } - - // Skip anonymous unions/structs. - cfg.skip_union(|u| u.ident().starts_with("__c_anonymous_")); - cfg.skip_struct(|s| s.ident().starts_with("__c_anonymous_")); + (x86_64, "crt_externs.h"), + ); cfg.skip_struct(|s| { match s.ident() { @@ -322,21 +326,6 @@ fn test_apple(target: &str) { // it is a moving target, changing through versions // also contains bitfields members "tcp_connection_info" => true, - // FIXME(macos): The size is changed in recent macOSes. - "malloc_introspection_t" => true, - _ => false, - } - }); - - cfg.skip_alias(|ty| ty.ident().starts_with("__c_anonymous_")); - cfg.skip_alias(|ty| { - match ty.ident() { - // FIXME(macos): Requires the macOS 14.4 SDK. - "os_sync_wake_by_address_flags_t" | "os_sync_wait_on_address_flags_t" => true, - - // FIXME(macos): "'__uint128' undeclared" in C - "__uint128" => true, - _ => false, } }); @@ -345,21 +334,14 @@ fn test_apple(target: &str) { match constant.ident() { // They're declared via `deprecated_mach` and we don't support it anymore. x if x.starts_with("VM_FLAGS_") => true, - // These OSX constants are removed in Sierra. + // FIXME(deprecated): These OSX constants are removed in Sierra. // https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html "KERN_KDENABLE_BG_TRACE" | "KERN_KDDISABLE_BG_TRACE" => true, - // FIXME(macos): the value has been changed since Catalina (0xffff0000 -> 0x3fff0000). - "SF_SETTABLE" => true, - // FIXME(macos): XCode 13.1 doesn't have it. + // FIXME(deprecated): Removed since 12.0.1 / xnu-8019.41.5. See `ttycom.h` at + // https://github.com/apple-oss-distributions/xnu/commit/e6231be02a03711ca404e5121a151b24afbff733 "TIOCREMOTE" => true, - // FIXME(macos): Requires the macOS 14.4 SDK. - "OS_SYNC_WAKE_BY_ADDRESS_NONE" - | "OS_SYNC_WAKE_BY_ADDRESS_SHARED" - | "OS_SYNC_WAIT_ON_ADDRESS_NONE" - | "OS_SYNC_WAIT_ON_ADDRESS_SHARED" => true, - _ => false, } }); @@ -369,41 +351,17 @@ fn test_apple(target: &str) { match func.ident() { // FIXME: https://github.com/rust-lang/libc/issues/1272 "execv" | "execve" | "execvp" => true, - // close calls the close_nocancel system call - "close" => true, - // FIXME(1.0): std removed libresolv support: https://github.com/rust-lang/rust/pull/102766 "res_init" => true, - - // FIXME(macos): remove once the target in CI is updated - "pthread_jit_write_freeze_callbacks_np" => true, - - // FIXME(macos): ABI has been changed on recent macOSes. - "os_unfair_lock_assert_owner" | "os_unfair_lock_assert_not_owner" => true, - - // FIXME(macos): Once the SDK get updated to Ventura's level - "freadlink" | "mknodat" | "mkfifoat" => true, - - // FIXME(macos): Requires the macOS 14.4 SDK. - "os_sync_wake_by_address_any" - | "os_sync_wake_by_address_all" - | "os_sync_wake_by_address_flags_t" - | "os_sync_wait_on_address" - | "os_sync_wait_on_address_flags_t" - | "os_sync_wait_on_address_with_deadline" - | "os_sync_wait_on_address_with_timeout" => true, - _ => false, } }); cfg.skip_struct_field(move |struct_, field| { match (struct_.ident(), field.ident()) { - // FIXME(macos): the array size has been changed since macOS 10.15 ([8] -> [7]). - ("statfs", "f_reserved") => true, - ("__darwin_arm_neon_state64", "__v") => true, // MAXPATHLEN is too big for auto-derive traits on arrays. ("vnode_info_path", "vip_path") => true, + // Anonymous ADT fields ("ifreq", "ifr_ifru") => true, ("in6_ifreq", "ifr_ifru") => true, ("ifkpi", "ifk_data") => true, @@ -454,8 +412,6 @@ fn test_apple(target: &str) { cfg.skip_roundtrip(move |s| match s { // FIXME(macos): this type has the wrong ABI "max_align_t" if i686 => true, - // Can't return an array from a C function. - "uuid_t" | "vol_capabilities_set_t" => true, _ => false, }); @@ -470,7 +426,8 @@ fn test_openbsd(target: &str) { let x86_64 = target.contains("x86_64"); - headers! { cfg: + headers!( + cfg, "elf.h", "errno.h", "execinfo.h", @@ -492,7 +449,7 @@ fn test_openbsd(target: &str) { "ctype.h", "dirent.h", "sys/socket.h", - [x86_64]:"machine/fpu.h", + (x86_64, "machine/fpu.h"), "net/if.h", "net/route.h", "net/if_arp.h", @@ -554,7 +511,7 @@ fn test_openbsd(target: &str) { "sys/shm.h", "sys/param.h", "sys/auxv.h", - } + ); cfg.rename_type(|ty| match ty { // FIXME(openbsd): https://github.com/rust-lang/libc/issues/1273 @@ -630,9 +587,6 @@ fn test_openbsd(target: &str) { } }); - // Skip anonymous unions/structs. - cfg.skip_union(|u| u.ident().starts_with("__c_anonymous_")); - cfg.skip_struct(|s| s.ident().starts_with("__c_anonymous_")); cfg.skip_struct(move |ty| { match ty.ident() { // FIXME(union): actually a union @@ -670,7 +624,8 @@ fn test_cygwin(target: &str) { let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); - headers! { cfg: + headers!( + cfg, "ctype.h", "dirent.h", "dlfcn.h", @@ -720,7 +675,7 @@ fn test_cygwin(target: &str) { "utime.h", "wait.h", "wchar.h", - } + ); cfg.rename_type(|ty| match ty { "Ioctl" => Some("int".to_string()), @@ -768,14 +723,6 @@ fn test_cygwin(target: &str) { _ => false, }); - cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } - - false - }); - cfg.rename_struct_field(move |struct_, field| { match field.ident() { // Our stat *_nsec fields normally don't actually exist but are part @@ -846,7 +793,8 @@ fn test_windows(target: &str) { } cfg.define("_WIN32_WINNT", Some("0x8000")); - headers! { cfg: + headers!( + cfg, "direct.h", "errno.h", "fcntl.h", @@ -864,9 +812,9 @@ fn test_windows(target: &str) { "sys/utime.h", "time.h", "wchar.h", - [gnu]: "ws2tcpip.h", - [!gnu]: "Winsock2.h", - } + (gnu, "ws2tcpip.h"), + (!gnu, "Winsock2.h"), + ); cfg.rename_struct_ty(|ty| { match ty { @@ -907,17 +855,12 @@ fn test_windows(target: &str) { }); cfg.skip_struct(move |struct_| { - let ty = struct_.ident(); - if ty.starts_with("__c_anonymous_") { - return true; - } - match ty { + match struct_.ident() { // FIXME(windows): The size and alignment of this struct are incorrect "timespec" if gnu && i686 => true, _ => false, } }); - cfg.skip_union(move |union_| union_.ident().starts_with("__c_anonymous_")); cfg.skip_const(move |constant| { match constant.ident() { @@ -928,8 +871,6 @@ fn test_windows(target: &str) { "SIG_DFL" | "SIG_IGN" | "SIG_GET" | "SIG_SGE" | "SIG_ACK" => true, // FIXME(windows): newer windows-gnu environment on CI? "_O_OBTAIN_DIR" if gnu => true, - // FIXME: These constants have been changed since windows-2022 20251014.68.1: - "L_tmpnam" | "TMP_MAX" => true, _ => false, } }); @@ -967,8 +908,8 @@ fn test_redox(target: &str) { let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); - headers! { - cfg: + headers!( + cfg, "ctype.h", "dirent.h", "dlfcn.h", @@ -1006,7 +947,7 @@ fn test_redox(target: &str) { "unistd.h", "utime.h", "wchar.h", - } + ); ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } @@ -1032,8 +973,8 @@ fn test_solarish(target: &str) { cfg.define("SIGINFO", Some("41")); } - headers! { - cfg: + headers!( + cfg, "aio.h", "ctype.h", "dirent.h", @@ -1112,19 +1053,14 @@ fn test_solarish(target: &str) { "utime.h", "utmpx.h", "wchar.h", - } + ); if is_illumos { - headers! { cfg: - "sys/epoll.h", - "sys/eventfd.h", - } + headers!(cfg, "sys/epoll.h", "sys/eventfd.h",); } if is_solaris { - headers! { cfg: - "sys/lgrp_user_impl.h", - } + headers!(cfg, "sys/lgrp_user_impl.h",); } cfg.skip_alias(move |ty| match ty.ident() { @@ -1186,15 +1122,12 @@ fn test_solarish(target: &str) { cfg.skip_union(|union_| { // the union handling is a mess - if union_.ident().starts_with("__c_anonymous_") || union_.ident().contains("door_desc_t_") { + if union_.ident().contains("door_desc_t_") { return true; } false }); cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } // the union handling is a mess if struct_.ident().contains("door_desc_t_") { return true; @@ -1319,8 +1252,8 @@ fn test_netbsd(target: &str) { cfg.flag("-Wno-deprecated-declarations"); cfg.define("_NETBSD_SOURCE", Some("1")); - headers! { - cfg: + headers!( + cfg, "elf.h", "errno.h", "fcntl.h", @@ -1405,7 +1338,7 @@ fn test_netbsd(target: &str) { "sys/reboot.h", "sys/shm.h", "iconv.h", - } + ); cfg.rename_type(move |ty| { match ty { @@ -1437,13 +1370,7 @@ fn test_netbsd(target: &str) { } }); - cfg.skip_struct(|ty| ty.ident().starts_with("__c_anonymous_")); - cfg.skip_union(|ty| ty.ident().starts_with("__c_anonymous_")); - cfg.skip_alias(move |ty| { - if ty.ident().starts_with("__c_anonymous_") { - return true; - } match ty.ident() { // FIXME(netbsd): sighandler_t is crazy across platforms "sighandler_t" => true, @@ -1533,8 +1460,8 @@ fn test_dragonflybsd(target: &str) { let mut cfg = ctest_cfg(); cfg.flag("-Wno-deprecated-declarations"); - headers! { - cfg: + headers!( + cfg, "aio.h", "ctype.h", "dirent.h", @@ -1622,7 +1549,7 @@ fn test_dragonflybsd(target: &str) { "vm/vm_map.h", "wchar.h", "iconv.h", - } + ); cfg.rename_struct_ty(move |ty| { match ty { @@ -1672,9 +1599,6 @@ fn test_dragonflybsd(target: &str) { }); cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } match struct_.ident() { // FIXME(dragonflybsd): These are tested as part of the linux_fcntl tests since // there are header conflicts when including them with all the other @@ -1759,7 +1683,8 @@ fn test_wasi(target: &str) { let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); - headers! { cfg: + headers!( + cfg, "ctype.h", "dirent.h", "errno.h", @@ -1769,10 +1694,11 @@ fn test_wasi(target: &str) { "limits.h", "locale.h", "malloc.h", - [p2]: "netdb.h", - [p2]: "netinet/in.h", - [p2]: "netinet/tcp.h", + (p2, "netdb.h"), + (p2, "netinet/in.h"), + (p2, "netinet/tcp.h"), "poll.h", + "pthread.h", "sched.h", "stdbool.h", "stddef.h", @@ -1796,7 +1722,7 @@ fn test_wasi(target: &str) { "wasi/libc-nocwd.h", "wasi/libc.h", "wchar.h", - } + ); cfg.rename_struct_ty(move |ty| match ty { "FILE" | "fd_set" | "DIR" => Some(ty.to_string()), @@ -1857,151 +1783,150 @@ fn test_android(target: &str) { let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); - headers! { cfg: - "arpa/inet.h", - "ctype.h", - "dirent.h", - "dlfcn.h", - "elf.h", - "errno.h", - "fcntl.h", - "fnmatch.h", - "getopt.h", - "grp.h", - "ifaddrs.h", - "libgen.h", - "limits.h", - "link.h", - "linux/sysctl.h", - "locale.h", - "malloc.h", - "net/ethernet.h", - "net/if.h", - "net/if_arp.h", - "net/route.h", - "netdb.h", - "netinet/in.h", - "netinet/ip.h", - "netinet/tcp.h", - "netinet/udp.h", - "netpacket/packet.h", - "poll.h", - "pthread.h", - "pty.h", - "pwd.h", - "regex.h", - "resolv.h", - "sched.h", - "semaphore.h", - "signal.h", - "spawn.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "sys/auxv.h", - "sys/epoll.h", - "sys/eventfd.h", - "sys/file.h", - "sys/fsuid.h", - "sys/inotify.h", - "sys/ioctl.h", - "sys/klog.h", - "sys/mman.h", - "sys/mount.h", - "sys/personality.h", - "sys/prctl.h", - "sys/ptrace.h", - "sys/random.h", - "sys/reboot.h", - "sys/resource.h", - "sys/sendfile.h", - "sys/signalfd.h", - "sys/socket.h", - "sys/stat.h", - "sys/statvfs.h", - "sys/swap.h", - "sys/syscall.h", - "sys/sysinfo.h", - "sys/system_properties.h", - "sys/time.h", - "sys/timerfd.h", - "sys/times.h", - "sys/types.h", - "sys/ucontext.h", - "sys/uio.h", - "sys/un.h", - "sys/user.h", - "sys/utsname.h", - "sys/vfs.h", - "sys/xattr.h", - "sys/wait.h", - "syslog.h", - "termios.h", - "time.h", - "unistd.h", - "utime.h", - "utmp.h", - "wchar.h", - "xlocale.h", - // time64_t is not defined for 64-bit targets If included it will - // generate the error 'Your time_t is already 64-bit' - [target_pointer_width == 32]: "time64.h", - [x86]: "sys/reg.h", - } + headers!( + cfg, + "arpa/inet.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "elf.h", + "errno.h", + "fcntl.h", + "fnmatch.h", + "getopt.h", + "grp.h", + "ifaddrs.h", + "libgen.h", + "limits.h", + "link.h", + "linux/sysctl.h", + "locale.h", + "malloc.h", + "net/ethernet.h", + "net/if.h", + "net/if_arp.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/tcp.h", + "netinet/udp.h", + "netpacket/packet.h", + "poll.h", + "pthread.h", + "pty.h", + "pwd.h", + "regex.h", + "resolv.h", + "sched.h", + "semaphore.h", + "signal.h", + "spawn.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/auxv.h", + "sys/epoll.h", + "sys/eventfd.h", + "sys/file.h", + "sys/fsuid.h", + "sys/inotify.h", + "sys/ioctl.h", + "sys/klog.h", + "sys/mman.h", + "sys/mount.h", + "sys/personality.h", + "sys/prctl.h", + "sys/ptrace.h", + "sys/random.h", + "sys/reboot.h", + "sys/resource.h", + "sys/sendfile.h", + "sys/signalfd.h", + "sys/socket.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/swap.h", + "sys/syscall.h", + "sys/sysinfo.h", + "sys/system_properties.h", + "sys/time.h", + "sys/timerfd.h", + "sys/times.h", + "sys/types.h", + "sys/ucontext.h", + "sys/uio.h", + "sys/un.h", + "sys/user.h", + "sys/utsname.h", + "sys/vfs.h", + "sys/xattr.h", + "sys/wait.h", + "syslog.h", + "termios.h", + "time.h", + "unistd.h", + "utime.h", + "utmp.h", + "wchar.h", + "xlocale.h", + // time64_t is not defined for 64-bit targets If included it will + // generate the error 'Your time_t is already 64-bit' + (target_pointer_width == 32, "time64.h"), + (x86, "sys/reg.h"), + ); // Include linux headers at the end: - headers! { cfg: - "asm/mman.h", - "linux/auxvec.h", - "linux/dccp.h", - "linux/elf.h", - "linux/errqueue.h", - "linux/falloc.h", - "linux/filter.h", - "linux/futex.h", - "linux/fs.h", - "linux/genetlink.h", - "linux/if_alg.h", - "linux/if_addr.h", - "linux/if_ether.h", - "linux/if_link.h", - "linux/rtnetlink.h", - "linux/if_tun.h", - "linux/kexec.h", - "linux/magic.h", - "linux/membarrier.h", - "linux/memfd.h", - "linux/mempolicy.h", - "linux/module.h", - "linux/mount.h", - "linux/net_tstamp.h", - "linux/netfilter/nfnetlink.h", - "linux/netfilter/nfnetlink_log.h", - "linux/netfilter/nfnetlink_queue.h", - "linux/netfilter/nf_tables.h", - "linux/netfilter_arp.h", - "linux/netfilter_bridge.h", - "linux/netfilter_ipv4.h", - "linux/netfilter_ipv6.h", - "linux/netfilter_ipv6/ip6_tables.h", - "linux/netlink.h", - "linux/quota.h", - "linux/reboot.h", - "linux/seccomp.h", - "linux/sched.h", - "linux/sockios.h", - "linux/uinput.h", - "linux/vm_sockets.h", - "linux/wait.h", - - } + headers!( + cfg, + "asm/mman.h", + "linux/auxvec.h", + "linux/dccp.h", + "linux/elf.h", + "linux/errqueue.h", + "linux/falloc.h", + "linux/filter.h", + "linux/futex.h", + "linux/fs.h", + "linux/genetlink.h", + "linux/if_alg.h", + "linux/if_addr.h", + "linux/if_ether.h", + "linux/if_link.h", + "linux/rtnetlink.h", + "linux/if_tun.h", + "linux/kexec.h", + "linux/magic.h", + "linux/membarrier.h", + "linux/memfd.h", + "linux/mempolicy.h", + "linux/module.h", + "linux/mount.h", + "linux/net_tstamp.h", + "linux/netfilter/nfnetlink.h", + "linux/netfilter/nfnetlink_log.h", + "linux/netfilter/nfnetlink_queue.h", + "linux/netfilter/nf_tables.h", + "linux/netfilter_arp.h", + "linux/netfilter_bridge.h", + "linux/netfilter_ipv4.h", + "linux/netfilter_ipv6.h", + "linux/netfilter_ipv6/ip6_tables.h", + "linux/netlink.h", + "linux/quota.h", + "linux/reboot.h", + "linux/seccomp.h", + "linux/sched.h", + "linux/sockios.h", + "linux/uinput.h", + "linux/vm_sockets.h", + "linux/wait.h", + ); // Include Android-specific headers: - headers! { cfg: - "android/set_abort_message.h" - } + headers!(cfg, "android/set_abort_message.h",); cfg.rename_type(move |ty| match ty { "Ioctl" => Some("int".to_string()), @@ -2051,8 +1976,6 @@ fn test_android(target: &str) { "posix_spawn_file_actions_t" => true, "posix_spawnattr_t" => true, - // FIXME(android): "'__uint128' undeclared" in C - "__uint128" => true, // Added in API level 24 "if_nameindex" => true, @@ -2060,12 +1983,7 @@ fn test_android(target: &str) { } }); - cfg.skip_union(move |union_| union_.ident().starts_with("__c_anonymous_")); - cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } match struct_.ident() { // These are tested as part of the linux_fcntl tests since there are // header conflicts when including them with all the other structs. @@ -2237,6 +2155,9 @@ fn test_android(target: &str) { // FIXME(android): Requires >= 6.12 kernel headers. "SOF_TIMESTAMPING_OPT_RX_FILTER" => true, + // FIXME(android): Requires >= 6.9 kernel headers. + "AT_HWCAP3" | "AT_HWCAP4" => true, + _ => false, } }); @@ -2381,124 +2302,125 @@ fn test_freebsd(target: &str) { let freebsd14 = matches!(freebsd_ver, Some(n) if n >= 14); let freebsd15 = matches!(freebsd_ver, Some(n) if n >= 15); - headers! { cfg: - "aio.h", - "arpa/inet.h", - "bsm/audit.h", - "ctype.h", - "dirent.h", - "dlfcn.h", - "elf.h", - "errno.h", - "execinfo.h", - "fcntl.h", - "fnmatch.h", - "getopt.h", - "glob.h", - "grp.h", - "iconv.h", - "ifaddrs.h", - "kenv.h", - "langinfo.h", - "libgen.h", - "libutil.h", - "limits.h", - "link.h", - "locale.h", - "machine/elf.h", - "machine/reg.h", - "malloc_np.h", - "memstat.h", - "mqueue.h", - "net/bpf.h", - "net/if.h", - "net/if_arp.h", - "net/if_dl.h", - "net/if_mib.h", - "net/route.h", - "netdb.h", - "netinet/ip.h", - "netinet/in.h", - "netinet/sctp.h", - "netinet/tcp.h", - "netinet/udp.h", - "poll.h", - "pthread.h", - "pthread_np.h", - "pwd.h", - "regex.h", - "resolv.h", - "sched.h", - "semaphore.h", - "signal.h", - "spawn.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "sys/capsicum.h", - "sys/auxv.h", - "sys/cpuset.h", - "sys/domainset.h", - "sys/eui64.h", - "sys/event.h", - [freebsd13]:"sys/eventfd.h", - "sys/extattr.h", - "sys/file.h", - "sys/ioctl.h", - "sys/ipc.h", - "sys/jail.h", - "sys/mman.h", - "sys/mount.h", - "sys/msg.h", - "sys/procctl.h", - "sys/procdesc.h", - "sys/ptrace.h", - "sys/queue.h", - "sys/random.h", - "sys/reboot.h", - "sys/resource.h", - "sys/rtprio.h", - "sys/sem.h", - "sys/shm.h", - "sys/socket.h", - "sys/socketvar.h", - [freebsd15]:"sys/ktls.h", - "netinet/in_pcb.h", // must be after sys/socketvar.h, sys/ktls.h - "sys/stat.h", - "sys/statvfs.h", - "sys/sysctl.h", - "sys/thr.h", - "sys/time.h", - [freebsd14 || freebsd15]:"sys/timerfd.h", - [freebsd13 || freebsd14 || freebsd15]:"dev/evdev/input.h", - "sys/times.h", - "sys/timex.h", - "sys/types.h", - "sys/proc.h", - "kvm.h", // must be after "sys/types.h" - "sys/ucontext.h", - "sys/uio.h", - "sys/ktrace.h", - "sys/umtx.h", - "sys/un.h", - "sys/user.h", - "sys/utsname.h", - "sys/uuid.h", - "sys/vmmeter.h", - "sys/wait.h", - "libprocstat.h", - "devstat.h", - "syslog.h", - "termios.h", - "time.h", - "ufs/ufs/quota.h", - "unistd.h", - "utime.h", - "utmpx.h", - "wchar.h", - } + headers!( + cfg, + "aio.h", + "arpa/inet.h", + "bsm/audit.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "elf.h", + "errno.h", + "execinfo.h", + "fcntl.h", + "fnmatch.h", + "getopt.h", + "glob.h", + "grp.h", + "iconv.h", + "ifaddrs.h", + "kenv.h", + "langinfo.h", + "libgen.h", + "libutil.h", + "limits.h", + "link.h", + "locale.h", + "machine/elf.h", + "machine/reg.h", + "malloc_np.h", + "memstat.h", + "mqueue.h", + "net/bpf.h", + "net/if.h", + "net/if_arp.h", + "net/if_dl.h", + "net/if_mib.h", + "net/route.h", + "netdb.h", + "netinet/ip.h", + "netinet/in.h", + "netinet/sctp.h", + "netinet/tcp.h", + "netinet/udp.h", + "poll.h", + "pthread.h", + "pthread_np.h", + "pwd.h", + "regex.h", + "resolv.h", + "sched.h", + "semaphore.h", + "signal.h", + "spawn.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/capsicum.h", + "sys/auxv.h", + "sys/cpuset.h", + "sys/domainset.h", + "sys/eui64.h", + "sys/event.h", + (freebsd13, "sys/eventfd.h"), + "sys/extattr.h", + "sys/file.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/jail.h", + "sys/mman.h", + "sys/mount.h", + "sys/msg.h", + "sys/procctl.h", + "sys/procdesc.h", + "sys/ptrace.h", + "sys/queue.h", + "sys/random.h", + "sys/reboot.h", + "sys/resource.h", + "sys/rtprio.h", + "sys/sem.h", + "sys/shm.h", + "sys/socket.h", + "sys/socketvar.h", + (freebsd15, "sys/ktls.h"), + "netinet/in_pcb.h", // must be after sys/socketvar.h, sys/ktls.h + "sys/stat.h", + "sys/statvfs.h", + "sys/sysctl.h", + "sys/thr.h", + "sys/time.h", + (freebsd14 || freebsd15, "sys/timerfd.h"), + (freebsd13 || freebsd14 || freebsd15, "dev/evdev/input.h"), + "sys/times.h", + "sys/timex.h", + "sys/types.h", + "sys/proc.h", + "kvm.h", // must be after "sys/types.h" + "sys/ucontext.h", + "sys/uio.h", + "sys/ktrace.h", + "sys/umtx.h", + "sys/un.h", + "sys/user.h", + "sys/utsname.h", + "sys/uuid.h", + "sys/vmmeter.h", + "sys/wait.h", + "libprocstat.h", + "devstat.h", + "syslog.h", + "termios.h", + "time.h", + "ufs/ufs/quota.h", + "unistd.h", + "utime.h", + "utmpx.h", + "wchar.h", + ); cfg.rename_type(|ty| match ty { // FIXME(freebsd): https://github.com/rust-lang/libc/issues/1273 @@ -2833,6 +2755,9 @@ fn test_freebsd(target: &str) { // FIXME(deprecated): deprecated in 0.2, removed in main "TIOCMGDTRWAIT" | "TIOCMSDTRWAIT" => true, + // Added in FreeBSD 15 + "AT_HWCAP3" | "AT_HWCAP4" if Some(15) > freebsd_ver => true, + _ => false, } }); @@ -2849,13 +2774,8 @@ fn test_freebsd(target: &str) { } }); - cfg.skip_union(|u| u.ident().starts_with("__c_anonymous_")); cfg.skip_struct(move |struct_| { - let ty = struct_.ident(); - if ty.starts_with("__c_anonymous_") { - return true; - } - match ty { + match struct_.ident() { // `procstat` is a private struct "procstat" => true, @@ -3051,81 +2971,82 @@ fn test_emscripten(target: &str) { let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); // FIXME(emscripten): ?? - headers! { cfg: - "ctype.h", - "dirent.h", - "dlfcn.h", - "errno.h", - "fcntl.h", - "fnmatch.h", - "glob.h", - "grp.h", - "ifaddrs.h", - "langinfo.h", - "limits.h", - "locale.h", - "malloc.h", - "mntent.h", - "mqueue.h", - "net/ethernet.h", - "net/if.h", - "net/if_arp.h", - "net/route.h", - "netdb.h", - "netinet/in.h", - "netinet/ip.h", - "netinet/tcp.h", - "netinet/udp.h", - "netpacket/packet.h", - "poll.h", - "pthread.h", - "pty.h", - "pwd.h", - "resolv.h", - "sched.h", - "sched.h", - "semaphore.h", - "shadow.h", - "signal.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "sys/file.h", - "sys/ioctl.h", - "sys/ipc.h", - "sys/mman.h", - "sys/mount.h", - "sys/msg.h", - "sys/resource.h", - "sys/sem.h", - "sys/shm.h", - "sys/socket.h", - "sys/stat.h", - "sys/statvfs.h", - "sys/syscall.h", - "sys/sysinfo.h", - "sys/time.h", - "sys/times.h", - "sys/types.h", - "sys/uio.h", - "sys/un.h", - "sys/user.h", - "sys/utsname.h", - "sys/vfs.h", - "sys/wait.h", - "sys/xattr.h", - "syslog.h", - "termios.h", - "time.h", - "ucontext.h", - "unistd.h", - "utime.h", - "utmp.h", - "utmpx.h", - "wchar.h", - } + headers!( + cfg, + "ctype.h", + "dirent.h", + "dlfcn.h", + "errno.h", + "fcntl.h", + "fnmatch.h", + "glob.h", + "grp.h", + "ifaddrs.h", + "langinfo.h", + "limits.h", + "locale.h", + "malloc.h", + "mntent.h", + "mqueue.h", + "net/ethernet.h", + "net/if.h", + "net/if_arp.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/tcp.h", + "netinet/udp.h", + "netpacket/packet.h", + "poll.h", + "pthread.h", + "pty.h", + "pwd.h", + "resolv.h", + "sched.h", + "sched.h", + "semaphore.h", + "shadow.h", + "signal.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/file.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/mman.h", + "sys/mount.h", + "sys/msg.h", + "sys/resource.h", + "sys/sem.h", + "sys/shm.h", + "sys/socket.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/syscall.h", + "sys/sysinfo.h", + "sys/time.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/user.h", + "sys/utsname.h", + "sys/vfs.h", + "sys/wait.h", + "sys/xattr.h", + "syslog.h", + "termios.h", + "time.h", + "ucontext.h", + "unistd.h", + "utime.h", + "utmp.h", + "utmpx.h", + "wchar.h", + ); cfg.rename_struct_ty(move |ty| { match ty { @@ -3168,10 +3089,6 @@ fn test_emscripten(target: &str) { }); cfg.skip_union(|union_| { - if union_.ident().starts_with("__c_anonymous_") { - return true; - } - match union_.ident() { // No epoll support // https://github.com/emscripten-core/emscripten/issues/5033 @@ -3190,9 +3107,6 @@ fn test_emscripten(target: &str) { }); cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } match struct_.ident() { // This is actually a union, not a struct "sigval" => true, @@ -3308,17 +3222,19 @@ fn test_neutrino(target: &str) { .unwrap_or_else(|_| "QNX_TARGET_not_set_please_source_qnxsdp".into()); cfg.include(qnx_target_val + "/usr/include/io-sock"); - headers! { cfg: + headers!( + cfg, "io-sock.h", "sys/types.h", "sys/socket.h", "sys/sysctl.h", "net/if.h", - "net/if_arp.h" - } + "net/if_arp.h", + ); } - headers! { cfg: + headers!( + cfg, "ctype.h", "dirent.h", "dlfcn.h", @@ -3401,12 +3317,11 @@ fn test_neutrino(target: &str) { "net/bpf.h", "net/if_dl.h", "sys/syspage.h", - // TODO: The following header file doesn't appear as part of the default headers // found in a standard installation of Neutrino 7.1 SDP. The structures/ // functions dependent on it are currently commented out. //"sys/asyncmsg.h", - } + ); // Create and include a header file containing // items which are not included in any official @@ -3465,17 +3380,11 @@ fn test_neutrino(target: &str) { // Does not exist in Neutrino "locale_t" => true, - // FIXME: "'__uint128' undeclared" in C - "__uint128" => true, - _ => false, } }); cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } match struct_.ident() { "Elf64_Phdr" | "Elf32_Phdr" => true, @@ -3567,65 +3476,66 @@ fn test_vxworks(target: &str) { assert!(target.contains("vxworks")); let mut cfg = ctest_cfg(); - headers! { cfg: - "vxWorks.h", - "yvals.h", - "nfs/nfsCommon.h", - "rtpLibCommon.h", - "randomNumGen.h", - "taskLib.h", - "sysLib.h", - "ioLib.h", - "inetLib.h", - "socket.h", - "errnoLib.h", - "ctype.h", - "dirent.h", - "dlfcn.h", - "elf.h", - "fcntl.h", - "grp.h", - "sys/poll.h", - "ifaddrs.h", - "langinfo.h", - "limits.h", - "link.h", - "locale.h", - "sys/stat.h", - "netdb.h", - "pthread.h", - "pwd.h", - "sched.h", - "semaphore.h", - "signal.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "sys/file.h", - "sys/ioctl.h", - "sys/socket.h", - "sys/time.h", - "sys/times.h", - "sys/types.h", - "sys/uio.h", - "sys/un.h", - "sys/utsname.h", - "sys/wait.h", - "netinet/tcp.h", - "syslog.h", - "termios.h", - "time.h", - "ucontext.h", - "unistd.h", - "utime.h", - "wchar.h", - "errno.h", - "sys/mman.h", - "pathLib.h", - "mqueue.h", - } + headers!( + cfg, + "vxWorks.h", + "yvals.h", + "nfs/nfsCommon.h", + "rtpLibCommon.h", + "randomNumGen.h", + "taskLib.h", + "sysLib.h", + "ioLib.h", + "inetLib.h", + "socket.h", + "errnoLib.h", + "ctype.h", + "dirent.h", + "dlfcn.h", + "elf.h", + "fcntl.h", + "grp.h", + "sys/poll.h", + "ifaddrs.h", + "langinfo.h", + "limits.h", + "link.h", + "locale.h", + "sys/stat.h", + "netdb.h", + "pthread.h", + "pwd.h", + "sched.h", + "semaphore.h", + "signal.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/file.h", + "sys/ioctl.h", + "sys/socket.h", + "sys/time.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/utsname.h", + "sys/wait.h", + "netinet/tcp.h", + "syslog.h", + "termios.h", + "time.h", + "ucontext.h", + "unistd.h", + "utime.h", + "wchar.h", + "errno.h", + "sys/mman.h", + "pathLib.h", + "mqueue.h", + ); // FIXME(vxworks) cfg.skip_const(move |constant| match constant.ident() { // sighandler_t weirdness @@ -3742,6 +3652,7 @@ fn test_linux(target: &str) { let loongarch64 = target.contains("loongarch64"); let wasm32 = target.contains("wasm32"); let uclibc = target.contains("uclibc"); + let mips = target.contains("mips"); let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok(); let old_musl = musl && !musl_v1_2_3; @@ -3758,128 +3669,127 @@ fn test_linux(target: &str) { config_gnu_bits(target, &mut cfg); - headers! { cfg: - "ctype.h", - "dirent.h", - "dlfcn.h", - "elf.h", - "fcntl.h", - "fnmatch.h", - "getopt.h", - "glob.h", - [gnu]: "gnu/libc-version.h", - "grp.h", - "iconv.h", - "ifaddrs.h", - "langinfo.h", - "libgen.h", - "limits.h", - "link.h", - "linux/sysctl.h", - "locale.h", - "malloc.h", - "mntent.h", - "mqueue.h", - "net/ethernet.h", - "net/if.h", - "net/if_arp.h", - "net/route.h", - "netdb.h", - "netinet/in.h", - "netinet/ip.h", - "netinet/tcp.h", - "netinet/udp.h", - "poll.h", - "pthread.h", - "pty.h", - "pwd.h", - "regex.h", - "resolv.h", - "sched.h", - "semaphore.h", - "shadow.h", - "signal.h", - "spawn.h", - "stddef.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "sys/epoll.h", - "sys/eventfd.h", - "sys/file.h", - "sys/fsuid.h", - "sys/klog.h", - "sys/inotify.h", - "sys/ioctl.h", - "sys/ipc.h", - "sys/mman.h", - "sys/mount.h", - "sys/msg.h", - "sys/personality.h", - "sys/prctl.h", - "sys/ptrace.h", - "sys/quota.h", - "sys/random.h", - "sys/reboot.h", - "sys/resource.h", - "sys/sem.h", - "sys/sendfile.h", - "sys/shm.h", - "sys/signalfd.h", - "sys/socket.h", - "sys/stat.h", - "sys/statvfs.h", - "sys/swap.h", - "sys/syscall.h", - "sys/time.h", - "sys/timerfd.h", - "sys/times.h", - "sys/timex.h", - "sys/types.h", - "sys/uio.h", - "sys/un.h", - "sys/user.h", - "sys/utsname.h", - "sys/vfs.h", - "sys/wait.h", - "syslog.h", - "termios.h", - "time.h", - "ucontext.h", - "unistd.h", - "utime.h", - "utmp.h", - "utmpx.h", - "wchar.h", - "errno.h", - // `sys/io.h` is only available on x86*, Alpha, IA64, and 32-bit - // ARM: https://bugzilla.redhat.com/show_bug.cgi?id=1116162 - // Also unavailable on gnueabihf with glibc 2.30. - // https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=6b33f373c7b9199e00ba5fbafd94ac9bfb4337b1 - [(x86_64 || x86_32 || arm) && !gnueabihf]: "sys/io.h", - // `sys/reg.h` is only available on x86 and x86_64 - [x86_64 || x86_32]: "sys/reg.h", - // sysctl system call is deprecated and not available on musl - // It is also unsupported in x32, deprecated since glibc 2.30: - [!(x32 || musl || gnu)]: "sys/sysctl.h", - // is not supported by musl: - // https://www.openwall.com/lists/musl/2015/04/09/3 - // is not present on uclibc. - [!(musl || uclibc)]: "execinfo.h", - } + headers!( + cfg, + "ctype.h", + "dirent.h", + "dlfcn.h", + "elf.h", + "fcntl.h", + "fnmatch.h", + "getopt.h", + "glob.h", + (gnu, "gnu/libc-version.h"), + "grp.h", + "iconv.h", + "ifaddrs.h", + "langinfo.h", + "libgen.h", + "limits.h", + "link.h", + "linux/sysctl.h", + "locale.h", + "malloc.h", + "mntent.h", + "mqueue.h", + "net/ethernet.h", + "net/if.h", + "net/if_arp.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/tcp.h", + "netinet/udp.h", + "poll.h", + "pthread.h", + "pty.h", + "pwd.h", + "regex.h", + "resolv.h", + "sched.h", + "semaphore.h", + "shadow.h", + "signal.h", + "spawn.h", + "stddef.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "sys/epoll.h", + "sys/eventfd.h", + "sys/file.h", + "sys/fsuid.h", + "sys/klog.h", + "sys/inotify.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/mman.h", + "sys/mount.h", + "sys/msg.h", + "sys/personality.h", + "sys/prctl.h", + "sys/ptrace.h", + "sys/quota.h", + "sys/random.h", + "sys/reboot.h", + "sys/resource.h", + "sys/sem.h", + "sys/sendfile.h", + "sys/shm.h", + "sys/signalfd.h", + "sys/socket.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/swap.h", + "sys/syscall.h", + "sys/time.h", + "sys/timerfd.h", + "sys/times.h", + "sys/timex.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/user.h", + "sys/utsname.h", + "sys/vfs.h", + "sys/wait.h", + "syslog.h", + "termios.h", + "time.h", + "ucontext.h", + "unistd.h", + "utime.h", + "utmp.h", + "utmpx.h", + "wchar.h", + "errno.h", + // `sys/io.h` is only available on x86*, Alpha, IA64, and 32-bit + // ARM: https://bugzilla.redhat.com/show_bug.cgi?id=1116162 + // Also unavailable on gnueabihf with glibc 2.30. + // https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=6b33f373c7b9199e00ba5fbafd94ac9bfb4337b1 + ((x86_64 || x86_32 || arm) && !gnueabihf, "sys/io.h"), + // `sys/reg.h` is only available on x86 and x86_64 + (x86_64 || x86_32, "sys/reg.h"), + // sysctl system call is deprecated and not available on musl + // It is also unsupported in x32, deprecated since glibc 2.30: + (!(x32 || musl || gnu), "sys/sysctl.h"), + // is not supported by musl: + // https://www.openwall.com/lists/musl/2015/04/09/3 + // is not present on uclibc. + (!(musl || uclibc), "execinfo.h"), + ); // Include linux headers at the end: - headers! { - cfg: - [loongarch64 || riscv64]: "asm/hwcap.h", - "asm/mman.h", - } + headers!(cfg, (loongarch64 || riscv64, "asm/hwcap.h"), "asm/mman.h",); if !wasm32 { - headers! { cfg: - [gnu]: "linux/aio_abi.h", + headers!( + cfg, + (gnu, "linux/aio_abi.h"), "linux/can.h", + "linux/can/bcm.h", "linux/can/raw.h", "linux/can/j1939.h", "linux/cn_proc.h", @@ -3942,19 +3852,19 @@ fn test_linux(target: &str) { "linux/wireless.h", "sys/fanotify.h", // is not present on uclibc - [!uclibc]: "sys/auxv.h", - [gnu || musl]: "linux/close_range.h", - } + (!uclibc, "sys/auxv.h"), + (gnu || musl, "linux/close_range.h"), + ); } // note: aio.h must be included before sys/mount.h - headers! { - cfg: + headers!( + cfg, "sys/xattr.h", "sys/sysinfo.h", // AIO is not supported by uclibc: - [!uclibc]: "aio.h", - } + (!uclibc, "aio.h"), + ); // Just pass all these through, no need for a "struct" prefix let typedef_structs = [ @@ -3988,7 +3898,7 @@ fn test_linux(target: &str) { } }); - cfg.rename_struct_field(|struct_, field| { + cfg.rename_struct_field(move |struct_, field| { let struct_ = struct_.ident(); match field.ident() { // Our stat *_nsec fields normally don't actually exist but are part @@ -4011,6 +3921,9 @@ fn test_linux(target: &str) { Some("type".to_string()) } + // FIXME(1.0): field has a different name on loongarch + "uc_flags" if loongarch64 && struct_ == "ucontext_t" => Some("__uc_flags".to_string()), + _ => None, } }); @@ -4045,9 +3958,6 @@ fn test_linux(target: &str) { // specific type. "Ioctl" => true, - // FIXME: "'__uint128' undeclared" in C - "__uint128" => true, - t => { if musl { // LFS64 types have been removed in musl 1.2.4+ @@ -4059,10 +3969,6 @@ fn test_linux(target: &str) { } }); - // Skip structs and enums that are unnamed in C. - cfg.skip_union(move |union_| union_.ident().starts_with("__c_anonymous_")); - cfg.skip_struct(move |struct_| struct_.ident().starts_with("__c_anonymous_")); - cfg.skip_struct(move |struct_| { let ty = struct_.ident(); @@ -4081,11 +3987,6 @@ fn test_linux(target: &str) { return true; } - // FIXME(#1558): passing by value corrupts the value for reasons not understood. - if (gnu && sparc64) && (ty == "ip_mreqn" || ty == "hwtstamp_config") { - return true; - } - // FIXME(rust-lang/rust#43894): pass by value for structs that are not an even 32/64 bits // on big-endian systems corrupts the value for unknown reasons. if (sparc64 || ppc || ppc64 || s390x) @@ -4125,28 +4026,14 @@ fn test_linux(target: &str) { // structs. "termios2" => true, - // FIXME(linux): remove once we set minimum supported glibc version. - // ucontext_t added a new field as of glibc 2.28; our struct definition is - // conservative and omits the field, but that means the size doesn't match for newer - // glibcs (see https://github.com/rust-lang/libc/issues/1410) - "ucontext_t" if gnu => true, - - // FIXME(linux): Somehow we cannot include headers correctly in glibc 2.30. - // So let's ignore for now and re-visit later. - // Probably related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91085 - "statx" => true, - "statx_timestamp" => true, - // On Linux, the type of `ut_exit` field of struct `utmpx` // can be an anonymous struct, so an extra struct, // which is absent in musl, has to be defined. "__exit_status" if musl => true, - // clone_args might differ b/w libc versions - "clone_args" => true, - - // Might differ between kernel versions - "open_how" => true, + // FIXME(ppc): tests fail due to a field type mismatch (`long long unsigned` vs + // `long unsigned`). + "clone_args" if ppc64 => true, // Linux >= 6.13 (pidfd_info.exit_code: Linux >= 6.15) // Might differ between kernel versions @@ -4155,37 +4042,6 @@ fn test_linux(target: &str) { "sctp_initmsg" | "sctp_sndrcvinfo" | "sctp_sndinfo" | "sctp_rcvinfo" | "sctp_nxtinfo" | "sctp_prinfo" | "sctp_authinfo" => true, - // FIXME(linux): requires >= 6.1 kernel headers - "canxl_frame" => true, - - // FIXME(linux): The size of `iv` has been changed since Linux v6.0 - // https://github.com/torvalds/linux/commit/94dfc73e7cf4a31da66b8843f0b9283ddd6b8381 - "af_alg_iv" => true, - - // FIXME(linux): Requires >= 5.1 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "tls12_crypto_info_aes_gcm_256" - if (aarch64 || arm || i686 || s390x || x86_64) && musl => - { - true - } - - // FIXME(linux): Requires >= 5.11 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "tls12_crypto_info_chacha20_poly1305" - if (aarch64 || arm || i686 || s390x || x86_64) && musl => - { - true - } - - // FIXME(linux): Requires >= 5.3 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "xdp_options" if musl => true, - - // FIXME(linux): Requires >= 5.4 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "xdp_ring_offset" | "xdp_mmap_offsets" if musl => true, - // FIXME(linux): Requires >= 6.8 kernel headers. // A field was added in 6.8. // https://github.com/torvalds/linux/commit/341ac980eab90ac1f6c22ee9f9da83ed9604d899 @@ -4193,15 +4049,8 @@ fn test_linux(target: &str) { // https://github.com/torvalds/linux/commit/32654bbd6313b4cfc82297e6634fa9725c3c900f "xdp_umem_reg" => true, - // FIXME(linux): Requires >= 5.9 kernel headers. - // Everything that uses install-musl.sh has 4.19 kernel headers. - "xdp_statistics" if musl => true, - // FIXME(linux): Requires >= 6.8 kernel headers. - "xsk_tx_metadata" - | "__c_anonymous_xsk_tx_metadata_union" - | "xsk_tx_metadata_request" - | "xsk_tx_metadata_completion" => true, + "xsk_tx_metadata" | "xsk_tx_metadata_request" | "xsk_tx_metadata_completion" => true, // A new field was added in kernel 5.4, this is the old version for backwards compatibility. // https://github.com/torvalds/linux/commit/77cd0d7b3f257fd0e3096b4fdcff1a7d38e99e10 @@ -4230,9 +4079,6 @@ fn test_linux(target: &str) { // FIXME(linux): Requires >= 6.12 kernel headers. "mnt_ns_info" => true, - // FIXME(linux): Requires >= 6.4 kernel headers. - "ptrace_sud_config" => true, - // Struct has changed for new musl versions "tcp_info" if old_musl => true, @@ -4280,48 +4126,6 @@ fn test_linux(target: &str) { } } if musl { - // FIXME(linux): Requires >= 5.0 kernel headers - if name == "SECCOMP_GET_NOTIF_SIZES" - || name == "SECCOMP_FILTER_FLAG_NEW_LISTENER" - || name == "SECCOMP_FILTER_FLAG_TSYNC_ESRCH" - || name == "SECCOMP_USER_NOTIF_FLAG_CONTINUE" // requires >= 5.5 - || name == "SECCOMP_ADDFD_FLAG_SETFD" // requires >= 5.9 - || name == "SECCOMP_ADDFD_FLAG_SEND" // requires >= 5.9 - || name == "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" // requires >= 5.19 - { - return true; - } - // FIXME(linux): Requires >= 4.20 kernel headers - if name == "PTP_SYS_OFFSET_EXTENDED" { - return true; - } - // FIXME(linux): Requires >= 5.4 kernel headers - if name == "PTP_CLOCK_GETCAPS2" - || name == "PTP_ENABLE_PPS2" - || name == "PTP_EXTTS_REQUEST2" - || name == "PTP_PEROUT_REQUEST2" - || name == "PTP_PIN_GETFUNC2" - || name == "PTP_PIN_SETFUNC2" - || name == "PTP_SYS_OFFSET2" - || name == "PTP_SYS_OFFSET_PRECISE2" - || name == "PTP_SYS_OFFSET_EXTENDED2" - { - return true; - } - // FIXME(linux): Requires >= 5.4.1 kernel headers - if name.starts_with("J1939") - || name.starts_with("RTEXT_FILTER_") - || name.starts_with("SO_J1939") - || name.starts_with("SCM_J1939") - { - return true; - } - // FIXME(linux): Requires >= 5.10 kernel headers - if name.starts_with("MEMBARRIER_CMD_REGISTER") - || name.starts_with("MEMBARRIER_CMD_PRIVATE") - { - return true; - } // LFS64 types have been removed in musl 1.2.4+ if name.starts_with("RLIM64") { return true; @@ -4330,20 +4134,6 @@ fn test_linux(target: &str) { if name.starts_with("NI_IDN") { return true; } - // FIXME: Requires >= 6.3 kernel headers - if loongarch64 && (name == "MFD_NOEXEC_SEAL" || name == "MFD_EXEC") { - return true; - } - // FIXME: Requires >= 6.3 (6.6) kernel headers - if name == "PR_GET_MDWE" || name == "PR_MDWE_NO_INHERIT" || name == "PR_MDWE_REFUSE_EXEC_GAIN" || name == "PR_SET_MDWE" { - return true; - } - // Requires musl >= 1.2 - if old_musl && (name == "SO_PREFER_BUSY_POLL" - || name == "SO_BUSY_POLL_BUDGET") - { - return true; - } // FIXME(musl): Not in musl yet if name == "SO_NETNS_COOKIE" || name == "SO_BUF_LOCK" @@ -4356,20 +4146,10 @@ fn test_linux(target: &str) { || name == "SO_DEVMEM_DMABUF" || name == "SO_DEVMEM_DONTNEED" { - return true; - } - // FIXME(musl): Not in musl yet - if name == "SCM_DEVMEM_LINEAR" - || name == "SCM_DEVMEM_DMABUF" - { - return true; - } - // Values changed in newer musl versions on these arches - if old_musl && (riscv64 || x86_64) && name == "O_LARGEFILE" { return true; } - // Values changed in newer musl versions - if old_musl && name == "RLIM_NLIMITS" { + // FIXME(musl): Not in musl yet + if name == "SCM_DEVMEM_LINEAR" || name == "SCM_DEVMEM_DMABUF" { return true; } // FIXME: Does not exist on non-x86 architectures, slated for removal @@ -4378,18 +4158,50 @@ fn test_linux(target: &str) { return true; } } + if old_musl { + // Constants that don't exist on the old version of musl we test with, but do exist + // on newer versions. + match name { + "FAN_EVENT_INFO_TYPE_ERROR" + | "FAN_EVENT_INFO_TYPE_NEW_DFID_NAME" + | "FAN_EVENT_INFO_TYPE_OLD_DFID_NAME" + | "FAN_FS_ERROR" + | "FAN_INFO" + | "FAN_MARK_EVICTABLE" + | "FAN_MARK_IGNORE" + | "FAN_MARK_IGNORE_SURV" + | "FAN_RENAME" + | "FAN_REPORT_DFID_NAME_TARGET" + | "FAN_REPORT_TARGET_FID" + | "FAN_RESPONSE_INFO_AUDIT_RULE" + | "FAN_RESPONSE_INFO_NONE" + | "IPPROTO_ETHERNET" + | "IPPROTO_MPTCP" + | "PR_GET_MDWE" + | "PR_MDWE_NO_INHERIT" + | "PR_MDWE_REFUSE_EXEC_GAIN" + | "PR_SET_MDWE" + | "RLIM_NLIMITS" + | "SI_DETHREAD" + | "SO_BUSY_POLL_BUDGET" + | "SO_PREFER_BUSY_POLL" => return true, + // Values changed in newer musl versions on these arches + "O_LARGEFILE" if riscv64 || x86_64 => return true, + _ => (), + } + } match name { // These constants are not available if gnu headers have been included // and can therefore not be tested here // // The IPV6 constants are tested in the `linux_ipv6.rs` tests: - | "IPV6_FLOWINFO" + "IPV6_FLOWINFO" | "IPV6_FLOWLABEL_MGR" | "IPV6_FLOWINFO_SEND" | "IPV6_FLOWINFO_FLOWLABEL" - | "IPV6_FLOWINFO_PRIORITY" + | "IPV6_FLOWINFO_PRIORITY" => true, // The F_ fnctl constants are tested in the `linux_fnctl.rs` tests: - | "F_CANCELLK" + "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" | "F_SEAL_SEAL" @@ -4412,12 +4224,7 @@ fn test_linux(target: &str) { // FIXME(linux): conflicts with glibc headers and is tested in // `linux_termios.rs` below: - | "BOTHER" - | "IBSHIFT" - | "TCGETS2" - | "TCSETS2" - | "TCSETSW2" - | "TCSETSF2" => true, + "BOTHER" | "IBSHIFT" | "TCGETS2" | "TCSETS2" | "TCSETSW2" | "TCSETSF2" => true, // FIXME(musl): on musl the pthread types are defined a little differently // - these constants are used by the glibc implementation. @@ -4430,46 +4237,24 @@ fn test_linux(target: &str) { // deprecated: not available from Linux kernel 5.6: "VMADDR_CID_RESERVED" => true, - // IPPROTO_MAX was increased in 5.6 for IPPROTO_MPTCP: - | "IPPROTO_MAX" - | "IPPROTO_ETHERNET" - | "IPPROTO_MPTCP" => true, + // FIXME(value): IPPROTO_MAX was increased in 5.6 for IPPROTO_MPTCP: + "IPPROTO_MAX" => true, // FIXME(linux): Not yet implemented on sparc64 "SYS_clone3" if sparc64 => true, - // FIXME(linux): Not defined on ARM, gnueabihf, musl, PowerPC, riscv64, s390x, and sparc64. - "SYS_memfd_secret" if arm | gnueabihf | musl | ppc | riscv64 | s390x | sparc64 => true, - - // FIXME(linux): Added in Linux 5.16 - // https://github.com/torvalds/linux/commit/039c0ec9bb77446d7ada7f55f90af9299b28ca49 - "SYS_futex_waitv" => true, - - // FIXME(linux): Added in Linux 5.17 - // https://github.com/torvalds/linux/commit/c6018b4b254971863bd0ad36bb5e7d0fa0f0ddb0 - "SYS_set_mempolicy_home_node" => true, - - // FIXME(linux): Added in Linux 5.18 - // https://github.com/torvalds/linux/commit/8b5413647262dda8d8d0e07e14ea1de9ac7cf0b2 - "NFQA_PRIORITY" => true, - - // FIXME(linux): requires more recent kernel headers on CI - | "UINPUT_VERSION" - | "SW_MAX" - | "SW_CNT" - if ppc64 || riscv64 => true, - - // FIXME(linux): requires more recent kernel headers on CI - "SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV" if sparc64 => true, - - // FIXME(linux): Not currently available in headers on ARM and musl. - "NETLINK_GET_STRICT_CHK" if arm => true, + // FIXME(linux): Not defined on ARM, gnueabihf, mips, musl, PowerPC, riscv64, s390x, and sparc64. + "SYS_memfd_secret" + if arm | gnueabihf | mips | musl | ppc | riscv64 | s390x | sparc64 => + { + true + } // Skip as this signal codes and trap reasons need newer headers - "SI_DETHREAD" | "TRAP_PERF" => true, + "TRAP_PERF" => true, // kernel constants not available in uclibc 1.0.34 - | "EXTPROC" + "EXTPROC" | "IPPROTO_BEETPH" | "IPPROTO_MPLS" | "IPV6_HDRINCL" @@ -4482,7 +4267,10 @@ fn test_linux(target: &str) { | "SHM_EXEC" | "UDP_GRO" | "UDP_SEGMENT" - if uclibc => true, + if uclibc => + { + true + } // headers conflicts with linux/pidfd.h "PIDFD_NONBLOCK" => true, @@ -4514,69 +4302,36 @@ fn test_linux(target: &str) { // is a private value for kernel usage normally "FUSE_SUPER_MAGIC" => true, - // linux 5.17 min - "PR_SET_VMA" | "PR_SET_VMA_ANON_NAME" => true, - - // present in recent kernels only - "PR_SCHED_CORE" | "PR_SCHED_CORE_CREATE" | "PR_SCHED_CORE_GET" | "PR_SCHED_CORE_MAX" | "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" | "PR_SCHED_CORE_SCOPE_THREAD" | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" | "PR_SCHED_CORE_SHARE_FROM" | "PR_SCHED_CORE_SHARE_TO" => true, - - // present in recent kernels only >= 5.13 - "PR_PAC_SET_ENABLED_KEYS" | "PR_PAC_GET_ENABLED_KEYS" => true, - // present in recent kernels only >= 5.19 - "PR_SME_SET_VL" | "PR_SME_GET_VL" | "PR_SME_VL_LEN_MAX" | "PR_SME_SET_VL_INHERIT" | "PR_SME_SET_VL_ONE_EXEC" => true, - - // Added in Linux 5.14 - "FUTEX_LOCK_PI2" => true, - - // Added in linux 6.1 - "STATX_DIOALIGN" - | "CAN_RAW_XL_FRAMES" - | "CANXL_HDR_SIZE" - | "CANXL_MAX_DLC" - | "CANXL_MAX_DLC_MASK" - | "CANXL_MAX_DLEN" - | "CANXL_MAX_MTU" - | "CANXL_MIN_DLC" - | "CANXL_MIN_DLEN" - | "CANXL_MIN_MTU" - | "CANXL_MTU" - | "CANXL_PRIO_BITS" - | "CANXL_PRIO_MASK" - | "CANXL_SEC" - | "CANXL_XLF" - => true, + // Not present on old musl + "PR_SET_VMA" + | "PR_SET_VMA_ANON_NAME" + | "PR_SCHED_CORE" + | "PR_SCHED_CORE_CREATE" + | "PR_SCHED_CORE_GET" + | "PR_SCHED_CORE_MAX" + | "PR_SCHED_CORE_SCOPE_PROCESS_GROUP" + | "PR_SCHED_CORE_SCOPE_THREAD" + | "PR_SCHED_CORE_SCOPE_THREAD_GROUP" + | "PR_SCHED_CORE_SHARE_FROM" + | "PR_SCHED_CORE_SHARE_TO" + if old_musl => + { + true + } - // FIXME(linux): Parts of netfilter/nfnetlink*.h require more recent kernel headers: - | "RTNLGRP_MCTP_IFADDR" // linux v5.17+ - | "RTNLGRP_TUNNEL" // linux v5.18+ - | "RTNLGRP_STATS" // linux v5.18+ - => true, + // Not present in glibc + "PR_SME_VL_LEN_MAX" | "PR_SME_SET_VL_INHERIT" | "PR_SME_SET_VL_ONE_EXEC" if gnu => true, // FIXME(linux): The below is no longer const in glibc 2.34: // https://github.com/bminor/glibc/commit/5d98a7dae955bafa6740c26eaba9c86060ae0344 - | "PTHREAD_STACK_MIN" - | "SIGSTKSZ" - | "MINSIGSTKSZ" - if gnu => true, - - // FIXME(linux): Linux >= 5.16: - // https://github.com/torvalds/linux/commit/42df6e1d221dddc0f2acf2be37e68d553ad65f96 - "NF_NETDEV_EGRESS" if sparc64 => true, + "PTHREAD_STACK_MIN" | "SIGSTKSZ" | "MINSIGSTKSZ" if gnu => true, + // value changed "NF_NETDEV_NUMHOOKS" if sparc64 => true, - // FIXME(linux): requires Linux >= v5.8 - "IF_LINK_MODE_TESTING" if sparc64 => true, - // DIFF(main): fixed in 1.0 with e9abac9ac2 "CLONE_CLEAR_SIGHAND" | "CLONE_INTO_CGROUP" => true, - // kernel 6.1 minimum - "MADV_COLLAPSE" => true, - - // kernel 6.2 minimum - "TUN_F_USO4" | "TUN_F_USO6" | "IFF_NO_CARRIER" => true, - // kernel 6.9 minimum "RWF_NOAPPEND" => true, @@ -4586,38 +4341,6 @@ fn test_linux(target: &str) { // 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+ - | "IFLA_GRO_MAX_SIZE" // linux v5.16+ - | "IFLA_TSO_MAX_SIZE" // linux v5.18+ - | "IFLA_TSO_MAX_SEGS" // linux v5.18+ - | "IFLA_ALLMULTI" // linux v6.0+ - | "MADV_DONTNEED_LOCKED" // linux v5.18+ - => true, - "SCTP_FUTURE_ASSOC" | "SCTP_CURRENT_ASSOC" | "SCTP_ALL_ASSOC" | "SCTP_PEER_ADDR_THLDS_V2" => true, // linux 5.5+ - - // kernel 6.5 minimum - "MOVE_MOUNT_BENEATH" => true, - // FIXME(linux): Requires linux 6.1 - "ALG_SET_KEY_BY_KEY_SERIAL" | "ALG_SET_DRBG_ENTROPY" => true, - - // FIXME(linux): Requires more recent kernel headers - | "FAN_FS_ERROR" // linux v5.16+ - | "FAN_RENAME" // linux v5.17+ - | "FAN_REPORT_TARGET_FID" // linux v5.17+ - | "FAN_REPORT_DFID_NAME_TARGET" // linux v5.17+ - | "FAN_MARK_EVICTABLE" // linux v5.19+ - | "FAN_MARK_IGNORE" // linux v6.0+ - | "FAN_MARK_IGNORE_SURV" // linux v6.0+ - | "FAN_EVENT_INFO_TYPE_ERROR" // linux v5.16+ - | "FAN_EVENT_INFO_TYPE_OLD_DFID_NAME" // linux v5.17+ - | "FAN_EVENT_INFO_TYPE_NEW_DFID_NAME" // linux v5.17+ - | "FAN_RESPONSE_INFO_NONE" // linux v5.16+ - | "FAN_RESPONSE_INFO_AUDIT_RULE" // linux v5.16+ - | "FAN_INFO" // linux v5.16+ - => true, - // musl doesn't use in "FAN_REPORT_PIDFD" | "FAN_REPORT_DIR_FID" @@ -4628,43 +4351,36 @@ fn test_linux(target: &str) { | "FAN_EVENT_INFO_TYPE_PIDFD" | "FAN_NOPIDFD" | "FAN_EPIDFD" - if musl => true, - - // FIXME(linux): Requires linux 6.5 - "NFT_MSG_MAX" => true, - - // FIXME(linux): Requires >= 6.6 kernel headers. - "XDP_USE_SG" - | "XDP_PKT_CONTD" - => + if musl => { true } // FIXME(linux): Requires >= 6.6 kernel headers. - "PR_MDWE_NO_INHERIT" => true, + "XDP_USE_SG" | "XDP_PKT_CONTD" => true, + + // FIXME(linux): Missing only on this platform for some reason + "PR_MDWE_NO_INHERIT" if gnueabihf => true, // FIXME(linux): Requires >= 6.8 kernel headers. "XDP_UMEM_TX_SW_CSUM" | "XDP_TXMD_FLAGS_TIMESTAMP" | "XDP_TXMD_FLAGS_CHECKSUM" - | "XDP_TX_METADATA" - => - { - true - } + | "XDP_TX_METADATA" => true, // FIXME(linux): Requires >= 6.11 kernel headers. - "XDP_UMEM_TX_METADATA_LEN" - => - { - true - } + "XDP_UMEM_TX_METADATA_LEN" => 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, + "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, + "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, @@ -4673,58 +4389,30 @@ fn test_linux(target: &str) { "SYS_mseal" => true, // FIXME(linux): seems to not be available all the time (from : - "PF_VCPU" - | "PF_IDLE" - | "PF_EXITING" - | "PF_POSTCOREDUMP" - | "PF_IO_WORKER" - | "PF_WQ_WORKER" - | "PF_FORKNOEXEC" - | "PF_MCE_PROCESS" - | "PF_SUPERPRIV" - | "PF_DUMPCORE" - | "PF_SIGNALED" - | "PF_MEMALLOC" - | "PF_NPROC_EXCEEDED" - | "PF_USED_MATH" - | "PF_USER_WORKER" - | "PF_NOFREEZE" - | "PF_KSWAPD" - | "PF_MEMALLOC_NOFS" - | "PF_MEMALLOC_NOIO" - | "PF_LOCAL_THROTTLE" - | "PF_KTHREAD" - | "PF_RANDOMIZE" - | "PF_NO_SETAFFINITY" - | "PF_MCE_EARLY" - | "PF_MEMALLOC_PIN" - | "PF_BLOCK_TS" - | "PF_SUSPEND_TASK" => true, + "PF_VCPU" | "PF_IDLE" | "PF_EXITING" | "PF_POSTCOREDUMP" | "PF_IO_WORKER" + | "PF_WQ_WORKER" | "PF_FORKNOEXEC" | "PF_MCE_PROCESS" | "PF_SUPERPRIV" + | "PF_DUMPCORE" | "PF_SIGNALED" | "PF_MEMALLOC" | "PF_NPROC_EXCEEDED" + | "PF_USED_MATH" | "PF_USER_WORKER" | "PF_NOFREEZE" | "PF_KSWAPD" + | "PF_MEMALLOC_NOFS" | "PF_MEMALLOC_NOIO" | "PF_LOCAL_THROTTLE" | "PF_KTHREAD" + | "PF_RANDOMIZE" | "PF_NO_SETAFFINITY" | "PF_MCE_EARLY" | "PF_MEMALLOC_PIN" + | "PF_BLOCK_TS" | "PF_SUSPEND_TASK" => true, // FIXME(linux): Requires >= 6.9 kernel headers. - "EPIOCSPARAMS" - | "EPIOCGPARAMS" => true, + "EPIOCSPARAMS" | "EPIOCGPARAMS" => true, // FIXME(linux): Requires >= 6.11 kernel headers. "MAP_DROPPABLE" => true, - // FIXME(linux): Requires >= 6.2 kernel headers. - "SOF_TIMESTAMPING_OPT_ID_TCP" => true, - // FIXME(linux): Requires >= 6.12 kernel headers. "SOF_TIMESTAMPING_OPT_RX_FILTER" => true, // FIXME(linux): Requires >= 6.12 kernel headers. - "SO_DEVMEM_LINEAR" - | "SO_DEVMEM_DMABUF" - | "SO_DEVMEM_DONTNEED" - | "SCM_DEVMEM_LINEAR" - | "SCM_DEVMEM_DMABUF" => true, - // FIXME(linux): Requires >= 6.4 kernel headers. - "PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG" | "PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG" => true, + "SO_DEVMEM_LINEAR" | "SO_DEVMEM_DMABUF" | "SO_DEVMEM_DONTNEED" + | "SCM_DEVMEM_LINEAR" | "SCM_DEVMEM_DMABUF" => true, - // FIXME(linux): Requires >= 6.6 kernel headers. - "PROC_EVENT_NONZERO_EXIT" => true, + // FIXME(linux): Requires >= 6.4 kernel headers. + "PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG" + | "PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG" => true, // FIXME(linux): Requires >= 6.14 kernel headers. "SECBIT_EXEC_DENY_INTERACTIVE" @@ -4736,6 +4424,9 @@ fn test_linux(target: &str) { // FIXME(linux): Value changed in 6.14 "SECURE_ALL_BITS" | "SECURE_ALL_LOCKS" => true, + // FIXME(linux): Requires >= 6.9 kernel headers. + "AT_HWCAP3" | "AT_HWCAP4" => true, + _ => false, } }); @@ -4951,7 +4642,7 @@ fn test_linux(target: &str) { (musl && struct_ == "tcp_info" && field == "tcpi_delivery_fastopen_bitfields") || // either fsid_t or int[2] type (struct_ == "fanotify_event_info_fid" && field == "fsid") || - // `handle` is a VLA + // `handle` is a flexible array member (struct_ == "fanotify_event_info_fid" && field == "handle") || // `anonymous_1` is an anonymous union (struct_ == "ptp_perout_request" && field == "anonymous_1") || @@ -4969,7 +4660,11 @@ fn test_linux(target: &str) { // the `xsk_tx_metadata_union` field is an anonymous union (struct_ == "xsk_tx_metadata" && field == "xsk_tx_metadata_union") || // After musl 1.2.0, the type becomes `int` instead of `long`. - (old_musl && struct_ == "utmpx" && field == "ut_session") + (old_musl && struct_ == "utmpx" && field == "ut_session") || + // `frames` is a flexible array member + (struct_ == "bcm_msg_head" && field == "frames") || + // FAM + (struct_ == "af_alg_iv" && field == "iv") }); cfg.skip_roundtrip(move |s| match s { @@ -5008,6 +4703,7 @@ fn test_linux(target: &str) { "inotify_event" => true, "fanotify_event_info_fid" => true, "cmsghdr" => true, + "bcm_msg_head" => true, // FIXME(linux): the call ABI of max_align_t is incorrect on these platforms: "max_align_t" if i686 || ppc64 => true, @@ -5035,9 +4731,9 @@ fn test_linux_like_apis(target: &str) { if linux || android || emscripten { // test strerror_r from the `string.h` header config_gnu_bits(target, &mut cfg); - headers! { cfg: "string.h" } - cfg.skip_alias(|_| true) + cfg.header("string.h") + .skip_alias(|_| true) .skip_static(|_| true) .skip_const(|_| true) .skip_struct(|_| true) @@ -5120,10 +4816,7 @@ fn test_linux_like_apis(target: &str) { .skip_const(move |constant| !ipv6_constants.contains(&constant.ident())); config_gnu_bits(target, &mut cfg); - headers! { - cfg: - "linux/in6.h" - } + headers!(cfg, "linux/in6.h",); ctest::generate_test(&mut cfg, "../src/lib.rs", "linux_ipv6.rs").unwrap(); } @@ -5204,143 +4897,142 @@ fn test_haiku(target: &str) { cfg.language(ctest::Language::CXX); // POSIX API - headers! { cfg: - "alloca.h", - "arpa/inet.h", - "arpa/nameser.h", - "arpa/nameser_compat.h", - "assert.h", - "complex.h", - "ctype.h", - "dirent.h", - "div_t.h", - "dlfcn.h", - "endian.h", - "errno.h", - "fcntl.h", - "fenv.h", - "fnmatch.h", - "fts.h", - "ftw.h", - "getopt.h", - "glob.h", - "grp.h", - "inttypes.h", - "iovec.h", - "langinfo.h", - "libgen.h", - "libio.h", - "limits.h", - "locale.h", - "malloc.h", - "malloc_debug.h", - "math.h", - "memory.h", - "monetary.h", - "net/if.h", - "net/if_dl.h", - "net/if_media.h", - "net/if_tun.h", - "net/if_types.h", - "net/route.h", - "netdb.h", - "netinet/in.h", - "netinet/ip.h", - "netinet/ip6.h", - "netinet/ip_icmp.h", - "netinet/ip_var.h", - "netinet/tcp.h", - "netinet/udp.h", - "netinet6/in6.h", - "nl_types.h", - "null.h", - "poll.h", - "pthread.h", - "pwd.h", - "regex.h", - "resolv.h", - "sched.h", - "search.h", - "semaphore.h", - "setjmp.h", - "shadow.h", - "signal.h", - "size_t.h", - "spawn.h", - "stdint.h", - "stdio.h", - "stdlib.h", - "string.h", - "strings.h", - "sys/cdefs.h", - "sys/file.h", - "sys/ioctl.h", - "sys/ipc.h", - "sys/mman.h", - "sys/msg.h", - "sys/param.h", - "sys/poll.h", - "sys/resource.h", - "sys/select.h", - "sys/sem.h", - "sys/socket.h", - "sys/sockio.h", - "sys/stat.h", - "sys/statvfs.h", - "sys/time.h", - "sys/timeb.h", - "sys/times.h", - "sys/types.h", - "sys/uio.h", - "sys/un.h", - "sys/utsname.h", - "sys/wait.h", - "syslog.h", - "tar.h", - "termios.h", - "time.h", - "uchar.h", - "unistd.h", - "utime.h", - "utmpx.h", - "wchar.h", - "wchar_t.h", - "wctype.h" - } + headers!( + cfg, + "alloca.h", + "arpa/inet.h", + "arpa/nameser.h", + "arpa/nameser_compat.h", + "assert.h", + "complex.h", + "ctype.h", + "dirent.h", + "div_t.h", + "dlfcn.h", + "endian.h", + "errno.h", + "fcntl.h", + "fenv.h", + "fnmatch.h", + "fts.h", + "ftw.h", + "getopt.h", + "glob.h", + "grp.h", + "inttypes.h", + "iovec.h", + "langinfo.h", + "libgen.h", + "libio.h", + "limits.h", + "locale.h", + "malloc.h", + "malloc_debug.h", + "math.h", + "memory.h", + "monetary.h", + "net/if.h", + "net/if_dl.h", + "net/if_media.h", + "net/if_tun.h", + "net/if_types.h", + "net/route.h", + "netdb.h", + "netinet/in.h", + "netinet/ip.h", + "netinet/ip6.h", + "netinet/ip_icmp.h", + "netinet/ip_var.h", + "netinet/tcp.h", + "netinet/udp.h", + "netinet6/in6.h", + "nl_types.h", + "null.h", + "poll.h", + "pthread.h", + "pwd.h", + "regex.h", + "resolv.h", + "sched.h", + "search.h", + "semaphore.h", + "setjmp.h", + "shadow.h", + "signal.h", + "size_t.h", + "spawn.h", + "stdint.h", + "stdio.h", + "stdlib.h", + "string.h", + "strings.h", + "sys/cdefs.h", + "sys/file.h", + "sys/ioctl.h", + "sys/ipc.h", + "sys/mman.h", + "sys/msg.h", + "sys/param.h", + "sys/poll.h", + "sys/resource.h", + "sys/select.h", + "sys/sem.h", + "sys/socket.h", + "sys/sockio.h", + "sys/stat.h", + "sys/statvfs.h", + "sys/time.h", + "sys/timeb.h", + "sys/times.h", + "sys/types.h", + "sys/uio.h", + "sys/un.h", + "sys/utsname.h", + "sys/wait.h", + "syslog.h", + "tar.h", + "termios.h", + "time.h", + "uchar.h", + "unistd.h", + "utime.h", + "utmpx.h", + "wchar.h", + "wchar_t.h", + "wctype.h", + ); // BSD Extensions - headers! { cfg: - "ifaddrs.h", - "libutil.h", - "link.h", - "pty.h", - "stdlib.h", - "stringlist.h", - "sys/link_elf.h", - } + headers!( + cfg, + "ifaddrs.h", + "libutil.h", + "link.h", + "pty.h", + "stdlib.h", + "stringlist.h", + "sys/link_elf.h", + ); // Native API - headers! { cfg: - "kernel/OS.h", - "kernel/fs_attr.h", - "kernel/fs_index.h", - "kernel/fs_info.h", - "kernel/fs_query.h", - "kernel/fs_volume.h", - "kernel/image.h", - "kernel/scheduler.h", - "storage/FindDirectory.h", - "storage/StorageDefs.h", - "support/Errors.h", - "support/SupportDefs.h", - "support/TypeConstants.h" - } + headers!( + cfg, + "kernel/OS.h", + "kernel/fs_attr.h", + "kernel/fs_index.h", + "kernel/fs_info.h", + "kernel/fs_query.h", + "kernel/fs_volume.h", + "kernel/image.h", + "kernel/scheduler.h", + "storage/FindDirectory.h", + "storage/StorageDefs.h", + "support/Errors.h", + "support/SupportDefs.h", + "support/TypeConstants.h", + ); - cfg.skip_union(|union_| union_.ident().starts_with("__c_anonymous_")); cfg.skip_struct(move |struct_| { - if struct_.ident().starts_with("__c_anonymous_") { - return true; - } match struct_.ident() { // FIXME(union): actually a union "sigval" => true, @@ -5546,92 +5238,93 @@ fn test_aix(target: &str) { // '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", - "netinet/sctp.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", - } + 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", + "netinet/sctp.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_alias(move |ty| match ty.ident() { // AIX does not define type 'sighandler_t'. @@ -5752,6 +5445,12 @@ fn test_aix(target: &str) { // The field 'data' is actually a unnamed union in the AIX header. "pollfd_ext" if field.ident() == "data" => true, + // On AIX, declares 'tv_nsec' as 'long', but the + // underlying system calls return a 32-bit value in both 32-bit + // and 64-bit modes. In the 'libc' crate it is declared as 'i32' + // to match the system call. Skip this field. + "timespec" if field.ident() == "tv_nsec" => true, + _ => false, } }); diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 53ab742cf2a6a..644aeaa6667b9 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -150,6 +150,8 @@ AT_FLAGS AT_GID AT_HWCAP AT_HWCAP2 +AT_HWCAP3 +AT_HWCAP4 AT_IGNORE AT_MINSIGSTKSZ AT_NOTELF diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 1d340bd54929d..e9fb9cb31fb12 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -2033,6 +2033,7 @@ initgroups integer_t ip_mreqn ipc_perm +issetugid kern_return_t kevent kevent64 diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index 6c2a3a0d2e4e0..6d41c8c6cabd9 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -1403,6 +1403,7 @@ if_nameindex ifaddrs in6_pktinfo initgroups +issetugid jrand48 kevent killpg diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index cebe46464eebf..baf07600f5b12 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -96,6 +96,8 @@ AT_FLAGS AT_GID AT_HWCAP AT_HWCAP2 +AT_HWCAP3 +AT_HWCAP4 AT_NCPUS AT_NOTELF AT_NULL @@ -2052,6 +2054,7 @@ input_absinfo input_event ip_mreqn ipc_perm +issetugid jail jail_attach jail_get diff --git a/libc-test/semver/linux-gnu-powerpc64.txt b/libc-test/semver/linux-gnu-powerpc64.txt index 148688c5ff20d..46aa2db2cfdd3 100644 --- a/libc-test/semver/linux-gnu-powerpc64.txt +++ b/libc-test/semver/linux-gnu-powerpc64.txt @@ -10,5 +10,20 @@ KEYCTL_CAPS0_RESTRICT_KEYRING KEYCTL_CAPS1_NS_KEYRING_NAME KEYCTL_CAPS1_NS_KEY_TAG KEYCTL_MOVE +__NFPREG +__NGREG +__NVRREG +clone_args +fpregset_t +getcontext +gregset_t +makecontext max_align_t +mcontext_t +pt_regs +setcontext +swapcontext sysctl +ucontext_t +vrregset_t +vscr_t diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 318cca51b482e..f67a02f946527 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -168,6 +168,8 @@ AT_FLAGS AT_GID AT_HWCAP AT_HWCAP2 +AT_HWCAP3 +AT_HWCAP4 AT_IGNORE AT_MINSIGSTKSZ AT_NOTELF @@ -232,6 +234,7 @@ CAN_EFF_ID_BITS CAN_EFF_MASK CAN_ERR_FLAG CAN_ERR_MASK +CAN_FD_FRAME CAN_INV_FILTER CAN_ISOTP CAN_J1939 @@ -2709,6 +2712,17 @@ RT_TOS RUSAGE_CHILDREN RUSAGE_SELF RUSAGE_THREAD +RX_ANNOUNCE_RESUME +RX_CHANGED +RX_CHECK_DLC +RX_DELETE +RX_FILTER_ID +RX_NO_AUTOTIMER +RX_READ +RX_RTR_FRAME +RX_SETUP +RX_STATUS +RX_TIMEOUT SCHED_BATCH SCHED_FIFO SCHED_IDLE @@ -2842,6 +2856,7 @@ SEM_STAT SEM_STAT_ANY SEM_UNDO SETALL +SETTIMER SETVAL SFD_CLOEXEC SFD_NONBLOCK @@ -3086,6 +3101,7 @@ SPLICE_F_MOVE SPLICE_F_NONBLOCK SS_DISABLE SS_ONSTACK +STARTTIMER STICKY_TIMEOUTS ST_APPEND ST_IMMUTABLE @@ -3574,6 +3590,16 @@ TUN_TAP_DEV TUN_TUN_DEV TUN_TX_TIMESTAMP TUN_TYPE_MASK +TX_ANNOUNCE +TX_COUNTEVT +TX_CP_CAN_ID +TX_DELETE +TX_EXPIRED +TX_READ +TX_RESET_MULTI_IDX +TX_SEND +TX_SETUP +TX_STATUS T_FMT T_FMT_AMPM UDP_CORK @@ -3857,6 +3883,8 @@ arpd_request arphdr arpreq arpreq_old +bcm_msg_head +bcm_timeval blkcnt64_t brk bsearch diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 5821466cc8ddf..bcd25eca15b93 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1402,6 +1402,7 @@ in6_pktinfo in_pktinfo initgroups ipc_perm +issetugid itimerspec jrand48 kevent diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index cfb234fdfa3d1..412ba5a4bd481 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -1173,6 +1173,7 @@ initgroups ip_mreqn ipc_perm iso_args +issetugid jrand48 kevent key_t diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index b7aaa5706d626..e993475f20b4b 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -302,6 +302,8 @@ getgrouplist getline getpwent getpwnam_r +getresgid +getresuid getrlimit getrusage getservbyport @@ -324,6 +326,8 @@ reallocarray rlim_t setgrent setpwent +setresgid +setresuid setrlimit setservent sigqueue diff --git a/libc-test/tests/cmsg.rs b/libc-test/tests/cmsg.rs index bb832f1ba3d54..893dd56dba266 100644 --- a/libc-test/tests/cmsg.rs +++ b/libc-test/tests/cmsg.rs @@ -29,6 +29,7 @@ mod t { } #[test] + #[allow(unused_assignments)] // false-positive: https://github.com/rust-lang/rust/issues/147648 fn test_cmsg_firsthdr() { let mut buf = [0u8; 256]; let mut mhdr: msghdr = unsafe { mem::zeroed() }; diff --git a/libc-test/test/ctest.rs b/libc-test/tests/ctest.rs similarity index 100% rename from libc-test/test/ctest.rs rename to libc-test/tests/ctest.rs diff --git a/libc-test/test/linux_elf.rs b/libc-test/tests/linux_elf.rs similarity index 100% rename from libc-test/test/linux_elf.rs rename to libc-test/tests/linux_elf.rs diff --git a/libc-test/test/linux_fcntl.rs b/libc-test/tests/linux_fcntl.rs similarity index 100% rename from libc-test/test/linux_fcntl.rs rename to libc-test/tests/linux_fcntl.rs diff --git a/libc-test/test/linux_if_arp.rs b/libc-test/tests/linux_if_arp.rs similarity index 100% rename from libc-test/test/linux_if_arp.rs rename to libc-test/tests/linux_if_arp.rs diff --git a/libc-test/test/linux_ipv6.rs b/libc-test/tests/linux_ipv6.rs similarity index 100% rename from libc-test/test/linux_ipv6.rs rename to libc-test/tests/linux_ipv6.rs diff --git a/libc-test/test/linux_kernel_version.rs b/libc-test/tests/linux_kernel_version.rs similarity index 100% rename from libc-test/test/linux_kernel_version.rs rename to libc-test/tests/linux_kernel_version.rs diff --git a/libc-test/test/linux_strerror_r.rs b/libc-test/tests/linux_strerror_r.rs similarity index 100% rename from libc-test/test/linux_strerror_r.rs rename to libc-test/tests/linux_strerror_r.rs diff --git a/libc-test/test/linux_termios.rs b/libc-test/tests/linux_termios.rs similarity index 100% rename from libc-test/test/linux_termios.rs rename to libc-test/tests/linux_termios.rs diff --git a/libc-test/test/semver.rs b/libc-test/tests/semver.rs similarity index 100% rename from libc-test/test/semver.rs rename to libc-test/tests/semver.rs diff --git a/libc-test/test/check_style.rs b/libc-test/tests/style.rs similarity index 96% rename from libc-test/test/check_style.rs rename to libc-test/tests/style.rs index d1d7fdf4aa150..d5af8dddbf973 100644 --- a/libc-test/test/check_style.rs +++ b/libc-test/tests/style.rs @@ -9,12 +9,12 @@ //! cargo test --test style //! ``` -pub mod style; +pub mod style_lib; use std::env; use std::path::Path; -use style::{Result, StyleChecker}; +use style_lib::{Result, StyleChecker}; /// Relative to `src/`. const SKIP_PREFIXES: &[&str] = &[ diff --git a/libc-test/test/style/mod.rs b/libc-test/tests/style_lib/mod.rs similarity index 100% rename from libc-test/test/style/mod.rs rename to libc-test/tests/style_lib/mod.rs diff --git a/libc-test/test/style_tests.rs b/libc-test/tests/style_tests.rs similarity index 99% rename from libc-test/test/style_tests.rs rename to libc-test/tests/style_tests.rs index be8fddbccf644..e136bb66d26a4 100644 --- a/libc-test/test/style_tests.rs +++ b/libc-test/tests/style_tests.rs @@ -1,8 +1,8 @@ //! Verifies the implementation of the style checker in [style]. -use style::StyleChecker; +use style_lib::StyleChecker; -pub mod style; +pub mod style_lib; #[test] fn check_style_accept_correct_module_layout() { diff --git a/rustfmt.toml b/rustfmt.toml index de0fc5ecc0166..8016e2bbfeca9 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,3 +1,4 @@ +# Note that there is a separate configuration for `src/` edition = "2021" error_on_line_overflow = true group_imports = "StdExternalCrate" diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 31f13b16832d2..5a3d0784c434c 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -78,32 +78,10 @@ pub type fsblkcnt_t = c_ulonglong; pub type fsfilcnt_t = c_ulonglong; pub type rlim_t = c_ulonglong; -// FIXME(fuchsia): why are these uninhabited types? that seems... wrong? -// Presumably these should be `()` or an `extern type` (when that stabilizes). -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } -} -#[derive(Debug)] -pub enum DIR {} -impl Copy for DIR {} -impl Clone for DIR { - fn clone(&self) -> DIR { - *self - } -} - -#[derive(Debug)] -pub enum fpos64_t {} // FIXME(fuchsia): fill this out with a struct -impl Copy for fpos64_t {} -impl Clone for fpos64_t { - fn clone(&self) -> fpos64_t { - *self - } +extern_ty! { + pub enum timezone {} + pub enum DIR {} + pub enum fpos64_t {} // FIXME(fuchsia): fill this out with a struct } // PUB_STRUCT @@ -3421,21 +3399,9 @@ fn __MHDR_END(mhdr: *const msghdr) -> *mut c_uchar { #[link(name = "fdio")] extern "C" {} -#[derive(Debug)] -pub enum FILE {} -impl Copy for FILE {} -impl Clone for FILE { - fn clone(&self) -> FILE { - *self - } -} -#[derive(Debug)] -pub enum fpos_t {} // FIXME(fuchsia): fill this out with a struct -impl Copy for fpos_t {} -impl Clone for fpos_t { - fn clone(&self) -> fpos_t { - *self - } +extern_ty! { + pub enum FILE {} + pub enum fpos_t {} // FIXME(fuchsia): fill this out with a struct } extern "C" { diff --git a/src/lib.rs b/src/lib.rs index aa919b5ca038e..846c2189b79ed 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,6 @@ #![cfg_attr(libc_deny_warnings, deny(warnings))] // Attributes needed when building as part of the standard library #![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))] -#![cfg_attr(libc_thread_local, feature(thread_local))] #![cfg_attr(feature = "rustc-dep-of-std", allow(internal_features))] // DIFF(1.0): The thread local references that raise this lint were removed in 1.0 #![cfg_attr(feature = "rustc-dep-of-std", allow(static_mut_refs))] diff --git a/src/macros.rs b/src/macros.rs index 6906da6bd70da..a5359db0f62c5 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -76,26 +76,59 @@ macro_rules! prelude { #[allow(unused_imports)] pub(crate) use core::default::Default; #[allow(unused_imports)] - pub(crate) use core::marker::{Copy, Send, Sync}; + pub(crate) use core::marker::{ + Copy, + Send, + Sync, + }; #[allow(unused_imports)] pub(crate) use core::option::Option; #[allow(unused_imports)] pub(crate) use core::prelude::v1::derive; #[allow(unused_imports)] - pub(crate) use core::{fmt, hash, iter, mem, ptr}; + pub(crate) use core::{ + fmt, + hash, + iter, + mem, + ptr, + }; #[allow(unused_imports)] pub(crate) use fmt::Debug; #[allow(unused_imports)] - pub(crate) use mem::{align_of, align_of_val, size_of, size_of_val}; + pub(crate) use mem::{ + align_of, + align_of_val, + size_of, + size_of_val, + }; #[allow(unused_imports)] - pub(crate) use crate::types::{CEnumRepr, Padding}; + pub(crate) use crate::types::{ + CEnumRepr, + Padding, + }; // Commonly used types defined in this crate #[allow(unused_imports)] pub(crate) use crate::{ - c_char, c_double, c_float, c_int, c_long, c_longlong, c_short, c_uchar, c_uint, - c_ulong, c_ulonglong, c_ushort, c_void, intptr_t, size_t, ssize_t, uintptr_t, + c_char, + c_double, + c_float, + c_int, + c_long, + c_longlong, + c_short, + c_uchar, + c_uint, + c_ulong, + c_ulonglong, + c_ushort, + c_void, + intptr_t, + size_t, + ssize_t, + uintptr_t, }; } }; @@ -203,15 +236,25 @@ macro_rules! s_no_extra_traits { ); } -/// Specify that an enum should have no traits that aren't specified in the macro -/// invocation, i.e. no `Clone` or `Copy`. -macro_rules! missing { +/// Create an uninhabited type that can't be constructed. It implements `Debug`, `Clone`, +/// and `Copy`, but these aren't meaningful for extern types so they should eventually +/// be removed. +/// +/// Really what we want here is something that also can't be named without indirection (in +/// ADTs or function signatures), but this doesn't exist. +macro_rules! extern_ty { ($( $(#[$attr:meta])* pub enum $i:ident {} )*) => ($( $(#[$attr])* - #[allow(missing_copy_implementations)] + // FIXME(1.0): the type is uninhabited so these traits are unreachable and could be + // removed. + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + ::core::fmt::Debug, + )] pub enum $i { } )*); } @@ -246,36 +289,50 @@ macro_rules! e { /// unlisted values, but this is UB in Rust. This enum doesn't implement any traits, its main /// purpose is to calculate the correct enum values. /// +/// Use the magic name `#anon` if the C enum doesn't create a type. +/// /// See for more. macro_rules! c_enum { + // Matcher for multiple enums ($( $(#[repr($repr:ty)])? - pub enum $ty_name:ident { + pub enum $($ty_name:ident)? $(#$anon:ident)? { $($variant:ident $(= $value:expr)?,)+ } )+) => { - $(c_enum!(@expand; + $(c_enum!(@single; $(#[repr($repr)])? - pub enum $ty_name { + pub enum $($ty_name)? $(#$anon)? { $($variant $(= $value)?,)+ } );)+ }; - (@expand; + // Matcher for a single enum + (@single; $(#[repr($repr:ty)])? pub enum $ty_name:ident { $($variant:ident $(= $value:expr)?,)+ } ) => { pub type $ty_name = c_enum!(@ty $($repr)?); - c_enum!(@one; $ty_name; 0; $($variant $(= $value)?,)+); + c_enum!(@variant; $ty_name; 0; $($variant $(= $value)?,)+); + }; + + // Matcher for a single anonymous enum + (@single; + $(#[repr($repr:ty)])? + pub enum #anon { + $($variant:ident $(= $value:expr)?,)+ + } + ) => { + c_enum!(@variant; c_enum!(@ty $($repr)?); 0; $($variant $(= $value)?,)+); }; // Matcher for a single variant - (@one; $_ty_name:ident; $_idx:expr;) => {}; + (@variant; $_ty_name:ty; $_idx:expr;) => { /* end of the chain */ }; ( - @one; $ty_name:ident; $default_val:expr; + @variant; $ty_name:ty; $default_val:expr; $variant:ident $(= $value:expr)?, $($tail:tt)* ) => { @@ -288,7 +345,7 @@ macro_rules! c_enum { // The next value is always one more than the previous value, unless // set explicitly. - c_enum!(@one; $ty_name; $variant + 1; $($tail)*); + c_enum!(@variant; $ty_name; $variant + 1; $($tail)*); }; // Use a specific type if provided, otherwise default to `CEnumRepr` @@ -372,10 +429,12 @@ macro_rules! deprecated_mach { #[cfg(test)] mod tests { + use core::any::TypeId; + use crate::types::CEnumRepr; #[test] - fn c_enumbasic() { + fn c_enum_basic() { // By default, variants get sequential values. c_enum! { pub enum e { @@ -383,28 +442,50 @@ mod tests { VAR1, VAR2, } + + // Also check enums that don't create a type. + pub enum #anon { + ANON0, + ANON1, + ANON2, + } } + assert_eq!(TypeId::of::(), TypeId::of::()); assert_eq!(VAR0, 0 as CEnumRepr); assert_eq!(VAR1, 1 as CEnumRepr); assert_eq!(VAR2, 2 as CEnumRepr); + + assert_eq!(type_id_of_val(&ANON0), TypeId::of::()); + assert_eq!(ANON0, 0 as CEnumRepr); + assert_eq!(ANON1, 1 as CEnumRepr); + assert_eq!(ANON2, 2 as CEnumRepr); } #[test] - fn c_enumrepr() { - // By default, variants get sequential values. + fn c_enum_repr() { + // Check specifying the integer representation c_enum! { #[repr(u16)] pub enum e { VAR0, } + + #[repr(u16)] + pub enum #anon { + ANON0, + } } + assert_eq!(TypeId::of::(), TypeId::of::()); assert_eq!(VAR0, 0_u16); + + assert_eq!(type_id_of_val(&ANON0), TypeId::of::()); + assert_eq!(ANON0, 0_u16); } #[test] - fn c_enumset_value() { + fn c_enum_set_value() { // Setting an explicit value resets the count. c_enum! { pub enum e { @@ -420,7 +501,7 @@ mod tests { } #[test] - fn c_enummultiple_set_value() { + fn c_enum_multiple_set_value() { // C enums always take one more than the previous value, unless set to a specific // value. Duplicates are allowed. c_enum! { @@ -443,4 +524,8 @@ mod tests { assert_eq!(VAR3_1, 3 as CEnumRepr); assert_eq!(VAR4_1, 4 as CEnumRepr); } + + fn type_id_of_val(_: &T) -> TypeId { + TypeId::of::() + } } diff --git a/src/new/aix/mod.rs b/src/new/aix/mod.rs new file mode 100644 index 0000000000000..79645f12d7360 --- /dev/null +++ b/src/new/aix/mod.rs @@ -0,0 +1,4 @@ +//! IBM AIX libc. +//! +//! * Headers are not public +//! * Manual pages: (under "Technical reference" for that version) diff --git a/src/new/apple_libc/mod.rs b/src/new/apple_libc/mod.rs new file mode 100644 index 0000000000000..f53b8baa38ea1 --- /dev/null +++ b/src/new/apple_libc/mod.rs @@ -0,0 +1,3 @@ +//! Entrypoint for Apple headers, usually found as part of the Xcode SDK. + +pub(crate) mod signal; diff --git a/src/new/apple_libc/signal.rs b/src/new/apple_libc/signal.rs new file mode 100644 index 0000000000000..971c47318c041 --- /dev/null +++ b/src/new/apple_libc/signal.rs @@ -0,0 +1,5 @@ +//! Header: `signal.h` +//! +//! https://github.com/apple-oss-distributions/Libc/blob/main/include/signal.h + +pub use crate::sys::signal::*; diff --git a/src/new/apple_xnu/arm/_mcontext.rs b/src/new/apple_xnu/arm/_mcontext.rs new file mode 100644 index 0000000000000..e57bc4f8adb09 --- /dev/null +++ b/src/new/apple_xnu/arm/_mcontext.rs @@ -0,0 +1,15 @@ +//! Header: `arm/_mcontext.h` +//! +//! https://github.com/apple-oss-distributions/xnu/blob/main/bsd/arm/_mcontext.h + +pub use crate::mach::machine::_structs::*; + +s! { + pub struct __darwin_mcontext64 { + pub __es: __darwin_arm_exception_state64, + pub __ss: __darwin_arm_thread_state64, + pub __ns: __darwin_arm_neon_state64, + } +} + +pub type mcontext_t = *mut __darwin_mcontext64; diff --git a/src/new/apple_xnu/i386/_mcontext.rs b/src/new/apple_xnu/i386/_mcontext.rs new file mode 100644 index 0000000000000..8ca3b116d9f26 --- /dev/null +++ b/src/new/apple_xnu/i386/_mcontext.rs @@ -0,0 +1,15 @@ +//! Header: `i386/_mcontext.h` +//! +//! https://github.com/apple-oss-distributions/xnu/blob/main/bsd/i386/_mcontext.h + +pub use crate::mach::machine::_structs::*; + +s! { + pub struct __darwin_mcontext64 { + pub __es: __darwin_x86_exception_state64, + pub __ss: __darwin_x86_thread_state64, + pub __fs: __darwin_x86_float_state64, + } +} + +pub type mcontext_t = *mut __darwin_mcontext64; diff --git a/src/new/apple_xnu/mach/arm/_structs.rs b/src/new/apple_xnu/mach/arm/_structs.rs new file mode 100644 index 0000000000000..d8d3b958ad5dd --- /dev/null +++ b/src/new/apple_xnu/mach/arm/_structs.rs @@ -0,0 +1,37 @@ +//! Header: `arm/_structs.h` +//! +//! https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/mach/arm/_structs.h + +#[cfg(target_arch = "arm")] +use crate::prelude::*; + +s! { + pub struct __darwin_arm_exception_state64 { + pub __far: u64, + pub __esr: u32, + pub __exception: u32, + } + + pub struct __darwin_arm_thread_state64 { + pub __x: [u64; 29], + pub __fp: u64, + pub __lr: u64, + pub __sp: u64, + pub __pc: u64, + pub __cpsr: u32, + pub __pad: u32, + } + + #[cfg(target_arch = "aarch64")] + pub struct __darwin_arm_neon_state64 { + pub __v: [crate::__uint128_t; 32], + pub __fpsr: u32, + pub __fpcr: u32, + } + + #[cfg(target_arch = "arm")] + #[repr(align(16))] + pub struct __darwin_arm_neon_state64 { + opaque: [c_char; (32 * 16) + (2 * size_of::())], + } +} diff --git a/src/new/apple_xnu/mach/i386/_structs.rs b/src/new/apple_xnu/mach/i386/_structs.rs new file mode 100644 index 0000000000000..ea274e26a6885 --- /dev/null +++ b/src/new/apple_xnu/mach/i386/_structs.rs @@ -0,0 +1,92 @@ +//! Header: `i386/_structs.h` +//! +//! https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/mach/i386/_structs.h + +use crate::prelude::*; + +s! { + pub struct __darwin_mmst_reg { + pub __mmst_reg: [c_char; 10], + pub __mmst_rsrv: [c_char; 6], + } + + pub struct __darwin_xmm_reg { + pub __xmm_reg: [c_char; 16], + } + + pub struct __darwin_x86_thread_state64 { + pub __rax: u64, + pub __rbx: u64, + pub __rcx: u64, + pub __rdx: u64, + pub __rdi: u64, + pub __rsi: u64, + pub __rbp: u64, + pub __rsp: u64, + pub __r8: u64, + pub __r9: u64, + pub __r10: u64, + pub __r11: u64, + pub __r12: u64, + pub __r13: u64, + pub __r14: u64, + pub __r15: u64, + pub __rip: u64, + pub __rflags: u64, + pub __cs: u64, + pub __fs: u64, + pub __gs: u64, + } + + pub struct __darwin_x86_exception_state64 { + pub __trapno: u16, + pub __cpu: u16, + pub __err: u32, + pub __faultvaddr: u64, + } + + pub struct __darwin_x86_float_state64 { + pub __fpu_reserved: [c_int; 2], + __fpu_fcw: c_short, + __fpu_fsw: c_short, + pub __fpu_ftw: u8, + pub __fpu_rsrv1: u8, + pub __fpu_fop: u16, + pub __fpu_ip: u32, + pub __fpu_cs: u16, + pub __fpu_rsrv2: u16, + pub __fpu_dp: u32, + pub __fpu_ds: u16, + pub __fpu_rsrv3: u16, + pub __fpu_mxcsr: u32, + pub __fpu_mxcsrmask: u32, + pub __fpu_stmm0: __darwin_mmst_reg, + pub __fpu_stmm1: __darwin_mmst_reg, + pub __fpu_stmm2: __darwin_mmst_reg, + pub __fpu_stmm3: __darwin_mmst_reg, + pub __fpu_stmm4: __darwin_mmst_reg, + pub __fpu_stmm5: __darwin_mmst_reg, + pub __fpu_stmm6: __darwin_mmst_reg, + pub __fpu_stmm7: __darwin_mmst_reg, + pub __fpu_xmm0: __darwin_xmm_reg, + pub __fpu_xmm1: __darwin_xmm_reg, + pub __fpu_xmm2: __darwin_xmm_reg, + pub __fpu_xmm3: __darwin_xmm_reg, + pub __fpu_xmm4: __darwin_xmm_reg, + pub __fpu_xmm5: __darwin_xmm_reg, + pub __fpu_xmm6: __darwin_xmm_reg, + pub __fpu_xmm7: __darwin_xmm_reg, + pub __fpu_xmm8: __darwin_xmm_reg, + pub __fpu_xmm9: __darwin_xmm_reg, + pub __fpu_xmm10: __darwin_xmm_reg, + pub __fpu_xmm11: __darwin_xmm_reg, + pub __fpu_xmm12: __darwin_xmm_reg, + pub __fpu_xmm13: __darwin_xmm_reg, + pub __fpu_xmm14: __darwin_xmm_reg, + pub __fpu_xmm15: __darwin_xmm_reg, + // FIXME(apple): this field is actually [u8; 96], but defining it with a bigger type allows + // us to auto-implement traits for it since the length of the array is less than 32 + __fpu_rsrv4: [u32; 24], + pub __fpu_reserved1: c_int, + } +} diff --git a/src/new/apple_xnu/mach/machine/_structs.rs b/src/new/apple_xnu/mach/machine/_structs.rs new file mode 100644 index 0000000000000..47df1005c86f8 --- /dev/null +++ b/src/new/apple_xnu/mach/machine/_structs.rs @@ -0,0 +1,13 @@ +//! Header: `mach/machine/_structs.h` +//! +//! https://github.com/apple-oss-distributions/xnu/blob/main/osfmk/mach/machine/_structs.h + +cfg_if! { + if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { + pub use crate::mach::i386::_structs::*; + } else if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] { + pub use crate::mach::arm::_structs::*; + } else { + // Unsupported arch + } +} diff --git a/src/new/apple_xnu/mach/mod.rs b/src/new/apple_xnu/mach/mod.rs new file mode 100644 index 0000000000000..d5fbee83e970e --- /dev/null +++ b/src/new/apple_xnu/mach/mod.rs @@ -0,0 +1,20 @@ +//! Directory: `mach/` +//! +//! https://github.com/apple-oss-distributions/xnu/tree/main/osfmk/mach + +/// Directory: `mach/arm` +#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +pub(crate) mod arm { + pub(crate) mod _structs; +} + +/// Directory: `mach/i386` +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +pub(crate) mod i386 { + pub(crate) mod _structs; +} + +/// Directory: `mach/machine` +pub(crate) mod machine { + pub(crate) mod _structs; +} diff --git a/src/new/apple_xnu/machine/_mcontext.rs b/src/new/apple_xnu/machine/_mcontext.rs new file mode 100644 index 0000000000000..004b94707e33a --- /dev/null +++ b/src/new/apple_xnu/machine/_mcontext.rs @@ -0,0 +1,11 @@ +//! Header: `machine/_mcontext.h` + +cfg_if! { + if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { + pub use crate::i386::_mcontext::*; + } else if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] { + pub use crate::arm::_mcontext::*; + } else { + // Unsupported arch + } +} diff --git a/src/new/apple_xnu/mod.rs b/src/new/apple_xnu/mod.rs new file mode 100644 index 0000000000000..8b8afb6bc39d3 --- /dev/null +++ b/src/new/apple_xnu/mod.rs @@ -0,0 +1,30 @@ +//! Source from XNU +//! +//! We omit nesting for the `bsd` module since most items of interest are in there. + +/// Directory: `arm/` +/// +/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/arm +#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +pub(crate) mod arm { + pub(crate) mod _mcontext; +} + +/// Directory: `i386/` +/// +/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/i386 +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +pub(crate) mod i386 { + pub(crate) mod _mcontext; +} + +pub(crate) mod mach; + +/// Directory: `machine/` +/// +/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/machine +pub(crate) mod machine { + pub(crate) mod _mcontext; +} + +pub(crate) mod sys; diff --git a/src/new/apple_xnu/sys/_types/_ucontext.rs b/src/new/apple_xnu/sys/_types/_ucontext.rs new file mode 100644 index 0000000000000..53bc0f22d6691 --- /dev/null +++ b/src/new/apple_xnu/sys/_types/_ucontext.rs @@ -0,0 +1,17 @@ +//! Header: `sys/_types/_ucontext.h` + +pub use crate::machine::_mcontext::*; +use crate::prelude::*; + +s! { + pub struct __darwin_ucontext { + pub uc_onstack: c_int, + pub uc_sigmask: crate::sigset_t, + pub uc_stack: crate::stack_t, + pub uc_link: *mut ucontext_t, + pub uc_mcsize: usize, + pub uc_mcontext: mcontext_t, + } +} + +pub type ucontext_t = __darwin_ucontext; diff --git a/src/new/apple_xnu/sys/mod.rs b/src/new/apple_xnu/sys/mod.rs new file mode 100644 index 0000000000000..8fdbe2846b58b --- /dev/null +++ b/src/new/apple_xnu/sys/mod.rs @@ -0,0 +1,12 @@ +//! Directory: `sys/` +//! +//! https://github.com/apple-oss-distributions/xnu/tree/main/bsd/sys + +pub(crate) mod signal; + +/// Directory: `sys/_types` +/// +/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/sys/_types +pub(crate) mod _types { + pub(crate) mod _ucontext; +} diff --git a/src/new/apple_xnu/sys/signal.rs b/src/new/apple_xnu/sys/signal.rs new file mode 100644 index 0000000000000..8399c830dc8cd --- /dev/null +++ b/src/new/apple_xnu/sys/signal.rs @@ -0,0 +1,6 @@ +//! Header: `sys/signal.h` +//! +//! https://github.com/apple-oss-distributions/xnu/blob/main/bsd/sys/signal.h + +pub use crate::machine::_mcontext::*; +pub use crate::sys::_types::_ucontext::*; diff --git a/src/new/bionic/mod.rs b/src/new/bionic/mod.rs deleted file mode 100644 index 644a4ab96d90f..0000000000000 --- a/src/new/bionic/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod sys; -pub use sys::*; diff --git a/src/new/bionic/sys/mod.rs b/src/new/bionic/sys/mod.rs deleted file mode 100644 index fd96d0821ac88..0000000000000 --- a/src/new/bionic/sys/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod socket; -pub use socket::*; diff --git a/src/new/bionic_libc/mod.rs b/src/new/bionic_libc/mod.rs new file mode 100644 index 0000000000000..2863b72cc2ed9 --- /dev/null +++ b/src/new/bionic_libc/mod.rs @@ -0,0 +1,5 @@ +//! This directory maps to `bionic/libc/include` in the Android source. +//! +//! + +pub(crate) mod sys; diff --git a/src/new/bionic_libc/sys/mod.rs b/src/new/bionic_libc/sys/mod.rs new file mode 100644 index 0000000000000..a882cbd99fca1 --- /dev/null +++ b/src/new/bionic_libc/sys/mod.rs @@ -0,0 +1,3 @@ +//! Directory: `sys/` + +pub(crate) mod socket; diff --git a/src/new/bionic/sys/socket.rs b/src/new/bionic_libc/sys/socket.rs similarity index 95% rename from src/new/bionic/sys/socket.rs rename to src/new/bionic_libc/sys/socket.rs index 49af36fe93356..c4a4e781275d9 100644 --- a/src/new/bionic/sys/socket.rs +++ b/src/new/bionic_libc/sys/socket.rs @@ -1,4 +1,4 @@ -//! Header: `bionic/libc/include/sys/socket.h` +//! Header: `sys/socket.h` use crate::prelude::*; diff --git a/src/new/common/bsd.rs b/src/new/common/bsd.rs new file mode 100644 index 0000000000000..818daf93489c9 --- /dev/null +++ b/src/new/common/bsd.rs @@ -0,0 +1 @@ +//! Interfaces common across the BSD family. diff --git a/src/new/common/freebsd_like.rs b/src/new/common/freebsd_like.rs new file mode 100644 index 0000000000000..f49f2c9c2c06e --- /dev/null +++ b/src/new/common/freebsd_like.rs @@ -0,0 +1 @@ +//! Interfaces common in FreeBSD-derived operating systems. This includes FreeBSD and DragonFlyBSD. diff --git a/src/new/common/linux_like/mod.rs b/src/new/common/linux_like/mod.rs new file mode 100644 index 0000000000000..9aceb4e09f0e3 --- /dev/null +++ b/src/new/common/linux_like/mod.rs @@ -0,0 +1 @@ +//! API that primarily comes from Linux but is also used other platforms (e.g. Android). diff --git a/src/new/common/mod.rs b/src/new/common/mod.rs new file mode 100644 index 0000000000000..cb0588ca26100 --- /dev/null +++ b/src/new/common/mod.rs @@ -0,0 +1,38 @@ +//! Interfaces that are common across multiple platforms +//! +//! We make these available everywhere but each platform must opt in to reexporting. +//! +//! There shouldn't be any repeated definitions or complex configuration in this module. On +//! platforms that don't use common APIs it is fine to use `#[cfg(not(...))]`, but if a platform +//! needs a custom definition then it should be defined in the platform-specific module. +//! +//! The goal is that platforms need to opt in to the definitions here, so that worst case we have +//! an unused warning on untested platforms (rather than exposing incorrect API). + +#[cfg(any( + target_vendor = "apple", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd", + target_os = "openbsd", +))] +mod bsd; + +#[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "l4re", + target_os = "linux", +))] +mod linux_like; + +#[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] +mod freebsd_like; + +#[cfg(any(target_os = "netbsd", target_os = "openbsd"))] +mod netbsd_like; + +#[cfg(any(target_os = "illumos", target_os = "solaris"))] +mod solarish; + +mod posix; diff --git a/src/new/common/netbsd_like.rs b/src/new/common/netbsd_like.rs new file mode 100644 index 0000000000000..4267357ac9046 --- /dev/null +++ b/src/new/common/netbsd_like.rs @@ -0,0 +1 @@ +//! Interfaces common in NetBSD-derived operating systems. This includes NetBSD and OpenBSD. diff --git a/src/new/common/posix/mod.rs b/src/new/common/posix/mod.rs new file mode 100644 index 0000000000000..cb33296a9c656 --- /dev/null +++ b/src/new/common/posix/mod.rs @@ -0,0 +1 @@ +//! POSIX APIs that are used by a number of platforms diff --git a/src/new/common/solarish.rs b/src/new/common/solarish.rs new file mode 100644 index 0000000000000..f966114e370ae --- /dev/null +++ b/src/new/common/solarish.rs @@ -0,0 +1 @@ +//! Interfaces common in solaris-derived operating systems. This includes Solaris and Illumos. diff --git a/src/new/cygwin/mod.rs b/src/new/cygwin/mod.rs new file mode 100644 index 0000000000000..29d62f02f9fee --- /dev/null +++ b/src/new/cygwin/mod.rs @@ -0,0 +1,3 @@ +//! Cygwin libc. +//! +//! * Headers: diff --git a/src/new/dragonfly/mod.rs b/src/new/dragonfly/mod.rs new file mode 100644 index 0000000000000..9ea26f522be66 --- /dev/null +++ b/src/new/dragonfly/mod.rs @@ -0,0 +1,4 @@ +//! DragonFly BSD libc. +//! +//! * Headers: +//! * Manual pages: diff --git a/src/new/emscripten/mod.rs b/src/new/emscripten/mod.rs new file mode 100644 index 0000000000000..e58a3aceada16 --- /dev/null +++ b/src/new/emscripten/mod.rs @@ -0,0 +1,3 @@ +//! Emscripten libc. +//! +//! * Headers: diff --git a/src/new/espidf/mod.rs b/src/new/espidf/mod.rs new file mode 100644 index 0000000000000..061ea6e64614b --- /dev/null +++ b/src/new/espidf/mod.rs @@ -0,0 +1,2 @@ +//! Expressif libc. +// FIXME(espidf): link to headers needed. diff --git a/src/new/freebsd/mod.rs b/src/new/freebsd/mod.rs new file mode 100644 index 0000000000000..a1241c7a68cef --- /dev/null +++ b/src/new/freebsd/mod.rs @@ -0,0 +1,4 @@ +//! FreeBSD libc. +//! +//! * Headers: +//! * Symbol map: diff --git a/src/new/fuchsia/mod.rs b/src/new/fuchsia/mod.rs new file mode 100644 index 0000000000000..c1d275c95b3f6 --- /dev/null +++ b/src/new/fuchsia/mod.rs @@ -0,0 +1,2 @@ +//! Fuschia libc. +// FIXME(fuchsia): link to headers needed. diff --git a/src/new/glibc/mod.rs b/src/new/glibc/mod.rs new file mode 100644 index 0000000000000..8714820906414 --- /dev/null +++ b/src/new/glibc/mod.rs @@ -0,0 +1,4 @@ +//! GNU libc. +//! +//! * Headers: (official) +//! * Headers: (mirror) diff --git a/src/new/haiku/mod.rs b/src/new/haiku/mod.rs new file mode 100644 index 0000000000000..c119b67376269 --- /dev/null +++ b/src/new/haiku/mod.rs @@ -0,0 +1,2 @@ +//! Haiku OS libc. +// FIXME(haiku): link to headers needed. diff --git a/src/new/hermit_abi/mod.rs b/src/new/hermit_abi/mod.rs new file mode 100644 index 0000000000000..65f59fe12d691 --- /dev/null +++ b/src/new/hermit_abi/mod.rs @@ -0,0 +1,3 @@ +//! Hermit kernel libc. +//! +//! * Headers: diff --git a/src/new/horizon/mod.rs b/src/new/horizon/mod.rs new file mode 100644 index 0000000000000..338e9f0a4d840 --- /dev/null +++ b/src/new/horizon/mod.rs @@ -0,0 +1,2 @@ +//! Switch libc. +// FIXME(horizon): link to headers or manpages needed. diff --git a/src/new/hurd/mod.rs b/src/new/hurd/mod.rs new file mode 100644 index 0000000000000..12198d58bd582 --- /dev/null +++ b/src/new/hurd/mod.rs @@ -0,0 +1,2 @@ +//! GNU Hurd libc. +// FIXME(hurd): link to headers needed. diff --git a/src/new/illumos/mod.rs b/src/new/illumos/mod.rs new file mode 100644 index 0000000000000..66f6cb1ffd3c8 --- /dev/null +++ b/src/new/illumos/mod.rs @@ -0,0 +1,2 @@ +//! Illumos libc. +// FIXME(illumos): link to headers needed. diff --git a/src/new/l4re/mod.rs b/src/new/l4re/mod.rs new file mode 100644 index 0000000000000..cbf725f406b6b --- /dev/null +++ b/src/new/l4re/mod.rs @@ -0,0 +1,3 @@ +//! L4re. +//! +//! * Headers: diff --git a/src/new/linux_uapi/linux/can.rs b/src/new/linux_uapi/linux/can.rs index b9479a63bacea..108a90b1a92c6 100644 --- a/src/new/linux_uapi/linux/can.rs +++ b/src/new/linux_uapi/linux/can.rs @@ -1,11 +1,9 @@ //! Header: `uapi/linux/can.h` +pub(crate) mod bcm; pub(crate) mod j1939; pub(crate) mod raw; -pub use j1939::*; -pub use raw::*; - use crate::prelude::*; pub const CAN_EFF_FLAG: canid_t = 0x80000000; @@ -70,7 +68,6 @@ pub const CANXL_XLF: c_int = 0x80; pub const CANXL_SEC: c_int = 0x01; s! { - #[repr(align(8))] pub struct canxl_frame { pub prio: canid_t, pub flags: u8, diff --git a/src/new/linux_uapi/linux/can/bcm.rs b/src/new/linux_uapi/linux/can/bcm.rs new file mode 100644 index 0000000000000..10f67d2db04e9 --- /dev/null +++ b/src/new/linux_uapi/linux/can/bcm.rs @@ -0,0 +1,52 @@ +//! Header: `linux/can/bcm.h` + +pub use crate::linux::can::*; + +s! { + pub struct bcm_timeval { + pub tv_sec: c_long, + pub tv_usec: c_long, + } + + pub struct bcm_msg_head { + pub opcode: u32, + pub flags: u32, + pub count: u32, + pub ival1: bcm_timeval, + pub ival2: bcm_timeval, + pub can_id: canid_t, + pub nframes: u32, + pub frames: [can_frame; 0], + } +} + +c_enum! { + #[repr(u32)] + pub enum #anon { + TX_SETUP = 1, + TX_DELETE, + TX_READ, + TX_SEND, + RX_SETUP, + RX_DELETE, + RX_READ, + TX_STATUS, + TX_EXPIRED, + RX_STATUS, + RX_TIMEOUT, + RX_CHANGED, + } +} + +pub const SETTIMER: u32 = 0x0001; +pub const STARTTIMER: u32 = 0x0002; +pub const TX_COUNTEVT: u32 = 0x0004; +pub const TX_ANNOUNCE: u32 = 0x0008; +pub const TX_CP_CAN_ID: u32 = 0x0010; +pub const RX_FILTER_ID: u32 = 0x0020; +pub const RX_CHECK_DLC: u32 = 0x0040; +pub const RX_NO_AUTOTIMER: u32 = 0x0080; +pub const RX_ANNOUNCE_RESUME: u32 = 0x0100; +pub const TX_RESET_MULTI_IDX: u32 = 0x0200; +pub const RX_RTR_FRAME: u32 = 0x0400; +pub const CAN_FD_FRAME: u32 = 0x0800; diff --git a/src/new/linux_uapi/linux/can/raw.rs b/src/new/linux_uapi/linux/can/raw.rs index 1f92a13edbba6..470334bd5d147 100644 --- a/src/new/linux_uapi/linux/can/raw.rs +++ b/src/new/linux_uapi/linux/can/raw.rs @@ -1,4 +1,4 @@ -//! `linux/can/raw.h` +//! Header: `linux/can/raw.h` pub use crate::linux::can::*; diff --git a/src/new/linux_uapi/linux/keyctl.rs b/src/new/linux_uapi/linux/keyctl.rs new file mode 100644 index 0000000000000..cc6527a8a5113 --- /dev/null +++ b/src/new/linux_uapi/linux/keyctl.rs @@ -0,0 +1,69 @@ +//! Header: `linux/keyctl.h` + +pub const KEY_SPEC_THREAD_KEYRING: i32 = -1; +pub const KEY_SPEC_PROCESS_KEYRING: i32 = -2; +pub const KEY_SPEC_SESSION_KEYRING: i32 = -3; +pub const KEY_SPEC_USER_KEYRING: i32 = -4; +pub const KEY_SPEC_USER_SESSION_KEYRING: i32 = -5; +pub const KEY_SPEC_GROUP_KEYRING: i32 = -6; +pub const KEY_SPEC_REQKEY_AUTH_KEY: i32 = -7; +pub const KEY_SPEC_REQUESTOR_KEYRING: i32 = -8; + +pub const KEY_REQKEY_DEFL_NO_CHANGE: i32 = -1; +pub const KEY_REQKEY_DEFL_DEFAULT: i32 = 0; +pub const KEY_REQKEY_DEFL_THREAD_KEYRING: i32 = 1; +pub const KEY_REQKEY_DEFL_PROCESS_KEYRING: i32 = 2; +pub const KEY_REQKEY_DEFL_SESSION_KEYRING: i32 = 3; +pub const KEY_REQKEY_DEFL_USER_KEYRING: i32 = 4; +pub const KEY_REQKEY_DEFL_USER_SESSION_KEYRING: i32 = 5; +pub const KEY_REQKEY_DEFL_GROUP_KEYRING: i32 = 6; +pub const KEY_REQKEY_DEFL_REQUESTOR_KEYRING: i32 = 7; + +pub const KEYCTL_GET_KEYRING_ID: u32 = 0; +pub const KEYCTL_JOIN_SESSION_KEYRING: u32 = 1; +pub const KEYCTL_UPDATE: u32 = 2; +pub const KEYCTL_REVOKE: u32 = 3; +pub const KEYCTL_CHOWN: u32 = 4; +pub const KEYCTL_SETPERM: u32 = 5; +pub const KEYCTL_DESCRIBE: u32 = 6; +pub const KEYCTL_CLEAR: u32 = 7; +pub const KEYCTL_LINK: u32 = 8; +pub const KEYCTL_UNLINK: u32 = 9; +pub const KEYCTL_SEARCH: u32 = 10; +pub const KEYCTL_READ: u32 = 11; +pub const KEYCTL_INSTANTIATE: u32 = 12; +pub const KEYCTL_NEGATE: u32 = 13; +pub const KEYCTL_SET_REQKEY_KEYRING: u32 = 14; +pub const KEYCTL_SET_TIMEOUT: u32 = 15; +pub const KEYCTL_ASSUME_AUTHORITY: u32 = 16; +pub const KEYCTL_GET_SECURITY: u32 = 17; +pub const KEYCTL_SESSION_TO_PARENT: u32 = 18; +pub const KEYCTL_REJECT: u32 = 19; +pub const KEYCTL_INSTANTIATE_IOV: u32 = 20; +pub const KEYCTL_INVALIDATE: u32 = 21; +pub const KEYCTL_GET_PERSISTENT: u32 = 22; +pub const KEYCTL_DH_COMPUTE: u32 = 23; +pub const KEYCTL_PKEY_QUERY: u32 = 24; +pub const KEYCTL_PKEY_ENCRYPT: u32 = 25; +pub const KEYCTL_PKEY_DECRYPT: u32 = 26; +pub const KEYCTL_PKEY_SIGN: u32 = 27; +pub const KEYCTL_PKEY_VERIFY: u32 = 28; +pub const KEYCTL_RESTRICT_KEYRING: u32 = 29; +pub const KEYCTL_MOVE: u32 = 30; +pub const KEYCTL_CAPABILITIES: u32 = 31; + +pub const KEYCTL_SUPPORTS_ENCRYPT: u32 = 0x01; +pub const KEYCTL_SUPPORTS_DECRYPT: u32 = 0x02; +pub const KEYCTL_SUPPORTS_SIGN: u32 = 0x04; +pub const KEYCTL_SUPPORTS_VERIFY: u32 = 0x08; + +pub const KEYCTL_CAPS0_CAPABILITIES: u32 = 0x01; +pub const KEYCTL_CAPS0_PERSISTENT_KEYRINGS: u32 = 0x02; +pub const KEYCTL_CAPS0_DIFFIE_HELLMAN: u32 = 0x04; +pub const KEYCTL_CAPS0_PUBLIC_KEY: u32 = 0x08; +pub const KEYCTL_CAPS0_BIG_KEY: u32 = 0x10; +pub const KEYCTL_CAPS0_INVALIDATE: u32 = 0x20; +pub const KEYCTL_CAPS0_RESTRICT_KEYRING: u32 = 0x40; +pub const KEYCTL_CAPS0_MOVE: u32 = 0x80; +pub const KEYCTL_CAPS1_NS_KEYRING_NAME: u32 = 0x01; +pub const KEYCTL_CAPS1_NS_KEY_TAG: u32 = 0x02; diff --git a/src/new/linux_uapi/linux/mod.rs b/src/new/linux_uapi/linux/mod.rs index 4a9c04d6396b1..993394e4370ca 100644 --- a/src/new/linux_uapi/linux/mod.rs +++ b/src/new/linux_uapi/linux/mod.rs @@ -1,4 +1,6 @@ -//! The `linux` directory within `include/uapi` in the Linux source tree. +//! Directory: `linux/` +//! +//! pub(crate) mod can; -pub use can::*; +pub(crate) mod keyctl; diff --git a/src/new/linux_uapi/mod.rs b/src/new/linux_uapi/mod.rs index e0d4e094c435f..8ac3022d16578 100644 --- a/src/new/linux_uapi/mod.rs +++ b/src/new/linux_uapi/mod.rs @@ -1,4 +1,3 @@ //! This directory maps to `include/uapi` in the Linux source tree. pub(crate) mod linux; -pub use linux::*; diff --git a/src/new/mod.rs b/src/new/mod.rs index 0a2a55b0f469b..27f232cb56882 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -3,13 +3,176 @@ //! //! Eventually everything should be moved over, and we will move this directory to the top //! level in `src`. +//! +//! # Basic structure +//! +//! Each child module here represents a library or group of libraries that we are binding. Each of +//! these has several submodules, representing either a directory or a header file in that library. +//! +//! `#include`s turn into `pub use ...*;` statements. Then at the root level (here), we choose +//! which top-level headers we want to reexport the definitions for. +//! +//! All modules are only crate-public since we don't reexport this structure. +mod common; + +/* The `pub(crate) use ...` statements are commented while the modules are empty */ + +// Platform libraries and combined platform+libc +// +// Not supported or not needed: +// * amdhsa +// * cuda +// * lynxos178 +// * managarm +// * motor +// * none +// * psp +// * psx +// * uefi +// * unknown +// * vexos +// * zkvm +// +// Combined to target_vendor = "apple" +// * ios +// * macos +// * tvos +// * visionos +// * watchos cfg_if! { - if #[cfg(target_os = "linux")] { - mod linux_uapi; - pub use linux_uapi::*; + if #[cfg(target_os = "aix")] { + mod aix; + // pub(crate) use aix::*; } else if #[cfg(target_os = "android")] { - mod bionic; - pub use bionic::*; + mod bionic_libc; + pub(crate) use bionic_libc::*; + } else if #[cfg(target_vendor = "apple")] { + mod apple_libc; + mod apple_xnu; + pub(crate) use apple_libc::*; + pub(crate) use apple_xnu::*; + } else if #[cfg(target_os = "cygwin")] { + mod cygwin; + // pub(crate) use cygwin::*; + } else if #[cfg(target_os = "dragonfly")] { + mod dragonfly; + // pub(crate) use dragonfly::*; + } else if #[cfg(target_os = "emscripten")] { + mod emscripten; + // pub(crate) use emscripten::*; + } else if #[cfg(target_os = "espidf")] { + mod espidf; + // pub(crate) use espidf::*; + } else if #[cfg(target_os = "freebsd")] { + mod freebsd; + // pub(crate) use freebsd::*; + } else if #[cfg(target_os = "fuchsia")] { + mod fuchsia; + // pub(crate) use fuchsia::*; + } else if #[cfg(target_os = "haiku")] { + mod haiku; + // pub(crate) use haiku::*; + } else if #[cfg(target_os = "hermit")] { + mod hermit_abi; + // pub(crate) use hermit_abi::*; + } else if #[cfg(target_os = "horizon")] { + mod horizon; + // pub(crate) use horizon::*; + } else if #[cfg(target_os = "hurd")] { + mod hurd; + // pub(crate) use hurd::*; + } else if #[cfg(target_os = "illumos")] { + mod illumos; + // pub(crate) use illumos::*; + } else if #[cfg(target_os = "l4re")] { + mod l4re; + // pub(crate) use l4re::*; + } else if #[cfg(target_os = "linux")] { + mod linux_uapi; + pub(crate) use linux_uapi::*; + } else if #[cfg(target_os = "netbsd")] { + mod netbsd; + // pub(crate) use netbsd::*; + } else if #[cfg(target_os = "nto")] { + mod nto; + // pub(crate) use nto::*; + } else if #[cfg(target_os = "nuttx")] { + mod nuttx; + // pub(crate) use nuttx::*; + } else if #[cfg(target_os = "openbsd")] { + mod openbsd; + // pub(crate) use openbsd::*; + } else if #[cfg(target_os = "redox")] { + mod redox; + // pub(crate) use redox::*; + } else if #[cfg(target_os = "rtems")] { + mod rtems; + // pub(crate) use rtems::*; + } else if #[cfg(target_os = "solaris")] { + mod solaris; + // pub(crate) use solaris::*; + } else if #[cfg(target_os = "solid_asp3")] { + mod solid; + // pub(crate) use solid::*; + } else if #[cfg(target_os = "teeos")] { + mod teeos; + // pub(crate) use teeos::*; + } else if #[cfg(target_os = "trusty")] { + mod trusty; + // pub(crate) use trusty::*; + } else if #[cfg(target_os = "vita")] { + mod vita; + // pub(crate) use vita::*; + } else if #[cfg(target_os = "vxworks")] { + mod vxworks; + // pub(crate) use vxworks::*; + } else if #[cfg(target_os = "wasi")] { + mod wasi; + // pub(crate) use wasi::*; + } else if #[cfg(target_os = "windows")] { + mod ucrt; + // pub(crate) use ucrt::*; + } else if #[cfg(target_os = "xous")] { + mod xous; + // pub(crate) use xous::*; + } +} + +// Multi-platform libc +cfg_if! { + if #[cfg(target_env = "gnu")] { + mod glibc; + // pub(crate) use glibc::*; + } else if #[cfg(target_env = "musl")] { + mod musl; + // pub(crate) use musl::*; + } else if #[cfg(target_env = "newlib")] { + mod newlib; + // pub(crate) use newlib::*; + } else if #[cfg(target_env = "relibc")] { + mod relibc; + // pub(crate) use relibc::*; + } else if #[cfg(target_env = "sgx")] { + mod sgx; + // pub(crate) use sgx::*; + } else if #[cfg(target_env = "uclibc")] { + mod uclibc; + // pub(crate) use uclibc::*; + } +} + +// Headers we export +cfg_if! { + if #[cfg(target_os = "android")] { + pub use sys::socket::*; + } else if #[cfg(target_os = "linux")] { + pub use linux::can::bcm::*; + pub use linux::can::j1939::*; + pub use linux::can::raw::*; + pub use linux::can::*; + pub use linux::keyctl::*; + } else if #[cfg(target_vendor = "apple")] { + pub use signal::*; } } diff --git a/src/new/musl/mod.rs b/src/new/musl/mod.rs new file mode 100644 index 0000000000000..49f9abae21fb7 --- /dev/null +++ b/src/new/musl/mod.rs @@ -0,0 +1,4 @@ +//! Musl libc. +//! +//! * Headers: (official) +//! * Headers: (mirror) diff --git a/src/new/netbsd/mod.rs b/src/new/netbsd/mod.rs new file mode 100644 index 0000000000000..14b6a5f869e8f --- /dev/null +++ b/src/new/netbsd/mod.rs @@ -0,0 +1,3 @@ +//! NetBSD libc. +//! +//! * Manual pages: diff --git a/src/new/newlib/mod.rs b/src/new/newlib/mod.rs new file mode 100644 index 0000000000000..d5564cafcfd50 --- /dev/null +++ b/src/new/newlib/mod.rs @@ -0,0 +1,2 @@ +//! Newlib libc. +// FIXME(newlib): link to headers needed. diff --git a/src/new/nto/mod.rs b/src/new/nto/mod.rs new file mode 100644 index 0000000000000..8fa2d814eb8df --- /dev/null +++ b/src/new/nto/mod.rs @@ -0,0 +1,2 @@ +//! QNX Neutrino libc. +// FIXME(nto): link to manpages needed. diff --git a/src/new/nuttx/mod.rs b/src/new/nuttx/mod.rs new file mode 100644 index 0000000000000..89b9c05e849bd --- /dev/null +++ b/src/new/nuttx/mod.rs @@ -0,0 +1,2 @@ +//! RTEMS libc. +// FIXME(nuttx): link to headers needed. diff --git a/src/new/openbsd/mod.rs b/src/new/openbsd/mod.rs new file mode 100644 index 0000000000000..f97044effe76c --- /dev/null +++ b/src/new/openbsd/mod.rs @@ -0,0 +1,4 @@ +//! OpenBSD libc. +//! +//! * Headers: +//! * Manual pages: diff --git a/src/new/redox/mod.rs b/src/new/redox/mod.rs new file mode 100644 index 0000000000000..cf7806a2437ad --- /dev/null +++ b/src/new/redox/mod.rs @@ -0,0 +1,3 @@ +//! Redox libc. +//! +//! * Headers: diff --git a/src/new/relibc/mod.rs b/src/new/relibc/mod.rs new file mode 100644 index 0000000000000..baf26912ec7f0 --- /dev/null +++ b/src/new/relibc/mod.rs @@ -0,0 +1,3 @@ +//! Redox OS libc. +//! +//! * Headers: diff --git a/src/new/rtems/mod.rs b/src/new/rtems/mod.rs new file mode 100644 index 0000000000000..bd3dc3954c71e --- /dev/null +++ b/src/new/rtems/mod.rs @@ -0,0 +1,2 @@ +//! RTEMS libc. +// FIXME(rtems): link to headers needed. diff --git a/src/new/sgx/mod.rs b/src/new/sgx/mod.rs new file mode 100644 index 0000000000000..8b137891791fe --- /dev/null +++ b/src/new/sgx/mod.rs @@ -0,0 +1 @@ + diff --git a/src/new/solaris/mod.rs b/src/new/solaris/mod.rs new file mode 100644 index 0000000000000..b5d55492995de --- /dev/null +++ b/src/new/solaris/mod.rs @@ -0,0 +1,3 @@ +//! Solaris libc. +//! +//! * Manual pages: (under "Reference Manuals") diff --git a/src/new/solid/mod.rs b/src/new/solid/mod.rs new file mode 100644 index 0000000000000..4a197cfb62c5a --- /dev/null +++ b/src/new/solid/mod.rs @@ -0,0 +1,2 @@ +//! Kyoto Microcomputer SOLID. +// FIXME(solid): link to headers needed. diff --git a/src/new/teeos/mod.rs b/src/new/teeos/mod.rs new file mode 100644 index 0000000000000..96f44d3d39361 --- /dev/null +++ b/src/new/teeos/mod.rs @@ -0,0 +1,2 @@ +//! Per the target docs, TEEOS uses part of musl as its libc. +// FIXME(teeos): link to headers needed. diff --git a/src/new/trusty/mod.rs b/src/new/trusty/mod.rs new file mode 100644 index 0000000000000..261ecb09e46de --- /dev/null +++ b/src/new/trusty/mod.rs @@ -0,0 +1,2 @@ +//! Trusty libc. +// FIXME(trusty): link to headers needed. diff --git a/src/new/uclibc/mod.rs b/src/new/uclibc/mod.rs new file mode 100644 index 0000000000000..eda4b01d92d2c --- /dev/null +++ b/src/new/uclibc/mod.rs @@ -0,0 +1,4 @@ +//! uClibc. +//! +//! * About: +//! * Headers: (mirror) diff --git a/src/new/ucrt/mod.rs b/src/new/ucrt/mod.rs new file mode 100644 index 0000000000000..f6b5f5d1ef8fc --- /dev/null +++ b/src/new/ucrt/mod.rs @@ -0,0 +1,4 @@ +//! Windows Universal C Runtime. +//! +//! * Manual pages: +//! * UCRT information: diff --git a/src/new/vita/mod.rs b/src/new/vita/mod.rs new file mode 100644 index 0000000000000..21205ebd046fb --- /dev/null +++ b/src/new/vita/mod.rs @@ -0,0 +1,2 @@ +//! VITASDK system library. +// FIXME(vita): link to headers or manpages needed. diff --git a/src/new/vxworks/mod.rs b/src/new/vxworks/mod.rs new file mode 100644 index 0000000000000..a3116fce03803 --- /dev/null +++ b/src/new/vxworks/mod.rs @@ -0,0 +1,2 @@ +//! VxWorks libc. +// FIXME(vxworks): link to headers needed. diff --git a/src/new/wasi/mod.rs b/src/new/wasi/mod.rs new file mode 100644 index 0000000000000..341e6d5d16499 --- /dev/null +++ b/src/new/wasi/mod.rs @@ -0,0 +1,3 @@ +//! WASI libc. +//! +//! * Headers: diff --git a/src/new/xous/mod.rs b/src/new/xous/mod.rs new file mode 100644 index 0000000000000..8a9a28586c448 --- /dev/null +++ b/src/new/xous/mod.rs @@ -0,0 +1,2 @@ +//! Xous libc. +// FIXME(xous): link to headers needed. diff --git a/src/rustfmt.toml b/src/rustfmt.toml new file mode 100644 index 0000000000000..19e4b2fa60beb --- /dev/null +++ b/src/rustfmt.toml @@ -0,0 +1,7 @@ +# Note that there is a separate top-level configuration for everything else +edition = "2021" +error_on_line_overflow = true +group_imports = "StdExternalCrate" +imports_granularity = "Module" +# This crate gets large lists of reexports. Use vertical to reduce conflicts. +imports_layout = "Vertical" diff --git a/src/solid/mod.rs b/src/solid/mod.rs index 40d6a9d348586..37c7fe5f0a342 100644 --- a/src/solid/mod.rs +++ b/src/solid/mod.rs @@ -395,21 +395,9 @@ pub const SIGUSR1: c_int = 30; pub const SIGUSR2: c_int = 31; pub const SIGPWR: c_int = 32; -#[derive(Debug)] -pub enum FILE {} -impl Copy for FILE {} -impl Clone for FILE { - fn clone(&self) -> FILE { - *self - } -} -#[derive(Debug)] -pub enum fpos_t {} -impl Copy for fpos_t {} -impl Clone for fpos_t { - fn clone(&self) -> fpos_t { - *self - } +extern_ty! { + pub enum FILE {} + pub enum fpos_t {} } extern "C" { diff --git a/src/teeos/mod.rs b/src/teeos/mod.rs index fd9c0b168aba4..f9f8569360f97 100644 --- a/src/teeos/mod.rs +++ b/src/teeos/mod.rs @@ -61,89 +61,81 @@ pub type wctype_t = c_ulong; pub type cmpfunc = extern "C" fn(x: *const c_void, y: *const c_void) -> c_int; -#[repr(align(16))] -pub struct _CLongDouble(pub u128); - -#[repr(align(8))] -#[repr(C)] -pub struct pthread_cond_t { - #[doc(hidden)] - size: [u8; __SIZEOF_PTHREAD_COND_T], +s_paren! { + #[repr(align(16))] + pub struct _CLongDouble(pub u128); } -#[repr(align(8))] -#[repr(C)] -pub struct pthread_mutex_t { - #[doc(hidden)] - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], -} +s! { + #[repr(align(8))] + pub struct pthread_cond_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_COND_T], + } -#[repr(align(4))] -#[repr(C)] -pub struct pthread_mutexattr_t { - #[doc(hidden)] - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], -} + #[repr(align(8))] + pub struct pthread_mutex_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } -#[repr(align(4))] -#[repr(C)] -pub struct pthread_condattr_t { - #[doc(hidden)] - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], -} + #[repr(align(4))] + pub struct pthread_mutexattr_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + } -#[repr(C)] -pub struct pthread_attr_t { - __size: [u64; 7], -} + #[repr(align(4))] + pub struct pthread_condattr_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + } -#[repr(C)] -pub struct cpu_set_t { - bits: [c_ulong; 128 / size_of::()], -} + pub struct pthread_attr_t { + __size: [u64; 7], + } -#[repr(C)] -pub struct timespec { - pub tv_sec: time_t, - pub tv_nsec: c_long, -} + pub struct cpu_set_t { + bits: [c_ulong; 128 / size_of::()], + } -#[repr(C)] -pub struct timeval { - pub tv_sec: time_t, - pub tv_usec: suseconds_t, -} + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } -#[repr(C)] -pub struct tm { - pub tm_sec: c_int, - pub tm_min: c_int, - pub tm_hour: c_int, - pub tm_mday: c_int, - pub tm_mon: c_int, - pub tm_year: c_int, - pub tm_wday: c_int, - pub tm_yday: c_int, - pub tm_isdst: c_int, - pub __tm_gmtoff: c_long, - pub __tm_zone: *const c_char, -} + pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } -#[repr(C)] -pub struct mbstate_t { - pub __opaque1: c_uint, - pub __opaque2: c_uint, -} + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub __tm_gmtoff: c_long, + pub __tm_zone: *const c_char, + } -#[repr(C)] -pub struct sem_t { - pub __val: [c_int; 4 * size_of::() / size_of::()], -} + pub struct mbstate_t { + pub __opaque1: c_uint, + pub __opaque2: c_uint, + } -#[repr(C)] -pub struct div_t { - pub quot: c_int, - pub rem: c_int, + pub struct sem_t { + pub __val: [c_int; 4 * size_of::() / size_of::()], + } + + pub struct div_t { + pub quot: c_int, + pub rem: c_int, + } } // fcntl diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index b6d1af52d133c..b699a3c8001c8 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{in_addr_t, in_port_t}; +use crate::{ + in_addr_t, + in_port_t, +}; pub type caddr_t = *mut c_char; pub type clockid_t = c_longlong; @@ -263,6 +266,15 @@ s! { pub tv_nsec: c_int, } + // On AIX, declares 'tv_nsec' as 'long', but the underlying + // system calls return a 4-byte value in both 32-bit and 64-bit modes. + // It is declared as 'c_int' here to avoid using the other undefined 4 + // bytes in the 64-bit mode. + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_int, + } + pub struct statfs64 { pub f_version: c_int, pub f_type: c_int, diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index ba4ddc057c40b..1b62859ae1633 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -2,8 +2,7 @@ use crate::off_t; use crate::prelude::*; // Define lock_data_instrumented as an empty enum -missing! { - #[derive(Debug)] +extern_ty! { pub enum lock_data_instrumented {} } diff --git a/src/unix/bsd/apple/b64/aarch64/mod.rs b/src/unix/bsd/apple/b64/aarch64/mod.rs index a13013c09b03b..b5cbe8ff5175f 100644 --- a/src/unix/bsd/apple/b64/aarch64/mod.rs +++ b/src/unix/bsd/apple/b64/aarch64/mod.rs @@ -1,49 +1,11 @@ use crate::prelude::*; pub type boolean_t = c_int; -pub type mcontext_t = *mut __darwin_mcontext64; s! { pub struct malloc_zone_t { __private: [crate::uintptr_t; 18], // FIXME(macos): needs arm64 auth pointers support } - - pub struct ucontext_t { - pub uc_onstack: c_int, - pub uc_sigmask: crate::sigset_t, - pub uc_stack: crate::stack_t, - pub uc_link: *mut crate::ucontext_t, - pub uc_mcsize: usize, - pub uc_mcontext: mcontext_t, - } - - pub struct __darwin_mcontext64 { - pub __es: __darwin_arm_exception_state64, - pub __ss: __darwin_arm_thread_state64, - pub __ns: __darwin_arm_neon_state64, - } - - pub struct __darwin_arm_exception_state64 { - pub __far: u64, - pub __esr: u32, - pub __exception: u32, - } - - pub struct __darwin_arm_thread_state64 { - pub __x: [u64; 29], - pub __fp: u64, - pub __lr: u64, - pub __sp: u64, - pub __pc: u64, - pub __cpsr: u32, - pub __pad: u32, - } - - pub struct __darwin_arm_neon_state64 { - pub __v: [crate::__uint128_t; 32], - pub __fpsr: u32, - pub __fpcr: u32, - } } s_no_extra_traits! { diff --git a/src/unix/bsd/apple/b64/x86_64/mod.rs b/src/unix/bsd/apple/b64/x86_64/mod.rs index 5365becf66c3e..2b22f489b9c6b 100644 --- a/src/unix/bsd/apple/b64/x86_64/mod.rs +++ b/src/unix/bsd/apple/b64/x86_64/mod.rs @@ -1,110 +1,8 @@ use crate::prelude::*; pub type boolean_t = c_uint; -pub type mcontext_t = *mut __darwin_mcontext64; s! { - pub struct ucontext_t { - pub uc_onstack: c_int, - pub uc_sigmask: crate::sigset_t, - pub uc_stack: crate::stack_t, - pub uc_link: *mut crate::ucontext_t, - pub uc_mcsize: usize, - pub uc_mcontext: mcontext_t, - } - - pub struct __darwin_mcontext64 { - pub __es: __darwin_x86_exception_state64, - pub __ss: __darwin_x86_thread_state64, - pub __fs: __darwin_x86_float_state64, - } - - pub struct __darwin_x86_exception_state64 { - pub __trapno: u16, - pub __cpu: u16, - pub __err: u32, - pub __faultvaddr: u64, - } - - pub struct __darwin_x86_thread_state64 { - pub __rax: u64, - pub __rbx: u64, - pub __rcx: u64, - pub __rdx: u64, - pub __rdi: u64, - pub __rsi: u64, - pub __rbp: u64, - pub __rsp: u64, - pub __r8: u64, - pub __r9: u64, - pub __r10: u64, - pub __r11: u64, - pub __r12: u64, - pub __r13: u64, - pub __r14: u64, - pub __r15: u64, - pub __rip: u64, - pub __rflags: u64, - pub __cs: u64, - pub __fs: u64, - pub __gs: u64, - } - - pub struct __darwin_x86_float_state64 { - pub __fpu_reserved: [c_int; 2], - __fpu_fcw: c_short, - __fpu_fsw: c_short, - pub __fpu_ftw: u8, - pub __fpu_rsrv1: u8, - pub __fpu_fop: u16, - pub __fpu_ip: u32, - pub __fpu_cs: u16, - pub __fpu_rsrv2: u16, - pub __fpu_dp: u32, - pub __fpu_ds: u16, - pub __fpu_rsrv3: u16, - pub __fpu_mxcsr: u32, - pub __fpu_mxcsrmask: u32, - pub __fpu_stmm0: __darwin_mmst_reg, - pub __fpu_stmm1: __darwin_mmst_reg, - pub __fpu_stmm2: __darwin_mmst_reg, - pub __fpu_stmm3: __darwin_mmst_reg, - pub __fpu_stmm4: __darwin_mmst_reg, - pub __fpu_stmm5: __darwin_mmst_reg, - pub __fpu_stmm6: __darwin_mmst_reg, - pub __fpu_stmm7: __darwin_mmst_reg, - pub __fpu_xmm0: __darwin_xmm_reg, - pub __fpu_xmm1: __darwin_xmm_reg, - pub __fpu_xmm2: __darwin_xmm_reg, - pub __fpu_xmm3: __darwin_xmm_reg, - pub __fpu_xmm4: __darwin_xmm_reg, - pub __fpu_xmm5: __darwin_xmm_reg, - pub __fpu_xmm6: __darwin_xmm_reg, - pub __fpu_xmm7: __darwin_xmm_reg, - pub __fpu_xmm8: __darwin_xmm_reg, - pub __fpu_xmm9: __darwin_xmm_reg, - pub __fpu_xmm10: __darwin_xmm_reg, - pub __fpu_xmm11: __darwin_xmm_reg, - pub __fpu_xmm12: __darwin_xmm_reg, - pub __fpu_xmm13: __darwin_xmm_reg, - pub __fpu_xmm14: __darwin_xmm_reg, - pub __fpu_xmm15: __darwin_xmm_reg, - // this field is actually [u8; 96], but defining it with a bigger type - // allows us to auto-implement traits for it since the length of the - // array is less than 32 - __fpu_rsrv4: [u32; 24], - pub __fpu_reserved1: c_int, - } - - pub struct __darwin_mmst_reg { - pub __mmst_reg: [c_char; 10], - pub __mmst_rsrv: [c_char; 6], - } - - pub struct __darwin_xmm_reg { - pub __xmm_reg: [c_char; 16], - } - pub struct malloc_introspection_t { _private: [crate::uintptr_t; 16], // FIXME(macos): keeping private for now } diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 857508f794ad1..ec05791d9aed0 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -3,7 +3,10 @@ //! This covers *-apple-* triples currently use crate::prelude::*; -use crate::{cmsghdr, off_t}; +use crate::{ + cmsghdr, + off_t, +}; pub type wchar_t = i32; pub type clock_t = c_ulong; @@ -179,13 +182,8 @@ deprecated_mach! { pub type mach_timebase_info_data_t = mach_timebase_info; } -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum timezone {} } #[derive(Debug)] @@ -3322,6 +3320,7 @@ pub const TIOCMSET: c_ulong = 0x8004746d; pub const TIOCMBIS: c_ulong = 0x8004746c; pub const TIOCMBIC: c_ulong = 0x8004746b; pub const TIOCMGET: c_ulong = 0x4004746a; +#[deprecated(since = "0.2.178", note = "Removed in MacOSX 12.0.1")] pub const TIOCREMOTE: c_ulong = 0x80047469; pub const TIOCGWINSZ: c_ulong = 0x40087468; pub const TIOCSWINSZ: c_ulong = 0x80087467; @@ -4777,7 +4776,7 @@ pub const UF_APPEND: c_uint = 0x00000004; pub const UF_OPAQUE: c_uint = 0x00000008; pub const UF_COMPRESSED: c_uint = 0x00000020; pub const UF_TRACKED: c_uint = 0x00000040; -pub const SF_SETTABLE: c_uint = 0xffff0000; +pub const SF_SETTABLE: c_uint = 0x3fff0000; pub const SF_ARCHIVED: c_uint = 0x00010000; pub const SF_IMMUTABLE: c_uint = 0x00020000; pub const SF_APPEND: c_uint = 0x00040000; diff --git a/src/unix/bsd/freebsdlike/dragonfly/errno.rs b/src/unix/bsd/freebsdlike/dragonfly/errno.rs deleted file mode 100644 index 874c1da84d3a5..0000000000000 --- a/src/unix/bsd/freebsdlike/dragonfly/errno.rs +++ /dev/null @@ -1,17 +0,0 @@ -use crate::prelude::*; - -/* DIFF(main): module removed in de76fee6 */ - -// DragonFlyBSD's __error function is declared with "static inline", so it must -// be implemented in the libc crate, as a pointer to a static thread_local. -f! { - #[deprecated(since = "0.2.77", note = "Use `__errno_location()` instead")] - pub fn __error() -> *mut c_int { - &mut errno - } -} - -extern "C" { - #[thread_local] - pub static mut errno: c_int; -} diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 8720bf7fb3649..632d83b0ea3b7 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{cmsghdr, off_t}; +use crate::{ + cmsghdr, + off_t, +}; pub type dev_t = u32; pub type wchar_t = i32; @@ -45,13 +48,8 @@ pub type vm_map_entry_t = *mut vm_map_entry; pub type pmap = __c_anonymous_pmap; -#[derive(Debug)] -pub enum sem {} -impl Copy for sem {} -impl Clone for sem { - fn clone(&self) -> sem { - *self - } +extern_ty! { + pub enum sem {} } e! { @@ -1625,11 +1623,3 @@ extern "C" { entry: vm_map_entry_t, ) -> vm_map_entry_t; } - -// DIFF(main): module removed in de76fee6 -cfg_if! { - if #[cfg(libc_thread_local)] { - mod errno; - pub use self::errno::*; - } -} diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index a5166d4e15c75..47698830a0398 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{cmsghdr, off_t}; +use crate::{ + cmsghdr, + off_t, +}; pub type fflags_t = u32; @@ -3807,6 +3810,8 @@ pub const AT_HWCAP: c_int = 25; pub const AT_HWCAP2: c_int = 26; pub const AT_USRSTACKBASE: c_int = 35; pub const AT_USRSTACKLIM: c_int = 36; +pub const AT_HWCAP3: c_int = 38; +pub const AT_HWCAP4: c_int = 39; pub const TABDLY: crate::tcflag_t = 0x00000004; pub const TAB0: crate::tcflag_t = 0x00000000; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 4bf62033474f0..453d3e0734f05 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -59,13 +59,8 @@ cfg_if! { // link.h -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum timezone {} } impl siginfo_t { diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 24531db853145..dd1c59907e881 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -945,6 +945,8 @@ extern "C" { ) -> size_t; pub fn devname(dev: crate::dev_t, mode_t: crate::mode_t) -> *mut c_char; + + pub fn issetugid() -> c_int; } cfg_if! { diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index bc3e4cdf094ff..294d334490bc1 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -16,21 +16,9 @@ pub type id_t = u32; pub type sem_t = *mut sem; pub type key_t = c_long; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } -} -#[derive(Debug)] -pub enum sem {} -impl Copy for sem {} -impl Clone for sem { - fn clone(&self) -> sem { - *self - } +extern_ty! { + pub enum timezone {} + pub enum sem {} } s! { diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 9f0831323af79..262c644aace5a 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{cmsghdr, off_t}; +use crate::{ + cmsghdr, + off_t, +}; pub type clock_t = c_uint; pub type suseconds_t = c_int; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index b28f4557f5218..199986b851e91 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1,6 +1,9 @@ use crate::prelude::*; use crate::unix::bsd::O_SYNC; -use crate::{cmsghdr, off_t}; +use crate::{ + cmsghdr, + off_t, +}; pub type clock_t = i64; pub type suseconds_t = c_long; diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index 12e30f3f9016c..028ac80cb52d3 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -28,13 +28,8 @@ pub type nlink_t = c_ushort; pub type suseconds_t = c_long; pub type useconds_t = c_ulong; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum timezone {} } pub type sigset_t = c_ulong; @@ -75,13 +70,8 @@ pub type nfds_t = c_uint; pub type sem_t = *mut sem; -#[derive(Debug)] -pub enum sem {} -impl Copy for sem {} -impl Clone for sem { - fn clone(&self) -> sem { - *self - } +extern_ty! { + pub enum sem {} } pub type tcflag_t = c_uint; diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 964598e97ca35..98764c497f0f6 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -80,13 +80,8 @@ pub type ACTION = c_int; pub type posix_spawnattr_t = *mut c_void; pub type posix_spawn_file_actions_t = *mut c_void; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum timezone {} } impl siginfo_t { diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 24e9fe56f392d..acd0981b1a8b2 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -225,22 +225,9 @@ pub type nl_item = c_int; pub type iconv_t = *mut c_void; -#[derive(Debug)] -pub enum fpos64_t {} // FIXME(hurd): fill this out with a struct -impl Copy for fpos64_t {} -impl Clone for fpos64_t { - fn clone(&self) -> fpos64_t { - *self - } -} - -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum fpos64_t {} // FIXME(hurd): fill this out with a struct + pub enum timezone {} } // structs diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index fbd8ac2f87cfc..c829adc656d22 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -1,7 +1,10 @@ //! Android-specific definitions for linux-like values use crate::prelude::*; -use crate::{cmsghdr, msghdr}; +use crate::{ + cmsghdr, + msghdr, +}; cfg_if! { if #[cfg(doc)] { @@ -3508,6 +3511,8 @@ pub const AT_RANDOM: c_ulong = 25; pub const AT_HWCAP2: c_ulong = 26; pub const AT_RSEQ_FEATURE_SIZE: c_ulong = 27; pub const AT_RSEQ_ALIGN: c_ulong = 28; +pub const AT_HWCAP3: c_ulong = 29; +pub const AT_HWCAP4: c_ulong = 30; pub const AT_EXECFN: c_ulong = 31; pub const AT_MINSIGSTKSZ: c_ulong = 51; diff --git a/src/unix/linux_like/emscripten/lfs64.rs b/src/unix/linux_like/emscripten/lfs64.rs index 06be875446bb6..501540943889f 100644 --- a/src/unix/linux_like/emscripten/lfs64.rs +++ b/src/unix/linux_like/emscripten/lfs64.rs @@ -109,7 +109,10 @@ pub unsafe extern "C" fn mmap64( // // These aliases are mostly fine though, neither function takes a LFS64-namespaced type as an // argument, nor do their names clash with any declared types. -pub use crate::{open as open64, openat as openat64}; +pub use crate::{ + open as open64, + openat as openat64, +}; #[inline] pub unsafe extern "C" fn posix_fadvise64( diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 417e3e593bc5e..91e506c57cc22 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -41,13 +41,8 @@ pub type statfs64 = crate::statfs; pub type statvfs64 = crate::statvfs; pub type dirent64 = crate::dirent; -#[derive(Debug)] -pub enum fpos64_t {} // FIXME(emscripten): fill this out with a struct -impl Copy for fpos64_t {} -impl Clone for fpos64_t { - fn clone(&self) -> fpos64_t { - *self - } +extern_ty! { + pub enum fpos64_t {} // FIXME(emscripten): fill this out with a struct } s! { diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs index 900851ab5f42c..0f7181e2aee1a 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = u32; diff --git a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs index 95881894a4b94..bb06c49df0a25 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = u32; diff --git a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs index d614fddeca9d9..ceaab898074b4 100644 --- a/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = i32; diff --git a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs index 3d2775cd800ae..98ce89e124891 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = i32; diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index 791f14956806d..54470e10d6145 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = i32; diff --git a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs index b04ee50462745..f4f04c91b7f87 100644 --- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -1,7 +1,10 @@ //! RISC-V-specific definitions for 32-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = c_int; diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index 801f31e2c0e34..03ecff3f342e1 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -1,7 +1,10 @@ //! SPARC-specific definitions for 32-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = i32; diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index 5f0dfe90adf81..26a95f85972f1 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -1,5 +1,8 @@ use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = i32; pub type greg_t = i32; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index 28b4e40fde543..b5af0e8ec9548 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -1,7 +1,10 @@ //! AArch64-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = u32; pub type nlink_t = u32; diff --git a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs index 8f15ce4d1529a..1eeb6098284b8 100644 --- a/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -1,5 +1,9 @@ use crate::prelude::*; -use crate::{off64_t, off_t, pthread_mutex_t}; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; pub type wchar_t = i32; diff --git a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs index 7f66330d9c7ed..da43c3268813a 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -1,5 +1,9 @@ use crate::prelude::*; -use crate::{off64_t, off_t, pthread_mutex_t}; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; pub type blksize_t = i64; pub type nlink_t = u64; diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs index 047efe55b1a38..153d25e2f3deb 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -1,7 +1,11 @@ //! PowerPC64-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t, pthread_mutex_t}; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; pub type wchar_t = i32; pub type nlink_t = u64; @@ -9,6 +13,8 @@ pub type blksize_t = i64; pub type suseconds_t = i64; pub type __u64 = c_ulong; pub type __s64 = c_long; +pub type gregset_t = [c_ulong; __NGREG]; +pub type fpregset_t = [c_ulong; __NFPREG]; s! { // FIXME(1.0): This should not implement `PartialEq` @@ -191,6 +197,21 @@ s! { pub ss_flags: c_int, pub ss_size: size_t, } + + #[repr(align(8))] + pub struct clone_args { + pub flags: c_ulonglong, + pub pidfd: c_ulonglong, + pub child_tid: c_ulonglong, + pub parent_tid: c_ulonglong, + pub exit_signal: c_ulonglong, + pub stack: c_ulonglong, + pub stack_size: c_ulonglong, + pub tls: c_ulonglong, + pub set_tid: c_ulonglong, + pub set_tid_size: c_ulonglong, + pub cgroup: c_ulonglong, + } } s_no_extra_traits! { @@ -198,6 +219,64 @@ s_no_extra_traits! { pub struct max_align_t { priv_: [i64; 4], } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_sigmask: crate::sigset_t, + pub uc_mcontext: mcontext_t, + } + + pub struct pt_regs { + pub gpr: [c_ulong; 32], + pub nip: c_ulong, + pub msr: c_ulong, + pub orig_gpr3: c_ulong, + pub ctr: c_ulong, + pub link: c_ulong, + pub xer: c_ulong, + pub ccr: c_ulong, + pub softe: c_ulong, + pub trap: c_ulong, + pub dar: c_ulong, + pub dsisr: c_ulong, + pub result: c_ulong, + } + + pub struct mcontext_t { + __glibc_reserved: [c_ulong; 4], + pub signal: c_int, + __pad0: c_int, + pub handler: c_ulong, + pub oldmask: c_ulong, + pub regs: *mut pt_regs, + pub gp_regs: crate::gregset_t, + pub fp_regs: crate::fpregset_t, + pub v_regs: *mut vrregset_t, + pub vmx_reserve: [c_long; __NVRREG + __NVRREG + 1], + } + + #[repr(align(16))] + pub struct vrregset_t { + pub vrregs: [[c_uint; 4]; 32], + pub vscr: vscr_t, + pub vrsave: c_uint, + __pad: [c_uint; 3], + } + + #[repr(align(4))] + pub struct vscr_t { + #[cfg(target_endian = "big")] + __pad: [c_uint; 3], + #[cfg(target_endian = "big")] + pub vscr_word: c_uint, + + #[cfg(target_endian = "little")] + pub vscr_word: c_uint, + #[cfg(target_endian = "little")] + __pad: [c_uint; 3], + } } pub const POSIX_FADV_DONTNEED: c_int = 4; @@ -210,6 +289,10 @@ pub const VEOF: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; +pub const __NGREG: usize = 48; +pub const __NFPREG: usize = 33; +pub const __NVRREG: usize = 34; + pub const O_APPEND: c_int = 1024; pub const O_CREAT: c_int = 64; pub const O_EXCL: c_int = 128; @@ -971,4 +1054,9 @@ extern "C" { newp: *mut c_void, newlen: size_t, ) -> c_int; + + pub fn getcontext(ucp: *mut ucontext_t) -> c_int; + pub fn setcontext(ucp: *const ucontext_t) -> c_int; + pub fn swapcontext(oucp: *mut ucontext_t, ucp: *const ucontext_t) -> c_int; + pub fn makecontext(ucp: *mut ucontext_t, func: extern "C" fn(), argc: c_int, ...); } 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 bfbc8ee5cf683..e5546cdae7fb3 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -1,7 +1,10 @@ //! RISC-V-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = c_int; diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index 029485c5b4a32..5bea1a100b1d7 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -1,7 +1,11 @@ //! s390x use crate::prelude::*; -use crate::{off64_t, off_t, pthread_mutex_t}; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; pub type blksize_t = i64; pub type nlink_t = u64; diff --git a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs index f18e53a99b466..0a40d7599bad9 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -1,7 +1,11 @@ //! SPARC64-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t, pthread_mutex_t}; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; pub type wchar_t = i32; pub type nlink_t = u32; diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs index f4555ee420230..e100871275776 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -1,7 +1,10 @@ //! x86_64-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = i32; pub type nlink_t = u64; @@ -310,11 +313,7 @@ s_no_extra_traits! { pub uc_mcontext: mcontext_t, pub uc_sigmask: crate::sigset_t, __private: [u8; 512], - // FIXME(glibc): the shadow stack field requires glibc >= 2.28. - // Re-add once we drop compatibility with glibc versions older than - // 2.28. - // - // __ssp: [c_ulonglong; 4], + __ssp: [c_ulonglong; 4], } #[repr(align(16))] diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 17d11d27a4dea..afd9fe3396180 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -892,42 +892,6 @@ pub const CLONE_NEWTIME: c_int = 0x80; pub const CLONE_CLEAR_SIGHAND: c_int = 0x100000000; pub const CLONE_INTO_CGROUP: c_int = 0x200000000; -// linux/keyctl.h -pub const KEYCTL_DH_COMPUTE: u32 = 23; -pub const KEYCTL_PKEY_QUERY: u32 = 24; -pub const KEYCTL_PKEY_ENCRYPT: u32 = 25; -pub const KEYCTL_PKEY_DECRYPT: u32 = 26; -pub const KEYCTL_PKEY_SIGN: u32 = 27; -pub const KEYCTL_PKEY_VERIFY: u32 = 28; -pub const KEYCTL_RESTRICT_KEYRING: u32 = 29; - -pub const KEYCTL_SUPPORTS_ENCRYPT: u32 = 0x01; -pub const KEYCTL_SUPPORTS_DECRYPT: u32 = 0x02; -pub const KEYCTL_SUPPORTS_SIGN: u32 = 0x04; -pub const KEYCTL_SUPPORTS_VERIFY: u32 = 0x08; -cfg_if! { - if #[cfg(not(any( - target_arch = "mips", - target_arch = "mips32r6", - target_arch = "mips64", - target_arch = "mips64r6" - )))] { - pub const KEYCTL_MOVE: u32 = 30; - pub const KEYCTL_CAPABILITIES: u32 = 31; - - pub const KEYCTL_CAPS0_CAPABILITIES: u32 = 0x01; - pub const KEYCTL_CAPS0_PERSISTENT_KEYRINGS: u32 = 0x02; - pub const KEYCTL_CAPS0_DIFFIE_HELLMAN: u32 = 0x04; - pub const KEYCTL_CAPS0_PUBLIC_KEY: u32 = 0x08; - pub const KEYCTL_CAPS0_BIG_KEY: u32 = 0x10; - pub const KEYCTL_CAPS0_INVALIDATE: u32 = 0x20; - pub const KEYCTL_CAPS0_RESTRICT_KEYRING: u32 = 0x40; - pub const KEYCTL_CAPS0_MOVE: u32 = 0x80; - pub const KEYCTL_CAPS1_NS_KEYRING_NAME: u32 = 0x01; - pub const KEYCTL_CAPS1_NS_KEY_TAG: u32 = 0x02; - } -} - pub const M_MXFAST: c_int = 1; pub const M_NLBLKS: c_int = 2; pub const M_GRAIN: c_int = 3; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 14401077479ed..45031ab2aa32c 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1,7 +1,13 @@ //! Linux-specific definitions for linux-like values use crate::prelude::*; -use crate::{sock_filter, _IO, _IOR, _IOW, _IOWR}; +use crate::{ + sock_filter, + _IO, + _IOR, + _IOW, + _IOWR, +}; pub type useconds_t = u32; pub type dev_t = u64; @@ -67,8 +73,7 @@ pub type eventfd_t = u64; cfg_if! { if #[cfg(not(target_env = "gnu"))] { - missing! { - #[derive(Debug)] + extern_ty! { pub enum fpos64_t {} // FIXME(linux): fill this out with a struct } } @@ -2544,6 +2549,8 @@ pub const AT_BASE_PLATFORM: c_ulong = 24; pub const AT_RANDOM: c_ulong = 25; pub const AT_HWCAP2: c_ulong = 26; +pub const AT_HWCAP3: c_ulong = 29; +pub const AT_HWCAP4: c_ulong = 30; pub const AT_EXECFN: c_ulong = 31; // defined in arch//include/uapi/asm/auxvec.h but has the same value @@ -4821,50 +4828,6 @@ const fn issecure_mask(x: c_int) -> c_int { 1 << x } -// linux/keyctl.h -pub const KEY_SPEC_THREAD_KEYRING: i32 = -1; -pub const KEY_SPEC_PROCESS_KEYRING: i32 = -2; -pub const KEY_SPEC_SESSION_KEYRING: i32 = -3; -pub const KEY_SPEC_USER_KEYRING: i32 = -4; -pub const KEY_SPEC_USER_SESSION_KEYRING: i32 = -5; -pub const KEY_SPEC_GROUP_KEYRING: i32 = -6; -pub const KEY_SPEC_REQKEY_AUTH_KEY: i32 = -7; -pub const KEY_SPEC_REQUESTOR_KEYRING: i32 = -8; - -pub const KEY_REQKEY_DEFL_NO_CHANGE: i32 = -1; -pub const KEY_REQKEY_DEFL_DEFAULT: i32 = 0; -pub const KEY_REQKEY_DEFL_THREAD_KEYRING: i32 = 1; -pub const KEY_REQKEY_DEFL_PROCESS_KEYRING: i32 = 2; -pub const KEY_REQKEY_DEFL_SESSION_KEYRING: i32 = 3; -pub const KEY_REQKEY_DEFL_USER_KEYRING: i32 = 4; -pub const KEY_REQKEY_DEFL_USER_SESSION_KEYRING: i32 = 5; -pub const KEY_REQKEY_DEFL_GROUP_KEYRING: i32 = 6; -pub const KEY_REQKEY_DEFL_REQUESTOR_KEYRING: i32 = 7; - -pub const KEYCTL_GET_KEYRING_ID: u32 = 0; -pub const KEYCTL_JOIN_SESSION_KEYRING: u32 = 1; -pub const KEYCTL_UPDATE: u32 = 2; -pub const KEYCTL_REVOKE: u32 = 3; -pub const KEYCTL_CHOWN: u32 = 4; -pub const KEYCTL_SETPERM: u32 = 5; -pub const KEYCTL_DESCRIBE: u32 = 6; -pub const KEYCTL_CLEAR: u32 = 7; -pub const KEYCTL_LINK: u32 = 8; -pub const KEYCTL_UNLINK: u32 = 9; -pub const KEYCTL_SEARCH: u32 = 10; -pub const KEYCTL_READ: u32 = 11; -pub const KEYCTL_INSTANTIATE: u32 = 12; -pub const KEYCTL_NEGATE: u32 = 13; -pub const KEYCTL_SET_REQKEY_KEYRING: u32 = 14; -pub const KEYCTL_SET_TIMEOUT: u32 = 15; -pub const KEYCTL_ASSUME_AUTHORITY: u32 = 16; -pub const KEYCTL_GET_SECURITY: u32 = 17; -pub const KEYCTL_SESSION_TO_PARENT: u32 = 18; -pub const KEYCTL_REJECT: u32 = 19; -pub const KEYCTL_INSTANTIATE_IOV: u32 = 20; -pub const KEYCTL_INVALIDATE: u32 = 21; -pub const KEYCTL_GET_PERSISTENT: u32 = 22; - pub const IN_MASK_CREATE: u32 = 0x1000_0000; pub const IN_MASK_ADD: u32 = 0x2000_0000; pub const IN_ISDIR: u32 = 0x4000_0000; @@ -4955,7 +4918,8 @@ cfg_if! { pub const NFT_MSG_GETOBJ_RESET: c_int = 21; } } -pub const NFT_MSG_MAX: c_int = 25; + +pub const NFT_MSG_MAX: c_int = 34; pub const NFT_SET_ANONYMOUS: c_int = 0x1; pub const NFT_SET_CONSTANT: c_int = 0x2; 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 a623ff9a9f757..7564dcf612f9c 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -363,7 +363,6 @@ pub const SIGTSTP: c_int = 24; pub const SIGURG: c_int = 21; pub const SIGIO: c_int = 22; pub const SIGSYS: c_int = 12; -pub const SIGSTKFLT: c_int = 7; pub const SIGPOLL: c_int = crate::SIGIO; pub const SIGPWR: c_int = 19; pub const SIG_SETMASK: c_int = 3; 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 ea4b51f006f0f..d78df7528d26f 100644 --- a/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -1,7 +1,10 @@ //! RISC-V-specific definitions for 32-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = c_int; 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 e014fbf48c0da..6ae9637cb58c6 100644 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -1,7 +1,10 @@ //! LoongArch-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = c_int; 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 8389af961cf58..cd93ef706deeb 100644 --- a/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -1,7 +1,10 @@ //! RISC-V-specific definitions for 64-bit linux-like values use crate::prelude::*; -use crate::{off64_t, off_t}; +use crate::{ + off64_t, + off_t, +}; pub type wchar_t = c_int; diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index 06cc61685b7ac..490d130c65bc4 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -84,6 +84,31 @@ s! { pub f_flags: c_uint, pub f_spare: [c_uint; 4], } + + pub struct __psw_t { + pub mask: c_ulong, + pub addr: c_ulong, + } + + pub struct fpregset_t { + pub fpc: c_uint, + pub fprs: [fpreg_t; 16], + } + + pub struct mcontext_t { + pub psw: __psw_t, + pub gregs: [c_ulong; 16], + pub aregs: [c_uint; 16], + pub fpregs: fpregset_t, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: crate::sigset_t, + } } s_no_extra_traits! { 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 29750e79e17e6..00dc4e5b97f2d 100644 --- a/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs @@ -681,7 +681,7 @@ pub const TOSTOP: crate::tcflag_t = 0x00000100; pub const FLUSHO: crate::tcflag_t = 0x00001000; cfg_if! { - if #[cfg(target_vendor = "wali")] { + if #[cfg(all(target_family = "wasm", target_env = "musl"))] { mod wali; pub use self::wali::*; } diff --git a/src/unix/linux_like/linux/musl/b64/wasm32/wali.rs b/src/unix/linux_like/linux/musl/b64/wasm32/wali.rs index bda5c241c1d2d..f347e8a69ddd0 100644 --- a/src/unix/linux_like/linux/musl/b64/wasm32/wali.rs +++ b/src/unix/linux_like/linux/musl/b64/wasm32/wali.rs @@ -1,400 +1,400 @@ //! WebAssembly Linux Interface syscall specification +use crate::prelude::*; + // --- Autogenerated from WALI/scripts/autogen.py --- #[link(wasm_import_module = "wali")] extern "C" { /* 0 */ #[link_name = "SYS_read"] - pub fn __syscall_SYS_read(a1: i32, a2: i32, a3: u32) -> ::c_long; + pub fn __syscall_SYS_read(a1: i32, a2: i32, a3: u32) -> c_long; /* 1 */ #[link_name = "SYS_write"] - pub fn __syscall_SYS_write(a1: i32, a2: i32, a3: u32) -> ::c_long; + pub fn __syscall_SYS_write(a1: i32, a2: i32, a3: u32) -> c_long; /* 2 */ #[link_name = "SYS_open"] - pub fn __syscall_SYS_open(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_open(a1: i32, a2: i32, a3: i32) -> c_long; /* 3 */ #[link_name = "SYS_close"] - pub fn __syscall_SYS_close(a1: i32) -> ::c_long; + pub fn __syscall_SYS_close(a1: i32) -> c_long; /* 4 */ #[link_name = "SYS_stat"] - pub fn __syscall_SYS_stat(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_stat(a1: i32, a2: i32) -> c_long; /* 5 */ #[link_name = "SYS_fstat"] - pub fn __syscall_SYS_fstat(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_fstat(a1: i32, a2: i32) -> c_long; /* 6 */ #[link_name = "SYS_lstat"] - pub fn __syscall_SYS_lstat(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_lstat(a1: i32, a2: i32) -> c_long; /* 7 */ #[link_name = "SYS_poll"] - pub fn __syscall_SYS_poll(a1: i32, a2: u32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_poll(a1: i32, a2: u32, a3: i32) -> c_long; /* 8 */ #[link_name = "SYS_lseek"] - pub fn __syscall_SYS_lseek(a1: i32, a2: i64, a3: i32) -> ::c_long; + pub fn __syscall_SYS_lseek(a1: i32, a2: i64, a3: i32) -> c_long; /* 9 */ #[link_name = "SYS_mmap"] - pub fn __syscall_SYS_mmap(a1: i32, a2: u32, a3: i32, a4: i32, a5: i32, a6: i64) -> ::c_long; + pub fn __syscall_SYS_mmap(a1: i32, a2: u32, a3: i32, a4: i32, a5: i32, a6: i64) -> c_long; /* 10 */ #[link_name = "SYS_mprotect"] - pub fn __syscall_SYS_mprotect(a1: i32, a2: u32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_mprotect(a1: i32, a2: u32, a3: i32) -> c_long; /* 11 */ #[link_name = "SYS_munmap"] - pub fn __syscall_SYS_munmap(a1: i32, a2: u32) -> ::c_long; + pub fn __syscall_SYS_munmap(a1: i32, a2: u32) -> c_long; /* 12 */ #[link_name = "SYS_brk"] - pub fn __syscall_SYS_brk(a1: i32) -> ::c_long; + pub fn __syscall_SYS_brk(a1: i32) -> c_long; /* 13 */ #[link_name = "SYS_rt_sigaction"] - pub fn __syscall_SYS_rt_sigaction(a1: i32, a2: i32, a3: i32, a4: u32) -> ::c_long; + pub fn __syscall_SYS_rt_sigaction(a1: i32, a2: i32, a3: i32, a4: u32) -> c_long; /* 14 */ #[link_name = "SYS_rt_sigprocmask"] - pub fn __syscall_SYS_rt_sigprocmask(a1: i32, a2: i32, a3: i32, a4: u32) -> ::c_long; + pub fn __syscall_SYS_rt_sigprocmask(a1: i32, a2: i32, a3: i32, a4: u32) -> c_long; /* 15 */ #[link_name = "SYS_rt_sigreturn"] - pub fn __syscall_SYS_rt_sigreturn(a1: i64) -> ::c_long; + pub fn __syscall_SYS_rt_sigreturn(a1: i64) -> c_long; /* 16 */ #[link_name = "SYS_ioctl"] - pub fn __syscall_SYS_ioctl(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_ioctl(a1: i32, a2: i32, a3: i32) -> c_long; /* 17 */ #[link_name = "SYS_pread64"] - pub fn __syscall_SYS_pread64(a1: i32, a2: i32, a3: u32, a4: i64) -> ::c_long; + pub fn __syscall_SYS_pread64(a1: i32, a2: i32, a3: u32, a4: i64) -> c_long; /* 18 */ #[link_name = "SYS_pwrite64"] - pub fn __syscall_SYS_pwrite64(a1: i32, a2: i32, a3: u32, a4: i64) -> ::c_long; + pub fn __syscall_SYS_pwrite64(a1: i32, a2: i32, a3: u32, a4: i64) -> c_long; /* 19 */ #[link_name = "SYS_readv"] - pub fn __syscall_SYS_readv(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_readv(a1: i32, a2: i32, a3: i32) -> c_long; /* 20 */ #[link_name = "SYS_writev"] - pub fn __syscall_SYS_writev(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_writev(a1: i32, a2: i32, a3: i32) -> c_long; /* 21 */ #[link_name = "SYS_access"] - pub fn __syscall_SYS_access(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_access(a1: i32, a2: i32) -> c_long; /* 22 */ #[link_name = "SYS_pipe"] - pub fn __syscall_SYS_pipe(a1: i32) -> ::c_long; + pub fn __syscall_SYS_pipe(a1: i32) -> c_long; /* 23 */ #[link_name = "SYS_select"] - pub fn __syscall_SYS_select(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_select(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; /* 24 */ #[link_name = "SYS_sched_yield"] - pub fn __syscall_SYS_sched_yield() -> ::c_long; + pub fn __syscall_SYS_sched_yield() -> c_long; /* 25 */ #[link_name = "SYS_mremap"] - pub fn __syscall_SYS_mremap(a1: i32, a2: u32, a3: u32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_mremap(a1: i32, a2: u32, a3: u32, a4: i32, a5: i32) -> c_long; /* 26 */ #[link_name = "SYS_msync"] - pub fn __syscall_SYS_msync(a1: i32, a2: u32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_msync(a1: i32, a2: u32, a3: i32) -> c_long; /* 28 */ #[link_name = "SYS_madvise"] - pub fn __syscall_SYS_madvise(a1: i32, a2: u32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_madvise(a1: i32, a2: u32, a3: i32) -> c_long; /* 32 */ #[link_name = "SYS_dup"] - pub fn __syscall_SYS_dup(a1: i32) -> ::c_long; + pub fn __syscall_SYS_dup(a1: i32) -> c_long; /* 33 */ #[link_name = "SYS_dup2"] - pub fn __syscall_SYS_dup2(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_dup2(a1: i32, a2: i32) -> c_long; /* 35 */ #[link_name = "SYS_nanosleep"] - pub fn __syscall_SYS_nanosleep(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_nanosleep(a1: i32, a2: i32) -> c_long; /* 37 */ #[link_name = "SYS_alarm"] - pub fn __syscall_SYS_alarm(a1: i32) -> ::c_long; + pub fn __syscall_SYS_alarm(a1: i32) -> c_long; /* 38 */ #[link_name = "SYS_setitimer"] - pub fn __syscall_SYS_setitimer(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_setitimer(a1: i32, a2: i32, a3: i32) -> c_long; /* 39 */ #[link_name = "SYS_getpid"] - pub fn __syscall_SYS_getpid() -> ::c_long; + pub fn __syscall_SYS_getpid() -> c_long; /* 41 */ #[link_name = "SYS_socket"] - pub fn __syscall_SYS_socket(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_socket(a1: i32, a2: i32, a3: i32) -> c_long; /* 42 */ #[link_name = "SYS_connect"] - pub fn __syscall_SYS_connect(a1: i32, a2: i32, a3: u32) -> ::c_long; + pub fn __syscall_SYS_connect(a1: i32, a2: i32, a3: u32) -> c_long; /* 43 */ #[link_name = "SYS_accept"] - pub fn __syscall_SYS_accept(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_accept(a1: i32, a2: i32, a3: i32) -> c_long; /* 44 */ #[link_name = "SYS_sendto"] - pub fn __syscall_SYS_sendto(a1: i32, a2: i32, a3: u32, a4: i32, a5: i32, a6: u32) -> ::c_long; + pub fn __syscall_SYS_sendto(a1: i32, a2: i32, a3: u32, a4: i32, a5: i32, a6: u32) -> c_long; /* 45 */ #[link_name = "SYS_recvfrom"] - pub fn __syscall_SYS_recvfrom(a1: i32, a2: i32, a3: u32, a4: i32, a5: i32, a6: i32) - -> ::c_long; + pub fn __syscall_SYS_recvfrom(a1: i32, a2: i32, a3: u32, a4: i32, a5: i32, a6: i32) -> c_long; /* 46 */ #[link_name = "SYS_sendmsg"] - pub fn __syscall_SYS_sendmsg(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_sendmsg(a1: i32, a2: i32, a3: i32) -> c_long; /* 47 */ #[link_name = "SYS_recvmsg"] - pub fn __syscall_SYS_recvmsg(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_recvmsg(a1: i32, a2: i32, a3: i32) -> c_long; /* 48 */ #[link_name = "SYS_shutdown"] - pub fn __syscall_SYS_shutdown(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_shutdown(a1: i32, a2: i32) -> c_long; /* 49 */ #[link_name = "SYS_bind"] - pub fn __syscall_SYS_bind(a1: i32, a2: i32, a3: u32) -> ::c_long; + pub fn __syscall_SYS_bind(a1: i32, a2: i32, a3: u32) -> c_long; /* 50 */ #[link_name = "SYS_listen"] - pub fn __syscall_SYS_listen(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_listen(a1: i32, a2: i32) -> c_long; /* 51 */ #[link_name = "SYS_getsockname"] - pub fn __syscall_SYS_getsockname(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_getsockname(a1: i32, a2: i32, a3: i32) -> c_long; /* 52 */ #[link_name = "SYS_getpeername"] - pub fn __syscall_SYS_getpeername(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_getpeername(a1: i32, a2: i32, a3: i32) -> c_long; /* 53 */ #[link_name = "SYS_socketpair"] - pub fn __syscall_SYS_socketpair(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_socketpair(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 54 */ #[link_name = "SYS_setsockopt"] - pub fn __syscall_SYS_setsockopt(a1: i32, a2: i32, a3: i32, a4: i32, a5: u32) -> ::c_long; + pub fn __syscall_SYS_setsockopt(a1: i32, a2: i32, a3: i32, a4: i32, a5: u32) -> c_long; /* 55 */ #[link_name = "SYS_getsockopt"] - pub fn __syscall_SYS_getsockopt(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_getsockopt(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; /* 57 */ #[link_name = "SYS_fork"] - pub fn __syscall_SYS_fork() -> ::c_long; + pub fn __syscall_SYS_fork() -> c_long; /* 59 */ #[link_name = "SYS_execve"] - pub fn __syscall_SYS_execve(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_execve(a1: i32, a2: i32, a3: i32) -> c_long; /* 60 */ #[link_name = "SYS_exit"] - pub fn __syscall_SYS_exit(a1: i32) -> ::c_long; + pub fn __syscall_SYS_exit(a1: i32) -> c_long; /* 61 */ #[link_name = "SYS_wait4"] - pub fn __syscall_SYS_wait4(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_wait4(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 62 */ #[link_name = "SYS_kill"] - pub fn __syscall_SYS_kill(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_kill(a1: i32, a2: i32) -> c_long; /* 63 */ #[link_name = "SYS_uname"] - pub fn __syscall_SYS_uname(a1: i32) -> ::c_long; + pub fn __syscall_SYS_uname(a1: i32) -> c_long; /* 72 */ #[link_name = "SYS_fcntl"] - pub fn __syscall_SYS_fcntl(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_fcntl(a1: i32, a2: i32, a3: i32) -> c_long; /* 73 */ #[link_name = "SYS_flock"] - pub fn __syscall_SYS_flock(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_flock(a1: i32, a2: i32) -> c_long; /* 74 */ #[link_name = "SYS_fsync"] - pub fn __syscall_SYS_fsync(a1: i32) -> ::c_long; + pub fn __syscall_SYS_fsync(a1: i32) -> c_long; /* 75 */ #[link_name = "SYS_fdatasync"] - pub fn __syscall_SYS_fdatasync(a1: i32) -> ::c_long; + pub fn __syscall_SYS_fdatasync(a1: i32) -> c_long; /* 77 */ #[link_name = "SYS_ftruncate"] - pub fn __syscall_SYS_ftruncate(a1: i32, a2: i64) -> ::c_long; + pub fn __syscall_SYS_ftruncate(a1: i32, a2: i64) -> c_long; /* 78 */ #[link_name = "SYS_getdents"] - pub fn __syscall_SYS_getdents(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_getdents(a1: i32, a2: i32, a3: i32) -> c_long; /* 79 */ #[link_name = "SYS_getcwd"] - pub fn __syscall_SYS_getcwd(a1: i32, a2: u32) -> ::c_long; + pub fn __syscall_SYS_getcwd(a1: i32, a2: u32) -> c_long; /* 80 */ #[link_name = "SYS_chdir"] - pub fn __syscall_SYS_chdir(a1: i32) -> ::c_long; + pub fn __syscall_SYS_chdir(a1: i32) -> c_long; /* 81 */ #[link_name = "SYS_fchdir"] - pub fn __syscall_SYS_fchdir(a1: i32) -> ::c_long; + pub fn __syscall_SYS_fchdir(a1: i32) -> c_long; /* 82 */ #[link_name = "SYS_rename"] - pub fn __syscall_SYS_rename(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_rename(a1: i32, a2: i32) -> c_long; /* 83 */ #[link_name = "SYS_mkdir"] - pub fn __syscall_SYS_mkdir(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_mkdir(a1: i32, a2: i32) -> c_long; /* 84 */ #[link_name = "SYS_rmdir"] - pub fn __syscall_SYS_rmdir(a1: i32) -> ::c_long; + pub fn __syscall_SYS_rmdir(a1: i32) -> c_long; /* 86 */ #[link_name = "SYS_link"] - pub fn __syscall_SYS_link(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_link(a1: i32, a2: i32) -> c_long; /* 87 */ #[link_name = "SYS_unlink"] - pub fn __syscall_SYS_unlink(a1: i32) -> ::c_long; + pub fn __syscall_SYS_unlink(a1: i32) -> c_long; /* 88 */ #[link_name = "SYS_symlink"] - pub fn __syscall_SYS_symlink(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_symlink(a1: i32, a2: i32) -> c_long; /* 89 */ #[link_name = "SYS_readlink"] - pub fn __syscall_SYS_readlink(a1: i32, a2: i32, a3: u32) -> ::c_long; + pub fn __syscall_SYS_readlink(a1: i32, a2: i32, a3: u32) -> c_long; /* 90 */ #[link_name = "SYS_chmod"] - pub fn __syscall_SYS_chmod(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_chmod(a1: i32, a2: i32) -> c_long; /* 91 */ #[link_name = "SYS_fchmod"] - pub fn __syscall_SYS_fchmod(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_fchmod(a1: i32, a2: i32) -> c_long; /* 92 */ #[link_name = "SYS_chown"] - pub fn __syscall_SYS_chown(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_chown(a1: i32, a2: i32, a3: i32) -> c_long; /* 93 */ #[link_name = "SYS_fchown"] - pub fn __syscall_SYS_fchown(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_fchown(a1: i32, a2: i32, a3: i32) -> c_long; /* 95 */ #[link_name = "SYS_umask"] - pub fn __syscall_SYS_umask(a1: i32) -> ::c_long; + pub fn __syscall_SYS_umask(a1: i32) -> c_long; /* 97 */ #[link_name = "SYS_getrlimit"] - pub fn __syscall_SYS_getrlimit(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_getrlimit(a1: i32, a2: i32) -> c_long; /* 98 */ #[link_name = "SYS_getrusage"] - pub fn __syscall_SYS_getrusage(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_getrusage(a1: i32, a2: i32) -> c_long; /* 99 */ #[link_name = "SYS_sysinfo"] - pub fn __syscall_SYS_sysinfo(a1: i32) -> ::c_long; + pub fn __syscall_SYS_sysinfo(a1: i32) -> c_long; /* 102 */ #[link_name = "SYS_getuid"] - pub fn __syscall_SYS_getuid() -> ::c_long; + pub fn __syscall_SYS_getuid() -> c_long; /* 104 */ #[link_name = "SYS_getgid"] - pub fn __syscall_SYS_getgid() -> ::c_long; + pub fn __syscall_SYS_getgid() -> c_long; /* 105 */ #[link_name = "SYS_setuid"] - pub fn __syscall_SYS_setuid(a1: i32) -> ::c_long; + pub fn __syscall_SYS_setuid(a1: i32) -> c_long; /* 106 */ #[link_name = "SYS_setgid"] - pub fn __syscall_SYS_setgid(a1: i32) -> ::c_long; + pub fn __syscall_SYS_setgid(a1: i32) -> c_long; /* 107 */ #[link_name = "SYS_geteuid"] - pub fn __syscall_SYS_geteuid() -> ::c_long; + pub fn __syscall_SYS_geteuid() -> c_long; /* 108 */ #[link_name = "SYS_getegid"] - pub fn __syscall_SYS_getegid() -> ::c_long; + pub fn __syscall_SYS_getegid() -> c_long; /* 109 */ #[link_name = "SYS_setpgid"] - pub fn __syscall_SYS_setpgid(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_setpgid(a1: i32, a2: i32) -> c_long; /* 110 */ #[link_name = "SYS_getppid"] - pub fn __syscall_SYS_getppid() -> ::c_long; + pub fn __syscall_SYS_getppid() -> c_long; /* 112 */ #[link_name = "SYS_setsid"] - pub fn __syscall_SYS_setsid() -> ::c_long; + pub fn __syscall_SYS_setsid() -> c_long; /* 113 */ #[link_name = "SYS_setreuid"] - pub fn __syscall_SYS_setreuid(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_setreuid(a1: i32, a2: i32) -> c_long; /* 114 */ #[link_name = "SYS_setregid"] - pub fn __syscall_SYS_setregid(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_setregid(a1: i32, a2: i32) -> c_long; /* 115 */ #[link_name = "SYS_getgroups"] - pub fn __syscall_SYS_getgroups(a1: u32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_getgroups(a1: u32, a2: i32) -> c_long; /* 116 */ #[link_name = "SYS_setgroups"] - pub fn __syscall_SYS_setgroups(a1: u32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_setgroups(a1: u32, a2: i32) -> c_long; /* 117 */ #[link_name = "SYS_setresuid"] - pub fn __syscall_SYS_setresuid(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_setresuid(a1: i32, a2: i32, a3: i32) -> c_long; /* 119 */ #[link_name = "SYS_setresgid"] - pub fn __syscall_SYS_setresgid(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_setresgid(a1: i32, a2: i32, a3: i32) -> c_long; /* 121 */ #[link_name = "SYS_getpgid"] - pub fn __syscall_SYS_getpgid(a1: i32) -> ::c_long; + pub fn __syscall_SYS_getpgid(a1: i32) -> c_long; /* 124 */ #[link_name = "SYS_getsid"] - pub fn __syscall_SYS_getsid(a1: i32) -> ::c_long; + pub fn __syscall_SYS_getsid(a1: i32) -> c_long; /* 127 */ #[link_name = "SYS_rt_sigpending"] - pub fn __syscall_SYS_rt_sigpending(a1: i32, a2: u32) -> ::c_long; + pub fn __syscall_SYS_rt_sigpending(a1: i32, a2: u32) -> c_long; /* 130 */ #[link_name = "SYS_rt_sigsuspend"] - pub fn __syscall_SYS_rt_sigsuspend(a1: i32, a2: u32) -> ::c_long; + pub fn __syscall_SYS_rt_sigsuspend(a1: i32, a2: u32) -> c_long; /* 131 */ #[link_name = "SYS_sigaltstack"] - pub fn __syscall_SYS_sigaltstack(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_sigaltstack(a1: i32, a2: i32) -> c_long; /* 132 */ #[link_name = "SYS_utime"] - pub fn __syscall_SYS_utime(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_utime(a1: i32, a2: i32) -> c_long; /* 137 */ #[link_name = "SYS_statfs"] - pub fn __syscall_SYS_statfs(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_statfs(a1: i32, a2: i32) -> c_long; /* 138 */ #[link_name = "SYS_fstatfs"] - pub fn __syscall_SYS_fstatfs(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_fstatfs(a1: i32, a2: i32) -> c_long; /* 157 */ #[link_name = "SYS_prctl"] - pub fn __syscall_SYS_prctl(a1: i32, a2: u64, a3: u64, a4: u64, a5: u64) -> ::c_long; + pub fn __syscall_SYS_prctl(a1: i32, a2: u64, a3: u64, a4: u64, a5: u64) -> c_long; /* 160 */ #[link_name = "SYS_setrlimit"] - pub fn __syscall_SYS_setrlimit(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_setrlimit(a1: i32, a2: i32) -> c_long; /* 161 */ #[link_name = "SYS_chroot"] - pub fn __syscall_SYS_chroot(a1: i32) -> ::c_long; + pub fn __syscall_SYS_chroot(a1: i32) -> c_long; /* 186 */ #[link_name = "SYS_gettid"] - pub fn __syscall_SYS_gettid() -> ::c_long; + pub fn __syscall_SYS_gettid() -> c_long; /* 200 */ #[link_name = "SYS_tkill"] - pub fn __syscall_SYS_tkill(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_tkill(a1: i32, a2: i32) -> c_long; /* 202 */ #[link_name = "SYS_futex"] - pub fn __syscall_SYS_futex(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32, a6: i32) -> ::c_long; + pub fn __syscall_SYS_futex(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32, a6: i32) -> c_long; /* 204 */ #[link_name = "SYS_sched_getaffinity"] - pub fn __syscall_SYS_sched_getaffinity(a1: i32, a2: u32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_sched_getaffinity(a1: i32, a2: u32, a3: i32) -> c_long; /* 217 */ #[link_name = "SYS_getdents64"] - pub fn __syscall_SYS_getdents64(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_getdents64(a1: i32, a2: i32, a3: i32) -> c_long; /* 218 */ #[link_name = "SYS_set_tid_address"] - pub fn __syscall_SYS_set_tid_address(a1: i32) -> ::c_long; + pub fn __syscall_SYS_set_tid_address(a1: i32) -> c_long; /* 221 */ #[link_name = "SYS_fadvise"] - pub fn __syscall_SYS_fadvise(a1: i32, a2: i64, a3: i64, a4: i32) -> ::c_long; + pub fn __syscall_SYS_fadvise(a1: i32, a2: i64, a3: i64, a4: i32) -> c_long; /* 228 */ #[link_name = "SYS_clock_gettime"] - pub fn __syscall_SYS_clock_gettime(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_clock_gettime(a1: i32, a2: i32) -> c_long; /* 229 */ #[link_name = "SYS_clock_getres"] - pub fn __syscall_SYS_clock_getres(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_clock_getres(a1: i32, a2: i32) -> c_long; /* 230 */ #[link_name = "SYS_clock_nanosleep"] - pub fn __syscall_SYS_clock_nanosleep(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_clock_nanosleep(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 231 */ #[link_name = "SYS_exit_group"] - pub fn __syscall_SYS_exit_group(a1: i32) -> ::c_long; + pub fn __syscall_SYS_exit_group(a1: i32) -> c_long; /* 233 */ #[link_name = "SYS_epoll_ctl"] - pub fn __syscall_SYS_epoll_ctl(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_epoll_ctl(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 257 */ #[link_name = "SYS_openat"] - pub fn __syscall_SYS_openat(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_openat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 258 */ #[link_name = "SYS_mkdirat"] - pub fn __syscall_SYS_mkdirat(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_mkdirat(a1: i32, a2: i32, a3: i32) -> c_long; /* 260 */ #[link_name = "SYS_fchownat"] - pub fn __syscall_SYS_fchownat(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_fchownat(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; /* 262 */ #[link_name = "SYS_fstatat"] - pub fn __syscall_SYS_fstatat(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_fstatat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 263 */ #[link_name = "SYS_unlinkat"] - pub fn __syscall_SYS_unlinkat(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_unlinkat(a1: i32, a2: i32, a3: i32) -> c_long; /* 265 */ #[link_name = "SYS_linkat"] - pub fn __syscall_SYS_linkat(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_linkat(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; /* 266 */ #[link_name = "SYS_symlinkat"] - pub fn __syscall_SYS_symlinkat(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_symlinkat(a1: i32, a2: i32, a3: i32) -> c_long; /* 267 */ #[link_name = "SYS_readlinkat"] - pub fn __syscall_SYS_readlinkat(a1: i32, a2: i32, a3: i32, a4: u32) -> ::c_long; + pub fn __syscall_SYS_readlinkat(a1: i32, a2: i32, a3: i32, a4: u32) -> c_long; /* 268 */ #[link_name = "SYS_fchmodat"] - pub fn __syscall_SYS_fchmodat(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_fchmodat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 269 */ #[link_name = "SYS_faccessat"] - pub fn __syscall_SYS_faccessat(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_faccessat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 270 */ #[link_name = "SYS_pselect6"] - pub fn __syscall_SYS_pselect6(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32, a6: i32) - -> ::c_long; + pub fn __syscall_SYS_pselect6(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32, a6: i32) -> c_long; /* 271 */ #[link_name = "SYS_ppoll"] - pub fn __syscall_SYS_ppoll(a1: i32, a2: u32, a3: i32, a4: i32, a5: u32) -> ::c_long; + pub fn __syscall_SYS_ppoll(a1: i32, a2: u32, a3: i32, a4: i32, a5: u32) -> c_long; /* 280 */ #[link_name = "SYS_utimensat"] - pub fn __syscall_SYS_utimensat(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_utimensat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 281 */ #[link_name = "SYS_epoll_pwait"] pub fn __syscall_SYS_epoll_pwait( @@ -404,38 +404,38 @@ extern "C" { a4: i32, a5: i32, a6: u32, - ) -> ::c_long; + ) -> c_long; /* 284 */ #[link_name = "SYS_eventfd"] - pub fn __syscall_SYS_eventfd(a1: i32) -> ::c_long; + pub fn __syscall_SYS_eventfd(a1: i32) -> c_long; /* 288 */ #[link_name = "SYS_accept4"] - pub fn __syscall_SYS_accept4(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_accept4(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 290 */ #[link_name = "SYS_eventfd2"] - pub fn __syscall_SYS_eventfd2(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_eventfd2(a1: i32, a2: i32) -> c_long; /* 291 */ #[link_name = "SYS_epoll_create1"] - pub fn __syscall_SYS_epoll_create1(a1: i32) -> ::c_long; + pub fn __syscall_SYS_epoll_create1(a1: i32) -> c_long; /* 292 */ #[link_name = "SYS_dup3"] - pub fn __syscall_SYS_dup3(a1: i32, a2: i32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_dup3(a1: i32, a2: i32, a3: i32) -> c_long; /* 293 */ #[link_name = "SYS_pipe2"] - pub fn __syscall_SYS_pipe2(a1: i32, a2: i32) -> ::c_long; + pub fn __syscall_SYS_pipe2(a1: i32, a2: i32) -> c_long; /* 302 */ #[link_name = "SYS_prlimit64"] - pub fn __syscall_SYS_prlimit64(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_prlimit64(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; /* 316 */ #[link_name = "SYS_renameat2"] - pub fn __syscall_SYS_renameat2(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_renameat2(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; /* 318 */ #[link_name = "SYS_getrandom"] - pub fn __syscall_SYS_getrandom(a1: i32, a2: u32, a3: i32) -> ::c_long; + pub fn __syscall_SYS_getrandom(a1: i32, a2: u32, a3: i32) -> c_long; /* 332 */ #[link_name = "SYS_statx"] - pub fn __syscall_SYS_statx(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> ::c_long; + pub fn __syscall_SYS_statx(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; /* 439 */ #[link_name = "SYS_faccessat2"] - pub fn __syscall_SYS_faccessat2(a1: i32, a2: i32, a3: i32, a4: i32) -> ::c_long; + pub fn __syscall_SYS_faccessat2(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; } diff --git a/src/unix/linux_like/linux/musl/lfs64.rs b/src/unix/linux_like/linux/musl/lfs64.rs index e6506fd3d385d..4d595fc42d72f 100644 --- a/src/unix/linux_like/linux/musl/lfs64.rs +++ b/src/unix/linux_like/linux/musl/lfs64.rs @@ -117,7 +117,10 @@ pub unsafe extern "C" fn mmap64( // // These aliases are mostly fine though, neither function takes a LFS64-namespaced type as an // argument, nor do their names clash with any declared types. -pub use crate::{open as open64, openat as openat64}; +pub use crate::{ + open as open64, + openat as openat64, +}; #[inline] pub unsafe extern "C" fn posix_fadvise64( diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index fd3fa996caad4..0b1f376233a62 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -8,8 +8,7 @@ pub type timer_t = *mut c_void; pub type key_t = c_int; pub type id_t = c_uint; -missing! { - #[derive(Debug)] +extern_ty! { pub enum timezone {} } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 6ba5d87de7ca0..0de47f4e92b8e 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -37,10 +37,11 @@ cfg_if! { } } -missing! { - #[derive(Debug)] +extern_ty! { pub enum DIR {} } + +#[cfg(not(target_os = "nuttx"))] pub type locale_t = *mut c_void; s! { @@ -68,7 +69,7 @@ s! { // linux x32 compatibility // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 - #[cfg(not(target_env = "gnu"))] + #[cfg(all(not(target_env = "gnu"), not(target_os = "aix")))] pub struct timespec { pub tv_sec: time_t, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] @@ -132,6 +133,7 @@ s! { __reserved: [c_long; 16], } + #[cfg(not(target_os = "nuttx"))] pub struct ipv6_mreq { pub ipv6mr_multiaddr: in6_addr, #[cfg(target_os = "android")] @@ -567,15 +569,13 @@ cfg_if! { cfg_if! { if #[cfg(not(all(target_os = "linux", target_env = "gnu")))] { - missing! { - #[derive(Debug)] + extern_ty! { pub enum fpos_t {} // FIXME(unix): fill this out with a struct } } } -missing! { - #[derive(Debug)] +extern_ty! { pub enum FILE {} } @@ -1466,6 +1466,7 @@ extern "C" { link_name = "mknod@FBSD_1.0" )] pub fn mknod(pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int; + #[cfg(not(target_os = "espidf"))] pub fn gethostname(name: *mut c_char, len: size_t) -> c_int; pub fn endservent(); pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent; @@ -1825,18 +1826,31 @@ cfg_if! { } cfg_if! { - if #[cfg(target_os = "aix")] { + if #[cfg(any(target_os = "aix", target_os = "nto"))] { extern "C" { pub fn cfmakeraw(termios: *mut crate::termios) -> c_int; + } + } else if #[cfg(not(any(target_os = "solaris", target_os = "illumos",)))] { + extern "C" { + pub fn cfmakeraw(termios: *mut crate::termios); + } + } +} + +cfg_if! { + if #[cfg(any( + target_os = "aix", + all(target_os = "nto", target_env = "nto80") + ))] { + extern "C" { 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", + target_os = "nto" )))] { extern "C" { - pub fn cfmakeraw(termios: *mut crate::termios); pub fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; } } diff --git a/src/unix/newlib/aarch64/mod.rs b/src/unix/newlib/aarch64/mod.rs index e4640580e2478..56c268fc5f2bb 100644 --- a/src/unix/newlib/aarch64/mod.rs +++ b/src/unix/newlib/aarch64/mod.rs @@ -49,4 +49,8 @@ pub const MSG_WAITALL: c_int = 0; pub const MSG_MORE: c_int = 0; pub const MSG_NOSIGNAL: c_int = 0; -pub use crate::unix::newlib::generic::{dirent, sigset_t, stat}; +pub use crate::unix::newlib::generic::{ + dirent, + sigset_t, + stat, +}; diff --git a/src/unix/newlib/arm/mod.rs b/src/unix/newlib/arm/mod.rs index aea4ed764b03c..26f3d52436b84 100644 --- a/src/unix/newlib/arm/mod.rs +++ b/src/unix/newlib/arm/mod.rs @@ -51,4 +51,8 @@ pub const MSG_WAITALL: c_int = 0; pub const MSG_MORE: c_int = 0; pub const MSG_NOSIGNAL: c_int = 0; -pub use crate::unix::newlib::generic::{dirent, sigset_t, stat}; +pub use crate::unix::newlib::generic::{ + dirent, + sigset_t, + stat, +}; diff --git a/src/unix/newlib/espidf/mod.rs b/src/unix/newlib/espidf/mod.rs index 57a033fcaf263..9bec89a7d78d4 100644 --- a/src/unix/newlib/espidf/mod.rs +++ b/src/unix/newlib/espidf/mod.rs @@ -117,4 +117,8 @@ extern "C" { pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; } -pub use crate::unix::newlib::generic::{dirent, sigset_t, stat}; +pub use crate::unix::newlib::generic::{ + dirent, + sigset_t, + stat, +}; diff --git a/src/unix/newlib/powerpc/mod.rs b/src/unix/newlib/powerpc/mod.rs index c4d4a2ed07c5e..f51a1b2cbe602 100644 --- a/src/unix/newlib/powerpc/mod.rs +++ b/src/unix/newlib/powerpc/mod.rs @@ -3,7 +3,11 @@ use crate::prelude::*; pub type clock_t = c_ulong; pub type wchar_t = c_int; -pub use crate::unix::newlib::generic::{dirent, sigset_t, stat}; +pub use crate::unix::newlib::generic::{ + dirent, + sigset_t, + stat, +}; // the newlib shipped with devkitPPC does not support the following components: // - sockaddr diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index 75f5b56902f7f..a81c210c80cf3 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -72,13 +72,8 @@ pub type sem_t = sync_t; pub type nl_item = c_int; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum timezone {} } s! { diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index 3d3e2c3448841..fe7c6ecb3007a 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -1,5 +1,10 @@ use crate::prelude::*; -use crate::{in6_addr, in_addr_t, timespec, DIR}; +use crate::{ + in6_addr, + in_addr_t, + timespec, + DIR, +}; pub type nlink_t = u16; pub type ino_t = u16; @@ -231,11 +236,6 @@ s! { pub ipv6mr_multiaddr: in6_addr, pub ipv6mr_interface: u32, } - - pub struct timeval { - pub tv_sec: time_t, - pub tv_usec: suseconds_t, - } } // Reserved two pointer size for reserved area for some structures. @@ -523,7 +523,6 @@ pub const SIGQUIT: c_int = 3; pub const SIGILL: c_int = 4; pub const SIGTRAP: c_int = 5; pub const SIGABRT: c_int = 6; -pub const SIGIOT: c_int = 6; pub const SIGBUS: c_int = 7; pub const SIGFPE: c_int = 8; pub const SIGKILL: c_int = 9; diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 50bdaf4d4f06b..55a8c15a234e2 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -32,13 +32,8 @@ pub type pid_t = usize; pub type uid_t = c_int; pub type gid_t = c_int; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } +extern_ty! { + pub enum timezone {} } s_no_extra_traits! { @@ -1186,6 +1181,18 @@ extern "C" { // unistd.h pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; pub fn getdtablesize() -> c_int; + pub fn getresgid( + rgid: *mut crate::gid_t, + egid: *mut crate::gid_t, + sgid: *mut crate::gid_t, + ) -> c_int; + pub fn getresuid( + ruid: *mut crate::uid_t, + euid: *mut crate::uid_t, + suid: *mut crate::uid_t, + ) -> c_int; + pub fn setresgid(rgid: crate::gid_t, egid: crate::gid_t, sgid: crate::gid_t) -> c_int; + pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int; // grp.h pub fn getgrent() -> *mut crate::group; diff --git a/src/unix/solarish/compat.rs b/src/unix/solarish/compat.rs index 22bcf12edcc82..6876a9d8fd319 100644 --- a/src/unix/solarish/compat.rs +++ b/src/unix/solarish/compat.rs @@ -3,7 +3,11 @@ use core::cmp::min; use crate::unix::solarish::*; -use crate::{c_char, c_int, size_t}; +use crate::{ + c_char, + c_int, + size_t, +}; pub unsafe fn cfmakeraw(termios: *mut crate::termios) { (*termios).c_iflag &= diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs index fbeadaf344fa0..42aa5731f9aaa 100644 --- a/src/unix/solarish/illumos.rs +++ b/src/unix/solarish/illumos.rs @@ -1,7 +1,13 @@ use crate::prelude::*; use crate::{ - exit_status, off_t, NET_MAC_AWARE, NET_MAC_AWARE_INHERIT, PRIV_AWARE_RESET, PRIV_DEBUG, - PRIV_PFEXEC, PRIV_XPOLICY, + exit_status, + off_t, + NET_MAC_AWARE, + NET_MAC_AWARE_INHERIT, + PRIV_AWARE_RESET, + PRIV_DEBUG, + PRIV_PFEXEC, + PRIV_XPOLICY, }; pub type lgrp_rsrc_t = c_int; diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index d8b32dfc0aae9..f78b09a3db63a 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -55,22 +55,9 @@ pub type lgrp_view_t = c_uint; pub type posix_spawnattr_t = *mut c_void; pub type posix_spawn_file_actions_t = *mut c_void; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } -} - -#[derive(Debug)] -pub enum ucred_t {} -impl Copy for ucred_t {} -impl Clone for ucred_t { - fn clone(&self) -> ucred_t { - *self - } +extern_ty! { + pub enum timezone {} + pub enum ucred_t {} } s! { diff --git a/src/unix/solarish/solaris.rs b/src/unix/solarish/solaris.rs index 58b097a16269b..c23ec5109cb9c 100644 --- a/src/unix/solarish/solaris.rs +++ b/src/unix/solarish/solaris.rs @@ -1,7 +1,14 @@ use crate::prelude::*; use crate::{ - exit_status, off_t, termios, NET_MAC_AWARE, NET_MAC_AWARE_INHERIT, PRIV_AWARE_RESET, - PRIV_DEBUG, PRIV_PFEXEC, PRIV_XPOLICY, + exit_status, + off_t, + termios, + NET_MAC_AWARE, + NET_MAC_AWARE_INHERIT, + PRIV_AWARE_RESET, + PRIV_DEBUG, + PRIV_PFEXEC, + PRIV_XPOLICY, }; pub type door_attr_t = c_uint; diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 809640d112221..ce6c91678caf4 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -4,13 +4,8 @@ use core::ptr::null_mut; use crate::prelude::*; -#[derive(Debug)] -pub enum DIR {} -impl Copy for DIR {} -impl Clone for DIR { - fn clone(&self) -> DIR { - *self - } +extern_ty! { + pub enum DIR {} } pub type intmax_t = i64; @@ -95,13 +90,8 @@ pub type sa_family_t = c_uchar; // mqueue.h pub type mqd_t = c_int; -#[derive(Debug)] -pub enum _Vx_semaphore {} -impl Copy for _Vx_semaphore {} -impl Clone for _Vx_semaphore { - fn clone(&self) -> _Vx_semaphore { - *self - } +extern_ty! { + pub enum _Vx_semaphore {} } impl siginfo_t { @@ -1054,21 +1044,9 @@ pub const MAP_CONTIG: c_int = 0x0020; pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; -#[derive(Debug)] -pub enum FILE {} -impl Copy for FILE {} -impl Clone for FILE { - fn clone(&self) -> FILE { - *self - } -} -#[derive(Debug)] -pub enum fpos_t {} // FIXME(vxworks): fill this out with a struct -impl Copy for fpos_t {} -impl Clone for fpos_t { - fn clone(&self) -> fpos_t { - *self - } +extern_ty! { + pub enum FILE {} + pub enum fpos_t {} // FIXME(vxworks): fill this out with a struct } f! { diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index bb3b729548780..d6979dd857318 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -33,6 +33,10 @@ pub type wchar_t = i32; pub type nl_item = c_int; pub type __wasi_rights_t = u64; pub type locale_t = *mut __locale_struct; +pub type pthread_t = *mut c_void; +pub type pthread_once_t = c_int; +pub type pthread_key_t = c_uint; +pub type pthread_spinlock_t = c_int; s_no_extra_traits! { #[repr(align(16))] @@ -170,6 +174,42 @@ s! { __nfds: usize, __fds: [c_int; FD_SETSIZE as usize], } + + pub struct pthread_attr_t { + size: [c_long; 9], + } + + pub struct pthread_mutexattr_t { + __attr: c_uint, + } + + pub struct pthread_condattr_t { + __attr: c_uint, + } + + pub struct pthread_barrierattr_t { + __attr: c_uint, + } + + pub struct pthread_rwlockattr_t { + __attr: [c_uint; 2], + } + + pub struct pthread_cond_t { + size: [*mut c_void; 12], + } + + pub struct pthread_mutex_t { + size: [*mut c_void; 6], + } + + pub struct pthread_rwlock_t { + size: [*mut c_void; 8], + } + + pub struct pthread_barrier_t { + size: [*mut c_void; 5], + } } // Declare dirent outside of s! so that it doesn't implement Copy, Eq, Hash, @@ -262,7 +302,9 @@ pub const DT_BLK: u8 = 1; pub const DT_CHR: u8 = 2; pub const DT_DIR: u8 = 3; pub const DT_REG: u8 = 4; +pub const DT_FIFO: u8 = 6; pub const DT_LNK: u8 = 7; +pub const DT_SOCK: u8 = 20; pub const FIONREAD: c_int = 1; pub const FIONBIO: c_int = 2; pub const F_OK: c_int = 0; @@ -438,6 +480,9 @@ pub const NOEXPR: crate::nl_item = 0x50001; pub const YESSTR: crate::nl_item = 0x50002; pub const NOSTR: crate::nl_item = 0x50003; +pub const PTHREAD_STACK_MIN: usize = 2048; +pub const TIMER_ABSTIME: c_int = 1; + f! { pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { let set = &*set; @@ -843,6 +888,72 @@ extern "C" { pub fn arc4random_uniform(a: u32) -> u32; pub fn __errno_location() -> *mut c_int; + + pub fn chmod(path: *const c_char, mode: mode_t) -> c_int; + pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; + pub fn realpath(pathname: *const c_char, resolved: *mut c_char) -> *mut c_char; + + pub fn pthread_self() -> pthread_t; + pub fn pthread_create( + native: *mut pthread_t, + attr: *const pthread_attr_t, + f: extern "C" fn(*mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + pub fn pthread_equal(t1: pthread_t, t2: pthread_t) -> c_int; + pub fn pthread_join(native: pthread_t, value: *mut *mut c_void) -> c_int; + pub fn pthread_attr_init(attr: *mut pthread_attr_t) -> c_int; + pub fn pthread_attr_destroy(attr: *mut pthread_attr_t) -> c_int; + pub fn pthread_attr_getstacksize(attr: *const pthread_attr_t, stacksize: *mut size_t) -> c_int; + pub fn pthread_attr_setstacksize(attr: *mut pthread_attr_t, stack_size: size_t) -> c_int; + pub fn pthread_attr_setdetachstate(attr: *mut pthread_attr_t, state: c_int) -> c_int; + pub fn pthread_detach(thread: pthread_t) -> c_int; + + pub fn pthread_key_create( + key: *mut pthread_key_t, + dtor: Option, + ) -> c_int; + pub fn pthread_key_delete(key: pthread_key_t) -> c_int; + pub fn pthread_getspecific(key: pthread_key_t) -> *mut c_void; + pub fn pthread_setspecific(key: pthread_key_t, value: *const c_void) -> c_int; + pub fn pthread_mutex_init( + lock: *mut pthread_mutex_t, + attr: *const pthread_mutexattr_t, + ) -> c_int; + pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> c_int; + + pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> c_int; + pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> c_int; + pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, _type: c_int) -> c_int; + + pub fn pthread_cond_init(cond: *mut pthread_cond_t, attr: *const pthread_condattr_t) -> c_int; + pub fn pthread_cond_wait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_cond_timedwait( + cond: *mut pthread_cond_t, + lock: *mut pthread_mutex_t, + abstime: *const timespec, + ) -> c_int; + pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> c_int; + pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> c_int; + pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> c_int; + pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> c_int; + pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> c_int; + + pub fn pthread_rwlock_init( + lock: *mut pthread_rwlock_t, + attr: *const pthread_rwlockattr_t, + ) -> c_int; + pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> c_int; + pub fn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t) -> c_int; } cfg_if! { diff --git a/src/windows/gnu/mod.rs b/src/windows/gnu/mod.rs index aee2c1efed108..7ea6a933c8e85 100644 --- a/src/windows/gnu/mod.rs +++ b/src/windows/gnu/mod.rs @@ -18,9 +18,6 @@ cfg_if! { } } -pub const L_tmpnam: c_uint = 14; -pub const TMP_MAX: c_uint = 0x7fff; - // stdio file descriptor numbers pub const STDIN_FILENO: c_int = 0; pub const STDOUT_FILENO: c_int = 1; diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 2f35af84c7493..775be13bac91c 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -29,14 +29,11 @@ cfg_if! { pub type off_t = i32; pub type dev_t = u32; pub type ino_t = u16; -#[derive(Debug)] -pub enum timezone {} -impl Copy for timezone {} -impl Clone for timezone { - fn clone(&self) -> timezone { - *self - } + +extern_ty! { + pub enum timezone {} } + pub type time64_t = i64; pub type SOCKET = crate::uintptr_t; @@ -243,6 +240,9 @@ pub const SIG_GET: crate::sighandler_t = 2; pub const SIG_SGE: crate::sighandler_t = 3; pub const SIG_ACK: crate::sighandler_t = 4; +pub const L_tmpnam: c_uint = 260; +pub const TMP_MAX: c_uint = 0x7fff_ffff; + // DIFF(main): removed in 458c58f409 // FIXME(msrv): done by `std` starting in 1.79.0 // inline comment below appeases style checker @@ -251,21 +251,9 @@ pub const SIG_ACK: crate::sighandler_t = 4; #[link(name = "libcmt", cfg(target_feature = "crt-static"))] extern "C" {} -#[derive(Debug)] -pub enum FILE {} -impl Copy for FILE {} -impl Clone for FILE { - fn clone(&self) -> FILE { - *self - } -} -#[derive(Debug)] -pub enum fpos_t {} // FIXME(windows): fill this out with a struct -impl Copy for fpos_t {} -impl Clone for fpos_t { - fn clone(&self) -> fpos_t { - *self - } +extern_ty! { + pub enum FILE {} + pub enum fpos_t {} // FIXME(windows): fill this out with a struct } // Special handling for all print and scan type functions because of https://github.com/rust-lang/libc/issues/2860 diff --git a/src/windows/msvc/mod.rs b/src/windows/msvc/mod.rs index 5b620bc6c1afa..967df8c57f8bd 100644 --- a/src/windows/msvc/mod.rs +++ b/src/windows/msvc/mod.rs @@ -1,8 +1,5 @@ use crate::prelude::*; -pub const L_tmpnam: c_uint = 260; -pub const TMP_MAX: c_uint = 0x7fff_ffff; - // POSIX Supplement (from errno.h) // This particular error code is only currently available in msvc toolchain pub const EOTHER: c_int = 131; diff --git a/triagebot.toml b/triagebot.toml index 6a6dfccd18e21..7e8f309b40c67 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -18,6 +18,11 @@ check-commits = false # don't forbid links to issues # Prevents mentions in commits to avoid users being spammed [no-mentions] +# Enable comments linking to triagebot range-diff when a PR is rebased +# onto a different base commit +# Documentation at: https://forge.rust-lang.org/triagebot/range-diff.html +[range-diff] + [autolabel."A-CI"] trigger_files = [ ".cirrus.yml", @@ -29,7 +34,10 @@ trigger_files = [ new_pr = true [autolabel."O-android"] -trigger_files = ["src/unix/linux_like/android"] +trigger_files = [ + "src/new/bionic_libc", + "src/unix/linux_like/android", +] [autolabel."O-arm"] trigger_files = [ @@ -70,7 +78,11 @@ trigger_files = [ trigger_files = ["src/unix/linux_like/mod.rs"] [autolabel."O-macos"] -trigger_files = ["src/unix/bsd/apple"] +trigger_files = [ + "src/unix/bsd/apple", + "src/new/apple_lib", + "src/new/apple_xnu", +] [autolabel."O-mips"] trigger_files = [