diff --git a/.cirrus.yml b/.cirrus.yml index 3a42cc356c255..e428871c41b84 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,11 +1,11 @@ task: - name: nightly x86_64-unknown-freebsd-12 + name: nightly x86_64-unknown-freebsd-13 freebsd_instance: - image_family: freebsd-12-4 + image_family: freebsd-13-2 setup_script: - pkg install -y libnghttp2 curl - curl https://sh.rustup.rs -sSf --output rustup.sh - - sh rustup.sh --default-toolchain nightly -y --profile=minimal + - sh rustup.sh -y --default-toolchain nightly --profile=minimal - . $HOME/.cargo/env test_script: - . $HOME/.cargo/env @@ -13,9 +13,9 @@ task: - sh ci/run.sh x86_64-unknown-freebsd task: - name: nightly x86_64-unknown-freebsd-13 + name: nightly x86_64-unknown-freebsd-14 freebsd_instance: - image_family: freebsd-13-2 + image: freebsd-14-0-release-amd64-ufs setup_script: - pkg install -y libnghttp2 curl - curl https://sh.rustup.rs -sSf --output rustup.sh @@ -27,9 +27,9 @@ task: - sh ci/run.sh x86_64-unknown-freebsd task: - name: nightly x86_64-unknown-freebsd-14 + name: nightly x86_64-unknown-freebsd-15 freebsd_instance: - image: freebsd-14-0-rc1-amd64 + image_family: freebsd-15-0-snap setup_script: - pkg install -y libnghttp2 curl - curl https://sh.rustup.rs -sSf --output rustup.sh diff --git a/.github/workflows/bors.yml b/.github/workflows/bors.yml index 77f236c033e07..6ecf7c83ffe74 100644 --- a/.github/workflows/bors.yml +++ b/.github/workflows/bors.yml @@ -73,12 +73,10 @@ jobs: ARCH_BITS: 64 ARCH: x86_64 - target: x86_64-pc-windows-msvc - # Disabled because broken: - # https://github.com/rust-lang/libc/issues/1592 - #- target: i686-pc-windows-gnu - # env: - # ARCH_BITS: 32 - # ARCH: i686 + - target: i686-pc-windows-gnu + env: + ARCH_BITS: 32 + ARCH: i686 - target: i686-pc-windows-msvc steps: - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@HEAD diff --git a/.github/workflows/full_ci.yml b/.github/workflows/full_ci.yml new file mode 100644 index 0000000000000..a83375753f8cf --- /dev/null +++ b/.github/workflows/full_ci.yml @@ -0,0 +1,322 @@ +name: full CI + +on: + merge_group: + pull_request: + branches: + - libc-0.2 + types: + - labeled + +jobs: + docker_linux_tier1: + if: github.event.label.name == 'libc-0.2-pre-merge-ci' + permissions: + contents: read # to fetch code (actions/checkout) + + name: Docker Linux Tier1 + runs-on: ubuntu-22.04 + strategy: + fail-fast: true + matrix: + target: [ + i686-unknown-linux-gnu, + x86_64-unknown-linux-gnu, + ] + steps: + - uses: actions/checkout@v4 + - name: Setup Rust toolchain + run: TARGET=${{ matrix.target }} sh ./ci/install-rust.sh + - name: Execute run-docker.sh + run: LIBC_CI=1 sh ./ci/run-docker.sh ${{ matrix.target }} + + macos: + if: github.event.label.name == 'libc-0.2-pre-merge-ci' + permissions: + contents: read # to fetch code (actions/checkout) + + name: macOS + runs-on: macos-13 + strategy: + fail-fast: true + matrix: + target: [ + x86_64-apple-darwin, + ] + steps: + - uses: actions/checkout@v4 + - name: Setup Rust toolchain + run: TARGET=${{ matrix.target }} sh ./ci/install-rust.sh + - name: Execute run.sh + run: LIBC_CI=1 sh ./ci/run.sh ${{ matrix.target }} + + windows: + if: github.event.label.name == 'libc-0.2-pre-merge-ci' + permissions: + contents: read # to fetch code (actions/checkout) + + name: Windows + runs-on: windows-2022 + env: + OS: windows + strategy: + fail-fast: true + matrix: + include: + - target: x86_64-pc-windows-gnu + env: + ARCH_BITS: 64 + ARCH: x86_64 + - target: x86_64-pc-windows-msvc + - target: i686-pc-windows-gnu + env: + ARCH_BITS: 32 + ARCH: i686 + - target: i686-pc-windows-msvc + steps: + - uses: actions/checkout@v4 + - name: Self-update rustup + run: rustup self update + shell: bash + - name: Setup Rust toolchain + run: TARGET=${{ matrix.target }} sh ./ci/install-rust.sh + shell: bash + - name: Execute run.sh + run: LIBC_CI=1 sh ./ci/run.sh ${{ matrix.target }} + shell: bash + + style_check: + if: github.event.label.name == 'libc-0.2-pre-merge-ci' + permissions: + contents: read # to fetch code (actions/checkout) + + name: Style check + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: Setup Rust toolchain + run: sh ./ci/install-rust.sh + - name: Check style + run: sh ci/style.sh + + docker_linux_tier2: + if: github.event.label.name == 'libc-0.2-pre-merge-ci' + permissions: + contents: read # to fetch code (actions/checkout) + + name: Docker Linux Tier2 + needs: [docker_linux_tier1, style_check] + runs-on: ubuntu-22.04 + strategy: + fail-fast: true + max-parallel: 12 + matrix: + target: [ + aarch64-linux-android, + aarch64-unknown-linux-gnu, + aarch64-unknown-linux-musl, + arm-linux-androideabi, + arm-unknown-linux-gnueabihf, + arm-unknown-linux-musleabihf, + i686-linux-android, + i686-unknown-linux-musl, + powerpc-unknown-linux-gnu, + powerpc64-unknown-linux-gnu, + powerpc64le-unknown-linux-gnu, + s390x-unknown-linux-gnu, + riscv64gc-unknown-linux-gnu, + # FIXME: A recent nightly causes a linker failure: + # https://github.com/rust-lang/rust/issues/76679 + # See this comment for more details: + # https://github.com/rust-lang/libc/pull/2225#issuecomment-880696737 + #wasm32-wasi, + sparc64-unknown-linux-gnu, + wasm32-unknown-emscripten, + x86_64-linux-android, + # FIXME: Exec format error (os error 8) + #x86_64-unknown-linux-gnux32, + x86_64-unknown-linux-musl, + # FIXME: It seems some items in `src/unix/mod.rs` + # aren't defined on redox actually. + # x86_64-unknown-redox, + ] + steps: + - uses: actions/checkout@v4 + - name: Setup Rust toolchain + run: TARGET=${{ matrix.target }} sh ./ci/install-rust.sh + - name: Execute run-docker.sh + run: LIBC_CI=1 sh ./ci/run-docker.sh ${{ matrix.target }} + + # These targets are tier 3 or otherwise need to have CI build std via -Zbuild-std. + # Because of this, only the nightly compiler can be used on these targets. + docker_linux_build_std: + permissions: + contents: read # to fetch code (actions/checkout) + + if: ${{ false }} # This is currently broken + name: Docker Linux Build-Std Targets + needs: [docker_linux_tier1, style_check] + runs-on: ubuntu-22.04 + strategy: + fail-fast: true + max-parallel: 12 + matrix: + target: [ + armv7-unknown-linux-uclibceabihf + ] + steps: + - uses: actions/checkout@v4 + - name: Setup Rust toolchain + run: TOOLCHAIN=nightly INSTALL_RUST_SRC=1 sh ./ci/install-rust.sh + - name: Execute run-docker.sh + run: LIBC_CI=1 TOOLCHAIN=nightly LIBC_CI_ZBUILD_STD=1 sh ./ci/run-docker.sh ${{ matrix.target }} + + # devkitpro's pacman needs to be connected from Docker. + docker_switch: + if: github.event.label.name == 'libc-0.2-pre-merge-ci' + permissions: + contents: read # to fetch code (actions/checkout) + + name: Docker Switch + needs: [docker_linux_tier1, style_check] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: Setup Rust toolchain + run: sh ./ci/install-rust.sh + - name: Execute run-docker.sh + run: LIBC_CI=1 sh ./ci/run-docker.sh switch + + build_channels_linux: + if: github.event.label.name == 'libc-0.2-pre-merge-ci' + permissions: + contents: read # to fetch code (actions/checkout) + + name: Build Channels Linux + needs: docker_linux_tier2 + runs-on: ubuntu-22.04 + env: + OS: linux + strategy: + fail-fast: true + max-parallel: 5 + matrix: + toolchain: [ + stable, + beta, + nightly, + # FIXME: Disabled due to: + # error: failed to parse registry's information for: serde + #1.13.0, + 1.19.0, + 1.24.0, + 1.25.0, + 1.30.0, + ] + steps: + - uses: actions/checkout@v4 + - name: Setup Rust toolchain + run: TOOLCHAIN=${{ matrix.toolchain }} sh ./ci/install-rust.sh + - name: Execute build.sh + run: LIBC_CI=1 TOOLCHAIN=${{ matrix.toolchain }} sh ./ci/build.sh + + build_channels_macos: + if: github.event.label.name == 'libc-0.2-pre-merge-ci' + permissions: + contents: read # to fetch code (actions/checkout) + + name: Build Channels macOS + needs: macos + env: + OS: macos + strategy: + fail-fast: true + max-parallel: 4 + matrix: + target: + - { toolchain: stable, os: macos-13 } + - { toolchain: beta, os: macos-13 } + - { toolchain: nightly, os: macos-13 } + # Use macOS 11 for older toolchains as newer Xcode donesn't work well. + # FIXME: Disabled due to: + # error: failed to parse registry's information for: serde + #- { toolchain: 1.13.0, os: macos-11 } + - { toolchain: 1.19.0, os: macos-11 } + - { toolchain: 1.24.0, os: macos-11 } + - { toolchain: 1.25.0, os: macos-11 } + - { toolchain: 1.30.0, os: macos-11 } + runs-on: ${{ matrix.target.os }} + steps: + - uses: actions/checkout@v4 + - name: Setup Rust toolchain + run: TOOLCHAIN=${{ matrix.target.toolchain }} sh ./ci/install-rust.sh + - name: Execute build.sh + run: LIBC_CI=1 TOOLCHAIN=${{ matrix.target.toolchain }} sh ./ci/build.sh + + build_channels_windows: + if: github.event.label.name == 'libc-0.2-pre-merge-ci' + permissions: + contents: read # to fetch code (actions/checkout) + + name: Build Channels Windows + runs-on: windows-2022 + env: + OS: windows + strategy: + fail-fast: true + matrix: + toolchain: [ + 1.19.0, + 1.24.0, + 1.25.0, + 1.30.0, + stable, + ] + steps: + - uses: actions/checkout@v4 + - name: Self-update rustup + run: rustup self update + shell: bash + - name: Execute build.sh + run: LIBC_CI=1 TOOLCHAIN=${{ matrix.toolchain }} sh ./ci/build.sh + shell: bash + + check_cfg: + if: github.event.label.name == 'libc-0.2-pre-merge-ci' + permissions: + contents: read # to fetch code (actions/checkout) + + name: "Check #[cfg]s" + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: Setup Rust toolchain + run: TOOLCHAIN=nightly sh ./ci/install-rust.sh + - name: Build with check-cfg + run: LIBC_CI=1 LIBC_CHECK_CFG=1 cargo build -Z unstable-options -Z check-cfg + + # One job that "summarizes" the success state of this pipeline. This can then be added to branch + # protection, rather than having to add each job separately. + success: + name: Success + runs-on: ubuntu-22.04 + needs: [ + docker_linux_tier1, + docker_linux_tier2, + #docker_linux_build_std, + macos, + windows, + style_check, + docker_switch, + build_channels_linux, + build_channels_macos, + build_channels_windows, + ] + # Github branch protection is exceedingly silly and treats "jobs skipped because a dependency + # failed" as success. So we have to do some contortions to ensure the job fails if any of its + # dependencies fails. + if: always() # make sure this is never "skipped" + steps: + # Manually check the status of all dependencies. `if: failure()` does not work. + - name: check if any dependency failed + run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eaf4ffec2ad3c..c7784fc117df9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -58,12 +58,10 @@ jobs: ARCH_BITS: 64 ARCH: x86_64 - target: x86_64-pc-windows-msvc - # Disabled because broken: - # https://github.com/rust-lang/libc/issues/1592 - #- target: i686-pc-windows-gnu - # env: - # ARCH_BITS: 32 - # ARCH: i686 + - target: i686-pc-windows-gnu + env: + ARCH_BITS: 32 + ARCH: i686 - target: i686-pc-windows-msvc steps: - uses: actions/checkout@v4 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d487162a5fd5d..b6f41cc6de85e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,6 +3,13 @@ Welcome! If you are reading this document, it means you are interested in contributing to the `libc` crate. +## v0.2 changes + +If you want to add your changes to v0.2, please submit them to the `libc-0.2` branch. +If you want to add any breaking changes, it should be submitted to the main branch, +which has changes for v0.3. +We will support and make a new release for v0.2 until we make the first release of v0.3. + ## Adding an API Want to use an API which currently isn't bound in `libc`? It's quite easy to add diff --git a/Cargo.toml b/Cargo.toml index dff98cfbc9796..f591205272b9d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libc" -version = "0.2.151" +version = "0.2.152" authors = ["The Rust Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" diff --git a/README.md b/README.md index 29d2a4b6160f7..395b94ce0c8f3 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,15 @@ More detailed information about the design of this library can be found in its [rfc]: https://github.com/rust-lang/rfcs/blob/HEAD/text/1291-promote-libc.md +## v0.3 Roadmap + +The main branch is now for v0.3 which has some breaking changes. + +For v0.2, please submit PRs to the `libc-0.2` branch instead. +We will stop making new v0.2 releases once we release v0.3 on crates.io. + +See the [tracking issue](https://github.com/rust-lang/libc/issues/3248) for details. + ## Usage Add the following to your `Cargo.toml`: diff --git a/build.rs b/build.rs index ee99981881c04..ec932007ae69f 100644 --- a/build.rs +++ b/build.rs @@ -13,6 +13,7 @@ const ALLOWED_CFGS: &'static [&'static str] = &[ "freebsd12", "freebsd13", "freebsd14", + "freebsd15", "libc_align", "libc_cfg_target_vendor", "libc_const_extern_fn", @@ -70,6 +71,7 @@ fn main() { Some(12) if libc_ci || rustc_dep_of_std => set_cfg("freebsd12"), Some(13) if libc_ci => set_cfg("freebsd13"), Some(14) if libc_ci => set_cfg("freebsd14"), + Some(15) if libc_ci => set_cfg("freebsd15"), Some(_) | None => set_cfg("freebsd11"), } @@ -252,6 +254,7 @@ fn which_freebsd() -> Option { s if s.starts_with("12") => Some(12), s if s.starts_with("13") => Some(13), s if s.starts_with("14") => Some(14), + s if s.starts_with("15") => Some(15), _ => None, } } @@ -274,7 +277,10 @@ fn emcc_version_code() -> Option { return None; } let version = stdout.unwrap(); - let mut pieces = version.trim().split('.'); + + // Some Emscripten versions come with `-git` attached, so split the + // version string also on the `-` char. + let mut pieces = version.trim().split(|c| c == '.' || c == '-'); let major = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); let minor = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index d09d3802ad72c..e715a98391fce 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libc-test" -version = "0.2.151" +version = "0.2.152" authors = ["The Rust Project Developers"] license = "MIT OR Apache-2.0" build = "build.rs" @@ -12,12 +12,11 @@ A test crate for the libc crate. [dependencies.libc] path = ".." -version = "0.2.151" +version = "0.2.152" default-features = false [build-dependencies] -# FIXME: 1.0.84 has a bug about macOS version detection. -cc = "=1.0.83" +cc = "1.0.83" # FIXME: Use fork ctest until the maintainer gets back. ctest2 = "0.4.3" diff --git a/libc-test/build.rs b/libc-test/build.rs index cb28758ad507f..1b65d65f95ec9 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -309,6 +309,9 @@ fn test_apple(target: &str) { // FIXME: The size is changed in recent macOSes. "malloc_zone_t" => true, + // it is a moving target, changing through versions + // also contains bitfields members + "tcp_connection_info" => true, _ => false, } @@ -478,6 +481,7 @@ fn test_openbsd(target: &str) { "pthread.h", "dlfcn.h", "search.h", + "spawn.h", "signal.h", "string.h", "sys/file.h", @@ -565,6 +569,10 @@ fn test_openbsd(target: &str) { // Available for openBSD 7.3 "mimmutable" => true, + // Removed in OpenBSD 7.5 + // https://marc.info/?l=openbsd-cvs&m=170239504300386 + "syscall" => true, + _ => false, } }); @@ -614,6 +622,7 @@ fn test_openbsd(target: &str) { fn test_windows(target: &str) { assert!(target.contains("windows")); let gnu = target.contains("gnu"); + let i686 = target.contains("i686"); let mut cfg = ctest_cfg(); if target.contains("msvc") { @@ -680,6 +689,8 @@ fn test_windows(target: &str) { cfg.skip_type(move |name| match name { "SSIZE_T" if !gnu => true, "ssize_t" if !gnu => true, + // FIXME: The size and alignment of this type are incorrect + "time_t" if gnu && i686 => true, _ => false, }); @@ -687,7 +698,11 @@ fn test_windows(target: &str) { if ty.starts_with("__c_anonymous_") { return true; } - return false; + match ty { + // FIXME: The size and alignment of this struct are incorrect + "timespec" if gnu && i686 => true, + _ => false, + } }); cfg.skip_const(move |name| { @@ -1968,21 +1983,6 @@ fn test_android(target: &str) { (struct_ == "flock64" && (field == "l_start" || field == "l_len")) }); - cfg.skip_field(move |struct_, field| { - // this is actually a union on linux, so we can't represent it well and - // just insert some padding. - (struct_ == "siginfo_t" && field == "_pad") || - // FIXME: `sa_sigaction` has type `sighandler_t` but that type is - // incorrect, see: https://github.com/rust-lang/libc/issues/1359 - (struct_ == "sigaction" && field == "sa_sigaction") || - // sigev_notify_thread_id is actually part of a sigev_un union - (struct_ == "sigevent" && field == "sigev_notify_thread_id") || - // signalfd had SIGSYS fields added in Android 4.19, but CI does not have that version yet. - (struct_ == "signalfd_siginfo" && (field == "ssi_syscall" || - field == "ssi_call_addr" || - field == "ssi_arch")) - }); - cfg.skip_field(|struct_, field| { match (struct_, field) { // conflicting with `p_type` macro from . @@ -1992,6 +1992,8 @@ fn test_android(target: &str) { // this is actually a union on linux, so we can't represent it well and // just insert some padding. ("siginfo_t", "_pad") => true, + ("ifreq", "ifr_ifru") => true, + ("ifconf", "ifc_ifcu") => true, _ => false, } @@ -2012,6 +2014,7 @@ fn test_freebsd(target: &str) { Some(12) => cfg.cfg("freebsd12", None), Some(13) => cfg.cfg("freebsd13", None), Some(14) => cfg.cfg("freebsd14", None), + Some(15) => cfg.cfg("freebsd15", None), _ => &mut cfg, }; @@ -2030,6 +2033,10 @@ fn test_freebsd(target: &str) { Some(n) if n >= 14 => true, _ => false, }; + let freebsd15 = match freebsd_ver { + Some(n) if n >= 15 => true, + _ => false, + }; headers! { cfg: "aio.h", @@ -2117,7 +2124,7 @@ fn test_freebsd(target: &str) { "sys/sysctl.h", "sys/thr.h", "sys/time.h", - [freebsd14]:"sys/timerfd.h", + [freebsd14 || freebsd15]:"sys/timerfd.h", "sys/times.h", "sys/timex.h", "sys/types.h", @@ -2401,6 +2408,9 @@ fn test_freebsd(target: &str) { true } + // Introduced in FreeBSD 14 then removed ? + "TCP_LRD" if freebsd_ver >= Some(15) => true, + // Added in FreeBSD 14 "LIO_READV" | "LIO_WRITEV" | "LIO_VECTORED" if Some(14) > freebsd_ver => true, @@ -2424,7 +2434,11 @@ fn test_freebsd(target: &str) { "AT_USRSTACKBASE" | "AT_USRSTACKLIM" if Some(13) > freebsd_ver => true, // Added in FreeBSD 14 - "TFD_CLOEXEC" | "TFD_NONBLOCK" if Some(14) > freebsd_ver => true, + "TFD_CLOEXEC" | "TFD_NONBLOCK" | "TFD_TIMER_ABSTIME" | "TFD_TIMER_CANCEL_ON_SET" + if Some(14) > freebsd_ver => + { + true + } _ => false, } @@ -3283,7 +3297,7 @@ fn test_linux(target: &str) { let mut cfg = ctest_cfg(); cfg.define("_GNU_SOURCE", None); - // This macro re-deifnes fscanf,scanf,sscanf to link to the symbols that are + // This macro re-defines fscanf,scanf,sscanf to link to the symbols that are // deprecated since glibc >= 2.29. This allows Rust binaries to link against // glibc versions older than 2.29. cfg.define("__GLIBC_USE_DEPRECATED_SCANF", None); @@ -3402,6 +3416,7 @@ fn test_linux(target: &str) { headers! { cfg: "asm/mman.h", + [gnu]: "linux/aio_abi.h", "linux/can.h", "linux/can/raw.h", // FIXME: requires kernel headers >= 5.4.1. @@ -3567,6 +3582,19 @@ fn test_linux(target: &str) { if musl && ty.starts_with("uinput_") { return true; } + if musl && ty == "seccomp_notif" { + return true; + } + if musl && ty == "seccomp_notif_addfd" { + return true; + } + if musl && ty == "seccomp_notif_resp" { + return true; + } + if musl && ty == "seccomp_notif_sizes" { + return true; + } + // LFS64 types have been removed in musl 1.2.4+ if musl && (ty.ends_with("64") || ty.ends_with("64_t")) { return true; @@ -3677,6 +3705,12 @@ fn test_linux(target: &str) { // https://github.com/torvalds/linux/commit/c05cd3645814724bdeb32a2b4d953b12bdea5f8c "xdp_umem_reg_v1" => true, + // Is defined in `` but if this file is included at the same time + // as ``, the `struct sched_param` is defined twice, causing the compilation to + // fail. The problem doesn't seem to be present in more recent versions of the linux + // kernel so we can drop this and test the type once this new version is used in CI. + "sched_attr" => true, + _ => false, } }); @@ -3719,6 +3753,17 @@ fn test_linux(target: &str) { } } if musl { + // FIXME: 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: Requires >= 5.4.1 kernel headers if name.starts_with("J1939") || name.starts_with("RTEXT_FILTER_") @@ -3850,7 +3895,7 @@ fn test_linux(target: &str) { "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, + "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, @@ -4057,6 +4102,41 @@ fn test_linux(target: &str) { true } + // FIXME: 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" => true, + + "SCHED_FLAG_KEEP_POLICY" + | "SCHED_FLAG_KEEP_PARAMS" + | "SCHED_FLAG_UTIL_CLAMP_MIN" + | "SCHED_FLAG_UTIL_CLAMP_MAX" + | "SCHED_FLAG_KEEP_ALL" + | "SCHED_FLAG_UTIL_CLAMP" + | "SCHED_FLAG_ALL" if musl => true, // Needs more recent linux headers. + _ => false, } }); @@ -4454,6 +4534,7 @@ fn which_freebsd() -> Option { s if s.starts_with("12") => Some(12), s if s.starts_with("13") => Some(13), s if s.starts_with("14") => Some(14), + s if s.starts_with("15") => Some(15), _ => None, } } diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index a7c235eefb3ed..f0e4358d37c62 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -2241,7 +2241,44 @@ SIOCADDMULTI SIOCADDRT SIOCDARP SIOCDELMULTI +SIOCGIFINDEX +SIOGIFINDEX +SIOCSIFPFLAGS +SIOCGIFPFLAGS +SIOCDIFADDR +SIOCSIFHWBROADCAST +SIOCGIFCOUNT +SIOCGIFBR +SIOCSIFBR +SIOCGIFTXQLEN +SIOCSIFTXQLEN +SIOCETHTOOL +SIOCGMIIPHY +SIOCGMIIREG +SIOCSMIIREG +SIOCWANDEV +SIOCOUTQNSD +SIOCGSKNS +SIOCADDDLCI +SIOCDELDLCI +SIOCGIFVLAN +SIOCSIFVLAN +SIOCBONDENSLAVE +SIOCBONDRELEASE +SIOCBONDSETHWADDR +SIOCBONDSLAVEINFOQUERY +SIOCBONDINFOQUERY +SIOCBONDCHANGEACTIVE +SIOCBRADDBR +SIOCBRDELBR +SIOCBRADDIF +SIOCBRDELIF +SIOCSHWTSTAMP +SIOCGHWTSTAMP +SIOCDEVPRIVATE +SIOCPROTOPRIVATE SIOCDELRT +SIOCRTMSG SIOCDRARP SIOCGARP SIOCGIFADDR @@ -2250,6 +2287,7 @@ SIOCGIFCONF SIOCGIFDSTADDR SIOCGIFENCAP SIOCGIFFLAGS +SIOCSIFNAME SIOCGIFHWADDR SIOCGIFMAP SIOCGIFMEM @@ -3223,10 +3261,16 @@ group hostent id_t idtype_t +ifconf +ifreq +__c_anonymous_ifc_ifcu +__c_anonymous_ifr_ifru +__c_anonymous_ifru_map if_indextoname if_nametoindex ifaddrs in6_addr +in6_ifreq in6_pktinfo in6_rtmsg in_addr diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index a3e2161ab9ee1..ce9c6097bbb88 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1366,6 +1366,7 @@ TAB1 TAB2 TAB3 TABDLY +TCP_CONNECTION_INFO TCP_FASTOPEN TCP_KEEPALIVE TCP_KEEPCNT @@ -2215,6 +2216,7 @@ shmid_ds sigaltstack sigevent siginfo_t +sigsuspend sigwait sockaddr_ctl sockaddr_dl @@ -2225,6 +2227,7 @@ statfs strcasecmp strcasestr strftime +strftime_l strncasecmp strndup strptime @@ -2245,6 +2248,7 @@ task_info task_inspect_t task_terminate task_threads +tcp_connection_info telldir thread_basic_info_t thread_extended_info_t diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index b9c8e7ee6180c..8135be3b4948d 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -1263,6 +1263,7 @@ chroot clearerr clock_getcpuclockid clock_getres +clock_nanosleep clock_settime cmsgcred cmsghdr @@ -1537,6 +1538,7 @@ shmget sigaltstack sigevent siginfo_t +sigsuspend sigtimedwait sigwait sigwaitinfo @@ -1547,6 +1549,8 @@ stack_t statfs strcasecmp strcasestr +strftime +strftime_l strncasecmp strndup strsignal diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 9f436ced22a81..1144c4d4c2481 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -2192,6 +2192,7 @@ shmid_ds sigaltstack sigevent siginfo_t +sigsuspend sigtimedwait sigwait sigwaitinfo @@ -2204,6 +2205,8 @@ statfs strcasecmp strcasestr strchrnul +strftime +strftime_l strncasecmp strndup strsignal diff --git a/libc-test/semver/fuchsia.txt b/libc-test/semver/fuchsia.txt index c876cc6a5b812..525b26bd62940 100644 --- a/libc-test/semver/fuchsia.txt +++ b/libc-test/semver/fuchsia.txt @@ -1377,8 +1377,10 @@ pthread_cancel pthread_condattr_getclock pthread_condattr_setclock pthread_getattr_np +pthread_getname_np pthread_kill pthread_mutex_timedlock +pthread_setname_np ptsname_r pwritev quotactl diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 4d95520d3e9de..9bbdee0771b60 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -638,6 +638,7 @@ glob64 glob64_t globfree globfree64 +iocb lio_listio mallinfo mallinfo2 @@ -691,6 +692,7 @@ eaccess asctime_r ctime_r strftime +strftime_l strptime dirname posix_basename diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index 09a63c7294a76..2db034f813be7 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -78,6 +78,7 @@ euidaccess eaccess asctime_r strftime +strftime_l strptime dirname basename diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 37aab57f23ee3..ff82d18b355ee 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2383,23 +2383,33 @@ SCTP_STATUS SCTP_STREAM_RESET_INCOMING SCTP_STREAM_RESET_OUTGOING SCTP_UNORDERED +SECCOMP_ADDFD_FLAG_SEND +SECCOMP_ADDFD_FLAG_SETFD SECCOMP_FILTER_FLAG_LOG +SECCOMP_FILTER_FLAG_NEW_LISTENER SECCOMP_FILTER_FLAG_SPEC_ALLOW SECCOMP_FILTER_FLAG_TSYNC +SECCOMP_FILTER_FLAG_TSYNC_ESRCH +SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV +SECCOMP_GET_ACTION_AVAIL +SECCOMP_GET_NOTIF_SIZES SECCOMP_MODE_DISABLED -SECCOMP_MODE_FILTER SECCOMP_MODE_STRICT +SECCOMP_MODE_FILTER SECCOMP_RET_ACTION SECCOMP_RET_ACTION_FULL SECCOMP_RET_ALLOW SECCOMP_RET_DATA SECCOMP_RET_ERRNO -SECCOMP_RET_KILL SECCOMP_RET_KILL_PROCESS SECCOMP_RET_KILL_THREAD +SECCOMP_RET_KILL SECCOMP_RET_LOG SECCOMP_RET_TRACE SECCOMP_RET_TRAP +SECCOMP_SET_MODE_FILTER +SECCOMP_SET_MODE_STRICT +SECCOMP_USER_NOTIF_FLAG_CONTINUE SEEK_DATA SEEK_HOLE SELFMAG @@ -2475,6 +2485,7 @@ SIOCSIFMAP SIOCSIFMEM SIOCSIFMETRIC SIOCSIFMTU +SIOCSIFNAME SIOCSIFNETMASK SIOCSIFPFLAGS SIOCSIFSLAVE @@ -3747,6 +3758,10 @@ sched_setparam sched_setscheduler sctp_assoc_t seccomp_data +seccomp_notif +seccomp_notif_addfd +seccomp_notif_resp +seccomp_notif_sizes seed48 seekdir sem_close @@ -3860,3 +3875,6 @@ wait4 waitid eventfd_read eventfd_write +__c_anonymous_ifru_map +__c_anonymous_ifr_ifru +__c_anonymous_ifc_ifcu diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 145f02b441cf1..353b1e7356ff5 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1538,6 +1538,7 @@ shmid_ds sigaltstack sigevent siginfo_t +sigsuspend sigtimedwait sigwait sigwaitinfo @@ -1551,6 +1552,8 @@ stack_t strcasecmp strcasestr string_to_flags +strftime +strftime_l strncasecmp strndup strpct diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 5b0064f72e65b..fd4563212d60d 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -808,6 +808,7 @@ ST_RDONLY S_IEXEC S_IREAD S_IWRITE +TCP_INFO TCP_MAXSEG TCP_MD5SIG TCP_NOPUSH @@ -1014,6 +1015,7 @@ backtrace backtrace_symbols backtrace_symbols_fd backtrace_symbols_fmt +basename bsearch caddr_t calloc_conceal @@ -1027,6 +1029,7 @@ cmsghdr daemon difftime dirfd +dirname dl_iterate_phdr dl_phdr_info drand48 @@ -1153,6 +1156,27 @@ pipe2 pledge popen posix_madvise +posix_spawn +posix_spawn_file_actions_addclose +posix_spawn_file_actions_adddup2 +posix_spawn_file_actions_addopen +posix_spawn_file_actions_destroy +posix_spawn_file_actions_init +posix_spawnattr_destroy +posix_spawnattr_getflags +posix_spawnattr_getpgroup +posix_spawnattr_getschedparam +posix_spawnattr_getschedpolicy +posix_spawnattr_getsigdefault +posix_spawnattr_getsigmask +posix_spawnattr_init +posix_spawnattr_setflags +posix_spawnattr_setpgroup +posix_spawnattr_setschedparam +posix_spawnattr_setschedpolicy +posix_spawnattr_setsigdefault +posix_spawnattr_setsigmask +posix_spawnp preadv pseudo_AF_HDRCMPLT pseudo_AF_PFLOW @@ -1236,6 +1260,7 @@ shmget shmid_ds sigaltstack siginfo_t +sigsuspend sigwait sockaddr_dl sockpeercred @@ -1247,6 +1272,8 @@ stack_t statfs strcasecmp strcasestr +strftime +strftime_l strncasecmp strndup strsignal @@ -1254,6 +1281,7 @@ strtonum sync syscall sysctl +tcp_info telldir tmpfs_args truncate @@ -1268,6 +1296,5 @@ utimensat utmp utrace wait4 +waitid xucred -dirname -basename diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index 5f85e1aa7f3d4..80095a09f5345 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -145,6 +145,7 @@ TCGETS TCP_KEEPIDLE TCSETS TIOCGPGRP +TIOCSCTTY TIOCSPGRP UTSLENGTH VDISCARD @@ -207,11 +208,13 @@ getservbyport getservent killpg lockf +login_tty madvise memalign nice open_memstream open_wmemstream +openpty pipe2 pthread_condattr_setclock qsort diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 25124e6e0fcf8..4e028ff6cc45a 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -3826,6 +3826,8 @@ extern "C" { 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; + pub fn pthread_getname_np(thread: ::pthread_t, name: *mut ::c_char, len: ::size_t) -> ::c_int; + pub fn pthread_setname_np(thread: ::pthread_t, name: *const ::c_char) -> ::c_int; pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int; pub fn getsockopt( diff --git a/src/psp.rs b/src/psp.rs index 575232dad1f88..a4ca029b6e0c1 100644 --- a/src/psp.rs +++ b/src/psp.rs @@ -1382,15 +1382,18 @@ s_paren! { pub struct SceUid(pub i32); #[repr(transparent)] + #[allow(dead_code)] pub struct SceMpeg(*mut *mut c_void); #[repr(transparent)] + #[allow(dead_code)] pub struct SceMpegStream(*mut c_void); #[repr(transparent)] pub struct Mp3Handle(pub i32); #[repr(transparent)] + #[allow(dead_code)] pub struct RegHandle(u32); } diff --git a/src/teeos/mod.rs b/src/teeos/mod.rs index 066f81ca55e4c..25e06ffaa3b10 100644 --- a/src/teeos/mod.rs +++ b/src/teeos/mod.rs @@ -62,7 +62,7 @@ pub struct _CLongDouble(pub u128); // long double in C means A float point value, which has 128bit length. // but some bit maybe not used, so the really length of long double could be 80(x86) or 128(power pc/IEEE) -// this is different from f128(not stable and not inculded default) in Rust, so we use u128 for FFI(Rust to C). +// this is different from f128(not stable and not included default) in Rust, so we use u128 for FFI(Rust to C). // this is unstable and will couse to memfault/data abort. pub type c_longdouble = _CLongDouble; diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index c7169a2274769..2e7827231e65f 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -1138,6 +1138,49 @@ s! { #[cfg(not(libc_union))] pub ifc_ifcu: *mut ifreq, } + + #[cfg_attr(libc_align, repr(align(8)))] + pub struct tcp_connection_info { + pub tcpi_state: u8, + pub tcpi_snd_wscale: u8, + pub tcpi_rcv_wscale: u8, + __pad1: u8, + pub tcpi_options: u32, + pub tcpi_flags: u32, + pub tcpi_rto: u32, + pub tcpi_maxseg: u32, + pub tcpi_snd_ssthresh: u32, + pub tcpi_snd_cwnd: u32, + pub tcpi_snd_wnd: u32, + pub tcpi_snd_sbbytes: u32, + pub tcpi_rcv_wnd: u32, + pub tcpi_rttcur: u32, + pub tcpi_srtt: u32, + pub tcpi_rttvar: u32, + pub tcpi_tfo_cookie_req: u32, + pub tcpi_tfo_cookie_rcv: u32, + pub tcpi_tfo_syn_loss: u32, + pub tcpi_tfo_syn_data_sent: u32, + pub tcpi_tfo_syn_data_acked: u32, + pub tcpi_tfo_syn_data_rcv: u32, + pub tcpi_tfo_cookie_req_rcv: u32, + pub tcpi_tfo_cookie_sent: u32, + pub tcpi_tfo_cookie_invalid: u32, + pub tcpi_tfo_cookie_wrong: u32, + pub tcpi_tfo_no_cookie_rcv: u32, + pub tcpi_tfo_heuristics_disable: u32, + pub tcpi_tfo_send_blackhole: u32, + pub tcpi_tfo_recv_blackhole: u32, + pub tcpi_tfo_onebyte_proxy: u32, + __pad2: u32, + pub tcpi_txpackets: u64, + pub tcpi_txbytes: u64, + pub tcpi_txretransmitbytes: u64, + pub tcpi_rxpackets: u64, + pub tcpi_rxbytes: u64, + pub tcpi_rxoutoforderbytes: u64, + pub tcpi_rxretransmitpackets: u64, + } } s_no_extra_traits! { @@ -4103,6 +4146,7 @@ pub const TCP_KEEPINTVL: ::c_int = 0x101; pub const TCP_KEEPCNT: ::c_int = 0x102; /// Enable/Disable TCP Fastopen on this socket pub const TCP_FASTOPEN: ::c_int = 0x105; +pub const TCP_CONNECTION_INFO: ::c_int = 0x106; pub const SOL_LOCAL: ::c_int = 0; @@ -5604,12 +5648,6 @@ extern "C" { pub fn asctime(tm: *const ::tm) -> *mut ::c_char; pub fn ctime(clock: *const time_t) -> *mut ::c_char; pub fn getdate(datestr: *const ::c_char) -> *mut ::tm; - pub fn strftime( - buf: *mut ::c_char, - maxsize: ::size_t, - format: *const ::c_char, - timeptr: *const ::tm, - ) -> ::size_t; pub fn strptime( buf: *const ::c_char, format: *const ::c_char, @@ -6245,7 +6283,7 @@ extern "C" { buffersize: u32, ) -> ::c_int; pub fn proc_kmsgbuf(buffer: *mut ::c_void, buffersize: u32) -> ::c_int; - pub fn proc_libversion(major: *mut ::c_int, mintor: *mut ::c_int) -> ::c_int; + pub fn proc_libversion(major: *mut ::c_int, minor: *mut ::c_int) -> ::c_int; pub fn proc_pid_rusage(pid: ::c_int, flavor: ::c_int, buffer: *mut rusage_info_t) -> ::c_int; // Available from Big Sur diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index 0e04a12e70e47..ec6bce2a03091 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -1,4 +1,4 @@ -// APIs in FreeBSD 14 that have changed since 11. +// APIs in FreeBSD 13 that have changed since 11. pub type nlink_t = u64; pub type dev_t = u64; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index a86ca6e7c56ea..160a4baae481b 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -1,4 +1,4 @@ -// APIs in FreeBSD 13 that have changed since 11. +// APIs in FreeBSD 14 that have changed since 11. pub type nlink_t = u64; pub type dev_t = u64; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/b64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/b64.rs new file mode 100644 index 0000000000000..80c6fa1684530 --- /dev/null +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/b64.rs @@ -0,0 +1,34 @@ +#[repr(C)] +#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] +pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + st_padding0: i16, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + st_padding1: i32, + pub st_rdev: ::dev_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: u64, + pub st_spare: [u64; 10], +} + +impl ::Copy for ::stat {} +impl ::Clone for ::stat { + fn clone(&self) -> ::stat { + *self + } +} diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs new file mode 100644 index 0000000000000..d73215a68ec33 --- /dev/null +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -0,0 +1,546 @@ +// APIs in FreeBSD 15 that have changed since 11. + +pub type nlink_t = u64; +pub type dev_t = u64; +pub type ino_t = ::c_ulong; +pub type shmatt_t = ::c_uint; +pub type kpaddr_t = u64; +pub type kssize_t = i64; +pub type domainset_t = __c_anonymous_domainset; + +s! { + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_lpid: ::pid_t, + pub shm_cpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + } + + pub struct kevent { + pub ident: ::uintptr_t, + pub filter: ::c_short, + pub flags: ::c_ushort, + pub fflags: ::c_uint, + pub data: i64, + pub udata: *mut ::c_void, + pub ext: [u64; 4], + } + + pub struct kvm_page { + pub kp_version: ::u_int, + pub kp_paddr: ::kpaddr_t, + pub kp_kmap_vaddr: ::kvaddr_t, + pub kp_dmap_vaddr: ::kvaddr_t, + pub kp_prot: ::vm_prot_t, + pub kp_offset: ::off_t, + pub kp_len: ::size_t, + } + + pub struct __c_anonymous_domainset { + _priv: [::uintptr_t; 4], + } + + pub struct kinfo_proc { + /// Size of this structure. + pub ki_structsize: ::c_int, + /// Reserved: layout identifier. + pub ki_layout: ::c_int, + /// Address of command arguments. + pub ki_args: *mut ::pargs, + // This is normally "struct proc". + /// Address of proc. + pub ki_paddr: *mut ::c_void, + // This is normally "struct user". + /// Kernel virtual address of u-area. + pub ki_addr: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to trace file. + pub ki_tracep: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to executable file. + pub ki_textvp: *mut ::c_void, + // This is normally "struct filedesc". + /// Pointer to open file info. + pub ki_fd: *mut ::c_void, + // This is normally "struct vmspace". + /// Pointer to kernel vmspace struct. + pub ki_vmspace: *mut ::c_void, + /// Sleep address. + pub ki_wchan: *const ::c_void, + /// Process identifier. + pub ki_pid: ::pid_t, + /// Parent process ID. + pub ki_ppid: ::pid_t, + /// Process group ID. + pub ki_pgid: ::pid_t, + /// tty process group ID. + pub ki_tpgid: ::pid_t, + /// Process session ID. + pub ki_sid: ::pid_t, + /// Terminal session ID. + pub ki_tsid: ::pid_t, + /// Job control counter. + pub ki_jobc: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short1: ::c_short, + /// Controlling tty dev. + pub ki_tdev_freebsd11: u32, + /// Signals arrived but not delivered. + pub ki_siglist: ::sigset_t, + /// Current signal mask. + pub ki_sigmask: ::sigset_t, + /// Signals being ignored. + pub ki_sigignore: ::sigset_t, + /// Signals being caught by user. + pub ki_sigcatch: ::sigset_t, + /// Effective user ID. + pub ki_uid: ::uid_t, + /// Real user ID. + pub ki_ruid: ::uid_t, + /// Saved effective user ID. + pub ki_svuid: ::uid_t, + /// Real group ID. + pub ki_rgid: ::gid_t, + /// Saved effective group ID. + pub ki_svgid: ::gid_t, + /// Number of groups. + pub ki_ngroups: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short2: ::c_short, + /// Groups. + pub ki_groups: [::gid_t; ::KI_NGROUPS], + /// Virtual size. + pub ki_size: ::vm_size_t, + /// Current resident set size in pages. + pub ki_rssize: ::segsz_t, + /// Resident set size before last swap. + pub ki_swrss: ::segsz_t, + /// Text size (pages) XXX. + pub ki_tsize: ::segsz_t, + /// Data size (pages) XXX. + pub ki_dsize: ::segsz_t, + /// Stack size (pages). + pub ki_ssize: ::segsz_t, + /// Exit status for wait & stop signal. + pub ki_xstat: ::u_short, + /// Accounting flags. + pub ki_acflag: ::u_short, + /// %cpu for process during `ki_swtime`. + pub ki_pctcpu: ::fixpt_t, + /// Time averaged value of `ki_cpticks`. + pub ki_estcpu: ::u_int, + /// Time since last blocked. + pub ki_slptime: ::u_int, + /// Time swapped in or out. + pub ki_swtime: ::u_int, + /// Number of copy-on-write faults. + pub ki_cow: ::u_int, + /// Real time in microsec. + pub ki_runtime: u64, + /// Starting time. + pub ki_start: ::timeval, + /// Time used by process children. + pub ki_childtime: ::timeval, + /// P_* flags. + pub ki_flag: ::c_long, + /// KI_* flags (below). + pub ki_kiflag: ::c_long, + /// Kernel trace points. + pub ki_traceflag: ::c_int, + /// S* process status. + pub ki_stat: ::c_char, + /// Process "nice" value. + pub ki_nice: i8, // signed char + /// Process lock (prevent swap) count. + pub ki_lock: ::c_char, + /// Run queue index. + pub ki_rqindex: ::c_char, + /// Which cpu we are on. + pub ki_oncpu_old: ::c_uchar, + /// Last cpu we were on. + pub ki_lastcpu_old: ::c_uchar, + /// Thread name. + pub ki_tdname: [::c_char; ::TDNAMLEN + 1], + /// Wchan message. + pub ki_wmesg: [::c_char; ::WMESGLEN + 1], + /// Setlogin name. + pub ki_login: [::c_char; ::LOGNAMELEN + 1], + /// Lock name. + pub ki_lockname: [::c_char; ::LOCKNAMELEN + 1], + /// Command name. + pub ki_comm: [::c_char; ::COMMLEN + 1], + /// Emulation name. + pub ki_emul: [::c_char; ::KI_EMULNAMELEN + 1], + /// Login class. + pub ki_loginclass: [::c_char; ::LOGINCLASSLEN + 1], + /// More thread name. + pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], + /// Spare string space. + pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + /// Spare room for growth. + pub ki_spareints: [::c_int; ::KI_NSPARE_INT], + /// Controlling tty dev. + pub ki_tdev: u64, + /// Which cpu we are on. + pub ki_oncpu: ::c_int, + /// Last cpu we were on. + pub ki_lastcpu: ::c_int, + /// PID of tracing process. + pub ki_tracer: ::c_int, + /// P2_* flags. + pub ki_flag2: ::c_int, + /// Default FIB number. + pub ki_fibnum: ::c_int, + /// Credential flags. + pub ki_cr_flags: ::u_int, + /// Process jail ID. + pub ki_jid: ::c_int, + /// Number of threads in total. + pub ki_numthreads: ::c_int, + /// Thread ID. + pub ki_tid: ::lwpid_t, + /// Process priority. + pub ki_pri: ::priority, + /// Process rusage statistics. + pub ki_rusage: ::rusage, + /// rusage of children processes. + pub ki_rusage_ch: ::rusage, + // This is normally "struct pcb". + /// Kernel virtual addr of pcb. + pub ki_pcb: *mut ::c_void, + /// Kernel virtual addr of stack. + pub ki_kstack: *mut ::c_void, + /// User convenience pointer. + pub ki_udata: *mut ::c_void, + // This is normally "struct thread". + pub ki_tdaddr: *mut ::c_void, + // This is normally "struct pwddesc". + /// Pointer to process paths info. + pub ki_pd: *mut ::c_void, + pub ki_spareptrs: [*mut ::c_void; ::KI_NSPARE_PTR], + pub ki_sparelongs: [::c_long; ::KI_NSPARE_LONG], + /// PS_* flags. + pub ki_sflag: ::c_long, + /// kthread flag. + pub ki_tdflags: ::c_long, + } +} + +s_no_extra_traits! { + pub struct dirent { + pub d_fileno: ::ino_t, + pub d_off: ::off_t, + pub d_reclen: u16, + pub d_type: u8, + d_pad0: u8, + pub d_namlen: u16, + d_pad1: u16, + pub d_name: [::c_char; 256], + } + + pub struct statfs { + pub f_version: u32, + pub f_type: u32, + pub f_flags: u64, + pub f_bsize: u64, + pub f_iosize: u64, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: i64, + pub f_files: u64, + pub f_ffree: i64, + pub f_syncwrites: u64, + pub f_asyncwrites: u64, + pub f_syncreads: u64, + pub f_asyncreads: u64, + f_spare: [u64; 10], + pub f_namemax: u32, + pub f_owner: ::uid_t, + pub f_fsid: ::fsid_t, + f_charspare: [::c_char; 80], + pub f_fstypename: [::c_char; 16], + pub f_mntfromname: [::c_char; 1024], + pub f_mntonname: [::c_char; 1024], + } + + pub struct vnstat { + pub vn_fileid: u64, + pub vn_size: u64, + pub vn_dev: u64, + pub vn_fsid: u64, + pub vn_mntdir: *mut ::c_char, + pub vn_type: ::c_int, + pub vn_mode: u16, + pub vn_devname: [::c_char; ::SPECNAMELEN as usize + 1], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for statfs { + fn eq(&self, other: &statfs) -> bool { + self.f_version == other.f_version + && self.f_type == other.f_type + && self.f_flags == other.f_flags + && self.f_bsize == other.f_bsize + && self.f_iosize == other.f_iosize + && self.f_blocks == other.f_blocks + && self.f_bfree == other.f_bfree + && self.f_bavail == other.f_bavail + && self.f_files == other.f_files + && self.f_ffree == other.f_ffree + && self.f_syncwrites == other.f_syncwrites + && self.f_asyncwrites == other.f_asyncwrites + && self.f_syncreads == other.f_syncreads + && self.f_asyncreads == other.f_asyncreads + && self.f_namemax == other.f_namemax + && self.f_owner == other.f_owner + && self.f_fsid == other.f_fsid + && self.f_fstypename == other.f_fstypename + && self + .f_mntfromname + .iter() + .zip(other.f_mntfromname.iter()) + .all(|(a,b)| a == b) + && self + .f_mntonname + .iter() + .zip(other.f_mntonname.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for statfs {} + impl ::fmt::Debug for statfs { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("statfs") + .field("f_bsize", &self.f_bsize) + .field("f_iosize", &self.f_iosize) + .field("f_blocks", &self.f_blocks) + .field("f_bfree", &self.f_bfree) + .field("f_bavail", &self.f_bavail) + .field("f_files", &self.f_files) + .field("f_ffree", &self.f_ffree) + .field("f_syncwrites", &self.f_syncwrites) + .field("f_asyncwrites", &self.f_asyncwrites) + .field("f_syncreads", &self.f_syncreads) + .field("f_asyncreads", &self.f_asyncreads) + .field("f_namemax", &self.f_namemax) + .field("f_owner", &self.f_owner) + .field("f_fsid", &self.f_fsid) + .field("f_fstypename", &self.f_fstypename) + .field("f_mntfromname", &&self.f_mntfromname[..]) + .field("f_mntonname", &&self.f_mntonname[..]) + .finish() + } + } + impl ::hash::Hash for statfs { + fn hash(&self, state: &mut H) { + self.f_version.hash(state); + self.f_type.hash(state); + self.f_flags.hash(state); + self.f_bsize.hash(state); + self.f_iosize.hash(state); + self.f_blocks.hash(state); + self.f_bfree.hash(state); + self.f_bavail.hash(state); + self.f_files.hash(state); + self.f_ffree.hash(state); + self.f_syncwrites.hash(state); + self.f_asyncwrites.hash(state); + self.f_syncreads.hash(state); + self.f_asyncreads.hash(state); + self.f_namemax.hash(state); + self.f_owner.hash(state); + self.f_fsid.hash(state); + self.f_charspare.hash(state); + self.f_fstypename.hash(state); + self.f_mntfromname.hash(state); + self.f_mntonname.hash(state); + } + } + + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_fileno == other.d_fileno + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self.d_namlen == other.d_namlen + && self + .d_name[..self.d_namlen as _] + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for dirent {} + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent") + .field("d_fileno", &self.d_fileno) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + .field("d_namlen", &self.d_namlen) + .field("d_name", &&self.d_name[..self.d_namlen as _]) + .finish() + } + } + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_fileno.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_namlen.hash(state); + self.d_name[..self.d_namlen as _].hash(state); + } + } + + impl PartialEq for vnstat { + fn eq(&self, other: &vnstat) -> bool { + let self_vn_devname: &[::c_char] = &self.vn_devname; + let other_vn_devname: &[::c_char] = &other.vn_devname; + + self.vn_fileid == other.vn_fileid && + self.vn_size == other.vn_size && + self.vn_dev == other.vn_dev && + self.vn_fsid == other.vn_fsid && + self.vn_mntdir == other.vn_mntdir && + self.vn_type == other.vn_type && + self.vn_mode == other.vn_mode && + self_vn_devname == other_vn_devname + } + } + impl Eq for vnstat {} + impl ::fmt::Debug for vnstat { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let self_vn_devname: &[::c_char] = &self.vn_devname; + + f.debug_struct("vnstat") + .field("vn_fileid", &self.vn_fileid) + .field("vn_size", &self.vn_size) + .field("vn_dev", &self.vn_dev) + .field("vn_fsid", &self.vn_fsid) + .field("vn_mntdir", &self.vn_mntdir) + .field("vn_type", &self.vn_type) + .field("vn_mode", &self.vn_mode) + .field("vn_devname", &self_vn_devname) + .finish() + } + } + impl ::hash::Hash for vnstat { + fn hash(&self, state: &mut H) { + let self_vn_devname: &[::c_char] = &self.vn_devname; + + self.vn_fileid.hash(state); + self.vn_size.hash(state); + self.vn_dev.hash(state); + self.vn_fsid.hash(state); + self.vn_mntdir.hash(state); + self.vn_type.hash(state); + self.vn_mode.hash(state); + self_vn_devname.hash(state); + } + } + } +} + +pub const RAND_MAX: ::c_int = 0x7fff_ffff; +pub const ELAST: ::c_int = 97; + +pub const KF_TYPE_EVENTFD: ::c_int = 13; + +/// max length of devicename +pub const SPECNAMELEN: ::c_int = 255; +pub const KI_NSPARE_PTR: usize = 5; + +/// domainset policies +pub const DOMAINSET_POLICY_INVALID: ::c_int = 0; +pub const DOMAINSET_POLICY_ROUNDROBIN: ::c_int = 1; +pub const DOMAINSET_POLICY_FIRSTTOUCH: ::c_int = 2; +pub const DOMAINSET_POLICY_PREFER: ::c_int = 3; +pub const DOMAINSET_POLICY_INTERLEAVE: ::c_int = 4; + +pub const MINCORE_SUPER: ::c_int = 0x60; + +safe_f! { + pub {const} fn makedev(major: ::c_uint, minor: ::c_uint) -> ::dev_t { + let major = major as ::dev_t; + let minor = minor as ::dev_t; + let mut dev = 0; + dev |= ((major & 0xffffff00) as dev_t) << 32; + dev |= ((major & 0x000000ff) as dev_t) << 8; + dev |= ((minor & 0x0000ff00) as dev_t) << 24; + dev |= ((minor & 0xffff00ff) as dev_t) << 0; + dev + } +} + +f! { + pub fn major(dev: ::dev_t) -> ::c_int { + (((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as ::c_int + } + + pub fn minor(dev: ::dev_t) -> ::c_int { + (((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as ::c_int + } +} + +extern "C" { + pub fn setgrent(); + pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; + pub fn freelocale(loc: ::locale_t); + pub fn msgrcv( + msqid: ::c_int, + msgp: *mut ::c_void, + msgsz: ::size_t, + msgtyp: ::c_long, + msgflg: ::c_int, + ) -> ::ssize_t; + + pub fn cpuset_getdomain( + level: ::cpulevel_t, + which: ::cpuwhich_t, + id: ::id_t, + setsize: ::size_t, + mask: *mut ::domainset_t, + policy: *mut ::c_int, + ) -> ::c_int; + pub fn cpuset_setdomain( + level: ::cpulevel_t, + which: ::cpuwhich_t, + id: ::id_t, + setsize: ::size_t, + mask: *const ::domainset_t, + policy: ::c_int, + ) -> ::c_int; + + pub fn dirname(path: *mut ::c_char) -> *mut ::c_char; + pub fn basename(path: *mut ::c_char) -> *mut ::c_char; +} + +#[link(name = "kvm")] +extern "C" { + pub fn kvm_kerndisp(kd: *mut ::kvm_t) -> ::kssize_t; +} + +cfg_if! { + if #[cfg(any(target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "riscv64"))] { + mod b64; + pub use self::b64::*; + } +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } +} diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/x86_64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/x86_64.rs new file mode 100644 index 0000000000000..01d0b4328da81 --- /dev/null +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/x86_64.rs @@ -0,0 +1,12 @@ +pub const PROC_KPTI_CTL: ::c_int = ::PROC_PROCCTL_MD_MIN; +pub const PROC_KPTI_CTL_ENABLE_ON_EXEC: ::c_int = 1; +pub const PROC_KPTI_CTL_DISABLE_ON_EXEC: ::c_int = 2; +pub const PROC_KPTI_STATUS: ::c_int = ::PROC_PROCCTL_MD_MIN + 1; +pub const PROC_KPTI_STATUS_ACTIVE: ::c_int = 0x80000000; +pub const PROC_LA_CTL: ::c_int = ::PROC_PROCCTL_MD_MIN + 2; +pub const PROC_LA_STATUS: ::c_int = ::PROC_PROCCTL_MD_MIN + 3; +pub const PROC_LA_CTL_LA48_ON_EXEC: ::c_int = 1; +pub const PROC_LA_CTL_LA57_ON_EXEC: ::c_int = 2; +pub const PROC_LA_CTL_DEFAULT_ON_EXEC: ::c_int = 3; +pub const PROC_LA_STATUS_LA48: ::c_int = 0x01000000; +pub const PROC_LA_STATUS_LA57: ::c_int = 0x02000000; diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 799e3811ed44c..78314084cc6ec 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -367,13 +367,13 @@ s! { } pub struct cpuset_t { - #[cfg(all(freebsd14, target_pointer_width = "64"))] + #[cfg(all(any(freebsd15, freebsd14), target_pointer_width = "64"))] __bits: [::c_long; 16], - #[cfg(all(freebsd14, target_pointer_width = "32"))] + #[cfg(all(any(freebsd15, freebsd14), target_pointer_width = "32"))] __bits: [::c_long; 32], - #[cfg(all(not(freebsd14), target_pointer_width = "64"))] + #[cfg(all(not(any(freebsd15, freebsd14)), target_pointer_width = "64"))] __bits: [::c_long; 4], - #[cfg(all(not(freebsd14), target_pointer_width = "32"))] + #[cfg(all(not(any(freebsd15, freebsd14)), target_pointer_width = "32"))] __bits: [::c_long; 8], } @@ -597,9 +597,9 @@ s! { pub sa_peer: ::sockaddr_storage, pub type_: ::c_int, pub dname: [::c_char; 32], - #[cfg(any(freebsd12, freebsd13, freebsd14))] + #[cfg(any(freebsd12, freebsd13, freebsd14, freebsd15))] pub sendq: ::c_uint, - #[cfg(any(freebsd12, freebsd13, freebsd14))] + #[cfg(any(freebsd12, freebsd13, freebsd14, freebsd15))] pub recvq: ::c_uint, } @@ -1046,39 +1046,41 @@ s! { pub tcpi_snd_rexmitpack: u32, pub tcpi_rcv_ooopack: u32, pub tcpi_snd_zerowin: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub tcpi_delivered_ce: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub tcpi_received_ce: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub __tcpi_delivered_e1_bytes: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub __tcpi_delivered_e0_bytes: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub __tcpi_delivered_ce_bytes: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub __tcpi_received_e1_bytes: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub __tcpi_received_e0_bytes: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub __tcpi_received_ce_bytes: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub tcpi_total_tlp: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub tcpi_total_tlp_bytes: u64, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub tcpi_snd_una: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub tcpi_snd_max: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub tcpi_rcv_numsacks: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub tcpi_rcv_adv: u32, - #[cfg(freebsd14)] + #[cfg(any(freebsd15, freebsd14))] pub tcpi_dupacks: u32, #[cfg(freebsd14)] pub __tcpi_pad: [u32; 10], - #[cfg(not(freebsd14))] + #[cfg(freebsd15)] + pub __tcpi_pad: [u32; 14], + #[cfg(not(any(freebsd15, freebsd14)))] pub __tcpi_pad: [u32; 26], } @@ -1406,9 +1408,9 @@ s_no_extra_traits! { } pub struct ptsstat { - #[cfg(any(freebsd12, freebsd13, freebsd14))] + #[cfg(any(freebsd12, freebsd13, freebsd14, freebsd15))] pub dev: u64, - #[cfg(not(any(freebsd12, freebsd13, freebsd14)))] + #[cfg(not(any(freebsd12, freebsd13, freebsd14, freebsd15)))] pub dev: u32, pub devname: [::c_char; SPECNAMELEN as usize + 1], } @@ -2622,7 +2624,7 @@ pub const DEVSTAT_NAME_LEN: ::c_int = 16; // sys/cpuset.h cfg_if! { - if #[cfg(freebsd14)] { + if #[cfg(any(freebsd15, freebsd14))] { pub const CPU_SETSIZE: ::c_int = 1024; } else { pub const CPU_SETSIZE: ::c_int = 256; @@ -4728,10 +4730,17 @@ pub const RB_POWERCYCLE: ::c_int = 0x400000; pub const RB_PROBE: ::c_int = 0x10000000; pub const RB_MULTIPLE: ::c_int = 0x20000000; +// sys/time.h +pub const CLOCK_BOOTTIME: ::clockid_t = ::CLOCK_UPTIME; +pub const CLOCK_REALTIME_COARSE: ::clockid_t = ::CLOCK_REALTIME_FAST; +pub const CLOCK_MONOTONIC_COARSE: ::clockid_t = ::CLOCK_MONOTONIC_FAST; + // sys/timerfd.h pub const TFD_NONBLOCK: ::c_int = ::O_NONBLOCK; pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC; +pub const TFD_TIMER_ABSTIME: ::c_int = 0x01; +pub const TFD_TIMER_CANCEL_ON_SET: ::c_int = 0x02; cfg_if! { if #[cfg(libc_const_extern_fn)] { @@ -5361,13 +5370,6 @@ extern "C" { pub fn getpagesizes(pagesize: *mut ::size_t, nelem: ::c_int) -> ::c_int; pub fn clock_getcpuclockid2(arg1: ::id_t, arg2: ::c_int, arg3: *mut clockid_t) -> ::c_int; - pub fn clock_nanosleep( - clk_id: ::clockid_t, - flags: ::c_int, - rqtp: *const ::timespec, - rmtp: *mut ::timespec, - ) -> ::c_int; - pub fn strchrnul(s: *const ::c_char, c: ::c_int) -> *mut ::c_char; pub fn shm_create_largepage( @@ -5708,7 +5710,10 @@ extern "C" { } cfg_if! { - if #[cfg(freebsd14)] { + if #[cfg(freebsd15)] { + mod freebsd15; + pub use self::freebsd15::*; + } else if #[cfg(freebsd14)] { mod freebsd14; pub use self::freebsd14::*; } else if #[cfg(freebsd13)] { diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index d2cd7794b107e..00a944e42bf2d 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -824,15 +824,12 @@ pub const CLOCK_VIRTUAL: ::clockid_t = 1; pub const CLOCK_PROF: ::clockid_t = 2; pub const CLOCK_MONOTONIC: ::clockid_t = 4; pub const CLOCK_UPTIME: ::clockid_t = 5; -pub const CLOCK_BOOTTIME: ::clockid_t = CLOCK_UPTIME; pub const CLOCK_UPTIME_PRECISE: ::clockid_t = 7; pub const CLOCK_UPTIME_FAST: ::clockid_t = 8; pub const CLOCK_REALTIME_PRECISE: ::clockid_t = 9; pub const CLOCK_REALTIME_FAST: ::clockid_t = 10; -pub const CLOCK_REALTIME_COARSE: ::clockid_t = CLOCK_REALTIME_FAST; pub const CLOCK_MONOTONIC_PRECISE: ::clockid_t = 11; pub const CLOCK_MONOTONIC_FAST: ::clockid_t = 12; -pub const CLOCK_MONOTONIC_COARSE: ::clockid_t = CLOCK_MONOTONIC_FAST; pub const CLOCK_SECOND: ::clockid_t = 13; pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 14; pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 15; @@ -1493,6 +1490,13 @@ extern "C" { atflag: ::c_int, ) -> ::c_int; + pub fn clock_nanosleep( + clk_id: ::clockid_t, + flags: ::c_int, + rqtp: *const ::timespec, + rmtp: *mut ::timespec, + ) -> ::c_int; + pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 6ce041357ebee..9a2e6c463d36b 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -761,6 +761,7 @@ extern "C" { )] #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int; + pub fn sigsuspend(mask: *const ::sigset_t) -> ::c_int; pub fn sem_close(sem: *mut sem_t) -> ::c_int; pub fn getdtablesize() -> ::c_int; pub fn getgrnam_r( @@ -899,6 +900,20 @@ extern "C" { longopts: *const option, longindex: *mut ::c_int, ) -> ::c_int; + + pub fn strftime( + buf: *mut ::c_char, + maxsize: ::size_t, + format: *const ::c_char, + timeptr: *const ::tm, + ) -> ::size_t; + pub fn strftime_l( + buf: *mut ::c_char, + maxsize: ::size_t, + format: *const ::c_char, + timeptr: *const ::tm, + locale: ::locale_t, + ) -> ::size_t; } cfg_if! { diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 07dc39be54e36..e92cf65940141 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -364,6 +364,13 @@ pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; pub const POSIX_MADV_WILLNEED: ::c_int = 3; pub const POSIX_MADV_DONTNEED: ::c_int = 4; +pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01; +pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02; +pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_int = 0x04; +pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x08; +pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x10; +pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x20; + pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; @@ -650,6 +657,8 @@ pub const TIMER_ABSTIME: ::c_int = 1; pub const RB_AUTOBOOT: ::c_int = 0; +pub const TCP_INFO: ::c_int = 9; + #[link(name = "util")] extern "C" { pub fn setgrent(); @@ -745,6 +754,89 @@ extern "C" { argv: *const *const ::c_char, envp: *const *const ::c_char, ) -> ::c_int; + pub fn waitid( + idtype: idtype_t, + id: ::id_t, + infop: *mut ::siginfo_t, + options: ::c_int, + ) -> ::c_int; + + pub fn posix_spawn( + pid: *mut ::pid_t, + path: *const ::c_char, + file_actions: *const ::posix_spawn_file_actions_t, + attrp: *const ::posix_spawnattr_t, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char, + ) -> ::c_int; + pub fn posix_spawnp( + pid: *mut ::pid_t, + file: *const ::c_char, + file_actions: *const ::posix_spawn_file_actions_t, + attrp: *const ::posix_spawnattr_t, + argv: *const *mut ::c_char, + envp: *const *mut ::c_char, + ) -> ::c_int; + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> ::c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> ::c_int; + pub fn posix_spawnattr_getsigdefault( + attr: *const posix_spawnattr_t, + default: *mut ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_setsigdefault( + attr: *mut posix_spawnattr_t, + default: *const ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_getsigmask( + attr: *const posix_spawnattr_t, + default: *mut ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_setsigmask( + attr: *mut posix_spawnattr_t, + default: *const ::sigset_t, + ) -> ::c_int; + pub fn posix_spawnattr_getflags( + attr: *const posix_spawnattr_t, + flags: *mut ::c_short, + ) -> ::c_int; + pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: ::c_short) -> ::c_int; + pub fn posix_spawnattr_getpgroup( + attr: *const posix_spawnattr_t, + flags: *mut ::pid_t, + ) -> ::c_int; + pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: ::pid_t) -> ::c_int; + pub fn posix_spawnattr_getschedpolicy( + attr: *const posix_spawnattr_t, + flags: *mut ::c_int, + ) -> ::c_int; + pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: ::c_int) -> ::c_int; + pub fn posix_spawnattr_getschedparam( + attr: *const posix_spawnattr_t, + param: *mut ::sched_param, + ) -> ::c_int; + pub fn posix_spawnattr_setschedparam( + attr: *mut posix_spawnattr_t, + param: *const ::sched_param, + ) -> ::c_int; + + pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> ::c_int; + pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> ::c_int; + pub fn posix_spawn_file_actions_addopen( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + path: *const ::c_char, + oflag: ::c_int, + mode: ::mode_t, + ) -> ::c_int; + pub fn posix_spawn_file_actions_addclose( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + ) -> ::c_int; + pub fn posix_spawn_file_actions_adddup2( + actions: *mut posix_spawn_file_actions_t, + fd: ::c_int, + newfd: ::c_int, + ) -> ::c_int; } extern "C" { diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 43b17e1a7ecf9..7c63db8e0e205 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1549,7 +1549,6 @@ pub const TCP_KEEPIDLE: ::c_int = 3; pub const TCP_KEEPINTVL: ::c_int = 5; pub const TCP_KEEPCNT: ::c_int = 6; pub const TCP_KEEPINIT: ::c_int = 7; -pub const TCP_INFO: ::c_int = 9; pub const TCP_MD5SIG: ::c_int = 0x10; pub const TCP_CONGCTL: ::c_int = 0x20; @@ -2344,13 +2343,6 @@ pub const PT_LWPNEXT: ::c_int = 25; pub const PT_SET_SIGPASS: ::c_int = 26; pub const PT_GET_SIGPASS: ::c_int = 27; pub const PT_FIRSTMACH: ::c_int = 32; - -pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01; -pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02; -pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_int = 0x04; -pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x08; -pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x10; -pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x20; pub const POSIX_SPAWN_RETURNERROR: ::c_int = 0x40; // Flags for chflags(2) @@ -2777,12 +2769,6 @@ extern "C" { timeout: *const ::timespec, ) -> ::c_int; pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> ::c_int; - pub fn waitid( - idtype: idtype_t, - id: ::id_t, - infop: *mut ::siginfo_t, - options: ::c_int, - ) -> ::c_int; pub fn duplocale(base: ::locale_t) -> ::locale_t; pub fn freelocale(loc: ::locale_t); @@ -2895,82 +2881,6 @@ extern "C" { ts: *const ::timespec, sigmask: *const ::sigset_t, ) -> ::c_int; - pub fn posix_spawn( - pid: *mut ::pid_t, - path: *const ::c_char, - file_actions: *const ::posix_spawn_file_actions_t, - attrp: *const ::posix_spawnattr_t, - argv: *const *mut ::c_char, - envp: *const *mut ::c_char, - ) -> ::c_int; - pub fn posix_spawnp( - pid: *mut ::pid_t, - file: *const ::c_char, - file_actions: *const ::posix_spawn_file_actions_t, - attrp: *const ::posix_spawnattr_t, - argv: *const *mut ::c_char, - envp: *const *mut ::c_char, - ) -> ::c_int; - pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> ::c_int; - pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> ::c_int; - pub fn posix_spawnattr_getsigdefault( - attr: *const posix_spawnattr_t, - default: *mut ::sigset_t, - ) -> ::c_int; - pub fn posix_spawnattr_setsigdefault( - attr: *mut posix_spawnattr_t, - default: *const ::sigset_t, - ) -> ::c_int; - pub fn posix_spawnattr_getsigmask( - attr: *const posix_spawnattr_t, - default: *mut ::sigset_t, - ) -> ::c_int; - pub fn posix_spawnattr_setsigmask( - attr: *mut posix_spawnattr_t, - default: *const ::sigset_t, - ) -> ::c_int; - pub fn posix_spawnattr_getflags( - attr: *const posix_spawnattr_t, - flags: *mut ::c_short, - ) -> ::c_int; - pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: ::c_short) -> ::c_int; - pub fn posix_spawnattr_getpgroup( - attr: *const posix_spawnattr_t, - flags: *mut ::pid_t, - ) -> ::c_int; - pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: ::pid_t) -> ::c_int; - pub fn posix_spawnattr_getschedpolicy( - attr: *const posix_spawnattr_t, - flags: *mut ::c_int, - ) -> ::c_int; - pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: ::c_int) -> ::c_int; - pub fn posix_spawnattr_getschedparam( - attr: *const posix_spawnattr_t, - param: *mut ::sched_param, - ) -> ::c_int; - pub fn posix_spawnattr_setschedparam( - attr: *mut posix_spawnattr_t, - param: *const ::sched_param, - ) -> ::c_int; - - pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> ::c_int; - pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> ::c_int; - pub fn posix_spawn_file_actions_addopen( - actions: *mut posix_spawn_file_actions_t, - fd: ::c_int, - path: *const ::c_char, - oflag: ::c_int, - mode: ::mode_t, - ) -> ::c_int; - pub fn posix_spawn_file_actions_addclose( - actions: *mut posix_spawn_file_actions_t, - fd: ::c_int, - ) -> ::c_int; - pub fn posix_spawn_file_actions_adddup2( - actions: *mut posix_spawn_file_actions_t, - fd: ::c_int, - newfd: ::c_int, - ) -> ::c_int; pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t; pub fn reboot(mode: ::c_int, bootstr: *mut ::c_char) -> ::c_int; diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 08c816566166c..8f470aff9a357 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -41,6 +41,10 @@ pub type Elf64_Xword = u64; pub type ENTRY = entry; pub type ACTION = ::c_uint; +// spawn.h +pub type posix_spawnattr_t = *mut ::c_void; +pub type posix_spawn_file_actions_t = *mut ::c_void; + cfg_if! { if #[cfg(target_pointer_width = "64")] { type Elf_Addr = Elf64_Addr; @@ -541,6 +545,68 @@ s! { #[cfg(not(libc_union))] pub ifr_ifru: ::sockaddr, } + + pub struct tcp_info { + pub tcpi_state: u8, + pub __tcpi_ca_state: u8, + pub __tcpi_retransmits: u8, + pub __tcpi_probes: u8, + pub __tcpi_backoff: u8, + pub tcpi_options: u8, + pub tcpi_snd_wscale: u8, + pub tcpi_rcv_wscale: u8, + pub tcpi_rto: u32, + pub __tcpi_ato: u32, + pub tcpi_snd_mss: u32, + pub tcpi_rcv_mss: u32, + pub __tcpi_unacked: u32, + pub __tcpi_sacked: u32, + pub __tcpi_lost: u32, + pub __tcpi_retrans: u32, + pub __tcpi_fackets: u32, + pub tcpi_last_data_sent: u32, + pub tcpi_last_ack_sent: u32, + pub tcpi_last_data_recv: u32, + pub tcpi_last_ack_recv: u32, + pub __tcpi_pmtu: u32, + pub __tcpi_rcv_ssthresh: u32, + pub tcpi_rtt: u32, + pub tcpi_rttvar: u32, + pub tcpi_snd_ssthresh: u32, + pub tcpi_snd_cwnd: u32, + pub __tcpi_advmss: u32, + pub __tcpi_reordering: u32, + pub __tcpi_rcv_rtt: u32, + pub tcpi_rcv_space: u32, + pub tcpi_snd_wnd: u32, + pub tcpi_snd_nxt: u32, + pub tcpi_rcv_nxt: u32, + pub tcpi_toe_tid: u32, + pub tcpi_snd_rexmitpack: u32, + pub tcpi_rcv_ooopack: u32, + pub tcpi_snd_zerowin: u32, + pub tcpi_rttmin: u32, + pub tcpi_max_sndwnd: u32, + pub tcpi_rcv_adv: u32, + pub tcpi_rcv_up: u32, + pub tcpi_snd_una: u32, + pub tcpi_snd_up: u32, + pub tcpi_snd_wl1: u32, + pub tcpi_snd_wl2: u32, + pub tcpi_snd_max: u32, + pub tcpi_ts_recent: u32, + pub tcpi_ts_recent_age: u32, + pub tcpi_rfbuf_cnt: u32, + pub tcpi_rfbuf_ts: u32, + pub tcpi_so_rcv_sb_cc: u32, + pub tcpi_so_rcv_sb_hiwat: u32, + pub tcpi_so_rcv_sb_lowat: u32, + pub tcpi_so_rcv_sb_wat: u32, + pub tcpi_so_snd_sb_cc: u32, + pub tcpi_so_snd_sb_hiwat: u32, + pub tcpi_so_snd_sb_lowat: u32, + pub tcpi_so_snd_sb_wat: u32, + } } impl siginfo_t { diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index a7d1719983c8f..e7b0f34dd371a 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1782,6 +1782,7 @@ extern "C" { groupcount: *mut ::c_int, ) -> ::c_int; pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int; + pub fn sigsuspend(mask: *const ::sigset_t) -> ::c_int; pub fn sem_close(sem: *mut sem_t) -> ::c_int; pub fn getdtablesize() -> ::c_int; pub fn getgrnam_r( diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 999a15440d12c..94c4eace85539 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -496,6 +496,22 @@ s! { pub flag: *mut ::c_int, pub val: ::c_int, } + + pub struct __c_anonymous_ifru_map { + pub mem_start: ::c_ulong, + pub mem_end: ::c_ulong, + pub base_addr: ::c_ushort, + pub irq: ::c_uchar, + pub dma: ::c_uchar, + pub port: ::c_uchar, + } + + pub struct in6_ifreq { + pub ifr6_addr: ::in6_addr, + pub ifr6_prefixlen: u32, + pub ifr6_ifindex: ::c_int, + } + } s_no_extra_traits! { @@ -591,6 +607,50 @@ s_no_extra_traits! { __serial: ::c_uint, __value: [[::c_char; 4]; 23], } + + #[cfg(libc_union)] + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: ::sockaddr, + pub ifru_dstaddr: ::sockaddr, + pub ifru_broadaddr: ::sockaddr, + pub ifru_netmask: ::sockaddr, + pub ifru_hwaddr: ::sockaddr, + pub ifru_flags: ::c_short, + pub ifru_ifindex: ::c_int, + pub ifru_metric: ::c_int, + pub ifru_mtu: ::c_int, + pub ifru_map: __c_anonymous_ifru_map, + pub ifru_slave: [::c_char; ::IFNAMSIZ], + pub ifru_newname: [::c_char; ::IFNAMSIZ], + pub ifru_data: *mut ::c_char, + } + + pub struct ifreq { + /// interface name, e.g. "en0" + pub ifr_name: [::c_char; ::IFNAMSIZ], + #[cfg(libc_union)] + pub ifr_ifru: __c_anonymous_ifr_ifru, + #[cfg(not(libc_union))] + pub ifr_ifru: ::sockaddr, + } + + #[cfg(libc_union)] + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: *mut ::c_char, + pub ifcu_req: *mut ::ifreq, + } + + /* Structure used in SIOCGIFCONF request. Used to retrieve interface + configuration for machine (useful for programs which must know all + networks accessible). */ + pub struct ifconf { + pub ifc_len: ::c_int, /* Size of buffer. */ + #[cfg(libc_union)] + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + #[cfg(not(libc_union))] + pub ifc_ifcu: *mut ::ifreq, + } + } cfg_if! { @@ -938,6 +998,53 @@ cfg_if! { } } + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ifr_ifru { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ifr_ifru") + .field("ifru_addr", unsafe { &self.ifru_addr }) + .field("ifru_dstaddr", unsafe { &self.ifru_dstaddr }) + .field("ifru_broadaddr", unsafe { &self.ifru_broadaddr }) + .field("ifru_netmask", unsafe { &self.ifru_netmask }) + .field("ifru_hwaddr", unsafe { &self.ifru_hwaddr }) + .field("ifru_flags", unsafe { &self.ifru_flags }) + .field("ifru_ifindex", unsafe { &self.ifru_ifindex }) + .field("ifru_metric", unsafe { &self.ifru_metric }) + .field("ifru_mtu", unsafe { &self.ifru_mtu }) + .field("ifru_map", unsafe { &self.ifru_map }) + .field("ifru_slave", unsafe { &self.ifru_slave }) + .field("ifru_newname", unsafe { &self.ifru_newname }) + .field("ifru_data", unsafe { &self.ifru_data }) + .finish() + } + } + impl ::fmt::Debug for ifreq { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ifreq") + .field("ifr_name", &self.ifr_name) + .field("ifr_ifru", &self.ifr_ifru) + .finish() + } + } + + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ifc_ifcu { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ifr_ifru") + .field("ifcu_buf", unsafe { &self.ifcu_buf }) + .field("ifcu_req", unsafe { &self.ifcu_req }) + .finish() + } + } + impl ::fmt::Debug for ifconf { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ifconf") + .field("ifc_len", &self.ifc_len) + .field("ifc_ifcu", &self.ifc_ifcu) + .finish() + } + } + #[allow(deprecated)] impl af_alg_iv { fn as_slice(&self) -> &[u8] { @@ -2715,6 +2822,7 @@ pub const NFEA_DONT_REFRESH: ::c_ushort = 2; pub const SIOCADDRT: ::c_ulong = 0x0000890B; pub const SIOCDELRT: ::c_ulong = 0x0000890C; +pub const SIOCRTMSG: ::c_ulong = 0x0000890D; pub const SIOCGIFNAME: ::c_ulong = 0x00008910; pub const SIOCSIFLINK: ::c_ulong = 0x00008911; pub const SIOCGIFCONF: ::c_ulong = 0x00008912; @@ -2734,6 +2842,7 @@ pub const SIOCGIFMEM: ::c_ulong = 0x0000891F; pub const SIOCSIFMEM: ::c_ulong = 0x00008920; pub const SIOCGIFMTU: ::c_ulong = 0x00008921; pub const SIOCSIFMTU: ::c_ulong = 0x00008922; +pub const SIOCSIFNAME: ::c_ulong = 0x00008923; pub const SIOCSIFHWADDR: ::c_ulong = 0x00008924; pub const SIOCGIFENCAP: ::c_ulong = 0x00008925; pub const SIOCSIFENCAP: ::c_ulong = 0x00008926; @@ -2742,6 +2851,24 @@ pub const SIOCGIFSLAVE: ::c_ulong = 0x00008929; pub const SIOCSIFSLAVE: ::c_ulong = 0x00008930; pub const SIOCADDMULTI: ::c_ulong = 0x00008931; pub const SIOCDELMULTI: ::c_ulong = 0x00008932; +pub const SIOCGIFINDEX: ::c_ulong = 0x00008933; +pub const SIOGIFINDEX: ::c_ulong = SIOCGIFINDEX; +pub const SIOCSIFPFLAGS: ::c_ulong = 0x00008934; +pub const SIOCGIFPFLAGS: ::c_ulong = 0x00008935; +pub const SIOCDIFADDR: ::c_ulong = 0x00008936; +pub const SIOCSIFHWBROADCAST: ::c_ulong = 0x00008937; +pub const SIOCGIFCOUNT: ::c_ulong = 0x00008938; +pub const SIOCGIFBR: ::c_ulong = 0x00008940; +pub const SIOCSIFBR: ::c_ulong = 0x00008941; +pub const SIOCGIFTXQLEN: ::c_ulong = 0x00008942; +pub const SIOCSIFTXQLEN: ::c_ulong = 0x00008943; +pub const SIOCETHTOOL: ::c_ulong = 0x00008946; +pub const SIOCGMIIPHY: ::c_ulong = 0x00008947; +pub const SIOCGMIIREG: ::c_ulong = 0x00008948; +pub const SIOCSMIIREG: ::c_ulong = 0x00008949; +pub const SIOCWANDEV: ::c_ulong = 0x0000894A; +pub const SIOCOUTQNSD: ::c_ulong = 0x0000894B; +pub const SIOCGSKNS: ::c_ulong = 0x0000894C; pub const SIOCDARP: ::c_ulong = 0x00008953; pub const SIOCGARP: ::c_ulong = 0x00008954; pub const SIOCSARP: ::c_ulong = 0x00008955; @@ -2750,6 +2877,24 @@ pub const SIOCGRARP: ::c_ulong = 0x00008961; pub const SIOCSRARP: ::c_ulong = 0x00008962; pub const SIOCGIFMAP: ::c_ulong = 0x00008970; pub const SIOCSIFMAP: ::c_ulong = 0x00008971; +pub const SIOCADDDLCI: ::c_ulong = 0x00008980; +pub const SIOCDELDLCI: ::c_ulong = 0x00008981; +pub const SIOCGIFVLAN: ::c_ulong = 0x00008982; +pub const SIOCSIFVLAN: ::c_ulong = 0x00008983; +pub const SIOCBONDENSLAVE: ::c_ulong = 0x00008990; +pub const SIOCBONDRELEASE: ::c_ulong = 0x00008991; +pub const SIOCBONDSETHWADDR: ::c_ulong = 0x00008992; +pub const SIOCBONDSLAVEINFOQUERY: ::c_ulong = 0x00008993; +pub const SIOCBONDINFOQUERY: ::c_ulong = 0x00008994; +pub const SIOCBONDCHANGEACTIVE: ::c_ulong = 0x00008995; +pub const SIOCBRADDBR: ::c_ulong = 0x000089a0; +pub const SIOCBRDELBR: ::c_ulong = 0x000089a1; +pub const SIOCBRADDIF: ::c_ulong = 0x000089a2; +pub const SIOCBRDELIF: ::c_ulong = 0x000089a3; +pub const SIOCSHWTSTAMP: ::c_ulong = 0x000089b0; +pub const SIOCGHWTSTAMP: ::c_ulong = 0x000089b1; +pub const SIOCDEVPRIVATE: ::c_ulong = 0x000089F0; +pub const SIOCPROTOPRIVATE: ::c_ulong = 0x000089E0; // linux/module.h pub const MODULE_INIT_IGNORE_MODVERSIONS: ::c_uint = 0x0001; 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 9b3a2ff861731..89c93aba8818e 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -162,12 +162,6 @@ s! { pub ss_size: ::size_t } - pub struct seccomp_notif_sizes { - pub seccomp_notif: ::__u16, - pub seccomp_notif_resp: ::__u16, - pub seccomp_data: ::__u16, - } - pub struct mcontext_t { pub trap_no: ::c_ulong, pub error_code: ::c_ulong, @@ -466,11 +460,6 @@ pub const B3000000: ::speed_t = 0o010015; pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; -pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; -pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; -pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; -pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; - pub const VEOL: usize = 11; pub const VEOL2: usize = 16; pub const VMIN: usize = 6; 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 9807cea831021..5e92e30073bee 100644 --- a/src/unix/linux_like/linux/gnu/b32/csky/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -415,11 +415,6 @@ pub const B3000000: ::speed_t = 0o010015; pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; -pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; -pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; -pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; -pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; - pub const VEOL: usize = 11; pub const VEOL2: usize = 16; pub const VMIN: usize = 6; 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 a3531c141fdb6..27f477bb48f85 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -236,11 +236,6 @@ s! { pub ss_size: ::size_t } - pub struct seccomp_notif_sizes { - pub seccomp_notif: ::__u16, - pub seccomp_notif_resp: ::__u16, - pub seccomp_data: ::__u16, - } } s_no_extra_traits! { @@ -1090,11 +1085,6 @@ pub const REG_EFL: ::c_int = 16; pub const REG_UESP: ::c_int = 17; pub const REG_SS: ::c_int = 18; -pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; -pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; -pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; -pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; - extern "C" { pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int; pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index 206283e22f6b2..284a1788f4409 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -197,11 +197,6 @@ s! { pub ss_size: ::size_t } - pub struct seccomp_notif_sizes { - pub seccomp_notif: ::__u16, - pub seccomp_notif_resp: ::__u16, - pub seccomp_data: ::__u16, - } } pub const VEOF: usize = 4; @@ -513,11 +508,6 @@ pub const B3000000: ::speed_t = 0o010015; pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; -pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; -pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; -pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; -pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; - pub const VEOL: usize = 11; pub const VEOL2: usize = 16; pub const VMIN: usize = 6; 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 9b2aac5c2ba34..609c74429c5bc 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 @@ -260,12 +260,6 @@ s! { __unused5: u64 } - pub struct seccomp_notif_sizes { - pub seccomp_notif: ::__u16, - pub seccomp_notif_resp: ::__u16, - pub seccomp_data: ::__u16, - } - pub struct ptrace_rseq_configuration { pub rseq_abi_pointer: ::__u64, pub rseq_abi_size: ::__u32, @@ -803,11 +797,6 @@ pub const REG_TRAPNO: ::c_int = 20; pub const REG_OLDMASK: ::c_int = 21; pub const REG_CR2: ::c_int = 22; -pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; -pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; -pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; -pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; - extern "C" { pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int; pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index e7284fd46f096..9af519e9077df 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -3,6 +3,7 @@ pub type __priority_which_t = ::c_uint; pub type __rlimit_resource_t = ::c_uint; pub type Lmid_t = ::c_long; pub type regoff_t = ::c_int; +pub type __kernel_rwf_t = ::c_int; cfg_if! { if #[cfg(doc)] { @@ -432,6 +433,27 @@ s! { pub len: ::__u32, pub options: ::__u32, } + + pub struct iocb { + pub aio_data: ::__u64, + #[cfg(target_endian = "little")] + pub aio_key: ::__u32, + #[cfg(target_endian = "little")] + pub aio_rw_flags: ::__kernel_rwf_t, + #[cfg(target_endian = "big")] + pub aio_rw_flags: ::__kernel_rwf_t, + #[cfg(target_endian = "big")] + pub aio_key: ::__u32, + pub aio_lio_opcode: ::__u16, + pub aio_reqprio: ::__s16, + pub aio_fildes: ::__u32, + pub aio_buf: ::__u64, + pub aio_nbytes: ::__u64, + pub aio_offset: ::__s64, + aio_reserved2: ::__u64, + pub aio_flags: ::__u32, + pub aio_resfd: ::__u32, + } } impl siginfo_t { @@ -1462,6 +1484,13 @@ extern "C" { format: *const ::c_char, tm: *const ::tm, ) -> ::size_t; + pub fn strftime_l( + s: *mut ::c_char, + max: ::size_t, + format: *const ::c_char, + tm: *const ::tm, + locale: ::locale_t, + ) -> ::size_t; pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char; pub fn dirname(path: *mut ::c_char) -> *mut ::c_char; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index b763ab6261bb9..acb10c603f725 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -575,6 +575,34 @@ s! { pub args: [::__u64; 6], } + pub struct seccomp_notif_sizes { + pub seccomp_notif: ::__u16, + pub seccomp_notif_resp: ::__u16, + pub seccomp_data: ::__u16, + } + + pub struct seccomp_notif { + pub id: ::__u64, + pub pid: ::__u32, + pub flags: ::__u32, + pub data: seccomp_data, + } + + pub struct seccomp_notif_resp { + pub id: ::__u64, + pub val: ::__s64, + pub error: ::__s32, + pub flags: ::__u32, + } + + pub struct seccomp_notif_addfd { + pub id: ::__u64, + pub flags: ::__u32, + pub srcfd: ::__u32, + pub newfd: ::__u32, + pub newfd_flags: ::__u32, + } + pub struct nlmsghdr { pub nlmsg_len: u32, pub nlmsg_type: u16, @@ -850,6 +878,17 @@ s_no_extra_traits! { pub d_type: ::c_uchar, pub d_name: [::c_char; 256], } + + pub struct sched_attr { + pub size: ::__u32, + pub sched_policy: ::__u32, + pub sched_flags: ::__u64, + pub sched_nice: ::__s32, + pub sched_priority: ::__u32, + pub sched_runtime: ::__u64, + pub sched_deadline: ::__u64, + pub sched_period: ::__u64, + } } s_no_extra_traits! { @@ -1315,6 +1354,46 @@ cfg_if! { self.rx_filter.hash(state); } } + + impl ::fmt::Debug for sched_attr { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sched_attr") + .field("size", &self.size) + .field("sched_policy", &self.sched_policy) + .field("sched_flags", &self.sched_flags) + .field("sched_nice", &self.sched_nice) + .field("sched_priority", &self.sched_priority) + .field("sched_runtime", &self.sched_runtime) + .field("sched_deadline", &self.sched_deadline) + .field("sched_period", &self.sched_period) + .finish() + } + } + impl PartialEq for sched_attr { + fn eq(&self, other: &sched_attr) -> bool { + self.size == other.size && + self.sched_policy == other.sched_policy && + self.sched_flags == other.sched_flags && + self.sched_nice == other.sched_nice && + self.sched_priority == other.sched_priority && + self.sched_runtime == other.sched_runtime && + self.sched_deadline == other.sched_deadline && + self.sched_period == other.sched_period + } + } + impl Eq for sched_attr {} + impl ::hash::Hash for sched_attr { + fn hash(&self, state: &mut H) { + self.size.hash(state); + self.sched_policy.hash(state); + self.sched_flags.hash(state); + self.sched_nice.hash(state); + self.sched_priority.hash(state); + self.sched_runtime.hash(state); + self.sched_deadline.hash(state); + self.sched_period.hash(state); + } + } } } @@ -2004,16 +2083,6 @@ pub const RENAME_NOREPLACE: ::c_uint = 1; pub const RENAME_EXCHANGE: ::c_uint = 2; pub const RENAME_WHITEOUT: ::c_uint = 4; -pub const SCHED_OTHER: ::c_int = 0; -pub const SCHED_FIFO: ::c_int = 1; -pub const SCHED_RR: ::c_int = 2; -pub const SCHED_BATCH: ::c_int = 3; -pub const SCHED_IDLE: ::c_int = 5; - -pub const SCHED_RESET_ON_FORK: ::c_int = 0x40000000; - -pub const CLONE_PIDFD: ::c_int = 0x1000; - // netinet/in.h // NOTE: These are in addition to the constants defined in src/unix/mod.rs @@ -2272,13 +2341,22 @@ pub const GRND_NONBLOCK: ::c_uint = 0x0001; pub const GRND_RANDOM: ::c_uint = 0x0002; pub const GRND_INSECURE: ::c_uint = 0x0004; +// pub const SECCOMP_MODE_DISABLED: ::c_uint = 0; pub const SECCOMP_MODE_STRICT: ::c_uint = 1; pub const SECCOMP_MODE_FILTER: ::c_uint = 2; +pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; +pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; +pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; +pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; + pub const SECCOMP_FILTER_FLAG_TSYNC: ::c_ulong = 1; pub const SECCOMP_FILTER_FLAG_LOG: ::c_ulong = 2; pub const SECCOMP_FILTER_FLAG_SPEC_ALLOW: ::c_ulong = 4; +pub const SECCOMP_FILTER_FLAG_NEW_LISTENER: ::c_ulong = 8; +pub const SECCOMP_FILTER_FLAG_TSYNC_ESRCH: ::c_ulong = 16; +pub const SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV: ::c_ulong = 32; pub const SECCOMP_RET_KILL_PROCESS: ::c_uint = 0x80000000; pub const SECCOMP_RET_KILL_THREAD: ::c_uint = 0x00000000; @@ -2293,6 +2371,11 @@ pub const SECCOMP_RET_ACTION_FULL: ::c_uint = 0xffff0000; pub const SECCOMP_RET_ACTION: ::c_uint = 0x7fff0000; pub const SECCOMP_RET_DATA: ::c_uint = 0x0000ffff; +pub const SECCOMP_USER_NOTIF_FLAG_CONTINUE: ::c_ulong = 1; + +pub const SECCOMP_ADDFD_FLAG_SETFD: ::c_ulong = 1; +pub const SECCOMP_ADDFD_FLAG_SEND: ::c_ulong = 2; + pub const ITIMER_REAL: ::c_int = 0; pub const ITIMER_VIRTUAL: ::c_int = 1; pub const ITIMER_PROF: ::c_int = 2; @@ -4519,6 +4602,65 @@ pub const NET_NETFILTER: ::c_int = 19; pub const NET_DCCP: ::c_int = 20; pub const NET_IRDA: ::c_int = 412; +// include/linux/sched.h +pub const PF_VCPU: ::c_int = 0x00000001; +pub const PF_IDLE: ::c_int = 0x00000002; +pub const PF_EXITING: ::c_int = 0x00000004; +pub const PF_POSTCOREDUMP: ::c_int = 0x00000008; +pub const PF_IO_WORKER: ::c_int = 0x00000010; +pub const PF_WQ_WORKER: ::c_int = 0x00000020; +pub const PF_FORKNOEXEC: ::c_int = 0x00000040; +pub const PF_MCE_PROCESS: ::c_int = 0x00000080; +pub const PF_SUPERPRIV: ::c_int = 0x00000100; +pub const PF_DUMPCORE: ::c_int = 0x00000200; +pub const PF_SIGNALED: ::c_int = 0x00000400; +pub const PF_MEMALLOC: ::c_int = 0x00000800; +pub const PF_NPROC_EXCEEDED: ::c_int = 0x00001000; +pub const PF_USED_MATH: ::c_int = 0x00002000; +pub const PF_USER_WORKER: ::c_int = 0x00004000; +pub const PF_NOFREEZE: ::c_int = 0x00008000; +pub const PF_KSWAPD: ::c_int = 0x00020000; +pub const PF_MEMALLOC_NOFS: ::c_int = 0x00040000; +pub const PF_MEMALLOC_NOIO: ::c_int = 0x00080000; +pub const PF_LOCAL_THROTTLE: ::c_int = 0x00100000; +pub const PF_KTHREAD: ::c_int = 0x00200000; +pub const PF_RANDOMIZE: ::c_int = 0x00400000; +pub const PF_NO_SETAFFINITY: ::c_int = 0x04000000; +pub const PF_MCE_EARLY: ::c_int = 0x08000000; +pub const PF_MEMALLOC_PIN: ::c_int = 0x10000000; + +pub const CSIGNAL: ::c_int = 0x000000ff; + +pub const SCHED_NORMAL: ::c_int = 0; +pub const SCHED_OTHER: ::c_int = 0; +pub const SCHED_FIFO: ::c_int = 1; +pub const SCHED_RR: ::c_int = 2; +pub const SCHED_BATCH: ::c_int = 3; +pub const SCHED_IDLE: ::c_int = 5; +pub const SCHED_DEADLINE: ::c_int = 6; + +pub const SCHED_RESET_ON_FORK: ::c_int = 0x40000000; + +pub const CLONE_PIDFD: ::c_int = 0x1000; + +pub const SCHED_FLAG_RESET_ON_FORK: ::c_int = 0x01; +pub const SCHED_FLAG_RECLAIM: ::c_int = 0x02; +pub const SCHED_FLAG_DL_OVERRUN: ::c_int = 0x04; +pub const SCHED_FLAG_KEEP_POLICY: ::c_int = 0x08; +pub const SCHED_FLAG_KEEP_PARAMS: ::c_int = 0x10; +pub const SCHED_FLAG_UTIL_CLAMP_MIN: ::c_int = 0x20; +pub const SCHED_FLAG_UTIL_CLAMP_MAX: ::c_int = 0x40; + +pub const SCHED_FLAG_KEEP_ALL: ::c_int = SCHED_FLAG_KEEP_POLICY | SCHED_FLAG_KEEP_PARAMS; + +pub const SCHED_FLAG_UTIL_CLAMP: ::c_int = SCHED_FLAG_UTIL_CLAMP_MIN | SCHED_FLAG_UTIL_CLAMP_MAX; + +pub const SCHED_FLAG_ALL: ::c_int = SCHED_FLAG_RESET_ON_FORK + | SCHED_FLAG_RECLAIM + | SCHED_FLAG_DL_OVERRUN + | SCHED_FLAG_KEEP_ALL + | SCHED_FLAG_UTIL_CLAMP; + f! { pub fn NLA_ALIGN(len: ::c_int) -> ::c_int { return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1) diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 944d6e7877d48..12280851e7471 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -157,6 +157,22 @@ s! { } s_no_extra_traits! { + pub struct user_fpxregs_struct { + pub cwd: ::c_ushort, + pub swd: ::c_ushort, + pub twd: ::c_ushort, + pub fop: ::c_ushort, + pub fip: ::c_long, + pub fcs: ::c_long, + pub foo: ::c_long, + pub fos: ::c_long, + pub mxcsr: ::c_long, + __reserved: ::c_long, + pub st_space: [::c_long; 32], + pub xmm_space: [::c_long; 32], + padding: [::c_long; 56], + } + pub struct ucontext_t { pub uc_flags: ::c_ulong, pub uc_link: *mut ucontext_t, @@ -169,6 +185,64 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { + impl PartialEq for user_fpxregs_struct { + fn eq(&self, other: &user_fpxregs_struct) -> bool { + self.cwd == other.cwd + && self.swd == other.swd + && self.twd == other.twd + && self.fop == other.fop + && self.fip == other.fip + && self.fcs == other.fcs + && self.foo == other.foo + && self.fos == other.fos + && self.mxcsr == other.mxcsr + // Ignore __reserved field + && self.st_space == other.st_space + && self.xmm_space == other.xmm_space + // Ignore padding field + } + } + + impl Eq for user_fpxregs_struct {} + + impl ::fmt::Debug for user_fpxregs_struct { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("user_fpxregs_struct") + .field("cwd", &self.cwd) + .field("swd", &self.swd) + .field("twd", &self.twd) + .field("fop", &self.fop) + .field("fip", &self.fip) + .field("fcs", &self.fcs) + .field("foo", &self.foo) + .field("fos", &self.fos) + .field("mxcsr", &self.mxcsr) + // Ignore __reserved field + .field("st_space", &self.st_space) + .field("xmm_space", &self.xmm_space) + // Ignore padding field + .finish() + } + } + + impl ::hash::Hash for user_fpxregs_struct { + fn hash(&self, state: &mut H) { + self.cwd.hash(state); + self.swd.hash(state); + self.twd.hash(state); + self.fop.hash(state); + self.fip.hash(state); + self.fcs.hash(state); + self.foo.hash(state); + self.fos.hash(state); + self.mxcsr.hash(state); + // Ignore __reserved field + self.st_space.hash(state); + self.xmm_space.hash(state); + // Ignore padding field + } + } + impl PartialEq for ucontext_t { fn eq(&self, other: &ucontext_t) -> bool { self.uc_flags == other.uc_flags diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 97429a7f3a21a..a4c1f708afd50 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -889,6 +889,13 @@ extern "C" { format: *const ::c_char, tm: *const ::tm, ) -> ::size_t; + pub fn strftime_l( + s: *mut ::c_char, + max: ::size_t, + format: *const ::c_char, + tm: *const ::tm, + locale: ::locale_t, + ) -> ::size_t; pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char; pub fn dirname(path: *mut ::c_char) -> *mut ::c_char; diff --git a/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs b/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs index c7cbafa16ecf3..56a0e37f6dfcb 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs @@ -13,7 +13,7 @@ s! { /// Combination of granularity and offset. /// /// The granularity defines how many CPUs each bit in map describes. - /// The offset is the numer of the first CPU described by the first + /// The offset is the number of the first CPU described by the first /// bit in the bitmap. /// offset must be a multiple of 2^graularity. /// diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 17242eaf2a1df..19315c3872c88 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -729,6 +729,7 @@ pub const FIOCLEX: ::c_ulong = 0x5451; pub const TCGETS: ::c_ulong = 0x5401; pub const TCSETS: ::c_ulong = 0x5402; pub const TCFLSH: ::c_ulong = 0x540B; +pub const TIOCSCTTY: ::c_ulong = 0x540E; pub const TIOCGPGRP: ::c_ulong = 0x540F; pub const TIOCSPGRP: ::c_ulong = 0x5410; pub const TIOCGWINSZ: ::c_ulong = 0x5413; @@ -813,6 +814,7 @@ pub const SOCK_NONBLOCK: ::c_int = 0o4_000; pub const SOCK_CLOEXEC: ::c_int = 0o2_000_000; pub const SOCK_SEQPACKET: ::c_int = 5; pub const SOL_SOCKET: ::c_int = 1; +pub const SOMAXCONN: ::c_int = 128; // sys/termios.h pub const VEOF: usize = 0; @@ -1137,6 +1139,15 @@ extern "C" { clock_id: ::clockid_t, ) -> ::c_int; + //pty.h + pub fn openpty( + amaster: *mut ::c_int, + aslave: *mut ::c_int, + name: *mut ::c_char, + termp: *const termios, + winp: *const ::winsize, + ) -> ::c_int; + // pwd.h pub fn getpwent() -> *mut passwd; pub fn setpwent(); @@ -1172,9 +1183,15 @@ extern "C" { pub fn sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int; // stdlib.h + pub fn getsubopt( + optionp: *mut *mut c_char, + tokens: *const *mut c_char, + valuep: *mut *mut c_char, + ) -> ::c_int; pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void; // string.h + pub fn explicit_bzero(p: *mut ::c_void, len: ::size_t); pub fn strlcat(dst: *mut ::c_char, src: *const ::c_char, siz: ::size_t) -> ::size_t; pub fn strlcpy(dst: *mut ::c_char, src: *const ::c_char, siz: ::size_t) -> ::size_t; @@ -1201,6 +1218,8 @@ extern "C" { pub fn shm_unlink(name: *const ::c_char) -> ::c_int; // sys/resource.h + pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; + pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; @@ -1229,17 +1248,8 @@ extern "C" { pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int; pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; - // strings.h - pub fn explicit_bzero(p: *mut ::c_void, len: ::size_t); - - pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; - pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; - - pub fn getsubopt( - optionp: *mut *mut c_char, - tokens: *const *mut c_char, - valuep: *mut *mut c_char, - ) -> ::c_int; + // utmp.h + pub fn login_tty(fd: ::c_int) -> ::c_int; } cfg_if! { diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index c34ff890b412a..c68cfba3c9932 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -1294,12 +1294,13 @@ pub const O_EXCL: ::c_int = 1024; pub const O_NOCTTY: ::c_int = 2048; pub const O_TRUNC: ::c_int = 512; pub const O_NOFOLLOW: ::c_int = 0x20000; -pub const O_DIRECTORY: ::c_int = 0x1000000; pub const O_SEARCH: ::c_int = 0x200000; pub const O_EXEC: ::c_int = 0x400000; pub const O_CLOEXEC: ::c_int = 0x800000; pub const O_ACCMODE: ::c_int = 0x600003; pub const O_XATTR: ::c_int = 0x4000; +pub const O_DIRECTORY: ::c_int = 0x1000000; +pub const O_DIRECT: ::c_int = 0x2000000; pub const S_IFIFO: mode_t = 4096; pub const S_IFCHR: mode_t = 8192; pub const S_IFBLK: mode_t = 24576; @@ -2951,6 +2952,7 @@ extern "C" { result: *mut *mut ::group, ) -> ::c_int; pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int; + pub fn sigsuspend(mask: *const ::sigset_t) -> ::c_int; pub fn sem_close(sem: *mut sem_t) -> ::c_int; pub fn getdtablesize() -> ::c_int; diff --git a/src/wasi.rs b/src/wasi.rs index 1a855e0e0fe77..ae490bf94d7a2 100644 --- a/src/wasi.rs +++ b/src/wasi.rs @@ -65,6 +65,7 @@ s_paren! { // in wasi-libc clockid_t is const struct __clockid* (where __clockid is an opaque struct), // but that's an implementation detail that we don't want to have to deal with #[repr(transparent)] + #[allow(dead_code)] pub struct clockid_t(*const u8); }