From 61f2baa0af6b2a54e0c109e5f73c8ff25f9f2ca6 Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Sat, 1 Jun 2019 11:46:58 -0700 Subject: Update libc crate to 0.2.57 This change updates the libc crate to version 0.2.57. Import subrepo libc/:libc at cdc48ea36d8d2890dba38e8f779001e6855339a2 --- libc/.cirrus.yml | 27 +- libc/.travis.yml | 11 +- libc/Cargo.toml | 8 +- libc/README.md | 4 +- libc/build.rs | 36 + libc/ci/android-install-ndk.sh | 31 +- libc/ci/android-install-sdk.sh | 44 +- libc/ci/build.sh | 7 + libc/ci/docker/aarch64-linux-android/Dockerfile | 2 +- .../docker/aarch64-unknown-linux-musl/Dockerfile | 18 +- libc/ci/docker/arm-linux-androideabi/Dockerfile | 2 +- .../docker/arm-unknown-linux-musleabihf/Dockerfile | 16 +- libc/ci/docker/i686-linux-android/Dockerfile | 2 +- libc/ci/docker/i686-unknown-linux-musl/Dockerfile | 25 +- libc/ci/docker/mips-unknown-linux-gnu/Dockerfile | 2 +- libc/ci/docker/mips-unknown-linux-musl/Dockerfile | 2 +- .../mips64-unknown-linux-gnuabi64/Dockerfile | 2 +- .../mips64el-unknown-linux-gnuabi64/Dockerfile | 2 +- .../ci/docker/wasm32-unknown-emscripten/Dockerfile | 6 + libc/ci/docker/x86_64-unknown-linux-gnu/Dockerfile | 6 +- .../ci/docker/x86_64-unknown-linux-musl/Dockerfile | 18 +- libc/ci/emscripten-entry.sh | 2 +- libc/ci/emscripten.sh | 6 +- libc/ci/install-musl.sh | 69 + libc/ci/run.sh | 8 +- libc/ci/test-runner-linux | 9 - libc/libc-test/Cargo.toml | 24 +- libc/libc-test/build.rs | 1315 ++++++------------ libc/libc-test/test/linux_elf.rs | 12 + libc/libc-test/test/linux_fcntl.rs | 4 +- libc/libc-test/test/linux_ipv6.rs | 12 + libc/libc-test/test/linux_strerror_r.rs | 12 + libc/libc-test/test/linux_termios.rs | 12 + libc/src/cloudabi/mod.rs | 9 - libc/src/fixed_width_ints.rs | 44 + libc/src/fuchsia/aarch64.rs | 11 + libc/src/fuchsia/mod.rs | 223 +-- libc/src/fuchsia/x86_64.rs | 11 + libc/src/hermit/mod.rs | 9 - libc/src/lib.rs | 24 + libc/src/macros.rs | 38 + libc/src/sgx.rs | 9 - libc/src/switch.rs | 9 - libc/src/unix/bsd/apple/b32.rs | 4 +- libc/src/unix/bsd/apple/b64.rs | 4 +- libc/src/unix/bsd/apple/mod.rs | 545 ++++---- libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs | 148 +- libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs | 4 +- libc/src/unix/bsd/freebsdlike/freebsd/arm.rs | 4 +- .../unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs | 214 +++ .../bsd/freebsdlike/freebsd/freebsd11/x86_64.rs | 30 + .../unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs | 207 +++ .../bsd/freebsdlike/freebsd/freebsd12/x86_64.rs | 32 + libc/src/unix/bsd/freebsdlike/freebsd/mod.rs | 374 ++--- libc/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs | 4 +- libc/src/unix/bsd/freebsdlike/freebsd/x86.rs | 4 +- libc/src/unix/bsd/freebsdlike/freebsd/x86_64.rs | 26 - libc/src/unix/bsd/freebsdlike/mod.rs | 27 +- libc/src/unix/bsd/mod.rs | 22 +- libc/src/unix/bsd/netbsdlike/mod.rs | 11 +- libc/src/unix/bsd/netbsdlike/netbsd/mod.rs | 154 ++- libc/src/unix/bsd/netbsdlike/openbsd/aarch64.rs | 14 + libc/src/unix/bsd/netbsdlike/openbsd/mod.rs | 1451 ++++++++++++++++++++ libc/src/unix/bsd/netbsdlike/openbsd/x86.rs | 14 + libc/src/unix/bsd/netbsdlike/openbsd/x86_64.rs | 22 + libc/src/unix/bsd/netbsdlike/openbsdlike/mod.rs | 945 ------------- .../bsd/netbsdlike/openbsdlike/openbsd/aarch64.rs | 14 - .../unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs | 497 ------- .../unix/bsd/netbsdlike/openbsdlike/openbsd/x86.rs | 14 - .../bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs | 22 - libc/src/unix/haiku/mod.rs | 14 +- libc/src/unix/hermit/mod.rs | 7 + libc/src/unix/mod.rs | 80 +- libc/src/unix/newlib/mod.rs | 10 + libc/src/unix/notbsd/android/b32/mod.rs | 63 +- libc/src/unix/notbsd/android/b64/aarch64.rs | 14 +- libc/src/unix/notbsd/android/b64/mod.rs | 39 +- libc/src/unix/notbsd/android/b64/x86_64.rs | 24 +- libc/src/unix/notbsd/android/mod.rs | 246 ++-- libc/src/unix/notbsd/emscripten/mod.rs | 162 ++- libc/src/unix/notbsd/linux/mips/mod.rs | 68 +- libc/src/unix/notbsd/linux/mod.rs | 413 ++++-- libc/src/unix/notbsd/linux/musl/b32/arm.rs | 27 +- libc/src/unix/notbsd/linux/musl/b32/mips.rs | 24 +- libc/src/unix/notbsd/linux/musl/b32/powerpc.rs | 23 +- libc/src/unix/notbsd/linux/musl/b32/x86.rs | 27 +- libc/src/unix/notbsd/linux/musl/b64/aarch64.rs | 16 +- libc/src/unix/notbsd/linux/musl/b64/mod.rs | 11 - libc/src/unix/notbsd/linux/musl/b64/powerpc64.rs | 14 +- libc/src/unix/notbsd/linux/musl/b64/x86_64.rs | 19 +- libc/src/unix/notbsd/linux/musl/mod.rs | 44 + libc/src/unix/notbsd/linux/other/b32/arm.rs | 21 +- libc/src/unix/notbsd/linux/other/b32/mod.rs | 4 + libc/src/unix/notbsd/linux/other/b32/powerpc.rs | 29 +- libc/src/unix/notbsd/linux/other/b32/x86.rs | 21 +- libc/src/unix/notbsd/linux/other/b64/aarch64.rs | 24 +- libc/src/unix/notbsd/linux/other/b64/not_x32.rs | 1 + libc/src/unix/notbsd/linux/other/b64/powerpc64.rs | 31 +- libc/src/unix/notbsd/linux/other/b64/sparc64.rs | 19 +- libc/src/unix/notbsd/linux/other/b64/x32.rs | 1 + libc/src/unix/notbsd/linux/other/b64/x86_64.rs | 24 +- libc/src/unix/notbsd/linux/other/mod.rs | 155 ++- libc/src/unix/notbsd/linux/s390x/mod.rs | 43 + libc/src/unix/notbsd/mod.rs | 63 +- libc/src/unix/redox/mod.rs | 8 + libc/src/unix/solarish/mod.rs | 19 +- libc/src/unix/uclibc/arm/mod.rs | 20 +- libc/src/unix/uclibc/mips/mod.rs | 18 +- libc/src/unix/uclibc/mod.rs | 175 ++- libc/src/wasi.rs | 8 - libc/src/windows/mod.rs | 9 - nitrocli/CHANGELOG.md | 2 +- nitrocli/Cargo.lock | 10 +- 113 files changed, 5032 insertions(+), 3968 deletions(-) create mode 100644 libc/ci/install-musl.sh create mode 100644 libc/libc-test/test/linux_elf.rs create mode 100644 libc/libc-test/test/linux_ipv6.rs create mode 100644 libc/libc-test/test/linux_strerror_r.rs create mode 100644 libc/libc-test/test/linux_termios.rs create mode 100644 libc/src/fixed_width_ints.rs create mode 100644 libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs create mode 100644 libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs create mode 100644 libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs create mode 100644 libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs create mode 100644 libc/src/unix/bsd/netbsdlike/openbsd/aarch64.rs create mode 100644 libc/src/unix/bsd/netbsdlike/openbsd/mod.rs create mode 100644 libc/src/unix/bsd/netbsdlike/openbsd/x86.rs create mode 100644 libc/src/unix/bsd/netbsdlike/openbsd/x86_64.rs delete mode 100644 libc/src/unix/bsd/netbsdlike/openbsdlike/mod.rs delete mode 100644 libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/aarch64.rs delete mode 100644 libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs delete mode 100644 libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86.rs delete mode 100644 libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs diff --git a/libc/.cirrus.yml b/libc/.cirrus.yml index 3aa24af..47807ab 100644 --- a/libc/.cirrus.yml +++ b/libc/.cirrus.yml @@ -1,14 +1,27 @@ -freebsd_instance: - image: freebsd-11-1-release-amd64 - task: - # This name gets reported as a build status in GitHub - name: stable x86_64-unknown-freebsd + name: stable x86_64-unknown-freebsd-11 + freebsd_instance: + image: freebsd-11-2-release-amd64 setup_script: - pkg install -y curl - curl https://sh.rustup.rs -sSf --output rustup.sh - sh rustup.sh -y + - . $HOME/.cargo/env + - rustup default stable + test_script: + - . $HOME/.cargo/env + - sh ci/run.sh x86_64-unknown-freebsd + +task: + name: nightly x86_64-unknown-freebsd-12 + freebsd_instance: + image: freebsd-12-0-release-amd64 + setup_script: + - pkg install -y curl + - curl https://sh.rustup.rs -sSf --output rustup.sh + - sh rustup.sh --default-toolchain nightly -y + - . $HOME/.cargo/env + - rustup default nightly test_script: - . $HOME/.cargo/env - - cd libc-test - - cargo test + - sh ci/run.sh x86_64-unknown-freebsd diff --git a/libc/.travis.yml b/libc/.travis.yml index 1fa0a8d..ea5e0ac 100644 --- a/libc/.travis.yml +++ b/libc/.travis.yml @@ -22,7 +22,8 @@ matrix: install: true script: - shellcheck --version - - shellcheck ci/*.sh + # FIXME: https://github.com/koalaman/shellcheck/issues/1591 + - shellcheck -e SC2103 ci/*.sh stage: tools-and-build-and-tier1 - name: "Style" install: true @@ -174,6 +175,8 @@ matrix: stage: tier2 - env: TARGET=asmjs-unknown-emscripten stage: tier2 + - env: TARGET=i686-linux-android + stage: tier2 - env: TARGET=i686-unknown-linux-musl stage: tier2 - env: TARGET=mips-unknown-linux-gnu @@ -230,12 +233,6 @@ matrix: allow_failures: - # FIXME: android build bots time out irregularly - - env: TARGET=aarch64-linux-android - - env: TARGET=arm-linux-androideabi - # FIXME: https://github.com/rust-lang/libc/issues/1226 - - env: TARGET=asmjs-unknown-emscripten - - env: TARGET=wasm32-unknown-emscripten - name: "Semver Linux" - name: "Semver MacOSX" diff --git a/libc/Cargo.toml b/libc/Cargo.toml index ef500be..82ecfe0 100644 --- a/libc/Cargo.toml +++ b/libc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libc" -version = "0.2.55" +version = "0.2.57" authors = ["The Rust Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" @@ -23,11 +23,13 @@ appveyor = { repository = "rust-lang/libc", project_name = "rust-lang-libs/libc" rustc-std-workspace-core = { version = "1.0.0", optional = true } [features] -default = ["use_std"] -use_std = [] +default = ["std"] +std = [] align = [] rustc-dep-of-std = ['align', 'rustc-std-workspace-core'] extra_traits = [] +# use_std is deprecated, use `std` instead +use_std = [ 'std' ] [workspace] members = ["libc-test"] diff --git a/libc/README.md b/libc/README.md index a974ccd..7bde17d 100644 --- a/libc/README.md +++ b/libc/README.md @@ -28,13 +28,15 @@ libc = "0.2" ## Features -* `use_std`: by default `libc` links to the standard library. Disable this +* `std`: by default `libc` links to the standard library. Disable this feature remove this dependency and be able to use `libc` in `#![no_std]` crates. * `extra_traits`: all `struct`s implemented in `libc` are `Copy` and `Clone`. This feature derives `Debug`, `Eq`, `Hash`, and `PartialEq`. +* **deprecated**: `use_std` is deprecated, and is equivalent to `std`. + ## Rust version support The minimum supported Rust toolchain version is **Rust 1.13.0** . APIs requiring diff --git a/libc/build.rs b/libc/build.rs index 9b13376..8452940 100644 --- a/libc/build.rs +++ b/libc/build.rs @@ -9,6 +9,19 @@ fn main() { std::env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); let align_cargo_feature = std::env::var("CARGO_FEATURE_ALIGN").is_ok(); + if std::env::var("CARGO_FEATURE_USE_STD").is_ok() { + println!( + "cargo:warning=\"libc's use_std cargo feature is deprecated since libc 0.2.55; \ + please consider using the `std` cargo feature instead\"" + ); + } + + if std::env::var("LIBC_CI").is_ok() { + if let Some(12) = which_freebsd() { + println!("cargo:rustc-cfg=freebsd12"); + } + } + // Rust >= 1.15 supports private module use: if rustc_minor_ver >= 15 || rustc_dep_of_std { println!("cargo:rustc-cfg=libc_priv_mod_use"); @@ -63,3 +76,26 @@ fn rustc_minor_version() -> Option { otry!(pieces.next()).parse().ok() } + +fn which_freebsd() -> Option { + let output = std::process::Command::new("freebsd-version").output().ok(); + if output.is_none() { + return None; + } + let output = output.unwrap(); + if !output.status.success() { + return None; + } + + let stdout = String::from_utf8(output.stdout).ok(); + if stdout.is_none() { + return None; + } + let stdout = stdout.unwrap(); + + match &stdout { + s if s.starts_with("11") => Some(11), + s if s.starts_with("12") => Some(12), + _ => None, + } +} diff --git a/libc/ci/android-install-ndk.sh b/libc/ci/android-install-ndk.sh index 54f7b2e..723e719 100644 --- a/libc/ci/android-install-ndk.sh +++ b/libc/ci/android-install-ndk.sh @@ -11,27 +11,40 @@ set -ex -curl --retry 10 -O https://dl.google.com/android/repository/android-ndk-r15b-linux-x86_64.zip -unzip -q android-ndk-r15b-linux-x86_64.zip +NDK=android-ndk-r19c +curl --retry 20 -O https://dl.google.com/android/repository/${NDK}-linux-x86_64.zip +unzip -q ${NDK}-linux-x86_64.zip case "$1" in + arm) + arch=arm + api=24 + ;; + armv7) + arch=arm + api=24 + ;; aarch64) arch=arm64 + api=24 ;; - i686) arch=x86 + api=28 + ;; + x86_64) + arch=x86_64 + api=28 ;; - *) - arch=$1 + echo "invalid arch: $1" + exit 1 ;; esac; -android-ndk-r15b/build/tools/make_standalone_toolchain.py \ - --unified-headers \ +${NDK}/build/tools/make_standalone_toolchain.py \ --install-dir "/android/ndk-${1}" \ --arch "${arch}" \ - --api 24 + --api ${api} -rm -rf ./android-ndk-r15b-linux-x86_64.zip ./android-ndk-r15b +rm -rf ./${NDK}-linux-x86_64.zip ./${NDK} diff --git a/libc/ci/android-install-sdk.sh b/libc/ci/android-install-sdk.sh index e011cfc..7f21040 100644 --- a/libc/ci/android-install-sdk.sh +++ b/libc/ci/android-install-sdk.sh @@ -18,46 +18,56 @@ set -ex # located in https://github.com/appunite/docker by just wrapping it in a script # which apparently magically accepts the licenses. +SDK=4333796 mkdir sdk -curl --retry 10 https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip -O -unzip -d sdk sdk-tools-linux-3859397.zip +curl --retry 20 https://dl.google.com/android/repository/sdk-tools-linux-${SDK}.zip -O +unzip -q -d sdk sdk-tools-linux-${SDK}.zip case "$1" in arm | armv7) - abi=armeabi-v7a + api=24 + image="system-images;android-${api};google_apis;armeabi-v7a" ;; - aarch64) - abi=arm64-v8a + api=24 + image="system-images;android-${api};google_apis;arm64-v8a" ;; - i686) - abi=x86 + api=28 + image="system-images;android-${api};default;x86" ;; - x86_64) - abi=x86_64 + api=28 + image="system-images;android-${api};default;x86_64" ;; - *) echo "invalid arch: $1" exit 1 ;; esac; -# See: https://stackoverflow.com/a/51644855/1422197 -export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee' +# Try to fix warning about missing file. +# See https://askubuntu.com/a/1078784 +mkdir -p /root/.android/ +echo '### User Sources for Android SDK Manager' >> /root/.android/repositories.cfg +echo '#Fri Nov 03 10:11:27 CET 2017 count=0' >> /root/.android/repositories.cfg + +# Print all available packages +# yes | ./sdk/tools/bin/sdkmanager --list --verbose # --no_https avoids - # javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found -yes | ./sdk/tools/bin/sdkmanager --licenses --no_https +# javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found +# +# | grep -v = || true removes the progress bar output from the sdkmanager +# which produces an insane amount of output. +yes | ./sdk/tools/bin/sdkmanager --licenses --no_https | grep -v = || true yes | ./sdk/tools/bin/sdkmanager --no_https \ "emulator" \ "platform-tools" \ - "platforms;android-24" \ - "system-images;android-24;default;$abi" + "platforms;android-${api}" \ + "${image}" | grep -v = || true echo "no" | ./sdk/tools/bin/avdmanager create avd \ --name "${1}" \ - --package "system-images;android-24;default;$abi" + --package "${image}" | grep -v = || true diff --git a/libc/ci/build.sh b/libc/ci/build.sh index eb07c18..707dd4a 100644 --- a/libc/ci/build.sh +++ b/libc/ci/build.sh @@ -23,6 +23,11 @@ test_target() { # See https://github.com/rust-lang/rust/issues/45417 opt="--release" fi + # FIXME: https://github.com/rust-lang/rust/issues/61174 + if [ "${TARGET}" = "sparcv9-sun-solaris" ] || + [ "${TARGET}" = "x86_64-sun-solaris" ]; then + return 0 + fi # If there is a std component, fetch it: if [ "${NO_STD}" != "1" ]; then @@ -170,6 +175,7 @@ done RUST_LINUX_NO_CORE_TARGETS="\ aarch64-pc-windows-msvc \ aarch64-unknown-cloudabi \ +aarch64-unknown-freebsd \ aarch64-unknown-hermit \ aarch64-unknown-netbsd \ aarch64-unknown-openbsd \ @@ -189,6 +195,7 @@ mipsel-unknown-linux-uclibc \ nvptx64-nvidia-cuda \ powerpc-unknown-linux-gnuspe \ powerpc-unknown-netbsd \ +powerpc64-unknown-freebsd \ riscv32imac-unknown-none-elf \ riscv32imc-unknown-none-elf \ sparc64-unknown-netbsd \ diff --git a/libc/ci/docker/aarch64-linux-android/Dockerfile b/libc/ci/docker/aarch64-linux-android/Dockerfile index 1458423..6751dd9 100644 --- a/libc/ci/docker/aarch64-linux-android/Dockerfile +++ b/libc/ci/docker/aarch64-linux-android/Dockerfile @@ -9,7 +9,7 @@ RUN dpkg --add-architecture i386 && \ python \ unzip \ expect \ - openjdk-11-jre \ + openjdk-8-jre \ libstdc++6:i386 \ libpulse0 \ gcc \ diff --git a/libc/ci/docker/aarch64-unknown-linux-musl/Dockerfile b/libc/ci/docker/aarch64-unknown-linux-musl/Dockerfile index 143a960..e9634bf 100644 --- a/libc/ci/docker/aarch64-unknown-linux-musl/Dockerfile +++ b/libc/ci/docker/aarch64-unknown-linux-musl/Dockerfile @@ -3,21 +3,9 @@ FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc make libc6-dev git curl ca-certificates \ gcc-aarch64-linux-gnu qemu-user -RUN curl --retry 5 https://www.musl-libc.org/releases/musl-1.1.19.tar.gz | \ - tar xzf - && \ - cd musl-1.1.19 && \ - CC=aarch64-linux-gnu-gcc \ - ./configure --prefix=/musl-aarch64 --enable-wrapper=yes && \ - make install -j4 && \ - cd .. && \ - rm -rf musl-1.1.19 -# Install linux kernel headers sanitized for use with musl -RUN curl --retry 5 -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-6.tar.gz | \ - tar xzf - && \ - cd kernel-headers-3.12.6-6 && \ - make ARCH=arm64 prefix=/musl-aarch64 install -j4 && \ - cd .. && \ - rm -rf kernel-headers-3.12.6-6 + +COPY install-musl.sh / +RUN sh /install-musl.sh aarch64 # FIXME: shouldn't need the `-lgcc` here, shouldn't that be in libstd? ENV PATH=$PATH:/musl-aarch64/bin:/rust/bin \ diff --git a/libc/ci/docker/arm-linux-androideabi/Dockerfile b/libc/ci/docker/arm-linux-androideabi/Dockerfile index acc784e..544d167 100644 --- a/libc/ci/docker/arm-linux-androideabi/Dockerfile +++ b/libc/ci/docker/arm-linux-androideabi/Dockerfile @@ -9,7 +9,7 @@ RUN dpkg --add-architecture i386 && \ python \ unzip \ expect \ - openjdk-11-jre \ + openjdk-8-jre \ libstdc++6:i386 \ libpulse0 \ gcc \ diff --git a/libc/ci/docker/arm-unknown-linux-musleabihf/Dockerfile b/libc/ci/docker/arm-unknown-linux-musleabihf/Dockerfile index e29e854..639b141 100644 --- a/libc/ci/docker/arm-unknown-linux-musleabihf/Dockerfile +++ b/libc/ci/docker/arm-unknown-linux-musleabihf/Dockerfile @@ -4,20 +4,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc make libc6-dev git curl ca-certificates \ gcc-arm-linux-gnueabihf qemu-user -RUN curl --retry 5 https://www.musl-libc.org/releases/musl-1.1.19.tar.gz | tar xzf - -WORKDIR /musl-1.1.19 -RUN CC=arm-linux-gnueabihf-gcc \ - CFLAGS="-march=armv6 -marm -mfpu=vfp" \ - ./configure --prefix=/musl-arm --enable-wrapper=yes -RUN make install -j4 - -# Install linux kernel headers sanitized for use with musl -RUN curl --retry 5 -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-6.tar.gz | \ - tar xzf - && \ - cd kernel-headers-3.12.6-6 && \ - make ARCH=arm prefix=/musl-arm install -j4 && \ - cd .. && \ - rm -rf kernel-headers-3.12.6-6 +COPY install-musl.sh / +RUN sh /install-musl.sh arm ENV PATH=$PATH:/musl-arm/bin:/rust/bin \ CC_arm_unknown_linux_musleabihf=musl-gcc \ diff --git a/libc/ci/docker/i686-linux-android/Dockerfile b/libc/ci/docker/i686-linux-android/Dockerfile index 59ea2d7..5403220 100644 --- a/libc/ci/docker/i686-linux-android/Dockerfile +++ b/libc/ci/docker/i686-linux-android/Dockerfile @@ -9,7 +9,7 @@ RUN dpkg --add-architecture i386 && \ python \ unzip \ expect \ - openjdk-11-jre \ + openjdk-8-jre \ libstdc++6:i386 \ libpulse0 \ gcc \ diff --git a/libc/ci/docker/i686-unknown-linux-musl/Dockerfile b/libc/ci/docker/i686-unknown-linux-musl/Dockerfile index c085c10..ac76a32 100644 --- a/libc/ci/docker/i686-unknown-linux-musl/Dockerfile +++ b/libc/ci/docker/i686-unknown-linux-musl/Dockerfile @@ -4,28 +4,9 @@ RUN dpkg --add-architecture i386 RUN apt-get update RUN apt-get install -y --no-install-recommends \ gcc-multilib make libc6-dev git curl ca-certificates libc6:i386 -# Below we're cross-compiling musl for i686 using the system compiler on an -# x86_64 system. This is an awkward thing to be doing and so we have to jump -# through a couple hoops to get musl to be happy. In particular: -# -# * We specifically pass -m32 in CFLAGS and override CC when running ./configure, -# since otherwise the script will fail to find a compiler. -# * We manually unset CROSS_COMPILE when running make; otherwise the makefile -# will call the non-existent binary 'i686-ar'. -RUN curl --retry 5 https://www.musl-libc.org/releases/musl-1.1.19.tar.gz | \ - tar xzf - && \ - cd musl-1.1.19 && \ - CC=gcc CFLAGS=-m32 ./configure --prefix=/musl-i686 --disable-shared --target=i686 && \ - make CROSS_COMPILE= install -j4 && \ - cd .. && \ - rm -rf musl-1.1.19 -# Install linux kernel headers sanitized for use with musl -RUN curl --retry 5 -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-6.tar.gz | \ - tar xzf - && \ - cd kernel-headers-3.12.6-6 && \ - make ARCH=i386 prefix=/musl-i686 install -j4 && \ - cd .. && \ - rm -rf kernel-headers-3.12.6-6 + +COPY install-musl.sh / +RUN sh /install-musl.sh i686 ENV PATH=$PATH:/musl-i686/bin:/rust/bin \ CC_i686_unknown_linux_musl=musl-gcc diff --git a/libc/ci/docker/mips-unknown-linux-gnu/Dockerfile b/libc/ci/docker/mips-unknown-linux-gnu/Dockerfile index 9f1bcaf..c8623a5 100644 --- a/libc/ci/docker/mips-unknown-linux-gnu/Dockerfile +++ b/libc/ci/docker/mips-unknown-linux-gnu/Dockerfile @@ -3,7 +3,7 @@ FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ gcc-mips-linux-gnu libc6-dev-mips-cross \ - qemu-system-mips + qemu-system-mips linux-headers-generic ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc \ CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_RUNNER="qemu-mips -L /usr/mips-linux-gnu" \ diff --git a/libc/ci/docker/mips-unknown-linux-musl/Dockerfile b/libc/ci/docker/mips-unknown-linux-musl/Dockerfile index 7f2764c..aee73be 100644 --- a/libc/ci/docker/mips-unknown-linux-musl/Dockerfile +++ b/libc/ci/docker/mips-unknown-linux-musl/Dockerfile @@ -9,7 +9,7 @@ RUN mkdir /toolchain # Note that this originally came from: # https://downloads.openwrt.org/snapshots/trunk/ar71xx/generic/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 RUN curl --retry 5 -L https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \ - tar xjf - -C /toolchain --strip-components=1 + tar xjf - -C /toolchain --strip-components=1 ENV PATH=$PATH:/rust/bin:/toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15/bin \ CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \ diff --git a/libc/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile b/libc/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile index b97cdb4..d4b972d 100644 --- a/libc/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile +++ b/libc/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile @@ -3,7 +3,7 @@ FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ gcc-mips64-linux-gnuabi64 libc6-dev-mips64-cross \ - qemu-system-mips64 + qemu-system-mips64 linux-headers-generic ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc \ CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64 -L /usr/mips64-linux-gnuabi64" \ diff --git a/libc/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile b/libc/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile index 7f79452..d0303da 100644 --- a/libc/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile +++ b/libc/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile @@ -3,7 +3,7 @@ FROM ubuntu:19.04 RUN apt-get update && apt-get install -y --no-install-recommends \ gcc libc6-dev qemu-user ca-certificates \ gcc-mips64el-linux-gnuabi64 libc6-dev-mips64el-cross \ - qemu-system-mips64el + qemu-system-mips64el linux-headers-generic ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER=mips64el-linux-gnuabi64-gcc \ CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64el -L /usr/mips64el-linux-gnuabi64" \ diff --git a/libc/ci/docker/wasm32-unknown-emscripten/Dockerfile b/libc/ci/docker/wasm32-unknown-emscripten/Dockerfile index de8e353..c0ce825 100644 --- a/libc/ci/docker/wasm32-unknown-emscripten/Dockerfile +++ b/libc/ci/docker/wasm32-unknown-emscripten/Dockerfile @@ -3,11 +3,17 @@ FROM ubuntu:19.04 RUN apt-get update && \ apt-get install -y --no-install-recommends \ ca-certificates \ + g++ \ + make \ + file \ curl \ gcc \ git \ libc6-dev \ python \ + cmake \ + sudo \ + gdb \ xz-utils COPY emscripten.sh / diff --git a/libc/ci/docker/x86_64-unknown-linux-gnu/Dockerfile b/libc/ci/docker/x86_64-unknown-linux-gnu/Dockerfile index 0dbb191..bfa2b17 100644 --- a/libc/ci/docker/x86_64-unknown-linux-gnu/Dockerfile +++ b/libc/ci/docker/x86_64-unknown-linux-gnu/Dockerfile @@ -1,5 +1,9 @@ FROM ubuntu:19.04 RUN apt-get update RUN apt-get install -y --no-install-recommends \ - gcc libc6-dev ca-certificates + gcc libc6-dev ca-certificates linux-headers-generic + +RUN apt search linux-headers +RUN ls /usr/src + ENV PATH=$PATH:/rust/bin diff --git a/libc/ci/docker/x86_64-unknown-linux-musl/Dockerfile b/libc/ci/docker/x86_64-unknown-linux-musl/Dockerfile index 59164d2..06a081b 100644 --- a/libc/ci/docker/x86_64-unknown-linux-musl/Dockerfile +++ b/libc/ci/docker/x86_64-unknown-linux-musl/Dockerfile @@ -3,18 +3,8 @@ FROM ubuntu:19.04 RUN apt-get update RUN apt-get install -y --no-install-recommends \ gcc make libc6-dev git curl ca-certificates -RUN curl --retry 5 https://www.musl-libc.org/releases/musl-1.1.19.tar.gz | \ - tar xzf - && \ - cd musl-1.1.19 && \ - ./configure --prefix=/musl-x86_64 && \ - make install -j4 && \ - cd .. && \ - rm -rf musl-1.1.19 -# Install linux kernel headers sanitized for use with musl -RUN curl --retry 5 -L https://github.com/sabotage-linux/kernel-headers/archive/v3.12.6-6.tar.gz | \ - tar xzf - && \ - cd kernel-headers-3.12.6-6 && \ - make ARCH=x86_64 prefix=/musl-x86_64 install -j4 && \ - cd .. && \ - rm -rf kernel-headers-3.12.6-6 + +COPY install-musl.sh / +RUN sh /install-musl.sh x86_64 + ENV PATH=$PATH:/musl-x86_64/bin:/rust/bin diff --git a/libc/ci/emscripten-entry.sh b/libc/ci/emscripten-entry.sh index e92c1cb..0016f56 100755 --- a/libc/ci/emscripten-entry.sh +++ b/libc/ci/emscripten-entry.sh @@ -15,6 +15,6 @@ set -ex source /emsdk-portable/emsdk_env.sh &> /dev/null # emsdk-portable provides a node binary, but we need version 8 to run wasm -export PATH="/node-v8.0.0-linux-x64/bin:$PATH" +export PATH="/node-v12.3.1-linux-x64/bin:$PATH" exec "$@" diff --git a/libc/ci/emscripten.sh b/libc/ci/emscripten.sh index ce3b541..db31323 100644 --- a/libc/ci/emscripten.sh +++ b/libc/ci/emscripten.sh @@ -34,8 +34,8 @@ curl --retry 5 -L https://s3.amazonaws.com/mozilla-games/emscripten/releases/ems cd /emsdk-portable ./emsdk update -hide_output ./emsdk install sdk-1.37.20-64bit -./emsdk activate sdk-1.37.20-64bit +hide_output ./emsdk install sdk-1.38.15-64bit +./emsdk activate sdk-1.38.15-64bit # Compile and cache libc # shellcheck disable=SC1091 @@ -51,6 +51,6 @@ chmod a+rxw -R /emsdk-portable # node 8 is required to run wasm cd / -curl --retry 5 -L https://nodejs.org/dist/v8.0.0/node-v8.0.0-linux-x64.tar.xz | \ +curl --retry 5 -L https://nodejs.org/dist/v12.3.1/node-v12.3.1-linux-x64.tar.xz | \ tar -xJ diff --git a/libc/ci/install-musl.sh b/libc/ci/install-musl.sh new file mode 100644 index 0000000..ab98c4f --- /dev/null +++ b/libc/ci/install-musl.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env sh +# +# Install musl and musl-sanitized linux kernel headers +# to musl-{$1} directory + +set -ex + +MUSL_VERSION=1.1.22 +MUSL="musl-${MUSL_VERSION}" + +# Download, configure, build, and install musl: +curl --retry 5 https://www.musl-libc.org/releases/${MUSL}.tar.gz | tar xzf - + +cd $MUSL +case ${1} in + aarch64) + musl_arch=aarch64 + kernel_arch=arm64 + CC=aarch64-linux-gnu-gcc \ + ./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes + make install -j4 + ;; + arm) + musl_arch=arm + kernel_arch=arm + CC=arm-linux-gnueabihf-gcc CFLAGS="-march=armv6 -marm -mfpu=vfp" \ + ./configure --prefix="/musl-${musl_arch}" --enable-wrapper=yes + make install -j4 + ;; + i686) + # cross-compile musl for i686 using the system compiler on an x86_64 + # system. + musl_arch=i686 + kernel_arch=i386 + # Specifically pass -m32 in CFLAGS and override CC when running + # ./configure, since otherwise the script will fail to find a compiler. + CC=gcc CFLAGS="-m32" \ + ./configure --prefix="/musl-${musl_arch}" --disable-shared --target=i686 + # unset CROSS_COMPILE when running make; otherwise the makefile will + # call the non-existent binary 'i686-ar'. + make CROSS_COMPILE= install -j4 + ;; + x86_64) + musl_arch=x86_64 + kernel_arch=x86_64 + ./configure --prefix="/musl-${musl_arch}" + make install -j4 + ;; + *) + echo "Unknown target arch: \"${1}\"" + exit 1 + ;; +esac + + +# shellcheck disable=SC2103 +cd .. +rm -rf $MUSL + +# Download, configure, build, and install musl-sanitized kernel headers: +KERNEL_HEADER_VER="4.4.2-2" +curl --retry 5 -L \ + "https://github.com/sabotage-linux/kernel-headers/archive/v${KERNEL_HEADER_VER}.tar.gz" | \ + tar xzf - +( + cd kernel-headers-${KERNEL_HEADER_VER} + make ARCH="${kernel_arch}" prefix="/musl-${musl_arch}" install -j4 +) +rm -rf kernel-headers-${KERNEL_HEADER_VER} diff --git a/libc/ci/run.sh b/libc/ci/run.sh index 427d3bf..8c56979 100755 --- a/libc/ci/run.sh +++ b/libc/ci/run.sh @@ -87,10 +87,12 @@ if [ "$TARGET" = "x86_64-unknown-linux-gnux32" ]; then opt="--release" fi -cargo test $opt --no-default-features --manifest-path libc-test/Cargo.toml \ +export LIBC_CI=1 + +cargo test -vv $opt --no-default-features --manifest-path libc-test/Cargo.toml \ --target "${TARGET}" -cargo test $opt --manifest-path libc-test/Cargo.toml --target "${TARGET}" +cargo test -vv $opt --manifest-path libc-test/Cargo.toml --target "${TARGET}" -cargo test $opt --features extra_traits --manifest-path libc-test/Cargo.toml \ +cargo test -vv $opt --features extra_traits --manifest-path libc-test/Cargo.toml \ --target "${TARGET}" diff --git a/libc/ci/test-runner-linux b/libc/ci/test-runner-linux index 569fa00..cad31ec 100755 --- a/libc/ci/test-runner-linux +++ b/libc/ci/test-runner-linux @@ -5,15 +5,6 @@ set -e arch=$1 prog=$2 -# Skip cmsg test on linux-s390x -# https://github.com/rust-lang/libc/issues/1240 -if [ "$arch" = "s390x" ]; then - progbasename=`basename $prog` - if [ "${progbasename%%-*}" = "cmsg" ]; then - exit 0 - fi -fi - cd /qemu/init echo "#!/bin/sh\n/prog --color=never" > run_prog.sh chmod +x run_prog.sh diff --git a/libc/libc-test/Cargo.toml b/libc/libc-test/Cargo.toml index 9862d3a..8d2d903 100644 --- a/libc/libc-test/Cargo.toml +++ b/libc/libc-test/Cargo.toml @@ -13,8 +13,8 @@ cc = "1.0" ctest = "0.2" [features] -default = [ "use_std" ] -use_std = [ "libc/use_std" ] +default = [ "std" ] +std = [ "libc/std" ] align = [ "libc/align" ] extra_traits = [ "libc/extra_traits" ] @@ -28,6 +28,26 @@ name = "linux-fcntl" path = "test/linux_fcntl.rs" harness = false +[[test]] +name = "linux-ipv6" +path = "test/linux_ipv6.rs" +harness = false + +[[test]] +name = "linux-elf" +path = "test/linux_elf.rs" +harness = false + +[[test]] +name = "linux-strerror_r" +path = "test/linux_strerror_r.rs" +harness = false + +[[test]] +name = "linux-termios" +path = "test/linux_termios.rs" +harness = false + [[test]] name = "cmsg" path = "test/cmsg.rs" diff --git a/libc/libc-test/build.rs b/libc/libc-test/build.rs index 6541fd5..5087906 100644 --- a/libc/libc-test/build.rs +++ b/libc/libc-test/build.rs @@ -37,14 +37,22 @@ fn main() { } macro_rules! headers { - ($cfg:ident: $header:expr) => { + ($cfg:ident: [$m:expr]: $header:literal) => { + if $m { + $cfg.header($header); + } + }; + ($cfg:ident: $header:literal) => { $cfg.header($header); }; - ($cfg:ident: $($header:expr),*) => { - $(headers!($cfg: $header);)* + ($($cfg:ident: $([$c:expr]:)* $header:literal,)*) => { + $(headers!($cfg: $([$c]:)* $header);)* }; - ($cfg:ident: $($header:expr,)*) => { - $(headers!($cfg: $header);)* + ($cfg:ident: $( $([$c:expr]:)* $header:literal,)*) => { + headers!($($cfg: $([$c]:)* $header,)*); + }; + ($cfg:ident: $( $([$c:expr]:)* $header:literal),*) => { + headers!($($cfg: $([$c]:)* $header,)*); }; } @@ -135,10 +143,7 @@ fn test_apple(target: &str) { "utmpx.h", "wchar.h", "xlocale.h", - } - - if x86_64 { - headers! { cfg: "crt_externs.h" } + [x86_64]: "crt_externs.h", } cfg.skip_struct(move |ty| { @@ -313,11 +318,9 @@ fn test_openbsd(target: &str) { cfg.skip_fn(move |name| { match name { + // FIXME: https://github.com/rust-lang/libc/issues/1272 "execv" | "execve" | "execvp" | "execvpe" => true, - // typed 2nd arg - "gettimeofday" => true, - // Removed in OpenBSD 6.5 // https://marc.info/?l=openbsd-cvs&m=154723400730318 "mincore" => true, @@ -388,12 +391,8 @@ fn test_windows(target: &str) { "sys/utime.h", "time.h", "wchar.h", - } - - if gnu { - headers! { cfg: "ws2tcpip.h" } - } else { - headers! { cfg: "Winsock2.h" }; + [gnu]: "ws2tcpip.h", + [!gnu]: "Winsock2.h", } cfg.type_name(move |ty, is_struct, is_union| { @@ -461,7 +460,7 @@ fn test_windows(target: &str) { cfg.skip_fn(move |name| { match name { - // FIXME: API error: + // FIXME: https://github.com/rust-lang/libc/issues/1272 "execv" | "execve" | "execvp" | "execvpe" => true, _ => false, @@ -852,7 +851,6 @@ fn test_netbsd(target: &str) { cfg.skip_signededness(move |c| { match c { "LARGE_INTEGER" | "float" | "double" => true, - // uuid_t is a struct, not an integer. n if n.starts_with("pthread") => true, // sem_t is a struct or pointer "sem_t" => true, @@ -876,12 +874,8 @@ fn test_netbsd(target: &str) { cfg.skip_fn(move |name| { match name { - // FIXME: incorrect API - "execv" | - "execve" | - "execvp" | - "execvpe" | - "fexecve" => true, + // FIXME: https://github.com/rust-lang/libc/issues/1272 + "execv" | "execve" | "execvp" => true, "getrlimit" | "getrlimit64" | // non-int in 1st arg "setrlimit" | "setrlimit64" | // non-int in 1st arg @@ -1028,14 +1022,9 @@ fn test_dragonflybsd(target: &str) { s.replace("e_nsec", ".tv_nsec") } "u64" if struct_ == "epoll_event" => "data.u64".to_string(), - "type_" - if struct_ == "input_event" - || struct_ == "input_mask" - || struct_ == "ff_effect" - || struct_ == "rtprio" => - { - "type".to_string() - } + // Field is named `type` in C but that is a Rust keyword, + // so these fields are translated to `type_` in the bindings. + "type_" if struct_ == "rtprio" => "type".to_string(), s => s.to_string(), } }); @@ -1105,17 +1094,13 @@ fn test_dragonflybsd(target: &str) { cfg.skip_fn(move |name| { // skip those that are manually verified match name { - "execv" | // crazy stuff with const/mut - "execve" | - "execvp" | - "execvpe" | - "fexecve" => true, + // FIXME: https://github.com/rust-lang/libc/issues/1272 + "execv" | "execve" | "execvp" => true, "getrlimit" | "getrlimit64" | // non-int in 1st arg "setrlimit" | "setrlimit64" | // non-int in 1st arg - "prlimit" | "prlimit64" | // non-int in 2nd arg - // typed 2nd arg on linux - "gettimeofday" => true, + "prlimit" | "prlimit64" // non-int in 2nd arg + => true, _ => false, } @@ -1226,14 +1211,6 @@ fn test_android(target: &str) { let mut cfg = ctest::TestGenerator::new(); cfg.define("_GNU_SOURCE", None); - // FIXME: still necessary? - cfg.flag("-Wno-deprecated-declarations"); - - // Android doesn't actually have in_port_t but it's much easier if we - // provide one for us to test against - // FIXME: still necessary? - cfg.define("in_port_t", Some("uint16_t")); - headers! { cfg: "arpa/inet.h", "asm/mman.h", @@ -1300,6 +1277,7 @@ fn test_android(target: &str) { "sys/personality.h", "sys/prctl.h", "sys/ptrace.h", + "sys/random.h", "sys/reboot.h", "sys/resource.h", "sys/sendfile.h", @@ -1317,6 +1295,7 @@ fn test_android(target: &str) { "sys/un.h", "sys/utsname.h", "sys/vfs.h", + "sys/xattr.h", "sys/wait.h", "syslog.h", "termios.h", @@ -1326,30 +1305,24 @@ fn test_android(target: &str) { "utmp.h", "wchar.h", "xlocale.h", - } - - if target_pointer_width == 32 { - // time64_t is not defined for 64-bit targets If included it will - // generate the error 'Your time_t is already 64-bit' - cfg.header("time64.h"); - } - if x86 { - cfg.header("sys/reg.h"); + // time64_t is not defined for 64-bit targets If included it will + // generate the error 'Your time_t is already 64-bit' + [target_pointer_width == 32]: "time64.h", + [x86]: "sys/reg.h", } cfg.type_name(move |ty, is_struct, is_union| { match ty { // Just pass all these through, no need for a "struct" prefix - // FIXME: still required ? - "FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" - | "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym" - | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr" - | "Elf64_Chdr" => ty.to_string(), + "FILE" | "fd_set" | "Dl_info" => ty.to_string(), t if is_union => format!("union {}", t), t if t.ends_with("_t") => t.to_string(), + // sigval is a struct in Rust, but a union in C: + "sigval" => format!("union sigval"), + // put `struct` in front of all structs:. t if is_struct => format!("struct {}", t), @@ -1364,7 +1337,7 @@ fn test_android(target: &str) { s if s.ends_with("_nsec") && struct_.starts_with("stat") => { s.to_string() } - // FIXME: still necessary? + // FIXME: appears that `epoll_event.data` is an union "u64" if struct_ == "epoll_event" => "data.u64".to_string(), s => s.to_string(), } @@ -1372,8 +1345,8 @@ fn test_android(target: &str) { cfg.skip_type(move |ty| { match ty { - // sighandler_t is crazy across platforms - // FIXME: still necessary? + // FIXME: `sighandler_t` type is incorrect, see: + // https://github.com/rust-lang/libc/issues/1359 "sighandler_t" => true, _ => false, } @@ -1381,71 +1354,24 @@ fn test_android(target: &str) { cfg.skip_struct(move |ty| { match ty { - // This is actually a union, not a struct - // FIXME: still necessary - "sigval" => true, - - // These structs have changed since unified headers in NDK r14b. - // `st_atime` and `st_atime_nsec` have changed sign. - // FIXME: unskip it for next major release - "stat" | "stat64" => true, - // These are tested as part of the linux_fcntl tests since there are // header conflicts when including them with all the other structs. - // FIXME: still necessary "termios2" => true, _ => false, } }); - cfg.skip_signededness(move |c| { - match c { - // FIXME: still necessary? - "LARGE_INTEGER" | "float" | "double" => true, - // FIXME: still necessary? - n if n.starts_with("pthread") => true, - _ => false, - } - }); - cfg.skip_const(move |name| { match name { - // FIXME: still necessary? - "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness - // FIXME: still necessary? - "SIGUNUSED" => true, // removed in glibc 2.26 - - // weird signed extension or something like that? - // FIXME: still necessary? - "MS_NOUSER" => true, - // FIXME: still necessary? - "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 - - // Android uses old kernel headers - // These are constants used in getrandom syscall - // FIXME: still necessary? - "GRND_NONBLOCK" | "GRND_RANDOM" => true, - - // Defined by libattr not libc on linux (hard to test). - // See constant definition for more details. - // FIXME: still necessary? + // FIXME: deprecated: not available in any header + // See: https://github.com/rust-lang/libc/issues/1356 "ENOATTR" => true, // FIXME: still necessary? - "BOTHER" => true, - - // MFD_HUGETLB is not available in some older libc versions on the CI builders. On the - // x86_64 and i686 builders it seems to be available for all targets, so at least test - // it there. - // FIXME: still necessary? - "MFD_HUGETLB" => true, - - // These change all the time from release to release of linux - // distros, let's just not bother trying to verify them. They - // shouldn't be used in code anyway... - // FIXME: still necessary? - "AF_MAX" | "PF_MAX" => true, + "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness + // FIXME: deprecated - removed in glibc 2.26 + "SIGUNUSED" => true, _ => false, } @@ -1454,128 +1380,72 @@ fn test_android(target: &str) { cfg.skip_fn(move |name| { // skip those that are manually verified match name { - // FIXME: still necessary? - "execv" | // crazy stuff with const/mut - "execve" | - "execvp" | - "execvpe" | - "fexecve" => true, - - // typed 2nd arg on android - // FIXME: still necessary? - "gettimeofday" => true, - - // not declared in newer android toolchains - // FIXME: still necessary? - "getdtablesize" => true, - - // FIXME: still necessary? - "dlerror" => true, // const-ness is added - - // Apparently the NDK doesn't have this defined on android, but - // it's in a header file? - // FIXME: still necessary? - "endpwent" => true, - - // Apparently res_init exists on Android, but isn't defined in a header: - // https://mail.gnome.org/archives/commits-list/2013-May/msg01329.html - // FIXME: still necessary? - "res_init" => true, - - // Definition of those functions as changed since unified headers from NDK r14b - // These changes imply some API breaking changes but are still ABI compatible. - // We can wait for the next major release to be compliant with the new API. - // FIXME: unskip these for next major release - "strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" | - "setpriority" | "personality" => true, - // In Android 64 bits, these functions have been fixed since unified headers. - // Ignore these until next major version. - "bind" | "writev" | "readv" | "sendmsg" | "recvmsg" - if target_pointer_width == 64 => true, + // FIXME: https://github.com/rust-lang/libc/issues/1272 + "execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true, - _ => false, - } - }); + // There are two versions of the sterror_r function, see + // + // https://linux.die.net/man/3/strerror_r + // + // An XSI-compliant version provided if: + // + // (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE + // + // and a GNU specific version provided if _GNU_SOURCE is defined. + // + // libc provides bindings for the XSI-compliant version, which is + // preferred for portable applications. + // + // We skip the test here since here _GNU_SOURCE is defined, and + // test the XSI version below. + "strerror_r" => true, - cfg.skip_static(move |name| { - match name { - // Internal constant, not declared in any headers. - // FIXME: still necessary - "__progname" => true, _ => false, } }); - // FIXME: still necessary? cfg.skip_field_type(move |struct_, field| { // This is a weird union, don't check the type. (struct_ == "ifaddrs" && field == "ifa_ifu") || - // sighandler_t type is super weird - (struct_ == "sigaction" && field == "sa_sigaction") || // sigval is actually a union, but we pretend it's a struct - (struct_ == "sigevent" && field == "sigev_value") || - // aio_buf is "volatile void*" and Rust doesn't understand volatile - (struct_ == "aiocb" && field == "aio_buf") + (struct_ == "sigevent" && field == "sigev_value") }); - // FIXME: still necessary? 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 Linux 4.18, but no libc release has them yet. - (struct_ == "signalfd_siginfo" && (field == "ssi_addr_lsb" || - field == "_pad2" || - field == "ssi_syscall" || + // 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")) }); - // FIXME: remove - cfg.fn_cname(move |name, _cname| name.to_string()); - cfg.generate("../src/lib.rs", "main.rs"); - // On Android also generate another script for testing linux/fcntl - // declarations. These cannot be tested normally because including both - // `linux/fcntl.h` and `fcntl.h` fails. - // - // FIXME: is still necessary? - let mut cfg = ctest::TestGenerator::new(); - cfg.skip_type(|_| true) - .skip_fn(|_| true) - .skip_static(|_| true); - cfg.header("linux/fcntl.h"); - cfg.header("net/if.h"); - cfg.header("linux/if.h"); - cfg.header("linux/quota.h"); - cfg.header("asm/termbits.h"); - cfg.skip_const(move |name| match name { - "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false, - "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => { - false - } - "BOTHER" => false, - _ => true, - }); - cfg.skip_struct(|s| s != "termios2"); - cfg.type_name(move |ty, is_struct, is_union| match ty { - t if is_struct => format!("struct {}", t), - t if is_union => format!("union {}", t), - t => t.to_string(), - }); - cfg.generate("../src/lib.rs", "linux_fcntl.rs"); + test_linux_like_apis(target); } fn test_freebsd(target: &str) { assert!(target.contains("freebsd")); - let x86 = target.contains("i686") || target.contains("x86_64"); - let mut cfg = ctest::TestGenerator::new(); + + let freebsd_ver = which_freebsd(); + + if let Some(12) = freebsd_ver { + // If the host is FreeBSD 12, run FreeBSD 12 tests + cfg.cfg("freebsd12", None); + } + // Required for `getline`: cfg.define("_WITH_GETLINE", None); + // Required for making freebsd11_stat available in the headers + cfg.define("_WANT_FREEBSD11_STAT", None); headers! { cfg: "aio.h", @@ -1655,19 +1525,18 @@ fn test_freebsd(target: &str) { cfg.type_name(move |ty, is_struct, is_union| { match ty { // Just pass all these through, no need for a "struct" prefix - // FIXME: still required? - "FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" - | "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym" - | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr" - | "Elf64_Chdr" => ty.to_string(), + "FILE" | "fd_set" | "Dl_info" | "DIR" => ty.to_string(), - // FIXME: still required? + // FIXME: https://github.com/rust-lang/libc/issues/1273 "sighandler_t" => "sig_t".to_string(), t if is_union => format!("union {}", t), t if t.ends_with("_t") => t.to_string(), + // sigval is a struct in Rust, but a union in C: + "sigval" => format!("union sigval"), + // put `struct` in front of all structs:. t if is_struct => format!("struct {}", t), @@ -1682,125 +1551,40 @@ fn test_freebsd(target: &str) { s if s.ends_with("_nsec") && struct_.starts_with("stat") => { s.replace("e_nsec", ".tv_nsec") } - // FIXME: still required? - "u64" if struct_ == "epoll_event" => "data.u64".to_string(), - // FIXME: still required? - "type_" - if struct_ == "input_event" - || struct_ == "input_mask" - || struct_ == "ff_effect" - || struct_ == "rtprio" => - { - "type".to_string() - } + // Field is named `type` in C but that is a Rust keyword, + // so these fields are translated to `type_` in the bindings. + "type_" if struct_ == "rtprio" => "type".to_string(), s => s.to_string(), } }); - cfg.skip_type(move |ty| { - match ty { - // sighandler_t is crazy across platforms - // FIXME: still required? - "sighandler_t" => true, - - _ => false, - } - }); - - cfg.skip_struct(move |ty| { - match ty { - // This is actually a union, not a struct - // FIXME: still required? - "sigval" => true, - - // These are tested as part of the linux_fcntl tests since there are - // header conflicts when including them with all the other structs. - // FIXME: still required? - "termios2" => true, - - _ => false, - } - }); - - cfg.skip_signededness(move |c| { - match c { - // FIXME: still required? - "LARGE_INTEGER" | "float" | "double" => true, - // FIXME: still required? - n if n.starts_with("pthread") => true, - // sem_t is a struct or pointer - // FIXME: still required? - "sem_t" => true, - // mqd_t is a pointer on FreeBSD - // FIXME: still required? - "mqd_t" => true, - - _ => false, - } - }); - cfg.skip_const(move |name| { match name { - // FIXME: still required? - "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness - // FIXME: still required? - "SIGUNUSED" => true, // removed in glibc 2.26 - - // weird signed extension or something like that? - // FIXME: still required? - "MS_NOUSER" => true, - // FIXME: still required? - "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 + // These constants were introduced in FreeBSD 12: + "SF_USER_READAHEAD" + | "EVFILT_EMPTY" + | "SO_REUSEPORT_LB" + | "IP_ORIGDSTADDR" + | "IP_RECVORIGDSTADDR" + | "IPV6_ORIGDSTADDR" + | "IPV6_RECVORIGDSTADDR" + if Some(12) != freebsd_ver => + { + true + } + // FIXME: There are deprecated - remove in a couple of releases. // These constants were removed in FreeBSD 11 (svn r273250) but will // still be accepted and ignored at runtime. - "MAP_RENAME" | "MAP_NORESERVE" => true, + "MAP_RENAME" | "MAP_NORESERVE" if Some(10) != freebsd_ver => true, + // FIXME: There are deprecated - remove in a couple of releases. // These constants were removed in FreeBSD 11 (svn r262489), // and they've never had any legitimate use outside of the // base system anyway. "CTL_MAXID" | "KERN_MAXID" | "HW_MAXID" | "NET_MAXID" | "USER_MAXID" => true, - // These constants were added in FreeBSD 11 - // FIXME: still required? - "EVFILT_PROCDESC" | "EVFILT_SENDFILE" | "EVFILT_EMPTY" - | "PD_CLOEXEC" | "PD_ALLOWED_AT_FORK" => true, - - // These constants were added in FreeBSD 12 - // FIXME: still required? - "SF_USER_READAHEAD" | "SO_REUSEPORT_LB" => true, - - // These constants are tested in a separate test program generated - // below because there are header conflicts if we try to include the - // headers that define them here. - // FIXME: still required? - "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => true, - // FIXME: still required? - "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" - | "F_SEAL_WRITE" => true, - // FIXME: still required? - "BOTHER" => true, - - // MFD_HUGETLB is not available in some older libc versions on the - // CI builders. On the x86_64 and i686 builders it seems to be - // available for all targets, so at least test it there. - // FIXME: still required? - "MFD_HUGETLB" if !x86 => true, - - // These change all the time from release to release of linux - // distros, let's just not bother trying to verify them. They - // shouldn't be used in code anyway... - // FIXME: still required? - "AF_MAX" | "PF_MAX" => true, - - // FreeBSD 12 required, but CI has FreeBSD 11. - // FIXME: still required? - "IP_ORIGDSTADDR" - | "IP_RECVORIGDSTADDR" - | "IPV6_ORIGDSTADDR" - | "IPV6_RECVORIGDSTADDR" => true, - _ => false, } }); @@ -1808,84 +1592,42 @@ fn test_freebsd(target: &str) { cfg.skip_fn(move |name| { // skip those that are manually verified match name { - // FIXME: still required? - "execv" | // crazy stuff with const/mut - "execve" | - "execvp" | - "execvpe" | - "fexecve" => true, - - // FIXME: for some reason, our signature is wrong - "gettimeofday" => true, - - // The `uname` function in freebsd is now an inline wrapper that - // delegates to another, but the symbol still exists, so don't check - // the symbol. - // FIXME: still required? - "uname" => true, - - // FIXME: need to upgrade FreeBSD version; see https://github.com/rust-lang/libc/issues/938 - // FIXME: still required? - "setgrent" => true, + // FIXME: https://github.com/rust-lang/libc/issues/1272 + "execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true, - // aio_waitcomplete's return type changed between FreeBSD 10 and 11. - // FIXME: still required? - "aio_waitcomplete" => true, + // The `uname` function in the `utsname.h` FreeBSD header is a C + // inline function (has no symbol) that calls the `__xuname` symbol. + // Therefore the function pointer comparison does not make sense for it. + "uname" => true, - // lio_listio confuses the checker, probably because one of its - // arguments is an array - // FIXME: still required? + // FIXME: Our API is unsound. The Rust API allows aliasing + // pointers, but the C API requires pointers not to alias. + // We should probably be at least using `&`/`&mut` here, see: + // https://github.com/gnzlbg/ctest/issues/68 "lio_listio" => true, - // Definition of those functions as changed since unified headers from NDK r14b - // These changes imply some API breaking changes but are still ABI compatible. - // We can wait for the next major release to be compliant with the new API. - // FIXME: unskip these for next major release - // FIXME: still required ? - "strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" | - _ => false, } }); - cfg.skip_field_type(move |struct_, field| { - // This is a weird union, don't check the type. - // FIXME: still required? - (struct_ == "ifaddrs" && field == "ifa_ifu") || - // FIXME: still required? - // sighandler_t type is super weird - (struct_ == "sigaction" && field == "sa_sigaction") || - // FIXME: still required? - // sigval is actually a union, but we pretend it's a struct - (struct_ == "sigevent" && field == "sigev_value") || - // aio_buf is "volatile void*" and Rust doesn't understand volatile - // FIXME: still required? - (struct_ == "aiocb" && field == "aio_buf") || - // stack_t.ss_sp's type changed from FreeBSD 10 to 11 in svn r294930 - // FIXME: still required? - (struct_ == "stack_t" && field == "ss_sp") + cfg.volatile_item(|i| { + use ctest::VolatileItemKind::*; + match i { + // aio_buf is a volatile void** but since we cannot express that in + // Rust types, we have to explicitly tell the checker about it here: + StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => { + true + } + _ => false, + } }); cfg.skip_field(move |struct_, field| { - // this is actually a union on linux, so we can't represent it well and - // just insert some padding. - // FIXME: still required? - (struct_ == "siginfo_t" && field == "_pad") || - // sigev_notify_thread_id is actually part of a sigev_un union - // FIXME: still required? - (struct_ == "sigevent" && field == "sigev_notify_thread_id") || - // signalfd had SIGSYS fields added in Linux 4.18, but no libc release has them yet. - // FIXME: still required? - (struct_ == "signalfd_siginfo" && (field == "ssi_addr_lsb" || - field == "_pad2" || - field == "ssi_syscall" || - field == "ssi_call_addr" || - field == "ssi_arch")) + // 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") }); - // FIXME: remove - cfg.fn_cname(move |name, _cname| name.to_string()); - cfg.generate("../src/lib.rs", "main.rs"); } @@ -1893,11 +1635,7 @@ fn test_emscripten(target: &str) { assert!(target.contains("emscripten")); let mut cfg = ctest::TestGenerator::new(); - // FIXME: still necessary? - cfg.define("_GNU_SOURCE", None); - - // FIXME: still necessary? - cfg.flag("-Wno-deprecated-declarations"); + cfg.define("_GNU_SOURCE", None); // FIXME: ?? headers! { cfg: "aio.h", @@ -1990,11 +1728,7 @@ fn test_emscripten(target: &str) { cfg.type_name(move |ty, is_struct, is_union| { match ty { // Just pass all these through, no need for a "struct" prefix - // FIXME: is this necessary? - "FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" - | "Elf64_Phdr" | "Elf32_Shdr" | "Elf64_Shdr" | "Elf32_Sym" - | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr" | "Elf32_Chdr" - | "Elf64_Chdr" => ty.to_string(), + "FILE" | "fd_set" | "Dl_info" | "DIR" => ty.to_string(), t if is_union => format!("union {}", t), @@ -2014,7 +1748,7 @@ fn test_emscripten(target: &str) { s if s.ends_with("_nsec") && struct_.starts_with("stat") => { s.replace("e_nsec", ".tv_nsec") } - // FIXME: is this necessary? + // FIXME: appears that `epoll_event.data` is an union "u64" if struct_ == "epoll_event" => "data.u64".to_string(), s => s.to_string(), } @@ -2032,158 +1766,32 @@ fn test_emscripten(target: &str) { cfg.skip_struct(move |ty| { match ty { - // FIXME: is this necessary? - "sockaddr_nl" => true, - // This is actually a union, not a struct // FIXME: is this necessary? "sigval" => true, - // Linux kernel headers used on musl are too old to have this - // definition. Because it's tested on other Linux targets, skip it. - // FIXME: is this necessary? - "input_mask" => true, - - // These are tested as part of the linux_fcntl tests since there are - // header conflicts when including them with all the other structs. - // FIXME: is this necessary? - "termios2" => true, - _ => false, } }); - cfg.skip_signededness(move |c| match c { - // FIXME: is this necessary? - "LARGE_INTEGER" | "float" | "double" => true, - // FIXME: is this necessary? - n if n.starts_with("pthread") => true, - _ => false, + cfg.skip_fn(move |name| { + match name { + // FIXME: https://github.com/rust-lang/libc/issues/1272 + "execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true, + + _ => false, + } }); cfg.skip_const(move |name| { match name { - // FIXME: is this necessary? - "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness - // FIXME: is this necessary? - "SIGUNUSED" => true, // removed in glibc 2.26 + // FIXME: deprecated - SIGNUNUSED was removed in glibc 2.26 + // users should use SIGSYS instead + "SIGUNUSED" => true, - // types on musl are defined a little differently - // FIXME: is this necessary? + // FIXME: emscripten uses different constants to constructs these n if n.contains("__SIZEOF_PTHREAD") => true, - // Skip constants not defined in MUSL but just passed down to the - // kernel regardless - // FIXME: is this necessary? - "RLIMIT_NLIMITS" - | "TCP_COOKIE_TRANSACTIONS" - | "RLIMIT_RTTIME" - | "MSG_COPY" - => - { - true - } - - // weird signed extension or something like that? - // FIXME: is this necessary? - "MS_NOUSER" => true, - // FIXME: is this necessary? - "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 - - // Musl uses old, patched kernel headers - // FIXME: is this necessary? - "FALLOC_FL_COLLAPSE_RANGE" - | "FALLOC_FL_ZERO_RANGE" - | "FALLOC_FL_INSERT_RANGE" - | "FALLOC_FL_UNSHARE_RANGE" - | "RENAME_NOREPLACE" - | "RENAME_EXCHANGE" - | "RENAME_WHITEOUT" - // ALG_SET_AEAD_* constants are available starting from kernel 3.19 - | "ALG_SET_AEAD_ASSOCLEN" - | "ALG_SET_AEAD_AUTHSIZE" - => - { - true - } - - // musl uses old kernel headers - // These are constants used in getrandom syscall - // FIXME: is this necessary? - "GRND_NONBLOCK" | "GRND_RANDOM" => true, - - - // These constants are tested in a separate test program generated below because there - // are header conflicts if we try to include the headers that define them here. - // FIXME: is this necessary? - "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => true, - // FIXME: is this necessary? - "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" - | "F_SEAL_WRITE" => true, - // FIXME: is this necessary? - "BOTHER" => true, - - // FIXME: is this necessary? - "MFD_CLOEXEC" | "MFD_ALLOW_SEALING" => true, - // MFD_HUGETLB is not available in some older libc versions on the CI builders. On the - // x86_64 and i686 builders it seems to be available for all targets, so at least test - // it there. - // FIXME: is this necessary? - "MFD_HUGETLB" => - { - true - } - - // These are defined for Solaris 11, but the crate is tested on - // illumos, where they are currently not defined - // FIXME: is this necessary? - "EADI" - | "PORT_SOURCE_POSTWAIT" - | "PORT_SOURCE_SIGNAL" - | "PTHREAD_STACK_MIN" => true, - - // These change all the time from release to release of linux - // distros, let's just not bother trying to verify them. They - // shouldn't be used in code anyway... - // FIXME: is this necessary? - "AF_MAX" | "PF_MAX" => true, - - _ => false, - } - }); - - cfg.skip_fn(move |name| { - // skip those that are manually verified - match name { - // FIXME: is this necessary? - "execv" | // crazy stuff with const/mut - "execve" | - "execvp" | - "execvpe" | - "fexecve" => true, - - "getrlimit" | "getrlimit64" | // non-int in 1st arg - "setrlimit" | "setrlimit64" | // non-int in 1st arg - "prlimit" | "prlimit64" | // non-int in 2nd arg - - // int vs uint. Sorry musl, your prototype declarations are "correct" in the sense that - // they match the interface defined by Linux verbatim, but they conflict with other - // send*/recv* syscalls - // FIXME: is this necessary? - "sendmmsg" | "recvmmsg" => true, - - // FIXME: is this necessary? - "dladdr" => true, // const-ness only added recently - - // FIXME: is this necessary? - "lio_listio" => true, - - // Definition of those functions as changed since unified headers from NDK r14b - // These changes imply some API breaking changes but are still ABI compatible. - // We can wait for the next major release to be compliant with the new API. - // FIXME: unskip these for next major release - "strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" | - _ => false, } }); @@ -2224,9 +1832,7 @@ fn test_emscripten(target: &str) { field == "ssi_arch")) }); - // FIXME: remove - cfg.fn_cname(move |name, _cname| name.to_string()); - + // FIXME: test linux like cfg.generate("../src/lib.rs", "main.rs"); } @@ -2248,22 +1854,21 @@ fn test_linux(target: &str) { ), } - let mips = target.contains("mips"); - let i686 = target.contains("i686"); + let arm = target.contains("arm"); let x86_64 = target.contains("x86_64"); - let x32 = target.ends_with("gnux32"); + let x86_32 = target.contains("i686"); + let x32 = target.contains("x32"); + let mips = target.contains("mips"); + let mips32_musl = mips && !target.contains("64") && musl; + let sparc64 = target.contains("sparc64"); let mut cfg = ctest::TestGenerator::new(); - // FIXME: still necessary? cfg.define("_GNU_SOURCE", None); // This macro re-deifnes 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); - // FIXME: still necessary? - cfg.flag("-Wno-deprecated-declarations"); - headers! { cfg: "ctype.h", "dirent.h", @@ -2319,6 +1924,8 @@ fn test_linux(target: &str) { "sys/prctl.h", "sys/ptrace.h", "sys/quota.h", + // FIXME: the mips-musl CI build jobs use ancient musl 1.0.15: + [!mips32_musl]: "sys/random.h", "sys/reboot.h", "sys/resource.h", "sys/sem.h", @@ -2347,86 +1954,61 @@ fn test_linux(target: &str) { "unistd.h", "utime.h", "utmp.h", + "utmpx.h", "wchar.h", "errno.h", + // `sys/io.h` is only available on x86*, Alpha, IA64, and 32-bit + // ARM: https://bugzilla.redhat.com/show_bug.cgi?id=1116162 + [x86_64 || x86_32 || arm]: "sys/io.h", + // `sys/reg.h` is only available on x86 and x86_64 + [x86_64 || x86_32]: "sys/reg.h", + // sysctl system call is deprecated and not available on musl + // It is also unsupported in x32: + [!(x32 || musl)]: "sys/sysctl.h", + // is not supported by musl: + // https://www.openwall.com/lists/musl/2015/04/09/3 + [!musl]: "execinfo.h", } // Include linux headers at the end: headers! { cfg: + "asm/mman.h", + "linux/dccp.h", "linux/falloc.h", - "linux/futex.h", "linux/fs.h", + "linux/futex.h", "linux/genetlink.h", + // FIXME: musl version 1.0.15 used by mips build jobs is ancient + [!mips32_musl]: "linux/if.h", + "linux/if_addr.h", "linux/if_alg.h", "linux/if_ether.h", "linux/if_tun.h", "linux/input.h", + "linux/magic.h", + "linux/memfd.h", "linux/module.h", "linux/net_tstamp.h", + "linux/netfilter/nf_tables.h", "linux/netfilter_ipv4.h", "linux/netfilter_ipv6.h", "linux/netlink.h", + "linux/quota.h", "linux/random.h", + "linux/reboot.h", + "linux/rtnetlink.h", "linux/seccomp.h", "linux/sockios.h", - } - - if x86_64 { - headers! { cfg: "sys/io.h" }; - } - if i686 || x86_64 { - headers! { cfg: "sys/reg.h" }; - } - - if !musl { - assert!(uclibc || gnu); - headers! { cfg: - "asm/mman.h", - "linux/if.h", - "linux/magic.h", - "linux/netfilter/nf_tables.h", - "linux/reboot.h", - "sys/auxv.h", - }; - - if !x32 { - assert!((gnu || uclibc) && !x32); - headers! { cfg: "sys/sysctl.h", } - } - if !uclibc { - assert!(gnu); - headers! { cfg: - "execinfo.h", - "utmpx.h", - } - } - if !mips { - assert!((gnu || uclibc) && !mips); - headers! { cfg: "linux/quota.h" }; - } - } - - // DCCP support - if !uclibc && !musl { - assert!(gnu); - headers! { cfg: "linux/dccp.h" }; - } - - if !musl || mips { - assert!(gnu || uclibc || (mips && musl)); - headers! { cfg: "linux/memfd.h" }; + "sys/auxv.h", } // note: aio.h must be included before sys/mount.h - if !uclibc { - assert!(gnu || musl); - // optionally included in uclibc - headers! { cfg: - "sys/xattr.h", - "sys/sysinfo.h", - "aio.h", - } + headers! { + cfg: + "sys/xattr.h", + "sys/sysinfo.h", + "aio.h", } cfg.type_name(move |ty, is_struct, is_union| { @@ -2455,42 +2037,48 @@ fn test_linux(target: &str) { s if s.ends_with("_nsec") && struct_.starts_with("stat") => { s.replace("e_nsec", ".tv_nsec") } - // FIXME: is this necessary? + // FIXME: epoll_event.data is actuall a union in C, but in Rust + // it is only a u64 because we only expose one field + // http://man7.org/linux/man-pages/man2/epoll_wait.2.html "u64" if struct_ == "epoll_event" => "data.u64".to_string(), - // FIXME: is this necessary? + // The following structs have a field called `type` in C, + // but `type` is a Rust keyword, so these fields are translated + // to `type_` in Rust. "type_" if struct_ == "input_event" || struct_ == "input_mask" - || struct_ == "ff_effect" - || struct_ == "rtprio" => + || struct_ == "ff_effect" => { "type".to_string() } + s => s.to_string(), } }); cfg.skip_type(move |ty| { match ty { - // sighandler_t is crazy across platforms - // FIXME: is this necessary? + // FIXME: `sighandler_t` type is incorrect, see: + // https://github.com/rust-lang/libc/issues/1359 "sighandler_t" => true, // These cannot be tested when "resolv.h" is included and are tested - // below. + // in the `linux_elf.rs` file. "Elf64_Phdr" | "Elf32_Phdr" => true, + // This type is private on Linux. It is implemented as a C `enum` + // (`c_uint`) and this clashes with the type of the `rlimit` APIs + // which expect a `c_int` even though both are ABI compatible. + "__rlimit_resource_t" => true, + _ => false, } }); cfg.skip_struct(move |ty| { match ty { - // FIXME: is this necessary? - "sockaddr_nl" if musl => true, - // These cannot be tested when "resolv.h" is included and are tested - // below. + // in the `linux_elf.rs` file. "Elf64_Phdr" | "Elf32_Phdr" => true, // On Linux, the type of `ut_tv` field of `struct utmpx` @@ -2498,184 +2086,79 @@ fn test_linux(target: &str) { // which is absent in glibc, has to be defined. "__timeval" => true, - // This is actually a union, not a struct + // FIXME: This is actually a union, not a struct "sigval" => true, - // Linux kernel headers used on musl are too old to have this - // definition. Because it's tested on other Linux targets, skip it. - // FIXME: is this necessary? - "input_mask" if musl => true, - - // These are tested as part of the linux_fcntl tests since there are - // header conflicts when including them with all the other structs. - // FIXME: is this necessary? + // This type is tested in the `linux_termios.rs` file since there + // are header conflicts when including them with all the other + // structs. "termios2" => true, + // FIXME: musl version using by mips build jobs 1.0.15 is ancient: + "ifmap" | "ifreq" | "ifconf" if mips32_musl => true, + _ => false, } }); - cfg.skip_signededness(move |c| match c { - // FIXME: is this necessary? - "LARGE_INTEGER" | "float" | "double" => true, - // FIXME: is this necessary? - n if n.starts_with("pthread") => true, - _ => false, - }); - cfg.skip_const(move |name| { match name { - // FIXME: is this necessary? - "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness - // FIXME: is this necessary? - "SIGUNUSED" => true, // removed in glibc 2.26 - - // types on musl are defined a little differently - // FIXME: is this necessary? - n if musl && n.contains("__SIZEOF_PTHREAD") => true, - - // Skip constants not defined in MUSL but just passed down to the - // kernel regardless - // FIXME: is this necessary? - "RLIMIT_NLIMITS" - | "TCP_COOKIE_TRANSACTIONS" - | "RLIMIT_RTTIME" - | "MSG_COPY" - if musl => - { - true - } - // work around super old mips toolchain - // FIXME: is this necessary? - "SCHED_IDLE" | "SHM_NORESERVE" => mips, - - // weird signed extension or something like that? - // FIXME: is this necessary? - "MS_NOUSER" => true, - // FIXME: is this necessary? - "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 - - // These are either unimplemented or optionally built into uClibc - // FIXME: is this necessary? - "LC_CTYPE_MASK" - | "LC_NUMERIC_MASK" - | "LC_TIME_MASK" - | "LC_COLLATE_MASK" - | "LC_MONETARY_MASK" - | "LC_MESSAGES_MASK" - | "MADV_MERGEABLE" - | "MADV_UNMERGEABLE" - | "MADV_HWPOISON" - | "IPV6_ADD_MEMBERSHIP" - | "IPV6_DROP_MEMBERSHIP" - | "IPV6_MULTICAST_LOOP" - | "IPV6_V6ONLY" - | "MAP_STACK" - | "RTLD_DEEPBIND" - | "SOL_IPV6" - | "SOL_ICMPV6" - if uclibc => - { - true - } + // These constants are not available if gnu headers have been included + // and can therefore not be tested here + // + // The IPV6 constants are tested in the `linux_ipv6.rs` tests: + | "IPV6_FLOWINFO" + | "IPV6_FLOWLABEL_MGR" + | "IPV6_FLOWINFO_SEND" + | "IPV6_FLOWINFO_FLOWLABEL" + | "IPV6_FLOWINFO_PRIORITY" + // The F_ fnctl constants are tested in the `linux_fnctl.rs` tests: + | "F_CANCELLK" + | "F_ADD_SEALS" + | "F_GET_SEALS" + | "F_SEAL_SEAL" + | "F_SEAL_SHRINK" + | "F_SEAL_GROW" + | "F_SEAL_WRITE" => true, - // Musl uses old, patched kernel headers - // FIXME: is this necessary? - "FALLOC_FL_COLLAPSE_RANGE" - | "FALLOC_FL_ZERO_RANGE" - | "FALLOC_FL_INSERT_RANGE" + // The musl-sanitized kernel headers used in CI + // target the Linux kernel 4.4 and do not contain the + // following constants: + // + // Requires Linux kernel 4.9 | "FALLOC_FL_UNSHARE_RANGE" - | "RENAME_NOREPLACE" - | "RENAME_EXCHANGE" - | "RENAME_WHITEOUT" - // ALG_SET_AEAD_* constants are available starting from kernel 3.19 - | "ALG_SET_AEAD_ASSOCLEN" - | "ALG_SET_AEAD_AUTHSIZE" - if musl => - { - true - } - - // musl uses old kernel headers - // These are constants used in getrandom syscall - // FIXME: is this necessary? - "GRND_NONBLOCK" | "GRND_RANDOM" if musl => true, - - // Defined by libattr not libc on linux (hard to test). - // See constant definition for more details. - // FIXME: is this necessary? + // + // Require Linux kernel 5.x: + | "MSG_COPY" + if musl => true, + // Require Linux kernel 5.1: + "F_SEAL_FUTURE_WRITE" => true, + + // The musl version 1.0.22 used in CI does not + // contain these glibc constants yet: + | "RLIMIT_RTTIME" // should be in `resource.h` + | "TCP_COOKIE_TRANSACTIONS" // should be in the `netinet/tcp.h` header + if musl => true, + + // FIXME: deprecated: not available in any header + // See: https://github.com/rust-lang/libc/issues/1356 "ENOATTR" => true, - // On mips*-unknown-linux-gnu* CMSPAR cannot be included with the set of headers we - // want to use here for testing. It's originally defined in asm/termbits.h, which is - // also included by asm/termios.h, but not the standard termios.h. There's no way to - // include both asm/termbits.h and termios.h and there's no way to include both - // asm/termios.h and ioctl.h (+ some other headers) because of redeclared types. - // FIXME: is this necessary? - "CMSPAR" if mips && !musl => true, - - // On mips Linux targets, MADV_SOFT_OFFLINE is currently missing, though it's been added but CI has too old - // of a Linux version. Since it exists on all other Linux targets, just ignore this for now and remove once - // it's been fixed in CI. - // FIXME: is this necessary? - "MADV_SOFT_OFFLINE" if mips => true, + // FIXME: SIGUNUSED was removed in glibc 2.26 + // Users should use SIGSYS instead. + "SIGUNUSED" => true, - // These constants are tested in a separate test program generated below because there - // are header conflicts if we try to include the headers that define them here. - // FIXME: is this necessary? - "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => true, - // FIXME: is this necessary? - "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" - | "F_SEAL_WRITE" => true, - // FIXME: is this necessary? - "QFMT_VFS_OLD" | "QFMT_VFS_V0" | "QFMT_VFS_V1" - if mips => - { - true - } // Only on MIPS - // FIXME: is this necessary? + // FIXME: conflicts with glibc headers and is tested in + // `linux_termios.rs` below: "BOTHER" => true, - // FIXME: is this necessary? - "MFD_CLOEXEC" | "MFD_ALLOW_SEALING" if !mips && musl => true, - // MFD_HUGETLB is not available in some older libc versions on the CI builders. On the - // x86_64 and i686 builders it seems to be available for all targets, so at least test - // it there. - // FIXME: is this necessary? - "MFD_HUGETLB" - if !(x86_64 || i686) || musl => - { - true - } - - // These are defined for Solaris 11, but the crate is tested on - // illumos, where they are currently not defined - // FIXME: is this necessary? - "EADI" - | "PORT_SOURCE_POSTWAIT" - | "PORT_SOURCE_SIGNAL" - | "PTHREAD_STACK_MIN" => true, - - // These change all the time from release to release of linux - // distros, let's just not bother trying to verify them. They - // shouldn't be used in code anyway... - // FIXME: is this necessary? - "AF_MAX" | "PF_MAX" => true, + // FIXME: on musl the pthread types are defined a little differently + // - these constants are used by the glibc implementation. + n if musl && n.contains("__SIZEOF_PTHREAD") => true, - // These are not in a glibc release yet, only in kernel headers. - // FIXME: is this necessary? - "AF_XDP" - | "PF_XDP" - | "SOL_XDP" - | "IPV6_FLOWINFO" - | "IPV6_FLOWLABEL_MGR" - | "IPV6_FLOWINFO_SEND" - | "IPV6_FLOWINFO_FLOWLABEL" - | "IPV6_FLOWINFO_PRIORITY" - => - { - true - } + // FIXME: musl version 1.0.15 used by mips build jobs is ancient + t if mips32_musl && t.starts_with("IFF") => true, + "MFD_HUGETLB" | "AF_XDP" | "PF_XDP" if mips32_musl => true, _ => false, } @@ -2684,70 +2167,41 @@ fn test_linux(target: &str) { cfg.skip_fn(move |name| { // skip those that are manually verified match name { - "execv" | // crazy stuff with const/mut - "execve" | - "execvp" | - "execvpe" | - "fexecve" => true, - - "getrlimit" | "getrlimit64" | // non-int in 1st arg - "setrlimit" | "setrlimit64" | // non-int in 1st arg - "prlimit" | "prlimit64" // non-int in 2nd arg - => true, - - // int vs uint. Sorry musl, your prototype declarations are "correct" in the sense that - // they match the interface defined by Linux verbatim, but they conflict with other - // send*/recv* syscalls - // FIXME: is this necessary? - "sendmmsg" | "recvmmsg" if musl => true, - - // typed 2nd arg on linux - // FIXME: is this necessary? - "gettimeofday" => true, - - // FIXME: is this necessary? - "dladdr" if musl => true, // const-ness only added recently + // FIXME: https://github.com/rust-lang/libc/issues/1272 + "execv" | "execve" | "execvp" | "execvpe" | "fexecve" => true, - // There seems to be a small error in EGLIBC's eventfd.h header. The - // [underlying system call][1] always takes its first `count` - // argument as an `unsigned int`, but [EGLIBC's - // header][2] declares it to take an `int`. [GLIBC's header][3] - // matches the kernel. + // There are two versions of the sterror_r function, see // - // EGLIBC is no longer actively developed, and Debian, the largest - // distribution that had been using it, switched back to GLIBC in - // April 2015. So effectively all Linux headers will - // be using `unsigned int` soon. + // https://linux.die.net/man/3/strerror_r // - // [1]: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/fs/eventfd.c?id=refs/tags/v3.12.51#n397 - // [2]: http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/trusty/eglibc/trusty/view/head:/sysdeps/unix/sysv/linux/sys/eventfd.h - // [3]: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/sys/eventfd.h;h=6295f32e937e779e74318eb9d3bdbe76aef8a8f3;hb=4e42b5b8f89f0e288e68be7ad70f9525aebc2cff#l34 - // FIXME: is this necessary? - "eventfd" => true, - + // An XSI-compliant version provided if: + // + // (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) + // && ! _GNU_SOURCE + // + // and a GNU specific version provided if _GNU_SOURCE is defined. + // + // libc provides bindings for the XSI-compliant version, which is + // preferred for portable applications. + // + // We skip the test here since here _GNU_SOURCE is defined, and + // test the XSI version below. + "strerror_r" => true, + + // FIXME: Our API is unsound. The Rust API allows aliasing + // pointers, but the C API requires pointers not to alias. + // We should probably be at least using `&`/`&mut` here, see: + // https://github.com/gnzlbg/ctest/issues/68 "lio_listio" if musl => true, - // These are either unimplemented or optionally built into uClibc - // or "sysinfo", where it's defined but the structs in linux/sysinfo.h and sys/sysinfo.h - // clash so it can't be tested - "getxattr" | "lgetxattr" | "fgetxattr" | "setxattr" | "lsetxattr" | "fsetxattr" | - "listxattr" | "llistxattr" | "flistxattr" | "removexattr" | "lremovexattr" | - "fremovexattr" | - "backtrace" | - "sysinfo" | "newlocale" | "duplocale" | "freelocale" | "uselocale" | - "nl_langinfo_l" | "wcslen" | "wcstombs" if uclibc => true, - - // Definition of those functions as changed since unified headers from NDK r14b - // These changes imply some API breaking changes but are still ABI compatible. - // We can wait for the next major release to be compliant with the new API. - // FIXME: unskip these for next major release - "strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" => true, + // FIXME: the glibc version used by the Sparc64 build jobs + // which use Debian 10.0 is too old. + "statx" if sparc64 => true, _ => false, } }); - // FIXME: is this necessary? cfg.skip_field_type(move |struct_, field| { // This is a weird union, don't check the type. (struct_ == "ifaddrs" && field == "ifa_ifu") || @@ -2757,12 +2211,22 @@ fn test_linux(target: &str) { (struct_ == "utmpx" && field == "ut_tv") || // sigval is actually a union, but we pretend it's a struct (struct_ == "sigevent" && field == "sigev_value") || - // aio_buf is "volatile void*" and Rust doesn't understand volatile - (struct_ == "aiocb" && field == "aio_buf") || // this one is an anonymous union (struct_ == "ff_effect" && field == "u") }); + cfg.volatile_item(|i| { + use ctest::VolatileItemKind::*; + match i { + // aio_buf is a volatile void** but since we cannot express that in + // Rust types, we have to explicitly tell the checker about it here: + StructField(ref n, ref f) if n == "aiocb" && f == "aio_buf" => { + true + } + _ => false, + } + }); + cfg.skip_field(move |struct_, field| { // this is actually a union on linux, so we can't represent it well and // just insert some padding. @@ -2773,7 +2237,8 @@ fn test_linux(target: &str) { (musl && struct_ == "statvfs" && field == "__f_unused") || // 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 Linux 4.18, but no libc release has them yet. + // signalfd had SIGSYS fields added in Linux 4.18, but no libc release + // has them yet. (struct_ == "signalfd_siginfo" && (field == "ssi_addr_lsb" || field == "_pad2" || field == "ssi_syscall" || @@ -2781,70 +2246,148 @@ fn test_linux(target: &str) { field == "ssi_arch")) }); - // FIXME: remove - cfg.fn_cname(move |name, _cname| name.to_string()); - cfg.generate("../src/lib.rs", "main.rs"); - // On Linux also generate another script for testing linux/fcntl declarations. - // These cannot be tested normally because including both `linux/fcntl.h` and `fcntl.h` - // fails on a lot of platforms. - let mut cfg = ctest::TestGenerator::new(); - cfg.skip_type(|_| true) - .skip_fn(|_| true) - .skip_static(|_| true); - // musl defines these directly in `fcntl.h` - if musl { - cfg.header("fcntl.h"); - } else { - cfg.header("linux/fcntl.h"); + test_linux_like_apis(target); +} + +// This function tests APIs that are incompatible to test when other APIs +// are included (e.g. because including both sets of headers clashes) +fn test_linux_like_apis(target: &str) { + let musl = target.contains("musl"); + let linux = target.contains("linux"); + let emscripten = target.contains("emscripten"); + let android = target.contains("android"); + assert!(linux || android || emscripten); + + if linux || android || emscripten { + // test strerror_r from the `string.h` header + let mut cfg = ctest::TestGenerator::new(); + cfg.skip_type(|_| true).skip_static(|_| true); + + headers! { cfg: "string.h" } + cfg.skip_fn(|f| match f { + "strerror_r" => false, + _ => true, + }) + .skip_const(|_| true) + .skip_struct(|_| true); + cfg.generate("../src/lib.rs", "linux_strerror_r.rs"); } - if !musl { - cfg.header("net/if.h"); - cfg.header("linux/if.h"); + + if linux || android || emscripten { + // test fcntl - see: + // http://man7.org/linux/man-pages/man2/fcntl.2.html + let mut cfg = ctest::TestGenerator::new(); + + if musl { + cfg.header("fcntl.h"); + } else { + cfg.header("linux/fcntl.h"); + } + + cfg.skip_type(|_| true) + .skip_static(|_| true) + .skip_struct(|_| true) + .skip_fn(|_| true) + .skip_const(move |name| match name { + // test fcntl constants: + "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" + | "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" + | "F_SEAL_WRITE" => false, + _ => true, + }) + .type_name(move |ty, is_struct, is_union| match ty { + t if is_struct => format!("struct {}", t), + t if is_union => format!("union {}", t), + t => t.to_string(), + }); + + cfg.generate("../src/lib.rs", "linux_fcntl.rs"); } - cfg.header("linux/quota.h"); - cfg.header("asm/termbits.h"); - cfg.skip_const(move |name| match name { - "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false, - "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => { - false - } - "QFMT_VFS_OLD" | "QFMT_VFS_V0" | "QFMT_VFS_V1" if mips => false, - "BOTHER" => false, - _ => true, - }); - cfg.skip_struct(|s| s != "termios2"); - cfg.type_name(move |ty, is_struct, is_union| match ty { - t if is_struct => format!("struct {}", t), - t if is_union => format!("union {}", t), - t => t.to_string(), - }); - cfg.generate("../src/lib.rs", "linux_fcntl.rs"); - // Test Elf64_Phdr and Elf32_Phdr - // These types have a field called `p_type`, but including - // "resolve.h" defines a `p_type` macro that expands to `__p_type` - // making the tests for these fails when both are included. - let mut cfg = ctest::TestGenerator::new(); - cfg.skip_fn(|_| true) - .skip_const(|_| true) - .skip_static(|_| true) - .type_name(move |ty, _is_struct, _is_union| { - ty.to_string() - }); - cfg.skip_struct(move |ty| { - match ty { - "Elf64_Phdr" | "Elf32_Phdr" => false, - _ => true, - } - }); - cfg.skip_type(move |ty| { - match ty { - "Elf64_Phdr" | "Elf32_Phdr" => false, - _ => true, - } - }); - cfg.header("elf.h"); - cfg.generate("../src/lib.rs", "linux_elf.rs"); + if linux || android { + // test termios + let mut cfg = ctest::TestGenerator::new(); + cfg.header("asm/termbits.h"); + cfg.skip_type(|_| true) + .skip_static(|_| true) + .skip_fn(|_| true) + .skip_const(|c| c != "BOTHER") + .skip_struct(|s| s != "termios2") + .type_name(move |ty, is_struct, is_union| match ty { + t if is_struct => format!("struct {}", t), + t if is_union => format!("union {}", t), + t => t.to_string(), + }); + cfg.generate("../src/lib.rs", "linux_termios.rs"); + } + + if linux || android { + // test IPV6_ constants: + let mut cfg = ctest::TestGenerator::new(); + headers! { + cfg: + "linux/in6.h" + } + cfg.skip_type(|_| true) + .skip_static(|_| true) + .skip_fn(|_| true) + .skip_const(|_| true) + .skip_struct(|_| true) + .skip_const(move |name| match name { + "IPV6_FLOWINFO" + | "IPV6_FLOWLABEL_MGR" + | "IPV6_FLOWINFO_SEND" + | "IPV6_FLOWINFO_FLOWLABEL" + | "IPV6_FLOWINFO_PRIORITY" => false, + _ => true, + }) + .type_name(move |ty, is_struct, is_union| match ty { + t if is_struct => format!("struct {}", t), + t if is_union => format!("union {}", t), + t => t.to_string(), + }); + cfg.generate("../src/lib.rs", "linux_ipv6.rs"); + } + + if linux || android { + // Test Elf64_Phdr and Elf32_Phdr + // These types have a field called `p_type`, but including + // "resolve.h" defines a `p_type` macro that expands to `__p_type` + // making the tests for these fails when both are included. + let mut cfg = ctest::TestGenerator::new(); + cfg.header("elf.h"); + cfg.skip_fn(|_| true) + .skip_static(|_| true) + .skip_fn(|_| true) + .skip_const(|_| true) + .type_name(move |ty, _is_struct, _is_union| ty.to_string()) + .skip_struct(move |ty| match ty { + "Elf64_Phdr" | "Elf32_Phdr" => false, + _ => true, + }) + .skip_type(move |ty| match ty { + "Elf64_Phdr" | "Elf32_Phdr" => false, + _ => true, + }); + cfg.generate("../src/lib.rs", "linux_elf.rs"); + } +} + +fn which_freebsd() -> Option { + let output = std::process::Command::new("freebsd-version") + .output() + .ok()?; + if !output.status.success() { + return None; + } + + let stdout = String::from_utf8(output.stdout).ok()?; + + match &stdout { + s if s.starts_with("11") => Some(11), + s if s.starts_with("12") => Some(12), + _ => None, + } } diff --git a/libc/libc-test/test/linux_elf.rs b/libc/libc-test/test/linux_elf.rs new file mode 100644 index 0000000..d149c9a --- /dev/null +++ b/libc/libc-test/test/linux_elf.rs @@ -0,0 +1,12 @@ +#![allow(bad_style, improper_ctypes, unused, deprecated)] + +extern crate libc; +use libc::*; + +#[cfg(target_os = "linux")] +include!(concat!(env!("OUT_DIR"), "/linux_elf.rs")); + +#[cfg(not(target_os = "linux"))] +fn main() { + println!("PASSED 0 tests"); +} diff --git a/libc/libc-test/test/linux_fcntl.rs b/libc/libc-test/test/linux_fcntl.rs index a54636c..49c06cc 100644 --- a/libc/libc-test/test/linux_fcntl.rs +++ b/libc/libc-test/test/linux_fcntl.rs @@ -7,4 +7,6 @@ use libc::*; include!(concat!(env!("OUT_DIR"), "/linux_fcntl.rs")); #[cfg(not(any(target_os = "linux", target_os = "android")))] -fn main() {} +fn main() { + println!("PASSED 0 tests"); +} diff --git a/libc/libc-test/test/linux_ipv6.rs b/libc/libc-test/test/linux_ipv6.rs new file mode 100644 index 0000000..83c389c --- /dev/null +++ b/libc/libc-test/test/linux_ipv6.rs @@ -0,0 +1,12 @@ +#![allow(bad_style, improper_ctypes, unused, deprecated)] + +extern crate libc; +use libc::*; + +#[cfg(target_os = "linux")] +include!(concat!(env!("OUT_DIR"), "/linux_ipv6.rs")); + +#[cfg(not(target_os = "linux"))] +fn main() { + println!("PASSED 0 tests"); +} diff --git a/libc/libc-test/test/linux_strerror_r.rs b/libc/libc-test/test/linux_strerror_r.rs new file mode 100644 index 0000000..17db959 --- /dev/null +++ b/libc/libc-test/test/linux_strerror_r.rs @@ -0,0 +1,12 @@ +#![allow(bad_style, improper_ctypes, unused, deprecated)] + +extern crate libc; +use libc::*; + +#[cfg(any(target_os = "linux", target_os = "android"))] +include!(concat!(env!("OUT_DIR"), "/linux_strerror_r.rs")); + +#[cfg(not(any(target_os = "linux", target_os = "android")))] +fn main() { + println!("PASSED 0 tests"); +} diff --git a/libc/libc-test/test/linux_termios.rs b/libc/libc-test/test/linux_termios.rs new file mode 100644 index 0000000..703a9b9 --- /dev/null +++ b/libc/libc-test/test/linux_termios.rs @@ -0,0 +1,12 @@ +#![allow(bad_style, improper_ctypes, unused, deprecated)] + +extern crate libc; +use libc::*; + +#[cfg(any(target_os = "linux", target_os = "android"))] +include!(concat!(env!("OUT_DIR"), "/linux_termios.rs")); + +#[cfg(not(any(target_os = "linux", target_os = "android")))] +fn main() { + println!("PASSED 0 tests"); +} diff --git a/libc/src/cloudabi/mod.rs b/libc/src/cloudabi/mod.rs index 8191967..0d86962 100644 --- a/libc/src/cloudabi/mod.rs +++ b/libc/src/cloudabi/mod.rs @@ -1,12 +1,3 @@ -pub type int8_t = i8; -pub type int16_t = i16; -pub type int32_t = i32; -pub type int64_t = i64; -pub type uint8_t = u8; -pub type uint16_t = u16; -pub type uint32_t = u32; -pub type uint64_t = u64; - pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; diff --git a/libc/src/fixed_width_ints.rs b/libc/src/fixed_width_ints.rs new file mode 100644 index 0000000..0c25d28 --- /dev/null +++ b/libc/src/fixed_width_ints.rs @@ -0,0 +1,44 @@ +//! This module contains type aliases for C's fixed-width integer types . +//! +//! These aliases are deprecated: use the Rust types instead. + +#[deprecated( + since = "0.2.55", + note = "Use i8 instead." +)] +pub type int8_t = i8; +#[deprecated( + since = "0.2.55", + note = "Use i16 instead." +)] +pub type int16_t = i16; +#[deprecated( + since = "0.2.55", + note = "Use i32 instead." +)] +pub type int32_t = i32; +#[deprecated( + since = "0.2.55", + note = "Use i64 instead." +)] +pub type int64_t = i64; +#[deprecated( + since = "0.2.55", + note = "Use u8 instead." +)] +pub type uint8_t = u8; +#[deprecated( + since = "0.2.55", + note = "Use u16 instead." +)] +pub type uint16_t = u16; +#[deprecated( + since = "0.2.55", + note = "Use u32 instead." +)] +pub type uint32_t = u32; +#[deprecated( + since = "0.2.55", + note = "Use u64 instead." +)] +pub type uint64_t = u64; diff --git a/libc/src/fuchsia/aarch64.rs b/libc/src/fuchsia/aarch64.rs index 572f8c1..654e8d1 100644 --- a/libc/src/fuchsia/aarch64.rs +++ b/libc/src/fuchsia/aarch64.rs @@ -66,8 +66,19 @@ pub const MINSIGSTKSZ: ::size_t = 6144; pub const SIGSTKSZ: ::size_t = 12288; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] pub const PF_MAX: ::c_int = 43; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +#[allow(deprecated)] pub const AF_MAX: ::c_int = PF_MAX; pub const SYS_io_setup: ::c_long = 0; diff --git a/libc/src/fuchsia/mod.rs b/libc/src/fuchsia/mod.rs index cef48e5..1d68341 100644 --- a/libc/src/fuchsia/mod.rs +++ b/libc/src/fuchsia/mod.rs @@ -5,15 +5,6 @@ // PUB_TYPE -pub type int8_t = i8; -pub type int16_t = i16; -pub type int32_t = i32; -pub type int64_t = i64; -pub type uint8_t = u8; -pub type uint16_t = u16; -pub type uint32_t = u32; -pub type uint64_t = u64; - pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; @@ -27,6 +18,8 @@ pub type c_ulonglong = u64; pub type intmax_t = i64; pub type uintmax_t = u64; +pub type locale_t = *mut ::c_void; + pub type size_t = usize; pub type ptrdiff_t = isize; pub type intptr_t = isize; @@ -110,12 +103,7 @@ impl ::Copy for DIR {} impl ::Clone for DIR { fn clone(&self) -> DIR { *self } } -#[cfg_attr(feature = "extra_traits", derive(Debug))] -pub enum locale_t {} -impl ::Copy for locale_t {} -impl ::Clone for locale_t { - fn clone(&self) -> locale_t { *self } -} + #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum fpos64_t {} // TODO: fill this out with a struct impl ::Copy for fpos64_t {} @@ -369,13 +357,6 @@ s! { pub ai_next: *mut addrinfo, } - pub struct sockaddr_nl { - pub nl_family: ::sa_family_t, - nl_pad: ::c_ushort, - pub nl_pid: u32, - pub nl_groups: u32 - } - pub struct sockaddr_ll { pub sll_family: ::c_ushort, pub sll_protocol: ::c_ushort, @@ -420,8 +401,8 @@ s! { } pub struct epoll_event { - pub events: ::uint32_t, - pub u64: ::uint64_t, + pub events: u32, + pub u64: u64, } pub struct lconv { @@ -531,40 +512,40 @@ s! { } pub struct dqblk { - pub dqb_bhardlimit: ::uint64_t, - pub dqb_bsoftlimit: ::uint64_t, - pub dqb_curspace: ::uint64_t, - pub dqb_ihardlimit: ::uint64_t, - pub dqb_isoftlimit: ::uint64_t, - pub dqb_curinodes: ::uint64_t, - pub dqb_btime: ::uint64_t, - pub dqb_itime: ::uint64_t, - pub dqb_valid: ::uint32_t, + pub dqb_bhardlimit: u64, + pub dqb_bsoftlimit: u64, + pub dqb_curspace: u64, + pub dqb_ihardlimit: u64, + pub dqb_isoftlimit: u64, + pub dqb_curinodes: u64, + pub dqb_btime: u64, + pub dqb_itime: u64, + pub dqb_valid: u32, } pub struct signalfd_siginfo { - pub ssi_signo: ::uint32_t, - pub ssi_errno: ::int32_t, - pub ssi_code: ::int32_t, - pub ssi_pid: ::uint32_t, - pub ssi_uid: ::uint32_t, - pub ssi_fd: ::int32_t, - pub ssi_tid: ::uint32_t, - pub ssi_band: ::uint32_t, - pub ssi_overrun: ::uint32_t, - pub ssi_trapno: ::uint32_t, - pub ssi_status: ::int32_t, - pub ssi_int: ::int32_t, - pub ssi_ptr: ::uint64_t, - pub ssi_utime: ::uint64_t, - pub ssi_stime: ::uint64_t, - pub ssi_addr: ::uint64_t, - pub ssi_addr_lsb: ::uint16_t, - _pad2: ::uint16_t, - pub ssi_syscall: ::int32_t, - pub ssi_call_addr: ::uint64_t, - pub ssi_arch: ::uint32_t, - _pad: [::uint8_t; 28], + pub ssi_signo: u32, + pub ssi_errno: i32, + pub ssi_code: i32, + pub ssi_pid: u32, + pub ssi_uid: u32, + pub ssi_fd: i32, + pub ssi_tid: u32, + pub ssi_band: u32, + pub ssi_overrun: u32, + pub ssi_trapno: u32, + pub ssi_status: i32, + pub ssi_int: i32, + pub ssi_ptr: u64, + pub ssi_utime: u64, + pub ssi_stime: u64, + pub ssi_addr: u64, + pub ssi_addr_lsb: u16, + _pad2: u16, + pub ssi_syscall: i32, + pub ssi_call_addr: u64, + pub ssi_arch: u32, + _pad: [u8; 28], } pub struct itimerspec { @@ -576,32 +557,6 @@ s! { __val: [::c_int; 2], } - // x32 compatibility - // See https://sourceware.org/bugzilla/show_bug.cgi?id=21279 - pub struct mq_attr { - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub mq_flags: i64, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub mq_maxmsg: i64, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub mq_msgsize: i64, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub mq_curmsgs: i64, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pad: [i64; 4], - - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub mq_flags: ::c_long, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub mq_maxmsg: ::c_long, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub mq_msgsize: ::c_long, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub mq_curmsgs: ::c_long, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pad: [::c_long; 4], - } - pub struct cpu_set_t { #[cfg(all(target_pointer_width = "32", not(target_arch = "x86_64")))] @@ -974,6 +929,39 @@ s_no_extra_traits! { pub d_type: ::c_uchar, pub d_name: [::c_char; 256], } + + // x32 compatibility + // See https://sourceware.org/bugzilla/show_bug.cgi?id=21279 + pub struct mq_attr { + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_flags: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_maxmsg: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_msgsize: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_curmsgs: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pad: [i64; 4], + + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_flags: ::c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_maxmsg: ::c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_msgsize: ::c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_curmsgs: ::c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pad: [::c_long; 4], + } + + pub struct sockaddr_nl { + pub nl_family: ::sa_family_t, + nl_pad: ::c_ushort, + pub nl_pid: u32, + pub nl_groups: u32 + } } cfg_if! { @@ -1214,6 +1202,59 @@ cfg_if! { self.d_name.hash(state); } } + + impl PartialEq for mq_attr { + fn eq(&self, other: &mq_attr) -> bool { + self.mq_flags == other.mq_flags && + self.mq_maxmsg == other.mq_maxmsg && + self.mq_msgsize == other.mq_msgsize && + self.mq_curmsgs == other.mq_curmsgs + } + } + impl Eq for mq_attr {} + impl ::fmt::Debug for mq_attr { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mq_attr") + .field("mq_flags", &self.mq_flags) + .field("mq_maxmsg", &self.mq_maxmsg) + .field("mq_msgsize", &self.mq_msgsize) + .field("mq_curmsgs", &self.mq_curmsgs) + .finish() + } + } + impl ::hash::Hash for mq_attr { + fn hash(&self, state: &mut H) { + self.mq_flags.hash(state); + self.mq_maxmsg.hash(state); + self.mq_msgsize.hash(state); + self.mq_curmsgs.hash(state); + } + } + + impl PartialEq for sockaddr_nl { + fn eq(&self, other: &sockaddr_nl) -> bool { + self.nl_family == other.nl_family && + self.nl_pid == other.nl_pid && + self.nl_groups == other.nl_groups + } + } + impl Eq for sockaddr_nl {} + impl ::fmt::Debug for sockaddr_nl { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_nl") + .field("nl_family", &self.nl_family) + .field("nl_pid", &self.nl_pid) + .field("nl_groups", &self.nl_groups) + .finish() + } + } + impl ::hash::Hash for sockaddr_nl { + fn hash(&self, state: &mut H) { + self.nl_family.hash(state); + self.nl_pid.hash(state); + self.nl_groups.hash(state); + } + } } } @@ -1753,16 +1794,16 @@ pub const MNT_EXPIRE: ::c_int = 0x4; pub const Q_GETFMT: ::c_int = 0x800004; pub const Q_GETINFO: ::c_int = 0x800005; pub const Q_SETINFO: ::c_int = 0x800006; -pub const QIF_BLIMITS: ::uint32_t = 1; -pub const QIF_SPACE: ::uint32_t = 2; -pub const QIF_ILIMITS: ::uint32_t = 4; -pub const QIF_INODES: ::uint32_t = 8; -pub const QIF_BTIME: ::uint32_t = 16; -pub const QIF_ITIME: ::uint32_t = 32; -pub const QIF_LIMITS: ::uint32_t = 5; -pub const QIF_USAGE: ::uint32_t = 10; -pub const QIF_TIMES: ::uint32_t = 48; -pub const QIF_ALL: ::uint32_t = 63; +pub const QIF_BLIMITS: u32 = 1; +pub const QIF_SPACE: u32 = 2; +pub const QIF_ILIMITS: u32 = 4; +pub const QIF_INODES: u32 = 8; +pub const QIF_BTIME: u32 = 16; +pub const QIF_ITIME: u32 = 32; +pub const QIF_LIMITS: u32 = 5; +pub const QIF_USAGE: u32 = 10; +pub const QIF_TIMES: u32 = 48; +pub const QIF_ALL: u32 = 63; pub const MNT_FORCE: ::c_int = 0x1; diff --git a/libc/src/fuchsia/x86_64.rs b/libc/src/fuchsia/x86_64.rs index eb22099..e01f16d 100644 --- a/libc/src/fuchsia/x86_64.rs +++ b/libc/src/fuchsia/x86_64.rs @@ -486,6 +486,17 @@ pub const SIGSTKSZ: ::size_t = 8192; pub const MINSIGSTKSZ: ::size_t = 2048; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] pub const AF_MAX: ::c_int = 42; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +#[allow(deprecated)] pub const PF_MAX: ::c_int = AF_MAX; diff --git a/libc/src/hermit/mod.rs b/libc/src/hermit/mod.rs index 3e15175..9880b50 100644 --- a/libc/src/hermit/mod.rs +++ b/libc/src/hermit/mod.rs @@ -13,15 +13,6 @@ // Ported by Colin Fink // and Stefan Lankes -pub type int8_t = i8; -pub type int16_t = i16; -pub type int32_t = i32; -pub type int64_t = i64; -pub type uint8_t = u8; -pub type uint16_t = u16; -pub type uint32_t = u32; -pub type uint64_t = u64; - pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; diff --git a/libc/src/lib.rs b/libc/src/lib.rs index baf6324..2dc4270 100644 --- a/libc/src/lib.rs +++ b/libc/src/lib.rs @@ -90,27 +90,51 @@ cfg_if! { cfg_if! { if #[cfg(windows)] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + mod windows; pub use windows::*; } else if #[cfg(target_os = "cloudabi")] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + mod cloudabi; pub use cloudabi::*; } else if #[cfg(target_os = "fuchsia")] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + mod fuchsia; pub use fuchsia::*; } else if #[cfg(target_os = "switch")] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + mod switch; pub use switch::*; } else if #[cfg(unix)] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + mod unix; pub use unix::*; } else if #[cfg(target_os = "hermit")] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + mod hermit; pub use hermit::*; } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + mod sgx; pub use sgx::*; } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] { + mod fixed_width_ints; + pub use fixed_width_ints::*; + mod wasi; pub use wasi::*; } else { diff --git a/libc/src/macros.rs b/libc/src/macros.rs index c48ae8b..14a2804 100644 --- a/libc/src/macros.rs +++ b/libc/src/macros.rs @@ -74,10 +74,13 @@ macro_rules! s { __item! { #[repr(C)] #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] + #[allow(deprecated)] $(#[$attr])* pub struct $i { $($field)* } } + #[allow(deprecated)] impl ::Copy for $i {} + #[allow(deprecated)] impl ::Clone for $i { fn clone(&self) -> $i { *self } } @@ -155,3 +158,38 @@ macro_rules! align_const { }; )*) } + +// This macro is used to deprecate items that should be accessed via the mach crate +#[allow(unused_macros)] +macro_rules! deprecated_mach { + (pub const $id:ident: $ty:ty = $expr:expr;) => { + #[deprecated( + since = "0.2.55", + note = "Use the `mach` crate instead", + )] + #[allow(deprecated)] + pub const $id: $ty = $expr; + }; + ($(pub const $id:ident: $ty:ty = $expr:expr;)*) => { + $( + deprecated_mach!( + pub const $id: $ty = $expr; + ); + )* + }; + (pub type $id:ident = $ty:ty;) => { + #[deprecated( + since = "0.2.55", + note = "Use the `mach` crate instead", + )] + #[allow(deprecated)] + pub type $id = $ty; + }; + ($(pub type $id:ident = $ty:ty;)*) => { + $( + deprecated_mach!( + pub type $id = $ty; + ); + )* + } +} diff --git a/libc/src/sgx.rs b/libc/src/sgx.rs index 8a69ad3..7da6269 100644 --- a/libc/src/sgx.rs +++ b/libc/src/sgx.rs @@ -1,14 +1,5 @@ //! SGX C types definition -pub type int8_t = i8; -pub type int16_t = i16; -pub type int32_t = i32; -pub type int64_t = i64; -pub type uint8_t = u8; -pub type uint16_t = u16; -pub type uint32_t = u32; -pub type uint64_t = u64; - pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; diff --git a/libc/src/switch.rs b/libc/src/switch.rs index 06fa203..801b8ed 100644 --- a/libc/src/switch.rs +++ b/libc/src/switch.rs @@ -1,14 +1,5 @@ //! Switch C type definitions -pub type int8_t = i8; -pub type int16_t = i16; -pub type int32_t = i32; -pub type int64_t = i64; -pub type uint8_t = u8; -pub type uint16_t = u16; -pub type uint32_t = u32; -pub type uint64_t = u64; - pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; diff --git a/libc/src/unix/bsd/apple/b32.rs b/libc/src/unix/bsd/apple/b32.rs index 13b1a0b..859809d 100644 --- a/libc/src/unix/bsd/apple/b32.rs +++ b/libc/src/unix/bsd/apple/b32.rs @@ -39,8 +39,8 @@ s! { pub struct bpf_hdr { pub bh_tstamp: ::timeval, - pub bh_caplen: ::uint32_t, - pub bh_datalen: ::uint32_t, + pub bh_caplen: u32, + pub bh_datalen: u32, pub bh_hdrlen: ::c_ushort, } } diff --git a/libc/src/unix/bsd/apple/b64.rs b/libc/src/unix/bsd/apple/b64.rs index 50b48fa..7b89fc6 100644 --- a/libc/src/unix/bsd/apple/b64.rs +++ b/libc/src/unix/bsd/apple/b64.rs @@ -44,8 +44,8 @@ s! { pub struct bpf_hdr { pub bh_tstamp: ::timeval32, - pub bh_caplen: ::uint32_t, - pub bh_datalen: ::uint32_t, + pub bh_caplen: u32, + pub bh_datalen: u32, pub bh_hdrlen: ::c_ushort, } } diff --git a/libc/src/unix/bsd/apple/mod.rs b/libc/src/unix/bsd/apple/mod.rs index 9483e90..af28dba 100644 --- a/libc/src/unix/bsd/apple/mod.rs +++ b/libc/src/unix/bsd/apple/mod.rs @@ -11,7 +11,6 @@ pub type mode_t = u16; pub type nlink_t = u16; pub type blksize_t = i32; pub type rlim_t = u64; -pub type mach_timebase_info_data_t = mach_timebase_info; pub type pthread_key_t = c_ulong; pub type sigset_t = u32; pub type clockid_t = ::c_uint; @@ -26,12 +25,17 @@ pub type idtype_t = ::c_uint; pub type integer_t = ::c_int; pub type cpu_type_t = integer_t; pub type cpu_subtype_t = integer_t; -pub type vm_prot_t = ::c_int; + pub type posix_spawnattr_t = *mut ::c_void; pub type posix_spawn_file_actions_t = *mut ::c_void; pub type key_t = ::c_int; pub type shmatt_t = ::c_ushort; -pub type vm_size_t = ::uintptr_t; + +deprecated_mach! { + pub type vm_prot_t = ::c_int; + pub type vm_size_t = ::uintptr_t; + pub type mach_timebase_info_data_t = mach_timebase_info; +} #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} @@ -83,6 +87,10 @@ s! { pub ai_next: *mut addrinfo, } + #[deprecated( + since = "0.2.55", + note = "Use the `mach` crate instead", + )] pub struct mach_timebase_info { pub numer: u32, pub denom: u32, @@ -107,10 +115,10 @@ s! { pub st_size: ::off_t, pub st_blocks: ::blkcnt_t, pub st_blksize: blksize_t, - pub st_flags: ::uint32_t, - pub st_gen: ::uint32_t, - pub st_lspare: ::int32_t, - pub st_qspare: [::int64_t; 2], + pub st_flags: u32, + pub st_gen: u32, + pub st_lspare: i32, + pub st_qspare: [i64; 2], } pub struct pthread_mutexattr_t { @@ -195,26 +203,26 @@ s! { } pub struct kevent64_s { - pub ident: ::uint64_t, - pub filter: ::int16_t, - pub flags: ::uint16_t, - pub fflags: ::uint32_t, - pub data: ::int64_t, - pub udata: ::uint64_t, - pub ext: [::uint64_t; 2], + pub ident: u64, + pub filter: i16, + pub flags: u16, + pub fflags: u32, + pub data: i64, + pub udata: u64, + pub ext: [u64; 2], } pub struct dqblk { - pub dqb_bhardlimit: ::uint64_t, - pub dqb_bsoftlimit: ::uint64_t, - pub dqb_curbytes: ::uint64_t, - pub dqb_ihardlimit: ::uint32_t, - pub dqb_isoftlimit: ::uint32_t, - pub dqb_curinodes: ::uint32_t, - pub dqb_btime: ::uint32_t, - pub dqb_itime: ::uint32_t, - pub dqb_id: ::uint32_t, - pub dqb_spare: [::uint32_t; 4], + pub dqb_bhardlimit: u64, + pub dqb_bsoftlimit: u64, + pub dqb_curbytes: u64, + pub dqb_ihardlimit: u32, + pub dqb_isoftlimit: u32, + pub dqb_curinodes: u32, + pub dqb_btime: u32, + pub dqb_itime: u32, + pub dqb_id: u32, + pub dqb_spare: [u32; 4], } pub struct if_msghdr { @@ -353,6 +361,10 @@ s! { pub cr_groups: [::gid_t;16] } + #[deprecated( + since = "0.2.55", + note = "Use the `mach` crate instead", + )] pub struct mach_header { pub magic: u32, pub cputype: cpu_type_t, @@ -363,6 +375,10 @@ s! { pub flags: u32, } + #[deprecated( + since = "0.2.55", + note = "Use the `mach` crate instead", + )] pub struct mach_header_64 { pub magic: u32, pub cputype: cpu_type_t, @@ -431,10 +447,10 @@ s! { pub struct sockaddr_ctl { pub sc_len: ::c_uchar, pub sc_family: ::c_uchar, - pub ss_sysaddr: ::uint16_t, - pub sc_id: ::uint32_t, - pub sc_unit: ::uint32_t, - pub sc_reserved: [::uint32_t; 5], + pub ss_sysaddr: u16, + pub sc_id: u32, + pub sc_unit: u32, + pub sc_reserved: [u32; 5], } pub struct in_pktinfo { @@ -487,9 +503,9 @@ s_no_extra_traits!{ #[cfg_attr(libc_packedN, repr(packed(4)))] pub struct kevent { pub ident: ::uintptr_t, - pub filter: ::int16_t, - pub flags: ::uint16_t, - pub fflags: ::uint32_t, + pub filter: i16, + pub flags: u16, + pub fflags: u32, pub data: ::intptr_t, pub udata: *mut ::c_void, } @@ -498,13 +514,13 @@ s_no_extra_traits!{ pub struct semid_ds { // Note the manpage shows different types than the system header. pub sem_perm: ipc_perm, - pub sem_base: ::int32_t, + pub sem_base: i32, pub sem_nsems: ::c_ushort, pub sem_otime: ::time_t, - pub sem_pad1: ::int32_t, + pub sem_pad1: i32, pub sem_ctime: ::time_t, - pub sem_pad2: ::int32_t, - pub sem_pad3: [::int32_t; 4], + pub sem_pad2: i32, + pub sem_pad3: [i32; 4], } #[cfg_attr(libc_packedN, repr(packed(4)))] @@ -536,22 +552,22 @@ s_no_extra_traits!{ } pub struct statfs { - pub f_bsize: ::uint32_t, - pub f_iosize: ::int32_t, - pub f_blocks: ::uint64_t, - pub f_bfree: ::uint64_t, - pub f_bavail: ::uint64_t, - pub f_files: ::uint64_t, - pub f_ffree: ::uint64_t, + pub f_bsize: u32, + pub f_iosize: i32, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, pub f_fsid: ::fsid_t, pub f_owner: ::uid_t, - pub f_type: ::uint32_t, - pub f_flags: ::uint32_t, - pub f_fssubtype: ::uint32_t, + pub f_type: u32, + pub f_flags: u32, + pub f_fssubtype: u32, pub f_fstypename: [::c_char; 16], pub f_mntonname: [::c_char; 1024], pub f_mntfromname: [::c_char; 1024], - pub f_reserved: [::uint32_t; 8], + pub f_reserved: [u32; 8], } pub struct dirent { @@ -594,7 +610,7 @@ s_no_extra_traits!{ pub ut_type: ::c_short, pub ut_tv: ::timeval, pub ut_host: [::c_char; _UTX_HOSTSIZE], - ut_pad: [::uint32_t; 16], + ut_pad: [u32; 16], } } @@ -1361,103 +1377,106 @@ pub const MAP_FIXED: ::c_int = 0x0010; pub const MAP_ANON: ::c_int = 0x1000; pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; -pub const VM_FLAGS_FIXED: ::c_int = 0x0000; -pub const VM_FLAGS_ANYWHERE: ::c_int = 0x0001; -pub const VM_FLAGS_PURGABLE: ::c_int = 0x0002; -pub const VM_FLAGS_RANDOM_ADDR: ::c_int = 0x0008; -pub const VM_FLAGS_NO_CACHE: ::c_int = 0x0010; -pub const VM_FLAGS_RESILIENT_CODESIGN: ::c_int = 0x0020; -pub const VM_FLAGS_RESILIENT_MEDIA: ::c_int = 0x0040; -pub const VM_FLAGS_OVERWRITE: ::c_int = 0x4000; -pub const VM_FLAGS_SUPERPAGE_MASK: ::c_int = 0x70000; -pub const VM_FLAGS_RETURN_DATA_ADDR: ::c_int = 0x100000; -pub const VM_FLAGS_RETURN_4K_DATA_ADDR: ::c_int = 0x800000; -pub const VM_FLAGS_ALIAS_MASK: ::c_int = 0xFF000000; -pub const VM_FLAGS_USER_ALLOCATE: ::c_int = 0xff07401f; -pub const VM_FLAGS_USER_MAP: ::c_int = 0xff97401f; -pub const VM_FLAGS_USER_REMAP: ::c_int = VM_FLAGS_FIXED | VM_FLAGS_ANYWHERE | - VM_FLAGS_RANDOM_ADDR | - VM_FLAGS_OVERWRITE | - VM_FLAGS_RETURN_DATA_ADDR | - VM_FLAGS_RESILIENT_CODESIGN; - -pub const VM_FLAGS_SUPERPAGE_SHIFT: ::c_int = 16; -pub const SUPERPAGE_NONE: ::c_int = 0; -pub const SUPERPAGE_SIZE_ANY: ::c_int = 1; -pub const VM_FLAGS_SUPERPAGE_NONE: ::c_int = SUPERPAGE_NONE << - VM_FLAGS_SUPERPAGE_SHIFT; -pub const VM_FLAGS_SUPERPAGE_SIZE_ANY: ::c_int = SUPERPAGE_SIZE_ANY << +deprecated_mach! { + pub const VM_FLAGS_FIXED: ::c_int = 0x0000; + pub const VM_FLAGS_ANYWHERE: ::c_int = 0x0001; + pub const VM_FLAGS_PURGABLE: ::c_int = 0x0002; + pub const VM_FLAGS_RANDOM_ADDR: ::c_int = 0x0008; + pub const VM_FLAGS_NO_CACHE: ::c_int = 0x0010; + pub const VM_FLAGS_RESILIENT_CODESIGN: ::c_int = 0x0020; + pub const VM_FLAGS_RESILIENT_MEDIA: ::c_int = 0x0040; + pub const VM_FLAGS_OVERWRITE: ::c_int = 0x4000; + pub const VM_FLAGS_SUPERPAGE_MASK: ::c_int = 0x70000; + pub const VM_FLAGS_RETURN_DATA_ADDR: ::c_int = 0x100000; + pub const VM_FLAGS_RETURN_4K_DATA_ADDR: ::c_int = 0x800000; + pub const VM_FLAGS_ALIAS_MASK: ::c_int = 0xFF000000; + pub const VM_FLAGS_USER_ALLOCATE: ::c_int = 0xff07401f; + pub const VM_FLAGS_USER_MAP: ::c_int = 0xff97401f; + pub const VM_FLAGS_USER_REMAP: ::c_int = VM_FLAGS_FIXED | + VM_FLAGS_ANYWHERE | + VM_FLAGS_RANDOM_ADDR | + VM_FLAGS_OVERWRITE | + VM_FLAGS_RETURN_DATA_ADDR | + VM_FLAGS_RESILIENT_CODESIGN; + + pub const VM_FLAGS_SUPERPAGE_SHIFT: ::c_int = 16; + pub const SUPERPAGE_NONE: ::c_int = 0; + pub const SUPERPAGE_SIZE_ANY: ::c_int = 1; + pub const VM_FLAGS_SUPERPAGE_NONE: ::c_int = SUPERPAGE_NONE << VM_FLAGS_SUPERPAGE_SHIFT; -pub const SUPERPAGE_SIZE_2MB: ::c_int = 2; -pub const VM_FLAGS_SUPERPAGE_SIZE_2MB: ::c_int = SUPERPAGE_SIZE_2MB << - VM_FLAGS_SUPERPAGE_SHIFT; - -pub const VM_MEMORY_MALLOC: ::c_int = 1; -pub const VM_MEMORY_MALLOC_SMALL: ::c_int = 2; -pub const VM_MEMORY_MALLOC_LARGE: ::c_int = 3; -pub const VM_MEMORY_MALLOC_HUGE: ::c_int = 4; -pub const VM_MEMORY_SBRK: ::c_int = 5; -pub const VM_MEMORY_REALLOC: ::c_int = 6; -pub const VM_MEMORY_MALLOC_TINY: ::c_int = 7; -pub const VM_MEMORY_MALLOC_LARGE_REUSABLE: ::c_int = 8; -pub const VM_MEMORY_MALLOC_LARGE_REUSED: ::c_int = 9; -pub const VM_MEMORY_ANALYSIS_TOOL: ::c_int = 10; -pub const VM_MEMORY_MALLOC_NANO: ::c_int = 11; -pub const VM_MEMORY_MACH_MSG: ::c_int = 20; -pub const VM_MEMORY_IOKIT: ::c_int = 21; -pub const VM_MEMORY_STACK: ::c_int = 30; -pub const VM_MEMORY_GUARD: ::c_int = 31; -pub const VM_MEMORY_SHARED_PMAP: ::c_int = 32; -pub const VM_MEMORY_DYLIB: ::c_int = 33; -pub const VM_MEMORY_OBJC_DISPATCHERS: ::c_int = 34; -pub const VM_MEMORY_UNSHARED_PMAP: ::c_int = 35; -pub const VM_MEMORY_APPKIT: ::c_int = 40; -pub const VM_MEMORY_FOUNDATION: ::c_int = 41; -pub const VM_MEMORY_COREGRAPHICS: ::c_int = 42; -pub const VM_MEMORY_CORESERVICES: ::c_int = 43; -pub const VM_MEMORY_CARBON: ::c_int = VM_MEMORY_CORESERVICES; -pub const VM_MEMORY_JAVA: ::c_int = 44; -pub const VM_MEMORY_COREDATA: ::c_int = 45; -pub const VM_MEMORY_COREDATA_OBJECTIDS: ::c_int = 46; -pub const VM_MEMORY_ATS: ::c_int = 50; -pub const VM_MEMORY_LAYERKIT: ::c_int = 51; -pub const VM_MEMORY_CGIMAGE: ::c_int = 52; -pub const VM_MEMORY_TCMALLOC: ::c_int = 53; -pub const VM_MEMORY_COREGRAPHICS_DATA: ::c_int = 54; -pub const VM_MEMORY_COREGRAPHICS_SHARED: ::c_int = 55; -pub const VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS: ::c_int = 56; -pub const VM_MEMORY_COREGRAPHICS_BACKINGSTORES: ::c_int = 57; -pub const VM_MEMORY_COREGRAPHICS_XALLOC: ::c_int = 58; -pub const VM_MEMORY_COREGRAPHICS_MISC: ::c_int = VM_MEMORY_COREGRAPHICS; -pub const VM_MEMORY_DYLD: ::c_int = 60; -pub const VM_MEMORY_DYLD_MALLOC: ::c_int = 61; -pub const VM_MEMORY_SQLITE: ::c_int = 62; -pub const VM_MEMORY_JAVASCRIPT_CORE: ::c_int = 63; -pub const VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR: ::c_int = 64; -pub const VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE: ::c_int = 65; -pub const VM_MEMORY_GLSL: ::c_int = 66; -pub const VM_MEMORY_OPENCL: ::c_int = 67; -pub const VM_MEMORY_COREIMAGE: ::c_int = 68; -pub const VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS: ::c_int = 69; -pub const VM_MEMORY_IMAGEIO: ::c_int = 70; -pub const VM_MEMORY_COREPROFILE: ::c_int = 71; -pub const VM_MEMORY_ASSETSD: ::c_int = 72; -pub const VM_MEMORY_OS_ALLOC_ONCE: ::c_int = 73; -pub const VM_MEMORY_LIBDISPATCH: ::c_int = 74; -pub const VM_MEMORY_ACCELERATE: ::c_int = 75; -pub const VM_MEMORY_COREUI: ::c_int = 76; -pub const VM_MEMORY_COREUIFILE: ::c_int = 77; -pub const VM_MEMORY_GENEALOGY: ::c_int = 78; -pub const VM_MEMORY_RAWCAMERA: ::c_int = 79; -pub const VM_MEMORY_CORPSEINFO: ::c_int = 80; -pub const VM_MEMORY_ASL: ::c_int = 81; -pub const VM_MEMORY_SWIFT_RUNTIME: ::c_int = 82; -pub const VM_MEMORY_SWIFT_METADATA: ::c_int = 83; -pub const VM_MEMORY_DHMM: ::c_int = 84; -pub const VM_MEMORY_SCENEKIT: ::c_int = 86; -pub const VM_MEMORY_SKYWALK: ::c_int = 87; -pub const VM_MEMORY_APPLICATION_SPECIFIC_1: ::c_int = 240; -pub const VM_MEMORY_APPLICATION_SPECIFIC_16: ::c_int = 255; + pub const VM_FLAGS_SUPERPAGE_SIZE_ANY: ::c_int = SUPERPAGE_SIZE_ANY << + VM_FLAGS_SUPERPAGE_SHIFT; + pub const SUPERPAGE_SIZE_2MB: ::c_int = 2; + pub const VM_FLAGS_SUPERPAGE_SIZE_2MB: ::c_int = SUPERPAGE_SIZE_2MB << + VM_FLAGS_SUPERPAGE_SHIFT; + + pub const VM_MEMORY_MALLOC: ::c_int = 1; + pub const VM_MEMORY_MALLOC_SMALL: ::c_int = 2; + pub const VM_MEMORY_MALLOC_LARGE: ::c_int = 3; + pub const VM_MEMORY_MALLOC_HUGE: ::c_int = 4; + pub const VM_MEMORY_SBRK: ::c_int = 5; + pub const VM_MEMORY_REALLOC: ::c_int = 6; + pub const VM_MEMORY_MALLOC_TINY: ::c_int = 7; + pub const VM_MEMORY_MALLOC_LARGE_REUSABLE: ::c_int = 8; + pub const VM_MEMORY_MALLOC_LARGE_REUSED: ::c_int = 9; + pub const VM_MEMORY_ANALYSIS_TOOL: ::c_int = 10; + pub const VM_MEMORY_MALLOC_NANO: ::c_int = 11; + pub const VM_MEMORY_MACH_MSG: ::c_int = 20; + pub const VM_MEMORY_IOKIT: ::c_int = 21; + pub const VM_MEMORY_STACK: ::c_int = 30; + pub const VM_MEMORY_GUARD: ::c_int = 31; + pub const VM_MEMORY_SHARED_PMAP: ::c_int = 32; + pub const VM_MEMORY_DYLIB: ::c_int = 33; + pub const VM_MEMORY_OBJC_DISPATCHERS: ::c_int = 34; + pub const VM_MEMORY_UNSHARED_PMAP: ::c_int = 35; + pub const VM_MEMORY_APPKIT: ::c_int = 40; + pub const VM_MEMORY_FOUNDATION: ::c_int = 41; + pub const VM_MEMORY_COREGRAPHICS: ::c_int = 42; + pub const VM_MEMORY_CORESERVICES: ::c_int = 43; + pub const VM_MEMORY_CARBON: ::c_int = VM_MEMORY_CORESERVICES; + pub const VM_MEMORY_JAVA: ::c_int = 44; + pub const VM_MEMORY_COREDATA: ::c_int = 45; + pub const VM_MEMORY_COREDATA_OBJECTIDS: ::c_int = 46; + pub const VM_MEMORY_ATS: ::c_int = 50; + pub const VM_MEMORY_LAYERKIT: ::c_int = 51; + pub const VM_MEMORY_CGIMAGE: ::c_int = 52; + pub const VM_MEMORY_TCMALLOC: ::c_int = 53; + pub const VM_MEMORY_COREGRAPHICS_DATA: ::c_int = 54; + pub const VM_MEMORY_COREGRAPHICS_SHARED: ::c_int = 55; + pub const VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS: ::c_int = 56; + pub const VM_MEMORY_COREGRAPHICS_BACKINGSTORES: ::c_int = 57; + pub const VM_MEMORY_COREGRAPHICS_XALLOC: ::c_int = 58; + pub const VM_MEMORY_COREGRAPHICS_MISC: ::c_int = VM_MEMORY_COREGRAPHICS; + pub const VM_MEMORY_DYLD: ::c_int = 60; + pub const VM_MEMORY_DYLD_MALLOC: ::c_int = 61; + pub const VM_MEMORY_SQLITE: ::c_int = 62; + pub const VM_MEMORY_JAVASCRIPT_CORE: ::c_int = 63; + pub const VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR: ::c_int = 64; + pub const VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE: ::c_int = 65; + pub const VM_MEMORY_GLSL: ::c_int = 66; + pub const VM_MEMORY_OPENCL: ::c_int = 67; + pub const VM_MEMORY_COREIMAGE: ::c_int = 68; + pub const VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS: ::c_int = 69; + pub const VM_MEMORY_IMAGEIO: ::c_int = 70; + pub const VM_MEMORY_COREPROFILE: ::c_int = 71; + pub const VM_MEMORY_ASSETSD: ::c_int = 72; + pub const VM_MEMORY_OS_ALLOC_ONCE: ::c_int = 73; + pub const VM_MEMORY_LIBDISPATCH: ::c_int = 74; + pub const VM_MEMORY_ACCELERATE: ::c_int = 75; + pub const VM_MEMORY_COREUI: ::c_int = 76; + pub const VM_MEMORY_COREUIFILE: ::c_int = 77; + pub const VM_MEMORY_GENEALOGY: ::c_int = 78; + pub const VM_MEMORY_RAWCAMERA: ::c_int = 79; + pub const VM_MEMORY_CORPSEINFO: ::c_int = 80; + pub const VM_MEMORY_ASL: ::c_int = 81; + pub const VM_MEMORY_SWIFT_RUNTIME: ::c_int = 82; + pub const VM_MEMORY_SWIFT_METADATA: ::c_int = 83; + pub const VM_MEMORY_DHMM: ::c_int = 84; + pub const VM_MEMORY_SCENEKIT: ::c_int = 86; + pub const VM_MEMORY_SKYWALK: ::c_int = 87; + pub const VM_MEMORY_APPLICATION_SPECIFIC_1: ::c_int = 240; + pub const VM_MEMORY_APPLICATION_SPECIFIC_16: ::c_int = 255; +} pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; @@ -2064,6 +2083,11 @@ pub const AF_NETBIOS: ::c_int = 33; pub const AF_PPP: ::c_int = 34; pub const pseudo_AF_HDRCMPLT: ::c_int = 35; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] pub const AF_MAX: ::c_int = 40; pub const AF_SYS_CONTROL: ::c_int = 2; @@ -2106,15 +2130,28 @@ pub const PF_SYSTEM: ::c_int = AF_SYSTEM; pub const PF_NETBIOS: ::c_int = AF_NETBIOS; pub const PF_PPP: ::c_int = AF_PPP; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +#[allow(deprecated)] pub const PF_MAX: ::c_int = AF_MAX; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +#[allow(deprecated)] pub const NET_MAXID: ::c_int = AF_MAX; pub const NET_RT_DUMP: ::c_int = 1; pub const NET_RT_FLAGS: ::c_int = 2; pub const NET_RT_IFLIST: ::c_int = 3; #[doc(hidden)] +#[deprecated(since = "0.2.55")] pub const NET_RT_MAXID: ::c_int = 10; pub const SOMAXCONN: ::c_int = 128; @@ -2372,109 +2409,111 @@ pub const FD_SETSIZE: usize = 1024; pub const ST_NOSUID: ::c_ulong = 2; -pub const EVFILT_READ: ::int16_t = -1; -pub const EVFILT_WRITE: ::int16_t = -2; -pub const EVFILT_AIO: ::int16_t = -3; -pub const EVFILT_VNODE: ::int16_t = -4; -pub const EVFILT_PROC: ::int16_t = -5; -pub const EVFILT_SIGNAL: ::int16_t = -6; -pub const EVFILT_TIMER: ::int16_t = -7; -pub const EVFILT_MACHPORT: ::int16_t = -8; -pub const EVFILT_FS: ::int16_t = -9; -pub const EVFILT_USER: ::int16_t = -10; -pub const EVFILT_VM: ::int16_t = -12; - -pub const EV_ADD: ::uint16_t = 0x1; -pub const EV_DELETE: ::uint16_t = 0x2; -pub const EV_ENABLE: ::uint16_t = 0x4; -pub const EV_DISABLE: ::uint16_t = 0x8; -pub const EV_ONESHOT: ::uint16_t = 0x10; -pub const EV_CLEAR: ::uint16_t = 0x20; -pub const EV_RECEIPT: ::uint16_t = 0x40; -pub const EV_DISPATCH: ::uint16_t = 0x80; -pub const EV_FLAG0: ::uint16_t = 0x1000; -pub const EV_POLL: ::uint16_t = 0x1000; -pub const EV_FLAG1: ::uint16_t = 0x2000; -pub const EV_OOBAND: ::uint16_t = 0x2000; -pub const EV_ERROR: ::uint16_t = 0x4000; -pub const EV_EOF: ::uint16_t = 0x8000; -pub const EV_SYSFLAGS: ::uint16_t = 0xf000; - -pub const NOTE_TRIGGER: ::uint32_t = 0x01000000; -pub const NOTE_FFNOP: ::uint32_t = 0x00000000; -pub const NOTE_FFAND: ::uint32_t = 0x40000000; -pub const NOTE_FFOR: ::uint32_t = 0x80000000; -pub const NOTE_FFCOPY: ::uint32_t = 0xc0000000; -pub const NOTE_FFCTRLMASK: ::uint32_t = 0xc0000000; -pub const NOTE_FFLAGSMASK: ::uint32_t = 0x00ffffff; -pub const NOTE_LOWAT: ::uint32_t = 0x00000001; -pub const NOTE_DELETE: ::uint32_t = 0x00000001; -pub const NOTE_WRITE: ::uint32_t = 0x00000002; -pub const NOTE_EXTEND: ::uint32_t = 0x00000004; -pub const NOTE_ATTRIB: ::uint32_t = 0x00000008; -pub const NOTE_LINK: ::uint32_t = 0x00000010; -pub const NOTE_RENAME: ::uint32_t = 0x00000020; -pub const NOTE_REVOKE: ::uint32_t = 0x00000040; -pub const NOTE_NONE: ::uint32_t = 0x00000080; -pub const NOTE_EXIT: ::uint32_t = 0x80000000; -pub const NOTE_FORK: ::uint32_t = 0x40000000; -pub const NOTE_EXEC: ::uint32_t = 0x20000000; +pub const EVFILT_READ: i16 = -1; +pub const EVFILT_WRITE: i16 = -2; +pub const EVFILT_AIO: i16 = -3; +pub const EVFILT_VNODE: i16 = -4; +pub const EVFILT_PROC: i16 = -5; +pub const EVFILT_SIGNAL: i16 = -6; +pub const EVFILT_TIMER: i16 = -7; +pub const EVFILT_MACHPORT: i16 = -8; +pub const EVFILT_FS: i16 = -9; +pub const EVFILT_USER: i16 = -10; +pub const EVFILT_VM: i16 = -12; + +pub const EV_ADD: u16 = 0x1; +pub const EV_DELETE: u16 = 0x2; +pub const EV_ENABLE: u16 = 0x4; +pub const EV_DISABLE: u16 = 0x8; +pub const EV_ONESHOT: u16 = 0x10; +pub const EV_CLEAR: u16 = 0x20; +pub const EV_RECEIPT: u16 = 0x40; +pub const EV_DISPATCH: u16 = 0x80; +pub const EV_FLAG0: u16 = 0x1000; +pub const EV_POLL: u16 = 0x1000; +pub const EV_FLAG1: u16 = 0x2000; +pub const EV_OOBAND: u16 = 0x2000; +pub const EV_ERROR: u16 = 0x4000; +pub const EV_EOF: u16 = 0x8000; +pub const EV_SYSFLAGS: u16 = 0xf000; + +pub const NOTE_TRIGGER: u32 = 0x01000000; +pub const NOTE_FFNOP: u32 = 0x00000000; +pub const NOTE_FFAND: u32 = 0x40000000; +pub const NOTE_FFOR: u32 = 0x80000000; +pub const NOTE_FFCOPY: u32 = 0xc0000000; +pub const NOTE_FFCTRLMASK: u32 = 0xc0000000; +pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff; +pub const NOTE_LOWAT: u32 = 0x00000001; +pub const NOTE_DELETE: u32 = 0x00000001; +pub const NOTE_WRITE: u32 = 0x00000002; +pub const NOTE_EXTEND: u32 = 0x00000004; +pub const NOTE_ATTRIB: u32 = 0x00000008; +pub const NOTE_LINK: u32 = 0x00000010; +pub const NOTE_RENAME: u32 = 0x00000020; +pub const NOTE_REVOKE: u32 = 0x00000040; +pub const NOTE_NONE: u32 = 0x00000080; +pub const NOTE_EXIT: u32 = 0x80000000; +pub const NOTE_FORK: u32 = 0x40000000; +pub const NOTE_EXEC: u32 = 0x20000000; +#[doc(hidden)] #[deprecated(since="0.2.49", note="Deprecated since MacOSX 10.9")] -pub const NOTE_REAP: ::uint32_t = 0x10000000; -pub const NOTE_SIGNAL: ::uint32_t = 0x08000000; -pub const NOTE_EXITSTATUS: ::uint32_t = 0x04000000; -pub const NOTE_EXIT_DETAIL: ::uint32_t = 0x02000000; -pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff; -pub const NOTE_PCTRLMASK: ::uint32_t = 0xfff00000; +pub const NOTE_REAP: u32 = 0x10000000; +pub const NOTE_SIGNAL: u32 = 0x08000000; +pub const NOTE_EXITSTATUS: u32 = 0x04000000; +pub const NOTE_EXIT_DETAIL: u32 = 0x02000000; +pub const NOTE_PDATAMASK: u32 = 0x000fffff; +pub const NOTE_PCTRLMASK: u32 = 0xfff00000; +#[doc(hidden)] #[deprecated(since="0.2.49", note="Deprecated since MacOSX 10.9")] -pub const NOTE_EXIT_REPARENTED: ::uint32_t = 0x00080000; -pub const NOTE_EXIT_DETAIL_MASK: ::uint32_t = 0x00070000; -pub const NOTE_EXIT_DECRYPTFAIL: ::uint32_t = 0x00010000; -pub const NOTE_EXIT_MEMORY: ::uint32_t = 0x00020000; -pub const NOTE_EXIT_CSERROR: ::uint32_t = 0x00040000; -pub const NOTE_VM_PRESSURE: ::uint32_t = 0x80000000; -pub const NOTE_VM_PRESSURE_TERMINATE: ::uint32_t = 0x40000000; -pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE: ::uint32_t = 0x20000000; -pub const NOTE_VM_ERROR: ::uint32_t = 0x10000000; -pub const NOTE_SECONDS: ::uint32_t = 0x00000001; -pub const NOTE_USECONDS: ::uint32_t = 0x00000002; -pub const NOTE_NSECONDS: ::uint32_t = 0x00000004; -pub const NOTE_ABSOLUTE: ::uint32_t = 0x00000008; -pub const NOTE_LEEWAY: ::uint32_t = 0x00000010; -pub const NOTE_CRITICAL: ::uint32_t = 0x00000020; -pub const NOTE_BACKGROUND: ::uint32_t = 0x00000040; -pub const NOTE_TRACK: ::uint32_t = 0x00000001; -pub const NOTE_TRACKERR: ::uint32_t = 0x00000002; -pub const NOTE_CHILD: ::uint32_t = 0x00000004; - -pub const OCRNL: ::c_int = 0x00000010; -pub const ONOCR: ::c_int = 0x00000020; -pub const ONLRET: ::c_int = 0x00000040; -pub const OFILL: ::c_int = 0x00000080; -pub const NLDLY: ::c_int = 0x00000300; -pub const TABDLY: ::c_int = 0x00000c04; -pub const CRDLY: ::c_int = 0x00003000; -pub const FFDLY: ::c_int = 0x00004000; -pub const BSDLY: ::c_int = 0x00008000; -pub const VTDLY: ::c_int = 0x00010000; -pub const OFDEL: ::c_int = 0x00020000; - -pub const NL0: ::c_int = 0x00000000; -pub const NL1: ::c_int = 0x00000100; -pub const TAB0: ::c_int = 0x00000000; -pub const TAB1: ::c_int = 0x00000400; -pub const TAB2: ::c_int = 0x00000800; -pub const CR0: ::c_int = 0x00000000; -pub const CR1: ::c_int = 0x00001000; -pub const CR2: ::c_int = 0x00002000; -pub const CR3: ::c_int = 0x00003000; -pub const FF0: ::c_int = 0x00000000; -pub const FF1: ::c_int = 0x00004000; -pub const BS0: ::c_int = 0x00000000; -pub const BS1: ::c_int = 0x00008000; -pub const TAB3: ::c_int = 0x00000004; -pub const VT0: ::c_int = 0x00000000; -pub const VT1: ::c_int = 0x00010000; +pub const NOTE_EXIT_REPARENTED: u32 = 0x00080000; +pub const NOTE_EXIT_DETAIL_MASK: u32 = 0x00070000; +pub const NOTE_EXIT_DECRYPTFAIL: u32 = 0x00010000; +pub const NOTE_EXIT_MEMORY: u32 = 0x00020000; +pub const NOTE_EXIT_CSERROR: u32 = 0x00040000; +pub const NOTE_VM_PRESSURE: u32 = 0x80000000; +pub const NOTE_VM_PRESSURE_TERMINATE: u32 = 0x40000000; +pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE: u32 = 0x20000000; +pub const NOTE_VM_ERROR: u32 = 0x10000000; +pub const NOTE_SECONDS: u32 = 0x00000001; +pub const NOTE_USECONDS: u32 = 0x00000002; +pub const NOTE_NSECONDS: u32 = 0x00000004; +pub const NOTE_ABSOLUTE: u32 = 0x00000008; +pub const NOTE_LEEWAY: u32 = 0x00000010; +pub const NOTE_CRITICAL: u32 = 0x00000020; +pub const NOTE_BACKGROUND: u32 = 0x00000040; +pub const NOTE_TRACK: u32 = 0x00000001; +pub const NOTE_TRACKERR: u32 = 0x00000002; +pub const NOTE_CHILD: u32 = 0x00000004; + +pub const OCRNL: ::tcflag_t = 0x00000010; +pub const ONOCR: ::tcflag_t = 0x00000020; +pub const ONLRET: ::tcflag_t = 0x00000040; +pub const OFILL: ::tcflag_t = 0x00000080; +pub const NLDLY: ::tcflag_t = 0x00000300; +pub const TABDLY: ::tcflag_t = 0x00000c04; +pub const CRDLY: ::tcflag_t = 0x00003000; +pub const FFDLY: ::tcflag_t = 0x00004000; +pub const BSDLY: ::tcflag_t = 0x00008000; +pub const VTDLY: ::tcflag_t = 0x00010000; +pub const OFDEL: ::tcflag_t = 0x00020000; + +pub const NL0: ::tcflag_t = 0x00000000; +pub const NL1: ::tcflag_t = 0x00000100; +pub const TAB0: ::tcflag_t = 0x00000000; +pub const TAB1: ::tcflag_t = 0x00000400; +pub const TAB2: ::tcflag_t = 0x00000800; +pub const CR0: ::tcflag_t = 0x00000000; +pub const CR1: ::tcflag_t = 0x00001000; +pub const CR2: ::tcflag_t = 0x00002000; +pub const CR3: ::tcflag_t = 0x00003000; +pub const FF0: ::tcflag_t = 0x00000000; +pub const FF1: ::tcflag_t = 0x00004000; +pub const BS0: ::tcflag_t = 0x00000000; +pub const BS1: ::tcflag_t = 0x00008000; +pub const TAB3: ::tcflag_t = 0x00000004; +pub const VT0: ::tcflag_t = 0x00000000; +pub const VT1: ::tcflag_t = 0x00010000; pub const IUTF8: ::tcflag_t = 0x00004000; pub const CRTSCTS: ::tcflag_t = 0x00030000; @@ -2632,8 +2671,10 @@ pub const KERN_KDSETRTCDEC: ::c_int = 15; pub const KERN_KDGETENTROPY: ::c_int = 16; pub const KERN_KDWRITETR: ::c_int = 17; pub const KERN_KDWRITEMAP: ::c_int = 18; +#[doc(hidden)] #[deprecated(since = "0.2.49", note ="Removed in MacOSX 10.12")] pub const KERN_KDENABLE_BG_TRACE: ::c_int = 19; +#[doc(hidden)] #[deprecated(since = "0.2.49", note ="Removed in MacOSX 10.12")] pub const KERN_KDDISABLE_BG_TRACE: ::c_int = 20; pub const KERN_KDREADCURTHRMAP: ::c_int = 21; @@ -2887,7 +2928,7 @@ pub const DLT_RAW: ::c_uint = 12; // raw IP pub const DLT_LOOP: ::c_uint = 108; // https://github.com/apple/darwin-xnu/blob/master/bsd/net/bpf.h#L100 -// sizeof(int32_t) +// sizeof(i32) pub const BPF_ALIGNMENT: ::c_int = 4; // sys/spawn.h: @@ -3014,11 +3055,15 @@ f! { } extern { + pub fn setgrent(); + #[doc(hidden)] #[deprecated(since="0.2.49", note="Deprecated in MacOSX 10.5")] #[link_name = "daemon$1050"] pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; + #[doc(hidden)] #[deprecated(since="0.2.49", note="Deprecated in MacOSX 10.10")] pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; + #[doc(hidden)] #[deprecated(since="0.2.49", note="Deprecated in MacOSX 10.10")] pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, @@ -3045,6 +3090,8 @@ extern { pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; + pub fn gettimeofday(tp: *mut ::timeval, + tz: *mut ::c_void) -> ::c_int; pub fn getutxent() -> *mut utmpx; pub fn getutxid(ut: *const utmpx) -> *mut utmpx; pub fn getutxline(ut: *const utmpx) -> *mut utmpx; @@ -3100,7 +3147,10 @@ extern { newp: *mut ::c_void, newlen: ::size_t) -> ::c_int; + #[deprecated(since = "0.2.55", note = "Use the mach crate")] pub fn mach_absolute_time() -> u64; + #[deprecated(since = "0.2.55", note = "Use the mach crate")] + #[allow(deprecated)] pub fn mach_timebase_info(info: *mut ::mach_timebase_info) -> ::c_int; pub fn pthread_setname_np(name: *const ::c_char) -> ::c_int; pub fn pthread_get_stackaddr_np(thread: ::pthread_t) -> *mut ::c_void; @@ -3220,9 +3270,14 @@ extern { pub fn brk(addr: *const ::c_void) -> *mut ::c_void; pub fn sbrk(increment: ::c_int) -> *mut ::c_void; pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int; + #[deprecated(since = "0.2.55", note = "Use the mach crate")] pub fn _dyld_image_count() -> u32; + #[deprecated(since = "0.2.55", note = "Use the mach crate")] + #[allow(deprecated)] pub fn _dyld_get_image_header(image_index: u32) -> *const mach_header; + #[deprecated(since = "0.2.55", note = "Use the mach crate")] pub fn _dyld_get_image_vmaddr_slide(image_index: u32) -> ::intptr_t; + #[deprecated(since = "0.2.55", note = "Use the mach crate")] pub fn _dyld_get_image_name(image_index: u32) -> *const ::c_char; pub fn posix_spawn(pid: *mut ::pid_t, diff --git a/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs index e91b351..26faffe 100644 --- a/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1,3 +1,4 @@ +pub type dev_t = u32; pub type c_char = i8; pub type clock_t = u64; pub type ino_t = u64; @@ -27,6 +28,15 @@ impl ::Clone for sem { } s! { + pub struct kevent { + pub ident: ::uintptr_t, + pub filter: ::c_short, + pub flags: ::c_ushort, + pub fflags: ::c_uint, + pub data: ::intptr_t, + pub udata: *mut ::c_void, + } + pub struct exit_status { pub e_termination: u16, pub e_exit: u16 @@ -100,7 +110,7 @@ s! { pub st_nlink: ::nlink_t, pub st_dev: ::dev_t, pub st_mode: ::mode_t, - pub st_padding1: ::uint16_t, + pub st_padding1: u16, pub st_uid: ::uid_t, pub st_gid: ::gid_t, pub st_rdev: ::dev_t, @@ -111,13 +121,13 @@ s! { pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, pub st_size: ::off_t, - pub st_blocks: ::int64_t, - pub st_blksize: ::uint32_t, - pub st_flags: ::uint32_t, - pub st_gen: ::uint32_t, - pub st_lspare: ::int32_t, - pub st_qspare1: ::int64_t, - pub st_qspare2: ::int64_t, + pub st_blocks: i64, + pub st_blksize: u32, + pub st_flags: u32, + pub st_gen: u32, + pub st_lspare: i32, + pub st_qspare1: i64, + pub st_qspare2: i64, } pub struct if_data { @@ -214,8 +224,8 @@ s_no_extra_traits! { pub f_ffree: ::c_long, pub f_fsid: ::fsid_t, pub f_owner: ::uid_t, - pub f_type: ::int32_t, - pub f_flags: ::int32_t, + pub f_type: i32, + pub f_flags: i32, pub f_syncwrites: ::c_long, pub f_asyncwrites: ::c_long, pub f_fstypename: [::c_char; 16], @@ -567,55 +577,55 @@ pub const CTL_P1003_1B_SIGQUEUE_MAX: ::c_int = 24; pub const CTL_P1003_1B_TIMER_MAX: ::c_int = 25; pub const CTL_P1003_1B_MAXID: ::c_int = 26; -pub const EVFILT_READ: ::int16_t = -1; -pub const EVFILT_WRITE: ::int16_t = -2; -pub const EVFILT_AIO: ::int16_t = -3; -pub const EVFILT_VNODE: ::int16_t = -4; -pub const EVFILT_PROC: ::int16_t = -5; -pub const EVFILT_SIGNAL: ::int16_t = -6; -pub const EVFILT_TIMER: ::int16_t = -7; -pub const EVFILT_EXCEPT: ::int16_t = -8; -pub const EVFILT_USER: ::int16_t = -9; -pub const EVFILT_FS: ::int16_t = -10; - -pub const EV_ADD: ::uint16_t = 0x1; -pub const EV_DELETE: ::uint16_t = 0x2; -pub const EV_ENABLE: ::uint16_t = 0x4; -pub const EV_DISABLE: ::uint16_t = 0x8; -pub const EV_ONESHOT: ::uint16_t = 0x10; -pub const EV_CLEAR: ::uint16_t = 0x20; -pub const EV_RECEIPT: ::uint16_t = 0x40; -pub const EV_DISPATCH: ::uint16_t = 0x80; -pub const EV_NODATA: ::uint16_t = 0x1000; -pub const EV_FLAG1: ::uint16_t = 0x2000; -pub const EV_ERROR: ::uint16_t = 0x4000; -pub const EV_EOF: ::uint16_t = 0x8000; -pub const EV_SYSFLAGS: ::uint16_t = 0xf000; - -pub const NOTE_TRIGGER: ::uint32_t = 0x01000000; -pub const NOTE_FFNOP: ::uint32_t = 0x00000000; -pub const NOTE_FFAND: ::uint32_t = 0x40000000; -pub const NOTE_FFOR: ::uint32_t = 0x80000000; -pub const NOTE_FFCOPY: ::uint32_t = 0xc0000000; -pub const NOTE_FFCTRLMASK: ::uint32_t = 0xc0000000; -pub const NOTE_FFLAGSMASK: ::uint32_t = 0x00ffffff; -pub const NOTE_LOWAT: ::uint32_t = 0x00000001; -pub const NOTE_OOB: ::uint32_t = 0x00000002; -pub const NOTE_DELETE: ::uint32_t = 0x00000001; -pub const NOTE_WRITE: ::uint32_t = 0x00000002; -pub const NOTE_EXTEND: ::uint32_t = 0x00000004; -pub const NOTE_ATTRIB: ::uint32_t = 0x00000008; -pub const NOTE_LINK: ::uint32_t = 0x00000010; -pub const NOTE_RENAME: ::uint32_t = 0x00000020; -pub const NOTE_REVOKE: ::uint32_t = 0x00000040; -pub const NOTE_EXIT: ::uint32_t = 0x80000000; -pub const NOTE_FORK: ::uint32_t = 0x40000000; -pub const NOTE_EXEC: ::uint32_t = 0x20000000; -pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff; -pub const NOTE_PCTRLMASK: ::uint32_t = 0xf0000000; -pub const NOTE_TRACK: ::uint32_t = 0x00000001; -pub const NOTE_TRACKERR: ::uint32_t = 0x00000002; -pub const NOTE_CHILD: ::uint32_t = 0x00000004; +pub const EVFILT_READ: i16 = -1; +pub const EVFILT_WRITE: i16 = -2; +pub const EVFILT_AIO: i16 = -3; +pub const EVFILT_VNODE: i16 = -4; +pub const EVFILT_PROC: i16 = -5; +pub const EVFILT_SIGNAL: i16 = -6; +pub const EVFILT_TIMER: i16 = -7; +pub const EVFILT_EXCEPT: i16 = -8; +pub const EVFILT_USER: i16 = -9; +pub const EVFILT_FS: i16 = -10; + +pub const EV_ADD: u16 = 0x1; +pub const EV_DELETE: u16 = 0x2; +pub const EV_ENABLE: u16 = 0x4; +pub const EV_DISABLE: u16 = 0x8; +pub const EV_ONESHOT: u16 = 0x10; +pub const EV_CLEAR: u16 = 0x20; +pub const EV_RECEIPT: u16 = 0x40; +pub const EV_DISPATCH: u16 = 0x80; +pub const EV_NODATA: u16 = 0x1000; +pub const EV_FLAG1: u16 = 0x2000; +pub const EV_ERROR: u16 = 0x4000; +pub const EV_EOF: u16 = 0x8000; +pub const EV_SYSFLAGS: u16 = 0xf000; + +pub const NOTE_TRIGGER: u32 = 0x01000000; +pub const NOTE_FFNOP: u32 = 0x00000000; +pub const NOTE_FFAND: u32 = 0x40000000; +pub const NOTE_FFOR: u32 = 0x80000000; +pub const NOTE_FFCOPY: u32 = 0xc0000000; +pub const NOTE_FFCTRLMASK: u32 = 0xc0000000; +pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff; +pub const NOTE_LOWAT: u32 = 0x00000001; +pub const NOTE_OOB: u32 = 0x00000002; +pub const NOTE_DELETE: u32 = 0x00000001; +pub const NOTE_WRITE: u32 = 0x00000002; +pub const NOTE_EXTEND: u32 = 0x00000004; +pub const NOTE_ATTRIB: u32 = 0x00000008; +pub const NOTE_LINK: u32 = 0x00000010; +pub const NOTE_RENAME: u32 = 0x00000020; +pub const NOTE_REVOKE: u32 = 0x00000040; +pub const NOTE_EXIT: u32 = 0x80000000; +pub const NOTE_FORK: u32 = 0x40000000; +pub const NOTE_EXEC: u32 = 0x20000000; +pub const NOTE_PDATAMASK: u32 = 0x000fffff; +pub const NOTE_PCTRLMASK: u32 = 0xf0000000; +pub const NOTE_TRACK: u32 = 0x00000001; +pub const NOTE_TRACKERR: u32 = 0x00000002; +pub const NOTE_CHILD: u32 = 0x00000004; pub const SO_SNDSPACE: ::c_int = 0x100a; pub const SO_CPUHINT: ::c_int = 0x1030; @@ -881,9 +891,22 @@ pub const TCP_FASTKEEP: ::c_int = 128; pub const AF_BLUETOOTH: ::c_int = 33; pub const AF_MPLS: ::c_int = 34; pub const AF_IEEE80211: ::c_int = 35; +#[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] pub const AF_MAX: ::c_int = 36; pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; +#[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +#[allow(deprecated)] pub const PF_MAX: ::c_int = AF_MAX; pub const NET_RT_DUMP: ::c_int = 1; @@ -894,6 +917,12 @@ pub const NET_RT_MAXID: ::c_int = 4; pub const SOMAXOPT_SIZE: ::c_int = 65536; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +#[allow(deprecated)] pub const NET_MAXID: ::c_int = AF_MAX; pub const MSG_UNUSED09: ::c_int = 0x00000200; @@ -1008,6 +1037,7 @@ f! { } extern { + pub fn setgrent(); pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs index 996abc5..22fd2b8 100644 --- a/libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs +++ b/libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -23,8 +23,8 @@ s! { pub st_blocks: ::blkcnt_t, pub st_blksize: ::blksize_t, pub st_flags: ::fflags_t, - pub st_gen: ::uint32_t, - pub st_lspare: ::int32_t, + pub st_gen: u32, + pub st_lspare: i32, pub st_birthtime: ::time_t, pub st_birthtime_nsec: ::c_long, } diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/arm.rs b/libc/src/unix/bsd/freebsdlike/freebsd/arm.rs index 945aca9..b7480aa 100644 --- a/libc/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/libc/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -26,8 +26,8 @@ s! { pub st_blocks: ::blkcnt_t, pub st_blksize: ::blksize_t, pub st_flags: ::fflags_t, - pub st_gen: ::uint32_t, - pub st_lspare: ::int32_t, + pub st_gen: u32, + pub st_lspare: i32, pub st_birthtime: ::time_t, pub st_birthtime_nsec: ::c_long, pub st_birthtime_pad: ::c_long, diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs new file mode 100644 index 0000000..7d7dc2c --- /dev/null +++ b/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -0,0 +1,214 @@ +// APIs that had breaking changes after FreeBSD 11 + +// The type of `nlink_t` changed from `u16` to `u64` in FreeBSD 12: +pub type nlink_t = u16; +// Type of `dev_t` changed from `u32` to `u64` in FreeBSD 12: +pub type dev_t = u32; +// Type of `ino_t` changed from `unsigned int` to `unsigned long` in FreeBSD 12: +pub type ino_t = u32; + +s! { + pub struct kevent { + pub ident: ::uintptr_t, + pub filter: ::c_short, + pub flags: ::c_ushort, + pub fflags: ::c_uint, + pub data: ::intptr_t, + pub udata: *mut ::c_void, + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_lpid: ::pid_t, + pub shm_cpid: ::pid_t, + // Type of shm_nattc changed from `int` to `shmatt_t` (aka `unsigned + // int`) in FreeBSD 12: + pub shm_nattch: ::c_int, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + } +} + +s_no_extra_traits! { + pub struct dirent { + pub d_fileno: ::ino_t, + pub d_reclen: u16, + pub d_type: u8, + // Type of `d_namlen` changed from `char` to `u16` in FreeBSD 12: + pub d_namlen: u8, + 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], + // Array length changed from 88 to 1024 in FreeBSD 12: + pub f_mntfromname: [::c_char; 88], + // Array length changed from 88 to 1024 in FreeBSD 12: + pub f_mntonname: [::c_char; 88], + } +} + +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_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_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_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_reclen.hash(state); + self.d_type.hash(state); + self.d_namlen.hash(state); + self.d_name[..self.d_namlen as _].hash(state); + } + } + } +} + +extern { + // Return type ::c_int was removed in FreeBSD 12 + pub fn setgrent() -> ::c_int; + + // Type of `addr` argument changed from `const void*` to `void*` + // in FreeBSD 12 + pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) + -> ::c_int; + + // Return type ::c_int was removed in FreeBSD 12 + pub fn freelocale(loc: ::locale_t) -> ::c_int; + + // Return type ::c_int changed to ::ssize_t in FreeBSD 12: + pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t, + msgtyp: ::c_long, msgflg: ::c_int) -> ::c_int; +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } +} diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs b/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs new file mode 100644 index 0000000..bba277e --- /dev/null +++ b/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs @@ -0,0 +1,30 @@ +#[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_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + 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_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: u32, + pub st_lspare: i32, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, +} + +impl ::Copy for ::stat {} +impl ::Clone for ::stat { + fn clone(&self) -> ::stat { *self } +} diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs new file mode 100644 index 0000000..ab1b8d9 --- /dev/null +++ b/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -0,0 +1,207 @@ +// APIs that changed in FreeBSD12 + +pub type nlink_t = u64; +pub type dev_t = u64; +pub type ino_t = ::c_ulong; +pub type shmatt_t = ::c_uint; + +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: ::intptr_t, + pub udata: *mut ::c_void, + pub ext: [u64; 4], + } +} + +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], + } +} + +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); + } + } + } +} + +extern { + 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; +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } +} diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs b/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs new file mode 100644 index 0000000..dbaa4ae --- /dev/null +++ b/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs @@ -0,0 +1,32 @@ +#[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/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs b/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs index 3ce96e8..e594551 100644 --- a/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1,14 +1,13 @@ pub type fflags_t = u32; pub type clock_t = i32; -pub type ino_t = u32; + pub type lwpid_t = i32; -pub type nlink_t = u16; pub type blksize_t = i32; pub type clockid_t = ::c_int; pub type sem_t = _sem; -pub type fsblkcnt_t = ::uint64_t; -pub type fsfilcnt_t = ::uint64_t; +pub type fsblkcnt_t = u64; +pub type fsfilcnt_t = u64; pub type idtype_t = ::c_uint; pub type key_t = ::c_long; @@ -47,14 +46,6 @@ s! { pub ip6: *mut ::in6_addr, } - pub struct mq_attr { - pub mq_flags: ::c_long, - pub mq_maxmsg: ::c_long, - pub mq_msgsize: ::c_long, - pub mq_curmsgs: ::c_long, - __reserved: [::c_long; 4] - } - pub struct sigevent { pub sigev_notify: ::c_int, pub sigev_signo: ::c_int, @@ -110,17 +101,6 @@ s! { pub msg_ctime: ::time_t, } - 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: ::c_int, - pub shm_atime: ::time_t, - pub shm_dtime: ::time_t, - pub shm_ctime: ::time_t, - } - pub struct xucred { pub cr_version: ::c_uint, pub cr_uid: ::uid_t, @@ -153,39 +133,6 @@ s_no_extra_traits! { pub __ut_spare: [::c_char; 64], } - pub struct dirent { - pub d_fileno: u32, - pub d_reclen: u16, - pub d_type: u8, - pub d_namlen: u8, - pub d_name: [::c_char; 256], - } - - pub struct statfs { - pub f_version: ::uint32_t, - pub f_type: ::uint32_t, - pub f_flags: ::uint64_t, - pub f_bsize: ::uint64_t, - pub f_iosize: ::uint64_t, - pub f_blocks: ::uint64_t, - pub f_bfree: ::uint64_t, - pub f_bavail: ::int64_t, - pub f_files: ::uint64_t, - pub f_ffree: ::int64_t, - pub f_syncwrites: ::uint64_t, - pub f_asyncwrites: ::uint64_t, - pub f_syncreads: ::uint64_t, - pub f_asyncreads: ::uint64_t, - f_spare: [::uint64_t; 10], - pub f_namemax: ::uint32_t, - 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; 88], - pub f_mntonname: [::c_char; 88], - } - pub struct sockaddr_dl { pub sdl_len: ::c_uchar, pub sdl_family: ::c_uchar, @@ -196,6 +143,14 @@ s_no_extra_traits! { pub sdl_slen: ::c_uchar, pub sdl_data: [::c_char; 46], } + + pub struct mq_attr { + pub mq_flags: ::c_long, + pub mq_maxmsg: ::c_long, + pub mq_msgsize: ::c_long, + pub mq_curmsgs: ::c_long, + __reserved: [::c_long; 4] + } } cfg_if! { @@ -248,132 +203,6 @@ cfg_if! { } } - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_fileno == other.d_fileno - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self.d_namlen == other.d_namlen - && self - .d_name - .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_reclen", &self.d_reclen) - .field("d_type", &self.d_type) - .field("d_namlen", &self.d_namlen) - // FIXME: .field("d_name", &self.d_name) - .finish() - } - } - impl ::hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_fileno.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_namlen.hash(state); - self.d_name.hash(state); - } - } - - 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_spare == other.f_spare - && self.f_namemax == other.f_namemax - && self.f_owner == other.f_owner - && self.f_fsid == other.f_fsid - && self - .f_charspare - .iter() - .zip(other.f_charspare.iter()) - .all(|(a,b)| a == b) - && 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_spare", &self.f_spare) - .field("f_namemax", &self.f_namemax) - .field("f_owner", &self.f_owner) - .field("f_fsid", &self.f_fsid) - // FIXME: .field("f_charspare", &self.f_charspare) - .field("f_fstypename", &self.f_fstypename) - // FIXME: .field("f_mntfromname", &self.f_mntfromname) - // FIXME: .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_spare.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 sockaddr_dl { fn eq(&self, other: &sockaddr_dl) -> bool { self.sdl_len == other.sdl_len @@ -417,6 +246,34 @@ cfg_if! { self.sdl_data.hash(state); } } + + impl PartialEq for mq_attr { + fn eq(&self, other: &mq_attr) -> bool { + self.mq_flags == other.mq_flags && + self.mq_maxmsg == other.mq_maxmsg && + self.mq_msgsize == other.mq_msgsize && + self.mq_curmsgs == other.mq_curmsgs + } + } + impl Eq for mq_attr {} + impl ::fmt::Debug for mq_attr { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mq_attr") + .field("mq_flags", &self.mq_flags) + .field("mq_maxmsg", &self.mq_maxmsg) + .field("mq_msgsize", &self.mq_msgsize) + .field("mq_curmsgs", &self.mq_curmsgs) + .finish() + } + } + impl ::hash::Hash for mq_attr { + fn hash(&self, state: &mut H) { + self.mq_flags.hash(state); + self.mq_maxmsg.hash(state); + self.mq_msgsize.hash(state); + self.mq_curmsgs.hash(state); + } + } } } @@ -465,61 +322,61 @@ pub const POSIX_FADV_NOREUSE: ::c_int = 5; pub const POLLINIGNEOF: ::c_short = 0x2000; -pub const EVFILT_READ: ::int16_t = -1; -pub const EVFILT_WRITE: ::int16_t = -2; -pub const EVFILT_AIO: ::int16_t = -3; -pub const EVFILT_VNODE: ::int16_t = -4; -pub const EVFILT_PROC: ::int16_t = -5; -pub const EVFILT_SIGNAL: ::int16_t = -6; -pub const EVFILT_TIMER: ::int16_t = -7; -pub const EVFILT_PROCDESC: ::int16_t = -8; -pub const EVFILT_FS: ::int16_t = -9; -pub const EVFILT_LIO: ::int16_t = -10; -pub const EVFILT_USER: ::int16_t = -11; -pub const EVFILT_SENDFILE: ::int16_t = -12; -pub const EVFILT_EMPTY: ::int16_t = -13; - -pub const EV_ADD: ::uint16_t = 0x1; -pub const EV_DELETE: ::uint16_t = 0x2; -pub const EV_ENABLE: ::uint16_t = 0x4; -pub const EV_DISABLE: ::uint16_t = 0x8; -pub const EV_ONESHOT: ::uint16_t = 0x10; -pub const EV_CLEAR: ::uint16_t = 0x20; -pub const EV_RECEIPT: ::uint16_t = 0x40; -pub const EV_DISPATCH: ::uint16_t = 0x80; -pub const EV_DROP: ::uint16_t = 0x1000; -pub const EV_FLAG1: ::uint16_t = 0x2000; -pub const EV_ERROR: ::uint16_t = 0x4000; -pub const EV_EOF: ::uint16_t = 0x8000; -pub const EV_SYSFLAGS: ::uint16_t = 0xf000; - -pub const NOTE_TRIGGER: ::uint32_t = 0x01000000; -pub const NOTE_FFNOP: ::uint32_t = 0x00000000; -pub const NOTE_FFAND: ::uint32_t = 0x40000000; -pub const NOTE_FFOR: ::uint32_t = 0x80000000; -pub const NOTE_FFCOPY: ::uint32_t = 0xc0000000; -pub const NOTE_FFCTRLMASK: ::uint32_t = 0xc0000000; -pub const NOTE_FFLAGSMASK: ::uint32_t = 0x00ffffff; -pub const NOTE_LOWAT: ::uint32_t = 0x00000001; -pub const NOTE_DELETE: ::uint32_t = 0x00000001; -pub const NOTE_WRITE: ::uint32_t = 0x00000002; -pub const NOTE_EXTEND: ::uint32_t = 0x00000004; -pub const NOTE_ATTRIB: ::uint32_t = 0x00000008; -pub const NOTE_LINK: ::uint32_t = 0x00000010; -pub const NOTE_RENAME: ::uint32_t = 0x00000020; -pub const NOTE_REVOKE: ::uint32_t = 0x00000040; -pub const NOTE_EXIT: ::uint32_t = 0x80000000; -pub const NOTE_FORK: ::uint32_t = 0x40000000; -pub const NOTE_EXEC: ::uint32_t = 0x20000000; -pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff; -pub const NOTE_PCTRLMASK: ::uint32_t = 0xf0000000; -pub const NOTE_TRACK: ::uint32_t = 0x00000001; -pub const NOTE_TRACKERR: ::uint32_t = 0x00000002; -pub const NOTE_CHILD: ::uint32_t = 0x00000004; -pub const NOTE_SECONDS: ::uint32_t = 0x00000001; -pub const NOTE_MSECONDS: ::uint32_t = 0x00000002; -pub const NOTE_USECONDS: ::uint32_t = 0x00000004; -pub const NOTE_NSECONDS: ::uint32_t = 0x00000008; +pub const EVFILT_READ: i16 = -1; +pub const EVFILT_WRITE: i16 = -2; +pub const EVFILT_AIO: i16 = -3; +pub const EVFILT_VNODE: i16 = -4; +pub const EVFILT_PROC: i16 = -5; +pub const EVFILT_SIGNAL: i16 = -6; +pub const EVFILT_TIMER: i16 = -7; +pub const EVFILT_PROCDESC: i16 = -8; +pub const EVFILT_FS: i16 = -9; +pub const EVFILT_LIO: i16 = -10; +pub const EVFILT_USER: i16 = -11; +pub const EVFILT_SENDFILE: i16 = -12; +pub const EVFILT_EMPTY: i16 = -13; + +pub const EV_ADD: u16 = 0x1; +pub const EV_DELETE: u16 = 0x2; +pub const EV_ENABLE: u16 = 0x4; +pub const EV_DISABLE: u16 = 0x8; +pub const EV_ONESHOT: u16 = 0x10; +pub const EV_CLEAR: u16 = 0x20; +pub const EV_RECEIPT: u16 = 0x40; +pub const EV_DISPATCH: u16 = 0x80; +pub const EV_DROP: u16 = 0x1000; +pub const EV_FLAG1: u16 = 0x2000; +pub const EV_ERROR: u16 = 0x4000; +pub const EV_EOF: u16 = 0x8000; +pub const EV_SYSFLAGS: u16 = 0xf000; + +pub const NOTE_TRIGGER: u32 = 0x01000000; +pub const NOTE_FFNOP: u32 = 0x00000000; +pub const NOTE_FFAND: u32 = 0x40000000; +pub const NOTE_FFOR: u32 = 0x80000000; +pub const NOTE_FFCOPY: u32 = 0xc0000000; +pub const NOTE_FFCTRLMASK: u32 = 0xc0000000; +pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff; +pub const NOTE_LOWAT: u32 = 0x00000001; +pub const NOTE_DELETE: u32 = 0x00000001; +pub const NOTE_WRITE: u32 = 0x00000002; +pub const NOTE_EXTEND: u32 = 0x00000004; +pub const NOTE_ATTRIB: u32 = 0x00000008; +pub const NOTE_LINK: u32 = 0x00000010; +pub const NOTE_RENAME: u32 = 0x00000020; +pub const NOTE_REVOKE: u32 = 0x00000040; +pub const NOTE_EXIT: u32 = 0x80000000; +pub const NOTE_FORK: u32 = 0x40000000; +pub const NOTE_EXEC: u32 = 0x20000000; +pub const NOTE_PDATAMASK: u32 = 0x000fffff; +pub const NOTE_PCTRLMASK: u32 = 0xf0000000; +pub const NOTE_TRACK: u32 = 0x00000001; +pub const NOTE_TRACKERR: u32 = 0x00000002; +pub const NOTE_CHILD: u32 = 0x00000004; +pub const NOTE_SECONDS: u32 = 0x00000001; +pub const NOTE_MSECONDS: u32 = 0x00000002; +pub const NOTE_USECONDS: u32 = 0x00000004; +pub const NOTE_NSECONDS: u32 = 0x00000008; pub const MADV_PROTECT: ::c_int = 10; pub const RUSAGE_THREAD: ::c_int = 1; @@ -768,6 +625,11 @@ pub const AF_IEEE80211: ::c_int = 37; pub const AF_INET_SDP: ::c_int = 40; pub const AF_INET6_SDP: ::c_int = 42; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] pub const AF_MAX: ::c_int = 42; // https://github.com/freebsd/freebsd/blob/master/sys/net/if.h#L140 @@ -779,14 +641,20 @@ pub const IFF_POINTOPOINT: ::c_int = 0x10; // (i) is a point-to-point link // 0x20 was IFF_SMART pub const IFF_RUNNING: ::c_int = 0x40; // (d) resources allocated #[doc(hidden)] -// IFF_DRV_RUNNING is deprecated. Use the portable `IFF_RUNNING` instead +#[deprecated( + since="0.2.54", + note="IFF_DRV_RUNNING is deprecated. Use the portable IFF_RUNNING instead" +)] pub const IFF_DRV_RUNNING: ::c_int = 0x40; pub const IFF_NOARP: ::c_int = 0x80; // (n) no address resolution protocol pub const IFF_PROMISC: ::c_int = 0x100; // (n) receive all packets pub const IFF_ALLMULTI: ::c_int = 0x200; // (n) receive all multicast packets pub const IFF_OACTIVE: ::c_int = 0x400; // (d) tx hardware queue is full #[doc(hidden)] -// IFF_DRV_OACTIVE is deprecated. Use the portable `IFF_OACTIVE` instead +#[deprecated( + since = "0.2.54", + note = "Use the portable `IFF_OACTIVE` instead", +)] pub const IFF_DRV_OACTIVE: ::c_int = 0x400; pub const IFF_SIMPLEX: ::c_int = 0x800; // (i) can't hear own transmissions pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit @@ -1070,6 +938,12 @@ pub const PF_IEEE80211: ::c_int = AF_IEEE80211; pub const PF_INET_SDP: ::c_int = AF_INET_SDP; pub const PF_INET6_SDP: ::c_int = AF_INET6_SDP; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +#[allow(deprecated)] pub const PF_MAX: ::c_int = AF_MAX; pub const NET_RT_DUMP: ::c_int = 1; @@ -1106,14 +980,20 @@ pub const SHM_ANON: *mut ::c_char = 1 as *mut ::c_char; // they were all removed in svn r262489. They remain here for backwards // compatibility only, and are scheduled to be removed in libc 1.0.0. #[doc(hidden)] +#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")] +#[allow(deprecated)] pub const NET_MAXID: ::c_int = AF_MAX; #[doc(hidden)] +#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")] pub const CTL_MAXID: ::c_int = 10; #[doc(hidden)] +#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")] pub const KERN_MAXID: ::c_int = 38; #[doc(hidden)] +#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")] pub const HW_MAXID: ::c_int = 13; #[doc(hidden)] +#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")] pub const USER_MAXID: ::c_int = 21; #[doc(hidden)] pub const CTL_P1003_1B_MAXID: ::c_int = 26; @@ -1251,9 +1131,6 @@ f! { extern { pub fn __error() -> *mut ::c_int; - pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) - -> ::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; @@ -1335,7 +1212,6 @@ extern { timeout: *mut ::timespec) -> ::ssize_t; pub fn mq_getfd_np(mqd: ::mqd_t) -> ::c_int; - pub fn freelocale(loc: ::locale_t) -> ::c_int; pub fn waitid(idtype: idtype_t, id: ::id_t, infop: *mut ::siginfo_t, options: ::c_int) -> ::c_int; @@ -1349,8 +1225,6 @@ extern { pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut ::msqid_ds) -> ::c_int; pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int; - pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t, - msgtyp: ::c_long, msgflg: ::c_int) -> ::c_int; pub fn msgsnd(msqid: ::c_int, msgp: *const ::c_void, msgsz: ::size_t, msgflg: ::c_int) -> ::c_int; pub fn cfmakesane(termios: *mut ::termios); @@ -1451,6 +1325,16 @@ extern { attrnamespace: *mut ::c_int) -> ::c_int; } +cfg_if! { + if #[cfg(freebsd12)] { + mod freebsd12; + pub use self::freebsd12::*; + } else { + mod freebsd11; + pub use self::freebsd11::*; + } +} + cfg_if! { if #[cfg(target_arch = "x86")] { mod x86; diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/libc/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index 9d893b6..5c0c6e7 100644 --- a/libc/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/libc/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -23,8 +23,8 @@ s! { pub st_blocks: ::blkcnt_t, pub st_blksize: ::blksize_t, pub st_flags: ::fflags_t, - pub st_gen: ::uint32_t, - pub st_lspare: ::int32_t, + pub st_gen: u32, + pub st_lspare: i32, pub st_birthtime: ::time_t, pub st_birthtime_nsec: ::c_long, } diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs b/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs index 845124d..adec88c 100644 --- a/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -23,8 +23,8 @@ s! { pub st_blocks: ::blkcnt_t, pub st_blksize: ::blksize_t, pub st_flags: ::fflags_t, - pub st_gen: ::uint32_t, - pub st_lspare: ::int32_t, + pub st_gen: u32, + pub st_lspare: i32, pub st_birthtime: ::time_t, pub st_birthtime_nsec: ::c_long, __unused: [u8; 8], diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/x86_64.rs b/libc/src/unix/bsd/freebsdlike/freebsd/x86_64.rs index 323d1ab..5220cde 100644 --- a/libc/src/unix/bsd/freebsdlike/freebsd/x86_64.rs +++ b/libc/src/unix/bsd/freebsdlike/freebsd/x86_64.rs @@ -4,32 +4,6 @@ pub type c_ulong = u64; pub type time_t = i64; pub type suseconds_t = i64; -s! { - pub struct stat { - pub st_dev: ::dev_t, - pub st_ino: ::ino_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - 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_size: ::off_t, - pub st_blocks: ::blkcnt_t, - pub st_blksize: ::blksize_t, - pub st_flags: ::fflags_t, - pub st_gen: ::uint32_t, - pub st_lspare: ::int32_t, - pub st_birthtime: ::time_t, - pub st_birthtime_nsec: ::c_long, - } -} - // should be pub(crate), but that requires Rust 1.18.0 cfg_if! { if #[cfg(libc_const_size_of)] { diff --git a/libc/src/unix/bsd/freebsdlike/mod.rs b/libc/src/unix/bsd/freebsdlike/mod.rs index 7a82a45..64168eb 100644 --- a/libc/src/unix/bsd/freebsdlike/mod.rs +++ b/libc/src/unix/bsd/freebsdlike/mod.rs @@ -1,4 +1,3 @@ -pub type dev_t = u32; pub type mode_t = u16; pub type pthread_attr_t = *mut ::c_void; pub type rlim_t = i64; @@ -46,15 +45,6 @@ s! { __unused8: *mut ::c_void, } - pub struct kevent { - pub ident: ::uintptr_t, - pub filter: ::c_short, - pub flags: ::c_ushort, - pub fflags: ::c_uint, - pub data: ::intptr_t, - pub udata: *mut ::c_void, - } - pub struct addrinfo { pub ai_flags: ::c_int, pub ai_family: ::c_int, @@ -758,7 +748,11 @@ pub const LOCK_NB: ::c_int = 4; pub const LOCK_UN: ::c_int = 8; pub const MAP_COPY: ::c_int = 0x0002; +#[doc(hidden)] +#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")] pub const MAP_RENAME: ::c_int = 0x0020; +#[doc(hidden)] +#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")] pub const MAP_NORESERVE: ::c_int = 0x0040; pub const MAP_HASSEMAPHORE: ::c_int = 0x0200; pub const MAP_STACK: ::c_int = 0x0400; @@ -1095,7 +1089,8 @@ extern { -> ::c_int; pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; - + pub fn gettimeofday(tp: *mut ::timeval, + tz: *mut ::timezone) -> ::c_int; pub fn accept4(s: ::c_int, addr: *mut ::sockaddr, addrlen: *mut ::socklen_t, flags: ::c_int) -> ::c_int; pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int; @@ -1140,7 +1135,10 @@ extern { pub fn getutxid(ut: *const utmpx) -> *mut utmpx; pub fn getutxline(ut: *const utmpx) -> *mut utmpx; pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int; - #[cfg_attr(target_os = "freebsd", link_name = "kevent@FBSD_1.0")] + #[cfg_attr( + all(target_os = "freebsd", not(freebsd12)), + link_name = "kevent@FBSD_1.0" + )] pub fn kevent(kq: ::c_int, changelist: *const ::kevent, nchanges: ::c_int, @@ -1156,7 +1154,10 @@ extern { n: ::size_t) -> *mut ::c_void; pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t) -> ::c_int; - #[cfg_attr(target_os = "freebsd", link_name = "mknodat@FBSD_1.1")] + #[cfg_attr( + all(target_os = "freebsd", not(freebsd12)), + link_name = "mknodat@FBSD_1.1" + )] pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t, dev: dev_t) -> ::c_int; pub fn mq_close(mqd: ::mqd_t) -> ::c_int; diff --git a/libc/src/unix/bsd/mod.rs b/libc/src/unix/bsd/mod.rs index 03c987d..8bc6c7c 100644 --- a/libc/src/unix/bsd/mod.rs +++ b/libc/src/unix/bsd/mod.rs @@ -94,7 +94,7 @@ s! { } pub struct fsid_t { - __fsid_val: [::int32_t; 2], + __fsid_val: [i32; 2], } pub struct if_nameindex { @@ -488,6 +488,15 @@ f! { } extern { + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "getrlimit$UNIX2003")] + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + #[cfg_attr(all(target_os = "macos", target_arch = "x86"), + link_name = "setrlimit$UNIX2003")] + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + + pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, + buflen: ::size_t) -> ::c_int; pub fn abs(i: ::c_int) -> ::c_int; pub fn atof(s: *const ::c_char) -> ::c_double; pub fn labs(i: ::c_long) -> ::c_long; @@ -506,7 +515,6 @@ extern { pub fn getpwent() -> *mut passwd; pub fn setpwent(); pub fn endpwent(); - pub fn setgrent(); pub fn endgrent(); pub fn getgrent() -> *mut ::group; @@ -522,14 +530,20 @@ extern { #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__glob30")] - #[cfg_attr(target_os = "freebsd", link_name = "glob@FBSD_1.0")] + #[cfg_attr( + all(target_os = "freebsd", not(freebsd12)), + link_name = "glob@FBSD_1.0" + )] pub fn glob(pattern: *const ::c_char, flags: ::c_int, errfunc: ::Option ::c_int>, pglob: *mut ::glob_t) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")] - #[cfg_attr(target_os = "freebsd", link_name = "globfree@FBSD_1.0")] + #[cfg_attr( + all(target_os = "freebsd", not(freebsd12)), + link_name = "globfree@FBSD_1.0" + )] pub fn globfree(pglob: *mut ::glob_t); pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) diff --git a/libc/src/unix/bsd/netbsdlike/mod.rs b/libc/src/unix/bsd/netbsdlike/mod.rs index 29b4dd7..2630a2f 100644 --- a/libc/src/unix/bsd/netbsdlike/mod.rs +++ b/libc/src/unix/bsd/netbsdlike/mod.rs @@ -1,14 +1,14 @@ pub type time_t = i64; pub type mode_t = u32; -pub type nlink_t = ::uint32_t; -pub type ino_t = ::uint64_t; +pub type nlink_t = u32; +pub type ino_t = u64; pub type pthread_key_t = ::c_int; pub type rlim_t = u64; pub type speed_t = ::c_uint; pub type tcflag_t = ::c_uint; pub type nl_item = c_long; pub type clockid_t = ::c_int; -pub type id_t = ::uint32_t; +pub type id_t = u32; pub type sem_t = *mut sem; #[cfg_attr(feature = "extra_traits", derive(Debug))] @@ -597,6 +597,7 @@ pub const TIMER_ABSTIME: ::c_int = 1; #[link(name = "util")] extern { + pub fn setgrent(); pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, @@ -677,8 +678,8 @@ cfg_if! { mod netbsd; pub use self::netbsd::*; } else if #[cfg(target_os = "openbsd")] { - mod openbsdlike; - pub use self::openbsdlike::*; + mod openbsd; + pub use self::openbsd::*; } else { // Unknown target_os } diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs b/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs index ad53c19..9d710eb 100644 --- a/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1,9 +1,9 @@ pub type clock_t = ::c_uint; pub type suseconds_t = ::c_int; pub type dev_t = u64; -pub type blksize_t = ::int32_t; -pub type fsblkcnt_t = ::uint64_t; -pub type fsfilcnt_t = ::uint64_t; +pub type blksize_t = i32; +pub type fsblkcnt_t = u64; +pub type fsfilcnt_t = u64; pub type idtype_t = ::c_int; pub type mqd_t = ::c_int; type __pthread_spin_t = __cpu_simple_lock_nv_t; @@ -77,9 +77,9 @@ s! { pub st_size: ::off_t, pub st_blocks: ::blkcnt_t, pub st_blksize: ::blksize_t, - pub st_flags: ::uint32_t, - pub st_gen: ::uint32_t, - pub st_spare: [::uint32_t; 2], + pub st_flags: u32, + pub st_gen: u32, + pub st_spare: [u32; 2], } pub struct addrinfo { @@ -163,22 +163,22 @@ s! { pub struct kevent { pub ident: ::uintptr_t, - pub filter: ::uint32_t, - pub flags: ::uint32_t, - pub fflags: ::uint32_t, - pub data: ::int64_t, + pub filter: u32, + pub flags: u32, + pub fflags: u32, + pub data: i64, pub udata: ::intptr_t, } pub struct dqblk { - pub dqb_bhardlimit: ::uint32_t, - pub dqb_bsoftlimit: ::uint32_t, - pub dqb_curblocks: ::uint32_t, - pub dqb_ihardlimit: ::uint32_t, - pub dqb_isoftlimit: ::uint32_t, - pub dqb_curinodes: ::uint32_t, - pub dqb_btime: ::int32_t, - pub dqb_itime: ::int32_t, + pub dqb_bhardlimit: u32, + pub dqb_bsoftlimit: u32, + pub dqb_curblocks: u32, + pub dqb_ihardlimit: u32, + pub dqb_isoftlimit: u32, + pub dqb_curinodes: u32, + pub dqb_btime: i32, + pub dqb_itime: i32, } pub struct Dl_info { @@ -261,10 +261,10 @@ s! { pub sdl_len: ::c_uchar, pub sdl_family: ::c_uchar, pub sdl_index: ::c_ushort, - pub sdl_type: ::uint8_t, - pub sdl_nlen: ::uint8_t, - pub sdl_alen: ::uint8_t, - pub sdl_slen: ::uint8_t, + pub sdl_type: u8, + pub sdl_nlen: u8, + pub sdl_alen: u8, + pub sdl_slen: u8, pub sdl_data: [::c_char; 12], } @@ -304,7 +304,7 @@ s_no_extra_traits! { pub sin_family: ::sa_family_t, pub sin_port: ::in_port_t, pub sin_addr: ::in_addr, - pub sin_zero: [::int8_t; 8], + pub sin_zero: [i8; 8], } pub struct dirent { @@ -331,18 +331,18 @@ s_no_extra_traits! { pub f_favail: ::fsfilcnt_t, pub f_fresvd: ::fsfilcnt_t, - pub f_syncreads: ::uint64_t, - pub f_syncwrites: ::uint64_t, + pub f_syncreads: u64, + pub f_syncwrites: u64, - pub f_asyncreads: ::uint64_t, - pub f_asyncwrites: ::uint64_t, + pub f_asyncreads: u64, + pub f_asyncwrites: u64, pub f_fsidx: ::fsid_t, pub f_fsid: ::c_ulong, pub f_namemax: ::c_ulong, pub f_owner: ::uid_t, - pub f_spare: [::uint32_t; 4], + pub f_spare: [u32; 4], pub f_fstypename: [::c_char; 32], pub f_mntonname: [::c_char; 1024], @@ -853,8 +853,21 @@ pub const AF_BLUETOOTH: ::c_int = 31; pub const AF_IEEE80211: ::c_int = 32; pub const AF_MPLS: ::c_int = 33; pub const AF_ROUTE: ::c_int = 34; +#[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] pub const AF_MAX: ::c_int = 36; +#[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +#[allow(deprecated)] pub const NET_MAXID: ::c_int = AF_MAX; pub const NET_RT_DUMP: ::c_int = 1; pub const NET_RT_FLAGS: ::c_int = 2; @@ -870,6 +883,14 @@ pub const PF_KEY: ::c_int = pseudo_AF_KEY; pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; pub const PF_MPLS: ::c_int = AF_MPLS; pub const PF_ROUTE: ::c_int = AF_ROUTE; + +#[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +#[allow(deprecated)] pub const PF_MAX: ::c_int = AF_MAX; pub const MSG_NBIO: ::c_int = 0x1000; @@ -1086,43 +1107,43 @@ pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1; pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL; -pub const EVFILT_AIO: ::uint32_t = 2; -pub const EVFILT_PROC: ::uint32_t = 4; -pub const EVFILT_READ: ::uint32_t = 0; -pub const EVFILT_SIGNAL: ::uint32_t = 5; -pub const EVFILT_TIMER: ::uint32_t = 6; -pub const EVFILT_VNODE: ::uint32_t = 3; -pub const EVFILT_WRITE: ::uint32_t = 1; - -pub const EV_ADD: ::uint32_t = 0x1; -pub const EV_DELETE: ::uint32_t = 0x2; -pub const EV_ENABLE: ::uint32_t = 0x4; -pub const EV_DISABLE: ::uint32_t = 0x8; -pub const EV_ONESHOT: ::uint32_t = 0x10; -pub const EV_CLEAR: ::uint32_t = 0x20; -pub const EV_RECEIPT: ::uint32_t = 0x40; -pub const EV_DISPATCH: ::uint32_t = 0x80; -pub const EV_FLAG1: ::uint32_t = 0x2000; -pub const EV_ERROR: ::uint32_t = 0x4000; -pub const EV_EOF: ::uint32_t = 0x8000; -pub const EV_SYSFLAGS: ::uint32_t = 0xf000; - -pub const NOTE_LOWAT: ::uint32_t = 0x00000001; -pub const NOTE_DELETE: ::uint32_t = 0x00000001; -pub const NOTE_WRITE: ::uint32_t = 0x00000002; -pub const NOTE_EXTEND: ::uint32_t = 0x00000004; -pub const NOTE_ATTRIB: ::uint32_t = 0x00000008; -pub const NOTE_LINK: ::uint32_t = 0x00000010; -pub const NOTE_RENAME: ::uint32_t = 0x00000020; -pub const NOTE_REVOKE: ::uint32_t = 0x00000040; -pub const NOTE_EXIT: ::uint32_t = 0x80000000; -pub const NOTE_FORK: ::uint32_t = 0x40000000; -pub const NOTE_EXEC: ::uint32_t = 0x20000000; -pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff; -pub const NOTE_PCTRLMASK: ::uint32_t = 0xf0000000; -pub const NOTE_TRACK: ::uint32_t = 0x00000001; -pub const NOTE_TRACKERR: ::uint32_t = 0x00000002; -pub const NOTE_CHILD: ::uint32_t = 0x00000004; +pub const EVFILT_AIO: u32 = 2; +pub const EVFILT_PROC: u32 = 4; +pub const EVFILT_READ: u32 = 0; +pub const EVFILT_SIGNAL: u32 = 5; +pub const EVFILT_TIMER: u32 = 6; +pub const EVFILT_VNODE: u32 = 3; +pub const EVFILT_WRITE: u32 = 1; + +pub const EV_ADD: u32 = 0x1; +pub const EV_DELETE: u32 = 0x2; +pub const EV_ENABLE: u32 = 0x4; +pub const EV_DISABLE: u32 = 0x8; +pub const EV_ONESHOT: u32 = 0x10; +pub const EV_CLEAR: u32 = 0x20; +pub const EV_RECEIPT: u32 = 0x40; +pub const EV_DISPATCH: u32 = 0x80; +pub const EV_FLAG1: u32 = 0x2000; +pub const EV_ERROR: u32 = 0x4000; +pub const EV_EOF: u32 = 0x8000; +pub const EV_SYSFLAGS: u32 = 0xf000; + +pub const NOTE_LOWAT: u32 = 0x00000001; +pub const NOTE_DELETE: u32 = 0x00000001; +pub const NOTE_WRITE: u32 = 0x00000002; +pub const NOTE_EXTEND: u32 = 0x00000004; +pub const NOTE_ATTRIB: u32 = 0x00000008; +pub const NOTE_LINK: u32 = 0x00000010; +pub const NOTE_RENAME: u32 = 0x00000020; +pub const NOTE_REVOKE: u32 = 0x00000040; +pub const NOTE_EXIT: u32 = 0x80000000; +pub const NOTE_FORK: u32 = 0x40000000; +pub const NOTE_EXEC: u32 = 0x20000000; +pub const NOTE_PDATAMASK: u32 = 0x000fffff; +pub const NOTE_PCTRLMASK: u32 = 0xf0000000; +pub const NOTE_TRACK: u32 = 0x00000001; +pub const NOTE_TRACKERR: u32 = 0x00000002; +pub const NOTE_CHILD: u32 = 0x00000004; pub const TMP_MAX : ::c_uint = 308915776; @@ -1492,6 +1513,9 @@ extern { #[link_name = "__lutimes50"] pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; + #[link_name = "__gettimeofday50"] + pub fn gettimeofday(tp: *mut ::timeval, + tz: *mut ::c_void) -> ::c_int; pub fn getnameinfo(sa: *const ::sockaddr, salen: ::socklen_t, host: *mut ::c_char, diff --git a/libc/src/unix/bsd/netbsdlike/openbsd/aarch64.rs b/libc/src/unix/bsd/netbsdlike/openbsd/aarch64.rs new file mode 100644 index 0000000..6a8cbb5 --- /dev/null +++ b/libc/src/unix/bsd/netbsdlike/openbsd/aarch64.rs @@ -0,0 +1,14 @@ +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = u8; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} diff --git a/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs b/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs new file mode 100644 index 0000000..09739cb --- /dev/null +++ b/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -0,0 +1,1451 @@ +use unix::bsd::O_SYNC; + +pub type clock_t = i64; +pub type suseconds_t = ::c_long; +pub type dev_t = i32; +pub type sigset_t = ::c_uint; +pub type blksize_t = i32; +pub type fsblkcnt_t = u64; +pub type fsfilcnt_t = u64; +pub type pthread_attr_t = *mut ::c_void; +pub type pthread_mutex_t = *mut ::c_void; +pub type pthread_mutexattr_t = *mut ::c_void; +pub type pthread_cond_t = *mut ::c_void; +pub type pthread_condattr_t = *mut ::c_void; +pub type pthread_rwlock_t = *mut ::c_void; +pub type pthread_rwlockattr_t = *mut ::c_void; +pub type caddr_t = *mut ::c_char; + +s! { + pub struct glob_t { + pub gl_pathc: ::size_t, + pub gl_matchc: ::size_t, + pub gl_offs: ::size_t, + pub gl_flags: ::c_int, + pub gl_pathv: *mut *mut ::c_char, + __unused1: *mut ::c_void, + __unused2: *mut ::c_void, + __unused3: *mut ::c_void, + __unused4: *mut ::c_void, + __unused5: *mut ::c_void, + __unused6: *mut ::c_void, + __unused7: *mut ::c_void, + } + + pub struct lconv { + pub decimal_point: *mut ::c_char, + pub thousands_sep: *mut ::c_char, + pub grouping: *mut ::c_char, + pub int_curr_symbol: *mut ::c_char, + pub currency_symbol: *mut ::c_char, + pub mon_decimal_point: *mut ::c_char, + pub mon_thousands_sep: *mut ::c_char, + pub mon_grouping: *mut ::c_char, + pub positive_sign: *mut ::c_char, + pub negative_sign: *mut ::c_char, + pub int_frac_digits: ::c_char, + pub frac_digits: ::c_char, + pub p_cs_precedes: ::c_char, + pub p_sep_by_space: ::c_char, + pub n_cs_precedes: ::c_char, + pub n_sep_by_space: ::c_char, + pub p_sign_posn: ::c_char, + pub n_sign_posn: ::c_char, + pub int_p_cs_precedes: ::c_char, + pub int_p_sep_by_space: ::c_char, + pub int_n_cs_precedes: ::c_char, + pub int_n_sep_by_space: ::c_char, + pub int_p_sign_posn: ::c_char, + pub int_n_sign_posn: ::c_char, + } + + pub struct ufs_args { + pub fspec: *mut ::c_char, + pub export_info: export_args, + } + + pub struct mfs_args { + pub fspec: *mut ::c_char, + pub export_info: export_args, + // https://github.com/openbsd/src/blob/master/sys/sys/types.h#L134 + pub base: *mut ::c_char, + pub size: ::c_ulong, + } + + pub struct iso_args { + pub fspec: *mut ::c_char, + pub export_info: export_args, + pub flags: ::c_int, + pub sess: ::c_int, + } + + pub struct nfs_args { + pub version: ::c_int, + pub addr: *mut ::sockaddr, + pub addrlen: ::c_int, + pub sotype: ::c_int, + pub proto: ::c_int, + pub fh: *mut ::c_uchar, + pub fhsize: ::c_int, + pub flags: ::c_int, + pub wsize: ::c_int, + pub rsize: ::c_int, + pub readdirsize: ::c_int, + pub timeo: ::c_int, + pub retrans: ::c_int, + pub maxgrouplist: ::c_int, + pub readahead: ::c_int, + pub leaseterm: ::c_int, + pub deadthresh: ::c_int, + pub hostname: *mut ::c_char, + pub acregmin: ::c_int, + pub acregmax: ::c_int, + pub acdirmin: ::c_int, + pub acdirmax: ::c_int, + } + + pub struct msdosfs_args { + pub fspec: *mut ::c_char, + pub export_info: export_args, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub mask: ::mode_t, + pub flags: ::c_int, + } + + pub struct ntfs_args { + pub fspec: *mut ::c_char, + pub export_info: export_args, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub mode: ::mode_t, + pub flag: ::c_ulong, + } + + pub struct udf_args { + pub fspec: *mut ::c_char, + pub lastblock: u32, + } + + pub struct tmpfs_args { + pub ta_version: ::c_int, + pub ta_nodes_max: ::ino_t, + pub ta_size_max: ::off_t, + pub ta_root_uid: ::uid_t, + pub ta_root_gid: ::gid_t, + pub ta_root_mode: ::mode_t, + } + + pub struct fusefs_args { + pub name: *mut ::c_char, + pub fd: ::c_int, + pub max_read: ::c_int, + pub allow_other: ::c_int, + } + + pub struct xucred { + pub cr_uid: ::uid_t, + pub cr_gid: ::gid_t, + pub cr_ngroups: ::c_short, + //https://github.com/openbsd/src/blob/master/sys/sys/syslimits.h#L44 + pub cr_groups: [::gid_t; 16], + } + + pub struct export_args { + pub ex_flags: ::c_int, + pub ex_root: ::uid_t, + pub ex_anon: xucred, + pub ex_addr: *mut ::sockaddr, + pub ex_addrlen: ::c_int, + pub ex_mask: *mut ::sockaddr, + pub ex_masklen: ::c_int, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: ::sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [i8; 8], + } + + 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 struct stat { + pub st_mode: ::mode_t, + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + 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_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: u32, + pub st_gen: u32, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + } + + pub struct addrinfo { + pub ai_flags: ::c_int, + pub ai_family: ::c_int, + pub ai_socktype: ::c_int, + pub ai_protocol: ::c_int, + pub ai_addrlen: ::socklen_t, + pub ai_addr: *mut ::sockaddr, + pub ai_canonname: *mut ::c_char, + pub ai_next: *mut ::addrinfo, + } + + pub struct Dl_info { + pub dli_fname: *const ::c_char, + pub dli_fbase: *mut ::c_void, + pub dli_sname: *const ::c_char, + pub dli_saddr: *mut ::c_void, + } + + pub struct if_data { + pub ifi_type: ::c_uchar, + pub ifi_addrlen: ::c_uchar, + pub ifi_hdrlen: ::c_uchar, + pub ifi_link_state: ::c_uchar, + pub ifi_mtu: u32, + pub ifi_metric: u32, + pub ifi_rdomain: u32, + pub ifi_baudrate: u64, + pub ifi_ipackets: u64, + pub ifi_ierrors: u64, + pub ifi_opackets: u64, + pub ifi_oerrors: u64, + pub ifi_collisions: u64, + pub ifi_ibytes: u64, + pub ifi_obytes: u64, + pub ifi_imcasts: u64, + pub ifi_omcasts: u64, + pub ifi_iqdrops: u64, + pub ifi_oqdrops: u64, + pub ifi_noproto: u64, + pub ifi_capabilities: u32, + pub ifi_lastchange: ::timeval, + } + + pub struct if_msghdr { + pub ifm_msglen: ::c_ushort, + pub ifm_version: ::c_uchar, + pub ifm_type: ::c_uchar, + pub ifm_hdrlen: ::c_ushort, + pub ifm_index: ::c_ushort, + pub ifm_tableid: ::c_ushort, + pub ifm_pad1: ::c_uchar, + pub ifm_pad2: ::c_uchar, + pub ifm_addrs: ::c_int, + pub ifm_flags: ::c_int, + pub ifm_xflags: ::c_int, + pub ifm_data: if_data, + } + + pub struct sockaddr_dl { + pub sdl_len: ::c_uchar, + pub sdl_family: ::c_uchar, + pub sdl_index: ::c_ushort, + pub sdl_type: ::c_uchar, + pub sdl_nlen: ::c_uchar, + pub sdl_alen: ::c_uchar, + pub sdl_slen: ::c_uchar, + pub sdl_data: [::c_char; 24], + } + + pub struct sockpeercred { + pub uid: ::uid_t, + pub gid: ::gid_t, + pub pid: ::pid_t, + } + + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } +} + +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, + pub d_namlen: u8, + __d_padding: [u8; 4], + pub d_name: [::c_char; 256], + } + + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: ::sa_family_t, + __ss_pad1: [u8; 6], + __ss_pad2: i64, + __ss_pad3: [u8; 240], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_code: ::c_int, + pub si_errno: ::c_int, + pub si_addr: *mut ::c_char, + #[cfg(target_pointer_width = "32")] + __pad: [u8; 112], + #[cfg(target_pointer_width = "64")] + __pad: [u8; 108], + } + + pub struct lastlog { + ll_time: ::time_t, + ll_line: [::c_char; UT_LINESIZE], + ll_host: [::c_char; UT_HOSTSIZE], + } + + pub struct utmp { + pub ut_line: [::c_char; UT_LINESIZE], + pub ut_name: [::c_char; UT_NAMESIZE], + pub ut_host: [::c_char; UT_HOSTSIZE], + pub ut_time: ::time_t, + } + + pub union mount_info { + pub ufs_args: ufs_args, + pub mfs_args: mfs_args, + pub nfs_args: nfs_args, + pub iso_args: iso_args, + pub msdosfs_args: msdosfs_args, + pub ntfs_args: ntfs_args, + pub tmpfs_args: tmpfs_args, + align: [::c_char; 160], + } + +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + 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 + .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) + // FIXME: .field("d_name", &self.d_name) + .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.hash(state); + } + } + + impl PartialEq for sockaddr_storage { + fn eq(&self, other: &sockaddr_storage) -> bool { + self.ss_len == other.ss_len + && self.ss_family == other.ss_family + } + } + + impl Eq for sockaddr_storage {} + + impl ::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_storage") + .field("ss_len", &self.ss_len) + .field("ss_family", &self.ss_family) + .finish() + } + } + + impl ::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { + self.ss_len.hash(state); + self.ss_family.hash(state); + } + } + + impl PartialEq for siginfo_t { + fn eq(&self, other: &siginfo_t) -> bool { + self.si_signo == other.si_signo + && self.si_code == other.si_code + && self.si_errno == other.si_errno + && self.si_addr == other.si_addr + } + } + + impl Eq for siginfo_t {} + + impl ::fmt::Debug for siginfo_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("siginfo_t") + .field("si_signo", &self.si_signo) + .field("si_code", &self.si_code) + .field("si_errno", &self.si_errno) + .field("si_addr", &self.si_addr) + .finish() + } + } + + impl ::hash::Hash for siginfo_t { + fn hash(&self, state: &mut H) { + self.si_signo.hash(state); + self.si_code.hash(state); + self.si_errno.hash(state); + self.si_addr.hash(state); + } + } + + impl PartialEq for lastlog { + fn eq(&self, other: &lastlog) -> bool { + self.ll_time == other.ll_time + && self + .ll_line + .iter() + .zip(other.ll_line.iter()) + .all(|(a,b)| a == b) + && self + .ll_host + .iter() + .zip(other.ll_host.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for lastlog {} + + impl ::fmt::Debug for lastlog { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("lastlog") + .field("ll_time", &self.ll_time) + // FIXME: .field("ll_line", &self.ll_line) + // FIXME: .field("ll_host", &self.ll_host) + .finish() + } + } + + impl ::hash::Hash for lastlog { + fn hash(&self, state: &mut H) { + self.ll_time.hash(state); + self.ll_line.hash(state); + self.ll_host.hash(state); + } + } + + impl PartialEq for utmp { + fn eq(&self, other: &utmp) -> bool { + self.ut_time == other.ut_time + && self + .ut_line + .iter() + .zip(other.ut_line.iter()) + .all(|(a,b)| a == b) + && self + .ut_name + .iter() + .zip(other.ut_name.iter()) + .all(|(a,b)| a == b) + && self + .ut_host + .iter() + .zip(other.ut_host.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for utmp {} + + impl ::fmt::Debug for utmp { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("utmp") + // FIXME: .field("ut_line", &self.ut_line) + // FIXME: .field("ut_name", &self.ut_name) + // FIXME: .field("ut_host", &self.ut_host) + .field("ut_time", &self.ut_time) + .finish() + } + } + + impl ::hash::Hash for utmp { + fn hash(&self, state: &mut H) { + self.ut_line.hash(state); + self.ut_name.hash(state); + self.ut_host.hash(state); + self.ut_time.hash(state); + } + } + + impl PartialEq for mount_info { + fn eq(&self, other: &mount_info) -> bool { + unsafe { + self.align + .iter() + .zip(other.align.iter()) + .all(|(a,b)| a == b) + } + } + } + + impl Eq for mount_info { } + + impl ::fmt::Debug for mount_info { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mount_info") + // FIXME: .field("align", &self.align) + .finish() + } + } + + impl ::hash::Hash for mount_info { + fn hash(&self, state: &mut H) { + unsafe { self.align.hash(state) }; + } + } + } +} + +cfg_if! { + if #[cfg(libc_union)] { + s_no_extra_traits! { + // This type uses the union mount_info: + pub struct statfs { + pub f_flags: u32, + pub f_bsize: u32, + pub f_iosize: u32, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: i64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: i64, + pub f_syncwrites: u64, + pub f_syncreads: u64, + pub f_asyncwrites: u64, + pub f_asyncreads: u64, + pub f_fsid: ::fsid_t, + pub f_namemax: u32, + pub f_owner: ::uid_t, + pub f_ctime: u64, + pub f_fstypename: [::c_char; 16], + pub f_mntonname: [::c_char; 90], + pub f_mntfromname: [::c_char; 90], + pub f_mntfromspec: [::c_char; 90], + pub mount_info: mount_info, + } + } + + cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for statfs { + fn eq(&self, other: &statfs) -> bool { + self.f_flags == other.f_flags + && self.f_bsize == other.f_bsize + && self.f_iosize == other.f_iosize + && self.f_blocks == other.f_blocks + && self.f_bfree == other.f_bfree + && self.f_bavail == other.f_bavail + && self.f_files == other.f_files + && self.f_ffree == other.f_ffree + && self.f_favail == other.f_favail + && self.f_syncwrites == other.f_syncwrites + && self.f_syncreads == other.f_syncreads + && self.f_asyncwrites == other.f_asyncwrites + && self.f_asyncreads == other.f_asyncreads + && self.f_fsid == other.f_fsid + && self.f_namemax == other.f_namemax + && self.f_owner == other.f_owner + && self.f_ctime == other.f_ctime + && self.f_fstypename + .iter() + .zip(other.f_fstypename.iter()) + .all(|(a,b)| a == b) + && self.f_mntonname + .iter() + .zip(other.f_mntonname.iter()) + .all(|(a,b)| a == b) + && self.f_mntfromname + .iter() + .zip(other.f_mntfromname.iter()) + .all(|(a,b)| a == b) + && self.f_mntfromspec + .iter() + .zip(other.f_mntfromspec.iter()) + .all(|(a,b)| a == b) + && self.mount_info == other.mount_info + } + } + + impl Eq for statfs { } + + impl ::fmt::Debug for statfs { + fn fmt(&self, f: &mut ::fmt::Formatter) + -> ::fmt::Result { + f.debug_struct("statfs") + .field("f_flags", &self.f_flags) + .field("f_bsize", &self.f_bsize) + .field("f_iosize", &self.f_iosize) + .field("f_blocks", &self.f_blocks) + .field("f_bfree", &self.f_bfree) + .field("f_bavail", &self.f_bavail) + .field("f_files", &self.f_files) + .field("f_ffree", &self.f_ffree) + .field("f_favail", &self.f_favail) + .field("f_syncwrites", &self.f_syncwrites) + .field("f_syncreads", &self.f_syncreads) + .field("f_asyncwrites", &self.f_asyncwrites) + .field("f_asyncreads", &self.f_asyncreads) + .field("f_fsid", &self.f_fsid) + .field("f_namemax", &self.f_namemax) + .field("f_owner", &self.f_owner) + .field("f_ctime", &self.f_ctime) + // FIXME: .field("f_fstypename", &self.f_fstypename) + // FIXME: .field("f_mntonname", &self.f_mntonname) + // FIXME: .field("f_mntfromname", &self.f_mntfromname) + // FIXME: .field("f_mntfromspec", &self.f_mntfromspec) + .field("mount_info", &self.mount_info) + .finish() + } + } + + impl ::hash::Hash for statfs { + fn hash(&self, state: &mut H) { + self.f_flags.hash(state); + self.f_bsize.hash(state); + self.f_iosize.hash(state); + self.f_blocks.hash(state); + self.f_bfree.hash(state); + self.f_bavail.hash(state); + self.f_files.hash(state); + self.f_ffree.hash(state); + self.f_favail.hash(state); + self.f_syncwrites.hash(state); + self.f_syncreads.hash(state); + self.f_asyncwrites.hash(state); + self.f_asyncreads.hash(state); + self.f_fsid.hash(state); + self.f_namemax.hash(state); + self.f_owner.hash(state); + self.f_ctime.hash(state); + self.f_fstypename.hash(state); + self.f_mntonname.hash(state); + self.f_mntfromname.hash(state); + self.f_mntfromspec.hash(state); + self.mount_info.hash(state); + } + } + } + } + } +} + +pub const UT_NAMESIZE: usize = 32; +pub const UT_LINESIZE: usize = 8; +pub const UT_HOSTSIZE: usize = 256; + +pub const O_CLOEXEC: ::c_int = 0x10000; +pub const O_DIRECTORY: ::c_int = 0x20000; +pub const O_RSYNC: ::c_int = O_SYNC; + +pub const MS_SYNC : ::c_int = 0x0002; +pub const MS_INVALIDATE : ::c_int = 0x0004; + +pub const POLLNORM: ::c_short = ::POLLRDNORM; + +pub const ENOATTR : ::c_int = 83; +pub const EILSEQ : ::c_int = 84; +pub const EOVERFLOW : ::c_int = 87; +pub const ECANCELED : ::c_int = 88; +pub const EIDRM : ::c_int = 89; +pub const ENOMSG : ::c_int = 90; +pub const ENOTSUP : ::c_int = 91; +pub const EBADMSG : ::c_int = 92; +pub const ENOTRECOVERABLE : ::c_int = 93; +pub const EOWNERDEAD : ::c_int = 94; +pub const EPROTO : ::c_int = 95; +pub const ELAST : ::c_int = 95; + +pub const F_DUPFD_CLOEXEC : ::c_int = 10; + +pub const AT_FDCWD: ::c_int = -100; +pub const AT_EACCESS: ::c_int = 0x01; +pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x02; +pub const AT_SYMLINK_FOLLOW: ::c_int = 0x04; +pub const AT_REMOVEDIR: ::c_int = 0x08; + +pub const RLIM_NLIMITS: ::c_int = 9; + +pub const SO_TIMESTAMP: ::c_int = 0x0800; +pub const SO_SNDTIMEO: ::c_int = 0x1005; +pub const SO_RCVTIMEO: ::c_int = 0x1006; +pub const SO_BINDANY: ::c_int = 0x1000; +pub const SO_NETPROC: ::c_int = 0x1020; +pub const SO_RTABLE: ::c_int = 0x1021; +pub const SO_PEERCRED: ::c_int = 0x1022; +pub const SO_SPLICE: ::c_int = 0x1023; + +// sys/netinet/in.h +// Protocols (RFC 1700) +// NOTE: These are in addition to the constants defined in src/unix/mod.rs + +// IPPROTO_IP defined in src/unix/mod.rs +/// Hop-by-hop option header +pub const IPPROTO_HOPOPTS: ::c_int = 0; +// IPPROTO_ICMP defined in src/unix/mod.rs +/// group mgmt protocol +pub const IPPROTO_IGMP: ::c_int = 2; +/// gateway^2 (deprecated) +pub const IPPROTO_GGP: ::c_int = 3; +/// for compatibility +pub const IPPROTO_IPIP: ::c_int = 4; +// IPPROTO_TCP defined in src/unix/mod.rs +/// exterior gateway protocol +pub const IPPROTO_EGP: ::c_int = 8; +/// pup +pub const IPPROTO_PUP: ::c_int = 12; +// IPPROTO_UDP defined in src/unix/mod.rs +/// xns idp +pub const IPPROTO_IDP: ::c_int = 22; +/// tp-4 w/ class negotiation +pub const IPPROTO_TP: ::c_int = 29; +// IPPROTO_IPV6 defined in src/unix/mod.rs +/// IP6 routing header +pub const IPPROTO_ROUTING: ::c_int = 43; +/// IP6 fragmentation header +pub const IPPROTO_FRAGMENT: ::c_int = 44; +/// resource reservation +pub const IPPROTO_RSVP: ::c_int = 46; +/// General Routing Encap. +pub const IPPROTO_GRE: ::c_int = 47; +/// IP6 Encap Sec. Payload +pub const IPPROTO_ESP: ::c_int = 50; +/// IP6 Auth Header +pub const IPPROTO_AH: ::c_int = 51; +/// IP Mobility RFC 2004 +pub const IPPROTO_MOBILE: ::c_int = 55; +// IPPROTO_ICMPV6 defined in src/unix/mod.rs +/// IP6 no next header +pub const IPPROTO_NONE: ::c_int = 59; +/// IP6 destination option +pub const IPPROTO_DSTOPTS: ::c_int = 60; +/// ISO cnlp +pub const IPPROTO_EON: ::c_int = 80; +/// Ethernet-in-IP +pub const IPPROTO_ETHERIP: ::c_int = 97; +/// encapsulation header +pub const IPPROTO_ENCAP: ::c_int = 98; +/// Protocol indep. multicast +pub const IPPROTO_PIM: ::c_int = 103; +/// IP Payload Comp. Protocol +pub const IPPROTO_IPCOMP: ::c_int = 108; +/// CARP +pub const IPPROTO_CARP: ::c_int = 112; +/// unicast MPLS packet +pub const IPPROTO_MPLS: ::c_int = 137; +/// PFSYNC +pub const IPPROTO_PFSYNC: ::c_int = 240; +pub const IPPROTO_MAX: ::c_int = 256; + +/* Only used internally, so it can be outside the range of valid IP protocols */ +/// Divert sockets +pub const IPPROTO_DIVERT: ::c_int = 258; + +pub const IP_RECVDSTADDR: ::c_int = 7; +pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR; +pub const IP_RECVIF: ::c_int = 30; + +// sys/netinet/in.h +pub const TCP_MD5SIG: ::c_int = 0x04; +pub const TCP_NOPUSH: ::c_int = 0x10; + +pub const AF_ECMA: ::c_int = 8; +pub const AF_ROUTE: ::c_int = 17; +pub const AF_ENCAP: ::c_int = 28; +pub const AF_SIP: ::c_int = 29; +pub const AF_KEY: ::c_int = 30; +pub const pseudo_AF_HDRCMPLT: ::c_int = 31; +pub const AF_BLUETOOTH: ::c_int = 32; +pub const AF_MPLS: ::c_int = 33; +pub const pseudo_AF_PFLOW: ::c_int = 34; +pub const pseudo_AF_PIPEX: ::c_int = 35; +#[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +pub const AF_MAX: ::c_int = 36; + +#[doc(hidden)] +#[allow(deprecated)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +pub const NET_MAXID: ::c_int = AF_MAX; +pub const NET_RT_DUMP: ::c_int = 1; +pub const NET_RT_FLAGS: ::c_int = 2; +pub const NET_RT_IFLIST: ::c_int = 3; +pub const NET_RT_STATS: ::c_int = 4; +pub const NET_RT_TABLE: ::c_int = 5; +pub const NET_RT_IFNAMES: ::c_int = 6; +#[doc(hidden)] +pub const NET_RT_MAXID: ::c_int = 7; + +pub const IPV6_JOIN_GROUP: ::c_int = 12; +pub const IPV6_LEAVE_GROUP: ::c_int = 13; + +pub const PF_ROUTE: ::c_int = AF_ROUTE; +pub const PF_ECMA: ::c_int = AF_ECMA; +pub const PF_ENCAP: ::c_int = AF_ENCAP; +pub const PF_SIP: ::c_int = AF_SIP; +pub const PF_KEY: ::c_int = AF_KEY; +pub const PF_BPF: ::c_int = pseudo_AF_HDRCMPLT; +pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; +pub const PF_MPLS: ::c_int = AF_MPLS; +pub const PF_PFLOW: ::c_int = pseudo_AF_PFLOW; +pub const PF_PIPEX: ::c_int = pseudo_AF_PIPEX; +#[doc(hidden)] +#[allow(deprecated)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +pub const PF_MAX: ::c_int = AF_MAX; + +pub const SCM_TIMESTAMP: ::c_int = 0x04; + +pub const O_DSYNC : ::c_int = 128; + +pub const MAP_RENAME : ::c_int = 0x0000; +pub const MAP_NORESERVE : ::c_int = 0x0000; +pub const MAP_HASSEMAPHORE : ::c_int = 0x0000; + +pub const EIPSEC : ::c_int = 82; +pub const ENOMEDIUM : ::c_int = 85; +pub const EMEDIUMTYPE : ::c_int = 86; + +pub const EAI_BADFLAGS: ::c_int = -1; +pub const EAI_NONAME: ::c_int = -2; +pub const EAI_AGAIN: ::c_int = -3; +pub const EAI_FAIL: ::c_int = -4; +pub const EAI_NODATA: ::c_int = -5; +pub const EAI_FAMILY: ::c_int = -6; +pub const EAI_SOCKTYPE: ::c_int = -7; +pub const EAI_SERVICE: ::c_int = -8; +pub const EAI_MEMORY: ::c_int = -10; +pub const EAI_SYSTEM: ::c_int = -11; +pub const EAI_OVERFLOW: ::c_int = -14; + +pub const RUSAGE_THREAD: ::c_int = 1; + +pub const MAP_COPY : ::c_int = 0x0002; +pub const MAP_NOEXTEND : ::c_int = 0x0000; + +pub const _PC_LINK_MAX : ::c_int = 1; +pub const _PC_MAX_CANON : ::c_int = 2; +pub const _PC_MAX_INPUT : ::c_int = 3; +pub const _PC_NAME_MAX : ::c_int = 4; +pub const _PC_PATH_MAX : ::c_int = 5; +pub const _PC_PIPE_BUF : ::c_int = 6; +pub const _PC_CHOWN_RESTRICTED : ::c_int = 7; +pub const _PC_NO_TRUNC : ::c_int = 8; +pub const _PC_VDISABLE : ::c_int = 9; +pub const _PC_2_SYMLINKS : ::c_int = 10; +pub const _PC_ALLOC_SIZE_MIN : ::c_int = 11; +pub const _PC_ASYNC_IO : ::c_int = 12; +pub const _PC_FILESIZEBITS : ::c_int = 13; +pub const _PC_PRIO_IO : ::c_int = 14; +pub const _PC_REC_INCR_XFER_SIZE : ::c_int = 15; +pub const _PC_REC_MAX_XFER_SIZE : ::c_int = 16; +pub const _PC_REC_MIN_XFER_SIZE : ::c_int = 17; +pub const _PC_REC_XFER_ALIGN : ::c_int = 18; +pub const _PC_SYMLINK_MAX : ::c_int = 19; +pub const _PC_SYNC_IO : ::c_int = 20; +pub const _PC_TIMESTAMP_RESOLUTION : ::c_int = 21; + +pub const _SC_CLK_TCK : ::c_int = 3; +pub const _SC_SEM_NSEMS_MAX : ::c_int = 31; +pub const _SC_SEM_VALUE_MAX : ::c_int = 32; +pub const _SC_HOST_NAME_MAX : ::c_int = 33; +pub const _SC_MONOTONIC_CLOCK : ::c_int = 34; +pub const _SC_2_PBS : ::c_int = 35; +pub const _SC_2_PBS_ACCOUNTING : ::c_int = 36; +pub const _SC_2_PBS_CHECKPOINT : ::c_int = 37; +pub const _SC_2_PBS_LOCATE : ::c_int = 38; +pub const _SC_2_PBS_MESSAGE : ::c_int = 39; +pub const _SC_2_PBS_TRACK : ::c_int = 40; +pub const _SC_ADVISORY_INFO : ::c_int = 41; +pub const _SC_AIO_LISTIO_MAX : ::c_int = 42; +pub const _SC_AIO_MAX : ::c_int = 43; +pub const _SC_AIO_PRIO_DELTA_MAX : ::c_int = 44; +pub const _SC_ASYNCHRONOUS_IO : ::c_int = 45; +pub const _SC_ATEXIT_MAX : ::c_int = 46; +pub const _SC_BARRIERS : ::c_int = 47; +pub const _SC_CLOCK_SELECTION : ::c_int = 48; +pub const _SC_CPUTIME : ::c_int = 49; +pub const _SC_DELAYTIMER_MAX : ::c_int = 50; +pub const _SC_IOV_MAX : ::c_int = 51; +pub const _SC_IPV6 : ::c_int = 52; +pub const _SC_MAPPED_FILES : ::c_int = 53; +pub const _SC_MEMLOCK : ::c_int = 54; +pub const _SC_MEMLOCK_RANGE : ::c_int = 55; +pub const _SC_MEMORY_PROTECTION : ::c_int = 56; +pub const _SC_MESSAGE_PASSING : ::c_int = 57; +pub const _SC_MQ_OPEN_MAX : ::c_int = 58; +pub const _SC_MQ_PRIO_MAX : ::c_int = 59; +pub const _SC_PRIORITIZED_IO : ::c_int = 60; +pub const _SC_PRIORITY_SCHEDULING : ::c_int = 61; +pub const _SC_RAW_SOCKETS : ::c_int = 62; +pub const _SC_READER_WRITER_LOCKS : ::c_int = 63; +pub const _SC_REALTIME_SIGNALS : ::c_int = 64; +pub const _SC_REGEXP : ::c_int = 65; +pub const _SC_RTSIG_MAX : ::c_int = 66; +pub const _SC_SEMAPHORES : ::c_int = 67; +pub const _SC_SHARED_MEMORY_OBJECTS : ::c_int = 68; +pub const _SC_SHELL : ::c_int = 69; +pub const _SC_SIGQUEUE_MAX : ::c_int = 70; +pub const _SC_SPAWN : ::c_int = 71; +pub const _SC_SPIN_LOCKS : ::c_int = 72; +pub const _SC_SPORADIC_SERVER : ::c_int = 73; +pub const _SC_SS_REPL_MAX : ::c_int = 74; +pub const _SC_SYNCHRONIZED_IO : ::c_int = 75; +pub const _SC_SYMLOOP_MAX : ::c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR : ::c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE : ::c_int = 78; +pub const _SC_THREAD_CPUTIME : ::c_int = 79; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : ::c_int = 80; +pub const _SC_THREAD_KEYS_MAX : ::c_int = 81; +pub const _SC_THREAD_PRIO_INHERIT : ::c_int = 82; +pub const _SC_THREAD_PRIO_PROTECT : ::c_int = 83; +pub const _SC_THREAD_PRIORITY_SCHEDULING : ::c_int = 84; +pub const _SC_THREAD_PROCESS_SHARED : ::c_int = 85; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT : ::c_int = 86; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT : ::c_int = 87; +pub const _SC_THREAD_SPORADIC_SERVER : ::c_int = 88; +pub const _SC_THREAD_STACK_MIN : ::c_int = 89; +pub const _SC_THREAD_THREADS_MAX : ::c_int = 90; +pub const _SC_THREADS : ::c_int = 91; +pub const _SC_TIMEOUTS : ::c_int = 92; +pub const _SC_TIMER_MAX : ::c_int = 93; +pub const _SC_TIMERS : ::c_int = 94; +pub const _SC_TRACE : ::c_int = 95; +pub const _SC_TRACE_EVENT_FILTER : ::c_int = 96; +pub const _SC_TRACE_EVENT_NAME_MAX : ::c_int = 97; +pub const _SC_TRACE_INHERIT : ::c_int = 98; +pub const _SC_TRACE_LOG : ::c_int = 99; +pub const _SC_GETGR_R_SIZE_MAX : ::c_int = 100; +pub const _SC_GETPW_R_SIZE_MAX : ::c_int = 101; +pub const _SC_LOGIN_NAME_MAX : ::c_int = 102; +pub const _SC_THREAD_SAFE_FUNCTIONS : ::c_int = 103; +pub const _SC_TRACE_NAME_MAX : ::c_int = 104; +pub const _SC_TRACE_SYS_MAX : ::c_int = 105; +pub const _SC_TRACE_USER_EVENT_MAX : ::c_int = 106; +pub const _SC_TTY_NAME_MAX : ::c_int = 107; +pub const _SC_TYPED_MEMORY_OBJECTS : ::c_int = 108; +pub const _SC_V6_ILP32_OFF32 : ::c_int = 109; +pub const _SC_V6_ILP32_OFFBIG : ::c_int = 110; +pub const _SC_V6_LP64_OFF64 : ::c_int = 111; +pub const _SC_V6_LPBIG_OFFBIG : ::c_int = 112; +pub const _SC_V7_ILP32_OFF32 : ::c_int = 113; +pub const _SC_V7_ILP32_OFFBIG : ::c_int = 114; +pub const _SC_V7_LP64_OFF64 : ::c_int = 115; +pub const _SC_V7_LPBIG_OFFBIG : ::c_int = 116; +pub const _SC_XOPEN_CRYPT : ::c_int = 117; +pub const _SC_XOPEN_ENH_I18N : ::c_int = 118; +pub const _SC_XOPEN_LEGACY : ::c_int = 119; +pub const _SC_XOPEN_REALTIME : ::c_int = 120; +pub const _SC_XOPEN_REALTIME_THREADS : ::c_int = 121; +pub const _SC_XOPEN_STREAMS : ::c_int = 122; +pub const _SC_XOPEN_UNIX : ::c_int = 123; +pub const _SC_XOPEN_UUCP : ::c_int = 124; +pub const _SC_XOPEN_VERSION : ::c_int = 125; +pub const _SC_PHYS_PAGES : ::c_int = 500; +pub const _SC_AVPHYS_PAGES : ::c_int = 501; +pub const _SC_NPROCESSORS_CONF : ::c_int = 502; +pub const _SC_NPROCESSORS_ONLN : ::c_int = 503; + +pub const FD_SETSIZE: usize = 1024; + +pub const ST_NOSUID: ::c_ulong = 2; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; + +pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; +pub const PTHREAD_MUTEX_NORMAL: ::c_int = 3; +pub const PTHREAD_MUTEX_STRICT_NP: ::c_int = 4; +pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_STRICT_NP; + +pub const EVFILT_AIO: i16 = -3; +pub const EVFILT_PROC: i16 = -5; +pub const EVFILT_READ: i16 = -1; +pub const EVFILT_SIGNAL: i16 = -6; +pub const EVFILT_TIMER: i16 = -7; +pub const EVFILT_VNODE: i16 = -4; +pub const EVFILT_WRITE: i16 = -2; + +pub const EV_ADD: u16 = 0x1; +pub const EV_DELETE: u16 = 0x2; +pub const EV_ENABLE: u16 = 0x4; +pub const EV_DISABLE: u16 = 0x8; +pub const EV_ONESHOT: u16 = 0x10; +pub const EV_CLEAR: u16 = 0x20; +pub const EV_RECEIPT: u16 = 0x40; +pub const EV_DISPATCH: u16 = 0x80; +pub const EV_FLAG1: u16 = 0x2000; +pub const EV_ERROR: u16 = 0x4000; +pub const EV_EOF: u16 = 0x8000; +pub const EV_SYSFLAGS: u16 = 0xf000; + +pub const NOTE_LOWAT: u32 = 0x00000001; +pub const NOTE_EOF: u32 = 0x00000002; +pub const NOTE_DELETE: u32 = 0x00000001; +pub const NOTE_WRITE: u32 = 0x00000002; +pub const NOTE_EXTEND: u32 = 0x00000004; +pub const NOTE_ATTRIB: u32 = 0x00000008; +pub const NOTE_LINK: u32 = 0x00000010; +pub const NOTE_RENAME: u32 = 0x00000020; +pub const NOTE_REVOKE: u32 = 0x00000040; +pub const NOTE_TRUNCATE: u32 = 0x00000080; +pub const NOTE_EXIT: u32 = 0x80000000; +pub const NOTE_FORK: u32 = 0x40000000; +pub const NOTE_EXEC: u32 = 0x20000000; +pub const NOTE_PDATAMASK: u32 = 0x000fffff; +pub const NOTE_PCTRLMASK: u32 = 0xf0000000; +pub const NOTE_TRACK: u32 = 0x00000001; +pub const NOTE_TRACKERR: u32 = 0x00000002; +pub const NOTE_CHILD: u32 = 0x00000004; + +pub const TMP_MAX : ::c_uint = 0x7fffffff; + +pub const NI_MAXHOST: ::size_t = 256; + +pub const RTLD_LOCAL: ::c_int = 0; + +pub const CTL_MAXNAME: ::c_int = 12; + +pub const CTLTYPE_NODE: ::c_int = 1; +pub const CTLTYPE_INT: ::c_int = 2; +pub const CTLTYPE_STRING: ::c_int = 3; +pub const CTLTYPE_QUAD: ::c_int = 4; +pub const CTLTYPE_STRUCT: ::c_int = 5; + +pub const CTL_UNSPEC: ::c_int = 0; +pub const CTL_KERN: ::c_int = 1; +pub const CTL_VM: ::c_int = 2; +pub const CTL_FS: ::c_int = 3; +pub const CTL_NET: ::c_int = 4; +pub const CTL_DEBUG: ::c_int = 5; +pub const CTL_HW: ::c_int = 6; +pub const CTL_MACHDEP: ::c_int = 7; +pub const CTL_DDB: ::c_int = 9; +pub const CTL_VFS: ::c_int = 10; +pub const CTL_MAXID: ::c_int = 11; + +pub const HW_NCPUONLINE: ::c_int = 25; + +pub const KERN_OSTYPE: ::c_int = 1; +pub const KERN_OSRELEASE: ::c_int = 2; +pub const KERN_OSREV: ::c_int = 3; +pub const KERN_VERSION: ::c_int = 4; +pub const KERN_MAXVNODES: ::c_int = 5; +pub const KERN_MAXPROC: ::c_int = 6; +pub const KERN_MAXFILES: ::c_int = 7; +pub const KERN_ARGMAX: ::c_int = 8; +pub const KERN_SECURELVL: ::c_int = 9; +pub const KERN_HOSTNAME: ::c_int = 10; +pub const KERN_HOSTID: ::c_int = 11; +pub const KERN_CLOCKRATE: ::c_int = 12; +pub const KERN_PROF: ::c_int = 16; +pub const KERN_POSIX1: ::c_int = 17; +pub const KERN_NGROUPS: ::c_int = 18; +pub const KERN_JOB_CONTROL: ::c_int = 19; +pub const KERN_SAVED_IDS: ::c_int = 20; +pub const KERN_BOOTTIME: ::c_int = 21; +pub const KERN_DOMAINNAME: ::c_int = 22; +pub const KERN_MAXPARTITIONS: ::c_int = 23; +pub const KERN_RAWPARTITION: ::c_int = 24; +pub const KERN_MAXTHREAD: ::c_int = 25; +pub const KERN_NTHREADS: ::c_int = 26; +pub const KERN_OSVERSION: ::c_int = 27; +pub const KERN_SOMAXCONN: ::c_int = 28; +pub const KERN_SOMINCONN: ::c_int = 29; +pub const KERN_USERMOUNT: ::c_int = 30; +pub const KERN_NOSUIDCOREDUMP: ::c_int = 32; +pub const KERN_FSYNC: ::c_int = 33; +pub const KERN_SYSVMSG: ::c_int = 34; +pub const KERN_SYSVSEM: ::c_int = 35; +pub const KERN_SYSVSHM: ::c_int = 36; +pub const KERN_ARND: ::c_int = 37; +pub const KERN_MSGBUFSIZE: ::c_int = 38; +pub const KERN_MALLOCSTATS: ::c_int = 39; +pub const KERN_CPTIME: ::c_int = 40; +pub const KERN_NCHSTATS: ::c_int = 41; +pub const KERN_FORKSTAT: ::c_int = 42; +pub const KERN_NSELCOLL: ::c_int = 43; +pub const KERN_TTY: ::c_int = 44; +pub const KERN_CCPU: ::c_int = 45; +pub const KERN_FSCALE: ::c_int = 46; +pub const KERN_NPROCS: ::c_int = 47; +pub const KERN_MSGBUF: ::c_int = 48; +pub const KERN_POOL: ::c_int = 49; +pub const KERN_STACKGAPRANDOM: ::c_int = 50; +pub const KERN_SYSVIPC_INFO: ::c_int = 51; +pub const KERN_SPLASSERT: ::c_int = 54; +pub const KERN_PROC_ARGS: ::c_int = 55; +pub const KERN_NFILES: ::c_int = 56; +pub const KERN_TTYCOUNT: ::c_int = 57; +pub const KERN_NUMVNODES: ::c_int = 58; +pub const KERN_MBSTAT: ::c_int = 59; +pub const KERN_SEMINFO: ::c_int = 61; +pub const KERN_SHMINFO: ::c_int = 62; +pub const KERN_INTRCNT: ::c_int = 63; +pub const KERN_WATCHDOG: ::c_int = 64; +pub const KERN_PROC: ::c_int = 66; +pub const KERN_MAXCLUSTERS: ::c_int = 67; +pub const KERN_EVCOUNT: ::c_int = 68; +pub const KERN_TIMECOUNTER: ::c_int = 69; +pub const KERN_MAXLOCKSPERUID: ::c_int = 70; +pub const KERN_CPTIME2: ::c_int = 71; +pub const KERN_CACHEPCT: ::c_int = 72; +pub const KERN_FILE: ::c_int = 73; +pub const KERN_CONSDEV: ::c_int = 75; +pub const KERN_NETLIVELOCKS: ::c_int = 76; +pub const KERN_POOL_DEBUG: ::c_int = 77; +pub const KERN_PROC_CWD: ::c_int = 78; +pub const KERN_PROC_NOBROADCASTKILL: ::c_int = 79; +pub const KERN_PROC_VMMAP: ::c_int = 80; +pub const KERN_GLOBAL_PTRACE: ::c_int = 81; +pub const KERN_CONSBUFSIZE: ::c_int = 82; +pub const KERN_CONSBUF: ::c_int = 83; +pub const KERN_AUDIO: ::c_int = 84; +pub const KERN_CPUSTATS: ::c_int = 85; +pub const KERN_PFSTATUS: ::c_int = 86; +pub const KERN_MAXID: ::c_int = 87; + +pub const KERN_PROC_ALL: ::c_int = 0; +pub const KERN_PROC_PID: ::c_int = 1; +pub const KERN_PROC_PGRP: ::c_int = 2; +pub const KERN_PROC_SESSION: ::c_int = 3; +pub const KERN_PROC_TTY: ::c_int = 4; +pub const KERN_PROC_UID: ::c_int = 5; +pub const KERN_PROC_RUID: ::c_int = 6; +pub const KERN_PROC_KTHREAD: ::c_int = 7; +pub const KERN_PROC_SHOW_THREADS: ::c_int = 0x40000000; + +pub const KERN_SYSVIPC_MSG_INFO: ::c_int = 1; +pub const KERN_SYSVIPC_SEM_INFO: ::c_int = 2; +pub const KERN_SYSVIPC_SHM_INFO: ::c_int = 3; + +pub const KERN_PROC_ARGV: ::c_int = 1; +pub const KERN_PROC_NARGV: ::c_int = 2; +pub const KERN_PROC_ENV: ::c_int = 3; +pub const KERN_PROC_NENV: ::c_int = 4; + +pub const KI_NGROUPS: ::c_int = 16; +pub const KI_MAXCOMLEN: ::c_int = 24; +pub const KI_WMESGLEN: ::c_int = 8; +pub const KI_MAXLOGNAME: ::c_int = 32; +pub const KI_EMULNAMELEN: ::c_int = 8; + +pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS; +pub const OLCUC: ::tcflag_t = 0x20; +pub const ONOCR: ::tcflag_t = 0x40; +pub const ONLRET: ::tcflag_t = 0x80; + +//https://github.com/openbsd/src/blob/master/sys/sys/mount.h +pub const ISOFSMNT_NORRIP: ::c_int = 0x1; // disable Rock Ridge Ext +pub const ISOFSMNT_GENS: ::c_int = 0x2; // enable generation numbers +pub const ISOFSMNT_EXTATT: ::c_int = 0x4; // enable extended attr +pub const ISOFSMNT_NOJOLIET: ::c_int = 0x8; // disable Joliet Ext +pub const ISOFSMNT_SESS: ::c_int = 0x10; // use iso_args.sess + +pub const NFS_ARGSVERSION: ::c_int = 4; // change when nfs_args changes + +pub const NFSMNT_RESVPORT: ::c_int = 0; // always use reserved ports +pub const NFSMNT_SOFT: ::c_int = 0x1; // soft mount (hard is default) +pub const NFSMNT_WSIZE: ::c_int = 0x2; // set write size +pub const NFSMNT_RSIZE: ::c_int = 0x4; // set read size +pub const NFSMNT_TIMEO: ::c_int = 0x8; // set initial timeout +pub const NFSMNT_RETRANS: ::c_int = 0x10; // set number of request retries +pub const NFSMNT_MAXGRPS: ::c_int = 0x20; // set maximum grouplist size +pub const NFSMNT_INT: ::c_int = 0x40; // allow interrupts on hard mount +pub const NFSMNT_NOCONN: ::c_int = 0x80; // Don't Connect the socket +pub const NFSMNT_NQNFS: ::c_int = 0x100; // Use Nqnfs protocol +pub const NFSMNT_NFSV3: ::c_int = 0x200; // Use NFS Version 3 protocol +pub const NFSMNT_KERB: ::c_int = 0x400; // Use Kerberos authentication +pub const NFSMNT_DUMBTIMR: ::c_int = 0x800; // Don't estimate rtt dynamically +pub const NFSMNT_LEASETERM: ::c_int = 0x1000; // set lease term (nqnfs) +pub const NFSMNT_READAHEAD: ::c_int = 0x2000; // set read ahead +pub const NFSMNT_DEADTHRESH: ::c_int = 0x4000; // set dead server retry thresh +pub const NFSMNT_NOAC: ::c_int = 0x8000; // disable attribute cache +pub const NFSMNT_RDIRPLUS: ::c_int = 0x10000; // Use Readdirplus for V3 +pub const NFSMNT_READDIRSIZE: ::c_int = 0x20000; // Set readdir size + +/* Flags valid only in mount syscall arguments */ +pub const NFSMNT_ACREGMIN: ::c_int = 0x40000; // acregmin field valid +pub const NFSMNT_ACREGMAX: ::c_int = 0x80000; // acregmax field valid +pub const NFSMNT_ACDIRMIN: ::c_int = 0x100000; // acdirmin field valid +pub const NFSMNT_ACDIRMAX: ::c_int = 0x200000; // acdirmax field valid + +/* Flags valid only in kernel */ +pub const NFSMNT_INTERNAL: ::c_int = 0xfffc0000; // Bits set internally +pub const NFSMNT_HASWRITEVERF: ::c_int = 0x40000; // Has write verifier for V3 +pub const NFSMNT_GOTPATHCONF: ::c_int = 0x80000; // Got the V3 pathconf info +pub const NFSMNT_GOTFSINFO: ::c_int = 0x100000; // Got the V3 fsinfo +pub const NFSMNT_MNTD: ::c_int = 0x200000; // Mnt server for mnt point +pub const NFSMNT_DISMINPROG: ::c_int = 0x400000; // Dismount in progress +pub const NFSMNT_DISMNT: ::c_int = 0x800000; // Dismounted +pub const NFSMNT_SNDLOCK: ::c_int = 0x1000000; // Send socket lock +pub const NFSMNT_WANTSND: ::c_int = 0x2000000; // Want above +pub const NFSMNT_RCVLOCK: ::c_int = 0x4000000; // Rcv socket lock +pub const NFSMNT_WANTRCV: ::c_int = 0x8000000; // Want above +pub const NFSMNT_WAITAUTH: ::c_int = 0x10000000; // Wait for authentication +pub const NFSMNT_HASAUTH: ::c_int = 0x20000000; // Has authenticator +pub const NFSMNT_WANTAUTH: ::c_int = 0x40000000; // Wants an authenticator +pub const NFSMNT_AUTHERR: ::c_int = 0x80000000; // Authentication error + +pub const MSDOSFSMNT_SHORTNAME: ::c_int = 0x1; // Force old DOS short names only +pub const MSDOSFSMNT_LONGNAME: ::c_int = 0x2; // Force Win'95 long names +pub const MSDOSFSMNT_NOWIN95: ::c_int = 0x4; // Completely ignore Win95 entries + +pub const NTFS_MFLAG_CASEINS: ::c_int = 0x1; +pub const NTFS_MFLAG_ALLNAMES: ::c_int = 0x2; + +pub const TMPFS_ARGS_VERSION: ::c_int = 1; + +pub const MAP_STACK : ::c_int = 0x4000; + +// https://github.com/openbsd/src/blob/master/sys/net/if.h#L187 +pub const IFF_UP: ::c_int = 0x1; // interface is up +pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid +pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging +pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net +pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link +pub const IFF_STATICARP: ::c_int = 0x20; // only static ARP +pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated +pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol +pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets +pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets +pub const IFF_OACTIVE: ::c_int = 0x400; // transmission in progress +pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions +pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit +pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit +pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit +pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast + +pub const PTHREAD_STACK_MIN : ::size_t = 4096; +pub const SIGSTKSZ : ::size_t = 28672; + +pub const PT_FIRSTMACH: ::c_int = 32; + +pub const SOCK_CLOEXEC: ::c_int = 0x8000; +pub const SOCK_NONBLOCK: ::c_int = 0x4000; +pub const SOCK_DNS: ::c_int = 0x1000; + +pub const PTRACE_FORK: ::c_int = 0x0002; + +pub const WCONTINUED: ::c_int = 8; + +fn _ALIGN(p: usize) -> usize { + (p + _ALIGNBYTES) & !_ALIGNBYTES +} + +f! { + pub fn WIFCONTINUED(status: ::c_int) -> bool { + status & 0o177777 == 0o177777 + } + + pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar { + (cmsg as *mut ::c_uchar) + .offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize) + } + + pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { + _ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length + } + + pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr) + -> *mut ::cmsghdr + { + if cmsg.is_null() { + return ::CMSG_FIRSTHDR(mhdr); + }; + let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + + _ALIGN(::mem::size_of::<::cmsghdr>()); + let max = (*mhdr).msg_control as usize + + (*mhdr).msg_controllen as usize; + if next > max { + 0 as *mut ::cmsghdr + } else { + (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) + as *mut ::cmsghdr + } + } + + pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { + (_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize)) + as ::c_uint + } + + pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + status >> 8 + } + + pub fn WIFSIGNALED(status: ::c_int) -> bool { + (status & 0o177) != 0o177 && (status & 0o177) != 0 + } + + pub fn WIFSTOPPED(status: ::c_int) -> bool { + (status & 0o177) == 0o177 + } +} + +extern { + pub fn gettimeofday(tp: *mut ::timeval, + tz: *mut ::timezone) -> ::c_int; + pub fn accept4(s: ::c_int, addr: *mut ::sockaddr, + addrlen: *mut ::socklen_t, flags: ::c_int) -> ::c_int; + pub fn execvpe(file: *const ::c_char, argv: *const *const ::c_char, + envp: *const *const ::c_char) -> ::c_int; + pub fn pledge(promises: *const ::c_char, + execpromises: *const ::c_char) -> ::c_int; + pub fn strtonum(nptr: *const ::c_char, minval: ::c_longlong, + maxval: ::c_longlong, + errstr: *mut *const ::c_char) -> ::c_longlong; + pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int; + pub fn chflags(path: *const ::c_char, flags: ::c_uint) -> ::c_int; + pub fn fchflags(fd: ::c_int, flags: ::c_uint) -> ::c_int; + pub fn chflagsat(fd: ::c_int, path: *const ::c_char, flags: ::c_uint, + atflag: ::c_int) -> ::c_int; + pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; + pub fn getnameinfo(sa: *const ::sockaddr, + salen: ::socklen_t, + host: *mut ::c_char, + hostlen: ::size_t, + serv: *mut ::c_char, + servlen: ::size_t, + flags: ::c_int) -> ::c_int; + pub fn kevent(kq: ::c_int, + changelist: *const ::kevent, + nchanges: ::c_int, + eventlist: *mut ::kevent, + nevents: ::c_int, + timeout: *const ::timespec) -> ::c_int; + pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) + -> ::c_int; + pub fn pthread_main_np() -> ::c_int; + pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); + pub fn pthread_stackseg_np(thread: ::pthread_t, + sinfo: *mut ::stack_t) -> ::c_int; + pub fn sysctl(name: *const ::c_int, + namelen: ::c_uint, + oldp: *mut ::c_void, + oldlenp: *mut ::size_t, + newp: *mut ::c_void, + newlen: ::size_t) + -> ::c_int; + pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; + pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int; + pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int; + pub fn ptrace(request: ::c_int, + pid: ::pid_t, + addr: caddr_t, + data: ::c_int) -> ::c_int; +} + +cfg_if! { + if #[cfg(libc_union)] { + extern { + // these functions use statfs which uses the union mount_info: + pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; + pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; + } + } +} + +cfg_if! { + if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else { + // Unknown target_arch + } +} diff --git a/libc/src/unix/bsd/netbsdlike/openbsd/x86.rs b/libc/src/unix/bsd/netbsdlike/openbsd/x86.rs new file mode 100644 index 0000000..05538cd --- /dev/null +++ b/libc/src/unix/bsd/netbsdlike/openbsd/x86.rs @@ -0,0 +1,14 @@ +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_char = i8; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 4 - 1; + } +} diff --git a/libc/src/unix/bsd/netbsdlike/openbsd/x86_64.rs b/libc/src/unix/bsd/netbsdlike/openbsd/x86_64.rs new file mode 100644 index 0000000..7daa9d8 --- /dev/null +++ b/libc/src/unix/bsd/netbsdlike/openbsd/x86_64.rs @@ -0,0 +1,22 @@ +use PT_FIRSTMACH; + +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = i8; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + +pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0; +pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; +pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; +pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 3; +pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 4; diff --git a/libc/src/unix/bsd/netbsdlike/openbsdlike/mod.rs b/libc/src/unix/bsd/netbsdlike/openbsdlike/mod.rs deleted file mode 100644 index 223064b..0000000 --- a/libc/src/unix/bsd/netbsdlike/openbsdlike/mod.rs +++ /dev/null @@ -1,945 +0,0 @@ -use unix::bsd::O_SYNC; - -pub type clock_t = i64; -pub type suseconds_t = ::c_long; -pub type dev_t = i32; -pub type sigset_t = ::c_uint; -pub type blksize_t = ::int32_t; -pub type fsblkcnt_t = ::uint64_t; -pub type fsfilcnt_t = ::uint64_t; -pub type pthread_attr_t = *mut ::c_void; -pub type pthread_mutex_t = *mut ::c_void; -pub type pthread_mutexattr_t = *mut ::c_void; -pub type pthread_cond_t = *mut ::c_void; -pub type pthread_condattr_t = *mut ::c_void; -pub type pthread_rwlock_t = *mut ::c_void; -pub type pthread_rwlockattr_t = *mut ::c_void; -pub type caddr_t = *mut ::c_char; - -s! { - pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, - } - - pub struct in_addr { - pub s_addr: ::in_addr_t, - } - - pub struct sockaddr_in { - pub sin_len: u8, - pub sin_family: ::sa_family_t, - pub sin_port: ::in_port_t, - pub sin_addr: ::in_addr, - pub sin_zero: [::int8_t; 8], - } - - pub struct kevent { - pub ident: ::uintptr_t, - pub filter: ::c_short, - pub flags: ::c_ushort, - pub fflags: ::c_uint, - pub data: ::int64_t, - pub udata: *mut ::c_void, - } - - pub struct stat { - pub st_mode: ::mode_t, - pub st_dev: ::dev_t, - pub st_ino: ::ino_t, - pub st_nlink: ::nlink_t, - pub st_uid: ::uid_t, - pub st_gid: ::gid_t, - 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_size: ::off_t, - pub st_blocks: ::blkcnt_t, - pub st_blksize: ::blksize_t, - pub st_flags: ::uint32_t, - pub st_gen: ::uint32_t, - pub st_birthtime: ::time_t, - pub st_birthtime_nsec: ::c_long, - } - - pub struct statvfs { - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_favail: ::fsfilcnt_t, - pub f_fsid: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_namemax: ::c_ulong, - } - - pub struct addrinfo { - pub ai_flags: ::c_int, - pub ai_family: ::c_int, - pub ai_socktype: ::c_int, - pub ai_protocol: ::c_int, - pub ai_addrlen: ::socklen_t, - pub ai_addr: *mut ::sockaddr, - pub ai_canonname: *mut ::c_char, - pub ai_next: *mut ::addrinfo, - } - - pub struct Dl_info { - pub dli_fname: *const ::c_char, - pub dli_fbase: *mut ::c_void, - pub dli_sname: *const ::c_char, - pub dli_saddr: *mut ::c_void, - } - - pub struct if_data { - pub ifi_type: ::c_uchar, - pub ifi_addrlen: ::c_uchar, - pub ifi_hdrlen: ::c_uchar, - pub ifi_link_state: ::c_uchar, - pub ifi_mtu: u32, - pub ifi_metric: u32, - pub ifi_rdomain: u32, - pub ifi_baudrate: u64, - pub ifi_ipackets: u64, - pub ifi_ierrors: u64, - pub ifi_opackets: u64, - pub ifi_oerrors: u64, - pub ifi_collisions: u64, - pub ifi_ibytes: u64, - pub ifi_obytes: u64, - pub ifi_imcasts: u64, - pub ifi_omcasts: u64, - pub ifi_iqdrops: u64, - pub ifi_oqdrops: u64, - pub ifi_noproto: u64, - pub ifi_capabilities: u32, - pub ifi_lastchange: ::timeval, - } - - pub struct if_msghdr { - pub ifm_msglen: ::c_ushort, - pub ifm_version: ::c_uchar, - pub ifm_type: ::c_uchar, - pub ifm_hdrlen: ::c_ushort, - pub ifm_index: ::c_ushort, - pub ifm_tableid: ::c_ushort, - pub ifm_pad1: ::c_uchar, - pub ifm_pad2: ::c_uchar, - pub ifm_addrs: ::c_int, - pub ifm_flags: ::c_int, - pub ifm_xflags: ::c_int, - pub ifm_data: if_data, - } - - pub struct sockaddr_dl { - pub sdl_len: ::c_uchar, - pub sdl_family: ::c_uchar, - pub sdl_index: ::c_ushort, - pub sdl_type: ::c_uchar, - pub sdl_nlen: ::c_uchar, - pub sdl_alen: ::c_uchar, - pub sdl_slen: ::c_uchar, - pub sdl_data: [::c_char; 24], - } - - pub struct sockpeercred { - pub uid: ::uid_t, - pub gid: ::gid_t, - pub pid: ::pid_t, - } - - pub struct arphdr { - pub ar_hrd: u16, - pub ar_pro: u16, - pub ar_hln: u8, - pub ar_pln: u8, - pub ar_op: u16, - } -} - -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, - pub d_namlen: u8, - __d_padding: [u8; 4], - pub d_name: [::c_char; 256], - } - - pub struct sockaddr_storage { - pub ss_len: u8, - pub ss_family: ::sa_family_t, - __ss_pad1: [u8; 6], - __ss_pad2: i64, - __ss_pad3: [u8; 240], - } - - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_code: ::c_int, - pub si_errno: ::c_int, - pub si_addr: *mut ::c_char, - #[cfg(target_pointer_width = "32")] - __pad: [u8; 112], - #[cfg(target_pointer_width = "64")] - __pad: [u8; 108], - } - - pub struct lastlog { - ll_time: ::time_t, - ll_line: [::c_char; UT_LINESIZE], - ll_host: [::c_char; UT_HOSTSIZE], - } - - pub struct utmp { - pub ut_line: [::c_char; UT_LINESIZE], - pub ut_name: [::c_char; UT_NAMESIZE], - pub ut_host: [::c_char; UT_HOSTSIZE], - pub ut_time: ::time_t, - } -} - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - 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 - .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) - // FIXME: .field("d_name", &self.d_name) - .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.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_len == other.ss_len - && self.ss_family == other.ss_family - } - } - - impl Eq for sockaddr_storage {} - - impl ::fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("sockaddr_storage") - .field("ss_len", &self.ss_len) - .field("ss_family", &self.ss_family) - .finish() - } - } - - impl ::hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_len.hash(state); - self.ss_family.hash(state); - } - } - - impl PartialEq for siginfo_t { - fn eq(&self, other: &siginfo_t) -> bool { - self.si_signo == other.si_signo - && self.si_code == other.si_code - && self.si_errno == other.si_errno - && self.si_addr == other.si_addr - } - } - - impl Eq for siginfo_t {} - - impl ::fmt::Debug for siginfo_t { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("siginfo_t") - .field("si_signo", &self.si_signo) - .field("si_code", &self.si_code) - .field("si_errno", &self.si_errno) - .field("si_addr", &self.si_addr) - .finish() - } - } - - impl ::hash::Hash for siginfo_t { - fn hash(&self, state: &mut H) { - self.si_signo.hash(state); - self.si_code.hash(state); - self.si_errno.hash(state); - self.si_addr.hash(state); - } - } - - impl PartialEq for lastlog { - fn eq(&self, other: &lastlog) -> bool { - self.ll_time == other.ll_time - && self - .ll_line - .iter() - .zip(other.ll_line.iter()) - .all(|(a,b)| a == b) - && self - .ll_host - .iter() - .zip(other.ll_host.iter()) - .all(|(a,b)| a == b) - } - } - - impl Eq for lastlog {} - - impl ::fmt::Debug for lastlog { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("lastlog") - .field("ll_time", &self.ll_time) - // FIXME: .field("ll_line", &self.ll_line) - // FIXME: .field("ll_host", &self.ll_host) - .finish() - } - } - - impl ::hash::Hash for lastlog { - fn hash(&self, state: &mut H) { - self.ll_time.hash(state); - self.ll_line.hash(state); - self.ll_host.hash(state); - } - } - - impl PartialEq for utmp { - fn eq(&self, other: &utmp) -> bool { - self.ut_time == other.ut_time - && self - .ut_line - .iter() - .zip(other.ut_line.iter()) - .all(|(a,b)| a == b) - && self - .ut_name - .iter() - .zip(other.ut_name.iter()) - .all(|(a,b)| a == b) - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a,b)| a == b) - } - } - - impl Eq for utmp {} - - impl ::fmt::Debug for utmp { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("utmp") - // FIXME: .field("ut_line", &self.ut_line) - // FIXME: .field("ut_name", &self.ut_name) - // FIXME: .field("ut_host", &self.ut_host) - .field("ut_time", &self.ut_time) - .finish() - } - } - - impl ::hash::Hash for utmp { - fn hash(&self, state: &mut H) { - self.ut_line.hash(state); - self.ut_name.hash(state); - self.ut_host.hash(state); - self.ut_time.hash(state); - } - } - } -} - -pub const UT_NAMESIZE: usize = 32; -pub const UT_LINESIZE: usize = 8; -pub const UT_HOSTSIZE: usize = 256; - -pub const O_CLOEXEC: ::c_int = 0x10000; -pub const O_DIRECTORY: ::c_int = 0x20000; -pub const O_RSYNC: ::c_int = O_SYNC; - -pub const MS_SYNC : ::c_int = 0x0002; -pub const MS_INVALIDATE : ::c_int = 0x0004; - -pub const POLLNORM: ::c_short = ::POLLRDNORM; - -pub const ENOATTR : ::c_int = 83; -pub const EILSEQ : ::c_int = 84; -pub const EOVERFLOW : ::c_int = 87; -pub const ECANCELED : ::c_int = 88; -pub const EIDRM : ::c_int = 89; -pub const ENOMSG : ::c_int = 90; -pub const ENOTSUP : ::c_int = 91; -pub const EBADMSG : ::c_int = 92; -pub const ENOTRECOVERABLE : ::c_int = 93; -pub const EOWNERDEAD : ::c_int = 94; -pub const EPROTO : ::c_int = 95; -pub const ELAST : ::c_int = 95; - -pub const F_DUPFD_CLOEXEC : ::c_int = 10; - -pub const AT_FDCWD: ::c_int = -100; -pub const AT_EACCESS: ::c_int = 0x01; -pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x02; -pub const AT_SYMLINK_FOLLOW: ::c_int = 0x04; -pub const AT_REMOVEDIR: ::c_int = 0x08; - -pub const RLIM_NLIMITS: ::c_int = 9; - -pub const SO_TIMESTAMP: ::c_int = 0x0800; -pub const SO_SNDTIMEO: ::c_int = 0x1005; -pub const SO_RCVTIMEO: ::c_int = 0x1006; -pub const SO_BINDANY: ::c_int = 0x1000; -pub const SO_NETPROC: ::c_int = 0x1020; -pub const SO_RTABLE: ::c_int = 0x1021; -pub const SO_PEERCRED: ::c_int = 0x1022; -pub const SO_SPLICE: ::c_int = 0x1023; - -// sys/netinet/in.h -// Protocols (RFC 1700) -// NOTE: These are in addition to the constants defined in src/unix/mod.rs - -// IPPROTO_IP defined in src/unix/mod.rs -/// Hop-by-hop option header -pub const IPPROTO_HOPOPTS: ::c_int = 0; -// IPPROTO_ICMP defined in src/unix/mod.rs -/// group mgmt protocol -pub const IPPROTO_IGMP: ::c_int = 2; -/// gateway^2 (deprecated) -pub const IPPROTO_GGP: ::c_int = 3; -/// for compatibility -pub const IPPROTO_IPIP: ::c_int = 4; -// IPPROTO_TCP defined in src/unix/mod.rs -/// exterior gateway protocol -pub const IPPROTO_EGP: ::c_int = 8; -/// pup -pub const IPPROTO_PUP: ::c_int = 12; -// IPPROTO_UDP defined in src/unix/mod.rs -/// xns idp -pub const IPPROTO_IDP: ::c_int = 22; -/// tp-4 w/ class negotiation -pub const IPPROTO_TP: ::c_int = 29; -// IPPROTO_IPV6 defined in src/unix/mod.rs -/// IP6 routing header -pub const IPPROTO_ROUTING: ::c_int = 43; -/// IP6 fragmentation header -pub const IPPROTO_FRAGMENT: ::c_int = 44; -/// resource reservation -pub const IPPROTO_RSVP: ::c_int = 46; -/// General Routing Encap. -pub const IPPROTO_GRE: ::c_int = 47; -/// IP6 Encap Sec. Payload -pub const IPPROTO_ESP: ::c_int = 50; -/// IP6 Auth Header -pub const IPPROTO_AH: ::c_int = 51; -/// IP Mobility RFC 2004 -pub const IPPROTO_MOBILE: ::c_int = 55; -// IPPROTO_ICMPV6 defined in src/unix/mod.rs -/// IP6 no next header -pub const IPPROTO_NONE: ::c_int = 59; -/// IP6 destination option -pub const IPPROTO_DSTOPTS: ::c_int = 60; -/// ISO cnlp -pub const IPPROTO_EON: ::c_int = 80; -/// Ethernet-in-IP -pub const IPPROTO_ETHERIP: ::c_int = 97; -/// encapsulation header -pub const IPPROTO_ENCAP: ::c_int = 98; -/// Protocol indep. multicast -pub const IPPROTO_PIM: ::c_int = 103; -/// IP Payload Comp. Protocol -pub const IPPROTO_IPCOMP: ::c_int = 108; -/// CARP -pub const IPPROTO_CARP: ::c_int = 112; -/// unicast MPLS packet -pub const IPPROTO_MPLS: ::c_int = 137; -/// PFSYNC -pub const IPPROTO_PFSYNC: ::c_int = 240; -pub const IPPROTO_MAX: ::c_int = 256; - -/* Only used internally, so it can be outside the range of valid IP protocols */ -/// Divert sockets -pub const IPPROTO_DIVERT: ::c_int = 258; - -pub const IP_RECVDSTADDR: ::c_int = 7; -pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR; -pub const IP_RECVIF: ::c_int = 30; - -// sys/netinet/in.h -pub const TCP_MD5SIG: ::c_int = 0x04; -pub const TCP_NOPUSH: ::c_int = 0x10; - -pub const AF_ECMA: ::c_int = 8; -pub const AF_ROUTE: ::c_int = 17; -pub const AF_ENCAP: ::c_int = 28; -pub const AF_SIP: ::c_int = 29; -pub const AF_KEY: ::c_int = 30; -pub const pseudo_AF_HDRCMPLT: ::c_int = 31; -pub const AF_BLUETOOTH: ::c_int = 32; -pub const AF_MPLS: ::c_int = 33; -pub const pseudo_AF_PFLOW: ::c_int = 34; -pub const pseudo_AF_PIPEX: ::c_int = 35; -#[doc(hidden)] -pub const AF_MAX: ::c_int = 36; - -#[doc(hidden)] -pub const NET_MAXID: ::c_int = AF_MAX; -pub const NET_RT_DUMP: ::c_int = 1; -pub const NET_RT_FLAGS: ::c_int = 2; -pub const NET_RT_IFLIST: ::c_int = 3; -pub const NET_RT_STATS: ::c_int = 4; -pub const NET_RT_TABLE: ::c_int = 5; -pub const NET_RT_IFNAMES: ::c_int = 6; -#[doc(hidden)] -pub const NET_RT_MAXID: ::c_int = 7; - -pub const IPV6_JOIN_GROUP: ::c_int = 12; -pub const IPV6_LEAVE_GROUP: ::c_int = 13; - -pub const PF_ROUTE: ::c_int = AF_ROUTE; -pub const PF_ECMA: ::c_int = AF_ECMA; -pub const PF_ENCAP: ::c_int = AF_ENCAP; -pub const PF_SIP: ::c_int = AF_SIP; -pub const PF_KEY: ::c_int = AF_KEY; -pub const PF_BPF: ::c_int = pseudo_AF_HDRCMPLT; -pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH; -pub const PF_MPLS: ::c_int = AF_MPLS; -pub const PF_PFLOW: ::c_int = pseudo_AF_PFLOW; -pub const PF_PIPEX: ::c_int = pseudo_AF_PIPEX; -#[doc(hidden)] -pub const PF_MAX: ::c_int = AF_MAX; - -pub const SCM_TIMESTAMP: ::c_int = 0x04; - -pub const O_DSYNC : ::c_int = 128; - -pub const MAP_RENAME : ::c_int = 0x0000; -pub const MAP_NORESERVE : ::c_int = 0x0000; -pub const MAP_HASSEMAPHORE : ::c_int = 0x0000; - -pub const EIPSEC : ::c_int = 82; -pub const ENOMEDIUM : ::c_int = 85; -pub const EMEDIUMTYPE : ::c_int = 86; - -pub const EAI_BADFLAGS: ::c_int = -1; -pub const EAI_NONAME: ::c_int = -2; -pub const EAI_AGAIN: ::c_int = -3; -pub const EAI_FAIL: ::c_int = -4; -pub const EAI_NODATA: ::c_int = -5; -pub const EAI_FAMILY: ::c_int = -6; -pub const EAI_SOCKTYPE: ::c_int = -7; -pub const EAI_SERVICE: ::c_int = -8; -pub const EAI_MEMORY: ::c_int = -10; -pub const EAI_SYSTEM: ::c_int = -11; -pub const EAI_OVERFLOW: ::c_int = -14; - -pub const RUSAGE_THREAD: ::c_int = 1; - -pub const MAP_COPY : ::c_int = 0x0002; -pub const MAP_NOEXTEND : ::c_int = 0x0000; - -pub const _PC_LINK_MAX : ::c_int = 1; -pub const _PC_MAX_CANON : ::c_int = 2; -pub const _PC_MAX_INPUT : ::c_int = 3; -pub const _PC_NAME_MAX : ::c_int = 4; -pub const _PC_PATH_MAX : ::c_int = 5; -pub const _PC_PIPE_BUF : ::c_int = 6; -pub const _PC_CHOWN_RESTRICTED : ::c_int = 7; -pub const _PC_NO_TRUNC : ::c_int = 8; -pub const _PC_VDISABLE : ::c_int = 9; -pub const _PC_2_SYMLINKS : ::c_int = 10; -pub const _PC_ALLOC_SIZE_MIN : ::c_int = 11; -pub const _PC_ASYNC_IO : ::c_int = 12; -pub const _PC_FILESIZEBITS : ::c_int = 13; -pub const _PC_PRIO_IO : ::c_int = 14; -pub const _PC_REC_INCR_XFER_SIZE : ::c_int = 15; -pub const _PC_REC_MAX_XFER_SIZE : ::c_int = 16; -pub const _PC_REC_MIN_XFER_SIZE : ::c_int = 17; -pub const _PC_REC_XFER_ALIGN : ::c_int = 18; -pub const _PC_SYMLINK_MAX : ::c_int = 19; -pub const _PC_SYNC_IO : ::c_int = 20; -pub const _PC_TIMESTAMP_RESOLUTION : ::c_int = 21; - -pub const _SC_CLK_TCK : ::c_int = 3; -pub const _SC_SEM_NSEMS_MAX : ::c_int = 31; -pub const _SC_SEM_VALUE_MAX : ::c_int = 32; -pub const _SC_HOST_NAME_MAX : ::c_int = 33; -pub const _SC_MONOTONIC_CLOCK : ::c_int = 34; -pub const _SC_2_PBS : ::c_int = 35; -pub const _SC_2_PBS_ACCOUNTING : ::c_int = 36; -pub const _SC_2_PBS_CHECKPOINT : ::c_int = 37; -pub const _SC_2_PBS_LOCATE : ::c_int = 38; -pub const _SC_2_PBS_MESSAGE : ::c_int = 39; -pub const _SC_2_PBS_TRACK : ::c_int = 40; -pub const _SC_ADVISORY_INFO : ::c_int = 41; -pub const _SC_AIO_LISTIO_MAX : ::c_int = 42; -pub const _SC_AIO_MAX : ::c_int = 43; -pub const _SC_AIO_PRIO_DELTA_MAX : ::c_int = 44; -pub const _SC_ASYNCHRONOUS_IO : ::c_int = 45; -pub const _SC_ATEXIT_MAX : ::c_int = 46; -pub const _SC_BARRIERS : ::c_int = 47; -pub const _SC_CLOCK_SELECTION : ::c_int = 48; -pub const _SC_CPUTIME : ::c_int = 49; -pub const _SC_DELAYTIMER_MAX : ::c_int = 50; -pub const _SC_IOV_MAX : ::c_int = 51; -pub const _SC_IPV6 : ::c_int = 52; -pub const _SC_MAPPED_FILES : ::c_int = 53; -pub const _SC_MEMLOCK : ::c_int = 54; -pub const _SC_MEMLOCK_RANGE : ::c_int = 55; -pub const _SC_MEMORY_PROTECTION : ::c_int = 56; -pub const _SC_MESSAGE_PASSING : ::c_int = 57; -pub const _SC_MQ_OPEN_MAX : ::c_int = 58; -pub const _SC_MQ_PRIO_MAX : ::c_int = 59; -pub const _SC_PRIORITIZED_IO : ::c_int = 60; -pub const _SC_PRIORITY_SCHEDULING : ::c_int = 61; -pub const _SC_RAW_SOCKETS : ::c_int = 62; -pub const _SC_READER_WRITER_LOCKS : ::c_int = 63; -pub const _SC_REALTIME_SIGNALS : ::c_int = 64; -pub const _SC_REGEXP : ::c_int = 65; -pub const _SC_RTSIG_MAX : ::c_int = 66; -pub const _SC_SEMAPHORES : ::c_int = 67; -pub const _SC_SHARED_MEMORY_OBJECTS : ::c_int = 68; -pub const _SC_SHELL : ::c_int = 69; -pub const _SC_SIGQUEUE_MAX : ::c_int = 70; -pub const _SC_SPAWN : ::c_int = 71; -pub const _SC_SPIN_LOCKS : ::c_int = 72; -pub const _SC_SPORADIC_SERVER : ::c_int = 73; -pub const _SC_SS_REPL_MAX : ::c_int = 74; -pub const _SC_SYNCHRONIZED_IO : ::c_int = 75; -pub const _SC_SYMLOOP_MAX : ::c_int = 76; -pub const _SC_THREAD_ATTR_STACKADDR : ::c_int = 77; -pub const _SC_THREAD_ATTR_STACKSIZE : ::c_int = 78; -pub const _SC_THREAD_CPUTIME : ::c_int = 79; -pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : ::c_int = 80; -pub const _SC_THREAD_KEYS_MAX : ::c_int = 81; -pub const _SC_THREAD_PRIO_INHERIT : ::c_int = 82; -pub const _SC_THREAD_PRIO_PROTECT : ::c_int = 83; -pub const _SC_THREAD_PRIORITY_SCHEDULING : ::c_int = 84; -pub const _SC_THREAD_PROCESS_SHARED : ::c_int = 85; -pub const _SC_THREAD_ROBUST_PRIO_INHERIT : ::c_int = 86; -pub const _SC_THREAD_ROBUST_PRIO_PROTECT : ::c_int = 87; -pub const _SC_THREAD_SPORADIC_SERVER : ::c_int = 88; -pub const _SC_THREAD_STACK_MIN : ::c_int = 89; -pub const _SC_THREAD_THREADS_MAX : ::c_int = 90; -pub const _SC_THREADS : ::c_int = 91; -pub const _SC_TIMEOUTS : ::c_int = 92; -pub const _SC_TIMER_MAX : ::c_int = 93; -pub const _SC_TIMERS : ::c_int = 94; -pub const _SC_TRACE : ::c_int = 95; -pub const _SC_TRACE_EVENT_FILTER : ::c_int = 96; -pub const _SC_TRACE_EVENT_NAME_MAX : ::c_int = 97; -pub const _SC_TRACE_INHERIT : ::c_int = 98; -pub const _SC_TRACE_LOG : ::c_int = 99; -pub const _SC_GETGR_R_SIZE_MAX : ::c_int = 100; -pub const _SC_GETPW_R_SIZE_MAX : ::c_int = 101; -pub const _SC_LOGIN_NAME_MAX : ::c_int = 102; -pub const _SC_THREAD_SAFE_FUNCTIONS : ::c_int = 103; -pub const _SC_TRACE_NAME_MAX : ::c_int = 104; -pub const _SC_TRACE_SYS_MAX : ::c_int = 105; -pub const _SC_TRACE_USER_EVENT_MAX : ::c_int = 106; -pub const _SC_TTY_NAME_MAX : ::c_int = 107; -pub const _SC_TYPED_MEMORY_OBJECTS : ::c_int = 108; -pub const _SC_V6_ILP32_OFF32 : ::c_int = 109; -pub const _SC_V6_ILP32_OFFBIG : ::c_int = 110; -pub const _SC_V6_LP64_OFF64 : ::c_int = 111; -pub const _SC_V6_LPBIG_OFFBIG : ::c_int = 112; -pub const _SC_V7_ILP32_OFF32 : ::c_int = 113; -pub const _SC_V7_ILP32_OFFBIG : ::c_int = 114; -pub const _SC_V7_LP64_OFF64 : ::c_int = 115; -pub const _SC_V7_LPBIG_OFFBIG : ::c_int = 116; -pub const _SC_XOPEN_CRYPT : ::c_int = 117; -pub const _SC_XOPEN_ENH_I18N : ::c_int = 118; -pub const _SC_XOPEN_LEGACY : ::c_int = 119; -pub const _SC_XOPEN_REALTIME : ::c_int = 120; -pub const _SC_XOPEN_REALTIME_THREADS : ::c_int = 121; -pub const _SC_XOPEN_STREAMS : ::c_int = 122; -pub const _SC_XOPEN_UNIX : ::c_int = 123; -pub const _SC_XOPEN_UUCP : ::c_int = 124; -pub const _SC_XOPEN_VERSION : ::c_int = 125; -pub const _SC_PHYS_PAGES : ::c_int = 500; -pub const _SC_AVPHYS_PAGES : ::c_int = 501; -pub const _SC_NPROCESSORS_CONF : ::c_int = 502; -pub const _SC_NPROCESSORS_ONLN : ::c_int = 503; - -pub const FD_SETSIZE: usize = 1024; - -pub const ST_NOSUID: ::c_ulong = 2; - -pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _; -pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; -pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; - -pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1; -pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; -pub const PTHREAD_MUTEX_NORMAL: ::c_int = 3; -pub const PTHREAD_MUTEX_STRICT_NP: ::c_int = 4; -pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_STRICT_NP; - -pub const EVFILT_AIO: ::int16_t = -3; -pub const EVFILT_PROC: ::int16_t = -5; -pub const EVFILT_READ: ::int16_t = -1; -pub const EVFILT_SIGNAL: ::int16_t = -6; -pub const EVFILT_TIMER: ::int16_t = -7; -pub const EVFILT_VNODE: ::int16_t = -4; -pub const EVFILT_WRITE: ::int16_t = -2; - -pub const EV_ADD: ::uint16_t = 0x1; -pub const EV_DELETE: ::uint16_t = 0x2; -pub const EV_ENABLE: ::uint16_t = 0x4; -pub const EV_DISABLE: ::uint16_t = 0x8; -pub const EV_ONESHOT: ::uint16_t = 0x10; -pub const EV_CLEAR: ::uint16_t = 0x20; -pub const EV_RECEIPT: ::uint16_t = 0x40; -pub const EV_DISPATCH: ::uint16_t = 0x80; -pub const EV_FLAG1: ::uint16_t = 0x2000; -pub const EV_ERROR: ::uint16_t = 0x4000; -pub const EV_EOF: ::uint16_t = 0x8000; -pub const EV_SYSFLAGS: ::uint16_t = 0xf000; - -pub const NOTE_LOWAT: ::uint32_t = 0x00000001; -pub const NOTE_EOF: ::uint32_t = 0x00000002; -pub const NOTE_DELETE: ::uint32_t = 0x00000001; -pub const NOTE_WRITE: ::uint32_t = 0x00000002; -pub const NOTE_EXTEND: ::uint32_t = 0x00000004; -pub const NOTE_ATTRIB: ::uint32_t = 0x00000008; -pub const NOTE_LINK: ::uint32_t = 0x00000010; -pub const NOTE_RENAME: ::uint32_t = 0x00000020; -pub const NOTE_REVOKE: ::uint32_t = 0x00000040; -pub const NOTE_TRUNCATE: ::uint32_t = 0x00000080; -pub const NOTE_EXIT: ::uint32_t = 0x80000000; -pub const NOTE_FORK: ::uint32_t = 0x40000000; -pub const NOTE_EXEC: ::uint32_t = 0x20000000; -pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff; -pub const NOTE_PCTRLMASK: ::uint32_t = 0xf0000000; -pub const NOTE_TRACK: ::uint32_t = 0x00000001; -pub const NOTE_TRACKERR: ::uint32_t = 0x00000002; -pub const NOTE_CHILD: ::uint32_t = 0x00000004; - -pub const TMP_MAX : ::c_uint = 0x7fffffff; - -pub const NI_MAXHOST: ::size_t = 256; - -pub const RTLD_LOCAL: ::c_int = 0; -pub const CTL_MAXNAME: ::c_int = 12; -pub const CTLTYPE_NODE: ::c_int = 1; -pub const CTLTYPE_INT: ::c_int = 2; -pub const CTLTYPE_STRING: ::c_int = 3; -pub const CTLTYPE_QUAD: ::c_int = 4; -pub const CTLTYPE_STRUCT: ::c_int = 5; -pub const CTL_UNSPEC: ::c_int = 0; -pub const CTL_KERN: ::c_int = 1; -pub const CTL_VM: ::c_int = 2; -pub const CTL_FS: ::c_int = 3; -pub const CTL_NET: ::c_int = 4; -pub const CTL_DEBUG: ::c_int = 5; -pub const CTL_HW: ::c_int = 6; -pub const CTL_MACHDEP: ::c_int = 7; -pub const CTL_DDB: ::c_int = 9; -pub const CTL_VFS: ::c_int = 10; -pub const CTL_MAXID: ::c_int = 11; -pub const HW_NCPUONLINE: ::c_int = 25; -pub const KERN_OSTYPE: ::c_int = 1; -pub const KERN_OSRELEASE: ::c_int = 2; -pub const KERN_OSREV: ::c_int = 3; -pub const KERN_VERSION: ::c_int = 4; -pub const KERN_MAXVNODES: ::c_int = 5; -pub const KERN_MAXPROC: ::c_int = 6; -pub const KERN_MAXFILES: ::c_int = 7; -pub const KERN_ARGMAX: ::c_int = 8; -pub const KERN_SECURELVL: ::c_int = 9; -pub const KERN_HOSTNAME: ::c_int = 10; -pub const KERN_HOSTID: ::c_int = 11; -pub const KERN_CLOCKRATE: ::c_int = 12; -pub const KERN_PROF: ::c_int = 16; -pub const KERN_POSIX1: ::c_int = 17; -pub const KERN_NGROUPS: ::c_int = 18; -pub const KERN_JOB_CONTROL: ::c_int = 19; -pub const KERN_SAVED_IDS: ::c_int = 20; -pub const KERN_BOOTTIME: ::c_int = 21; -pub const KERN_DOMAINNAME: ::c_int = 22; -pub const KERN_MAXPARTITIONS: ::c_int = 23; -pub const KERN_RAWPARTITION: ::c_int = 24; -pub const KERN_MAXTHREAD: ::c_int = 25; -pub const KERN_NTHREADS: ::c_int = 26; -pub const KERN_OSVERSION: ::c_int = 27; -pub const KERN_SOMAXCONN: ::c_int = 28; -pub const KERN_SOMINCONN: ::c_int = 29; -pub const KERN_USERMOUNT: ::c_int = 30; -pub const KERN_NOSUIDCOREDUMP: ::c_int = 32; -pub const KERN_FSYNC: ::c_int = 33; -pub const KERN_SYSVMSG: ::c_int = 34; -pub const KERN_SYSVSEM: ::c_int = 35; -pub const KERN_SYSVSHM: ::c_int = 36; -pub const KERN_ARND: ::c_int = 37; -pub const KERN_MSGBUFSIZE: ::c_int = 38; -pub const KERN_MALLOCSTATS: ::c_int = 39; -pub const KERN_CPTIME: ::c_int = 40; -pub const KERN_NCHSTATS: ::c_int = 41; -pub const KERN_FORKSTAT: ::c_int = 42; -pub const KERN_NSELCOLL: ::c_int = 43; -pub const KERN_TTY: ::c_int = 44; -pub const KERN_CCPU: ::c_int = 45; -pub const KERN_FSCALE: ::c_int = 46; -pub const KERN_NPROCS: ::c_int = 47; -pub const KERN_MSGBUF: ::c_int = 48; -pub const KERN_POOL: ::c_int = 49; -pub const KERN_STACKGAPRANDOM: ::c_int = 50; -pub const KERN_SYSVIPC_INFO: ::c_int = 51; -pub const KERN_SPLASSERT: ::c_int = 54; -pub const KERN_PROC_ARGS: ::c_int = 55; -pub const KERN_NFILES: ::c_int = 56; -pub const KERN_TTYCOUNT: ::c_int = 57; -pub const KERN_NUMVNODES: ::c_int = 58; -pub const KERN_MBSTAT: ::c_int = 59; -pub const KERN_SEMINFO: ::c_int = 61; -pub const KERN_SHMINFO: ::c_int = 62; -pub const KERN_INTRCNT: ::c_int = 63; -pub const KERN_WATCHDOG: ::c_int = 64; -pub const KERN_PROC: ::c_int = 66; -pub const KERN_MAXCLUSTERS: ::c_int = 67; -pub const KERN_EVCOUNT: ::c_int = 68; -pub const KERN_TIMECOUNTER: ::c_int = 69; -pub const KERN_MAXLOCKSPERUID: ::c_int = 70; -pub const KERN_CPTIME2: ::c_int = 71; -pub const KERN_CACHEPCT: ::c_int = 72; -pub const KERN_FILE: ::c_int = 73; -pub const KERN_CONSDEV: ::c_int = 75; -pub const KERN_NETLIVELOCKS: ::c_int = 76; -pub const KERN_POOL_DEBUG: ::c_int = 77; -pub const KERN_PROC_CWD: ::c_int = 78; -pub const KERN_PROC_NOBROADCASTKILL: ::c_int = 79; -pub const KERN_PROC_VMMAP: ::c_int = 80; -pub const KERN_GLOBAL_PTRACE: ::c_int = 81; -pub const KERN_CONSBUFSIZE: ::c_int = 82; -pub const KERN_CONSBUF: ::c_int = 83; -pub const KERN_AUDIO: ::c_int = 84; -pub const KERN_CPUSTATS: ::c_int = 85; -pub const KERN_MAXID: ::c_int = 86; -pub const KERN_PROC_ALL: ::c_int = 0; -pub const KERN_PROC_PID: ::c_int = 1; -pub const KERN_PROC_PGRP: ::c_int = 2; -pub const KERN_PROC_SESSION: ::c_int = 3; -pub const KERN_PROC_TTY: ::c_int = 4; -pub const KERN_PROC_UID: ::c_int = 5; -pub const KERN_PROC_RUID: ::c_int = 6; -pub const KERN_PROC_KTHREAD: ::c_int = 7; -pub const KERN_PROC_SHOW_THREADS: ::c_int = 0x40000000; -pub const KERN_SYSVIPC_MSG_INFO: ::c_int = 1; -pub const KERN_SYSVIPC_SEM_INFO: ::c_int = 2; -pub const KERN_SYSVIPC_SHM_INFO: ::c_int = 3; -pub const KERN_PROC_ARGV: ::c_int = 1; -pub const KERN_PROC_NARGV: ::c_int = 2; -pub const KERN_PROC_ENV: ::c_int = 3; -pub const KERN_PROC_NENV: ::c_int = 4; -pub const KI_NGROUPS: ::c_int = 16; -pub const KI_MAXCOMLEN: ::c_int = 24; -pub const KI_WMESGLEN: ::c_int = 8; -pub const KI_MAXLOGNAME: ::c_int = 32; -pub const KI_EMULNAMELEN: ::c_int = 8; - -pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS; -pub const OLCUC: ::tcflag_t = 0x20; -pub const ONOCR: ::tcflag_t = 0x40; -pub const ONLRET: ::tcflag_t = 0x80; - -pub const SOCK_CLOEXEC: ::c_int = 0x8000; -pub const SOCK_NONBLOCK: ::c_int = 0x4000; -pub const SOCK_DNS: ::c_int = 0x1000; - -pub const PTRACE_FORK: ::c_int = 0x0002; - -pub const WCONTINUED: ::c_int = 8; - -f! { - pub fn WIFCONTINUED(status: ::c_int) -> bool { - status & 0o177777 == 0o177777 - } -} - -extern { - pub fn chflags(path: *const ::c_char, flags: ::c_uint) -> ::c_int; - pub fn fchflags(fd: ::c_int, flags: ::c_uint) -> ::c_int; - pub fn chflagsat(fd: ::c_int, path: *const ::c_char, flags: ::c_uint, - atflag: ::c_int) -> ::c_int; - pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; - pub fn getnameinfo(sa: *const ::sockaddr, - salen: ::socklen_t, - host: *mut ::c_char, - hostlen: ::size_t, - serv: *mut ::c_char, - servlen: ::size_t, - flags: ::c_int) -> ::c_int; - pub fn kevent(kq: ::c_int, - changelist: *const ::kevent, - nchanges: ::c_int, - eventlist: *mut ::kevent, - nevents: ::c_int, - timeout: *const ::timespec) -> ::c_int; - pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) - -> ::c_int; - pub fn pthread_main_np() -> ::c_int; - pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); - pub fn pthread_stackseg_np(thread: ::pthread_t, - sinfo: *mut ::stack_t) -> ::c_int; - pub fn sysctl(name: *const ::c_int, - namelen: ::c_uint, - oldp: *mut ::c_void, - oldlenp: *mut ::size_t, - newp: *mut ::c_void, - newlen: ::size_t) - -> ::c_int; - pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; - pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int; - pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int; - pub fn ptrace(request: ::c_int, - pid: ::pid_t, - addr: caddr_t, - data: ::c_int) -> ::c_int; -} - -cfg_if! { - if #[cfg(target_os = "openbsd")] { - mod openbsd; - pub use self::openbsd::*; - } else { - // Unknown target_os - } -} diff --git a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/aarch64.rs b/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/aarch64.rs deleted file mode 100644 index 6a8cbb5..0000000 --- a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/aarch64.rs +++ /dev/null @@ -1,14 +0,0 @@ -pub type c_long = i64; -pub type c_ulong = u64; -pub type c_char = u8; - -// should be pub(crate), but that requires Rust 1.18.0 -cfg_if! { - if #[cfg(libc_const_size_of)] { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; - } else { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = 8 - 1; - } -} diff --git a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs b/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs deleted file mode 100644 index c168711..0000000 --- a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs +++ /dev/null @@ -1,497 +0,0 @@ -s! { - pub struct glob_t { - pub gl_pathc: ::size_t, - pub gl_matchc: ::size_t, - pub gl_offs: ::size_t, - pub gl_flags: ::c_int, - pub gl_pathv: *mut *mut ::c_char, - __unused1: *mut ::c_void, - __unused2: *mut ::c_void, - __unused3: *mut ::c_void, - __unused4: *mut ::c_void, - __unused5: *mut ::c_void, - __unused6: *mut ::c_void, - __unused7: *mut ::c_void, - } - - pub struct lconv { - pub decimal_point: *mut ::c_char, - pub thousands_sep: *mut ::c_char, - pub grouping: *mut ::c_char, - pub int_curr_symbol: *mut ::c_char, - pub currency_symbol: *mut ::c_char, - pub mon_decimal_point: *mut ::c_char, - pub mon_thousands_sep: *mut ::c_char, - pub mon_grouping: *mut ::c_char, - pub positive_sign: *mut ::c_char, - pub negative_sign: *mut ::c_char, - pub int_frac_digits: ::c_char, - pub frac_digits: ::c_char, - pub p_cs_precedes: ::c_char, - pub p_sep_by_space: ::c_char, - pub n_cs_precedes: ::c_char, - pub n_sep_by_space: ::c_char, - pub p_sign_posn: ::c_char, - pub n_sign_posn: ::c_char, - pub int_p_cs_precedes: ::c_char, - pub int_p_sep_by_space: ::c_char, - pub int_n_cs_precedes: ::c_char, - pub int_n_sep_by_space: ::c_char, - pub int_p_sign_posn: ::c_char, - pub int_n_sign_posn: ::c_char, - } - - pub struct ufs_args { - pub fspec: *mut ::c_char, - pub export_info: export_args, - } - - pub struct mfs_args { - pub fspec: *mut ::c_char, - pub export_info: export_args, - // https://github.com/openbsd/src/blob/master/sys/sys/types.h#L134 - pub base: *mut ::c_char, - pub size: ::c_ulong, - } - - pub struct iso_args { - pub fspec: *mut ::c_char, - pub export_info: export_args, - pub flags: ::c_int, - pub sess: ::c_int, - } - - pub struct nfs_args { - pub version: ::c_int, - pub addr: *mut ::sockaddr, - pub addrlen: ::c_int, - pub sotype: ::c_int, - pub proto: ::c_int, - pub fh: *mut ::c_uchar, - pub fhsize: ::c_int, - pub flags: ::c_int, - pub wsize: ::c_int, - pub rsize: ::c_int, - pub readdirsize: ::c_int, - pub timeo: ::c_int, - pub retrans: ::c_int, - pub maxgrouplist: ::c_int, - pub readahead: ::c_int, - pub leaseterm: ::c_int, - pub deadthresh: ::c_int, - pub hostname: *mut ::c_char, - pub acregmin: ::c_int, - pub acregmax: ::c_int, - pub acdirmin: ::c_int, - pub acdirmax: ::c_int, - } - - pub struct msdosfs_args { - pub fspec: *mut ::c_char, - pub export_info: export_args, - pub uid: ::uid_t, - pub gid: ::gid_t, - pub mask: ::mode_t, - pub flags: ::c_int, - } - - pub struct ntfs_args { - pub fspec: *mut ::c_char, - pub export_info: export_args, - pub uid: ::uid_t, - pub gid: ::gid_t, - pub mode: ::mode_t, - pub flag: ::c_ulong, - } - - pub struct udf_args { - pub fspec: *mut ::c_char, - pub lastblock: ::uint32_t, - } - - pub struct tmpfs_args { - pub ta_version: ::c_int, - pub ta_nodes_max: ::ino_t, - pub ta_size_max: ::off_t, - pub ta_root_uid: ::uid_t, - pub ta_root_gid: ::gid_t, - pub ta_root_mode: ::mode_t, - } - - pub struct fusefs_args { - pub name: *mut ::c_char, - pub fd: ::c_int, - pub max_read: ::c_int, - pub allow_other: ::c_int, - } - - pub struct xucred { - pub cr_uid: ::uid_t, - pub cr_gid: ::gid_t, - pub cr_ngroups: ::c_short, - //https://github.com/openbsd/src/blob/master/sys/sys/syslimits.h#L44 - pub cr_groups: [::gid_t; 16], - } - - pub struct export_args { - pub ex_flags: ::c_int, - pub ex_root: ::uid_t, - pub ex_anon: xucred, - pub ex_addr: *mut ::sockaddr, - pub ex_addrlen: ::c_int, - pub ex_mask: *mut ::sockaddr, - pub ex_masklen: ::c_int, - } -} - -s_no_extra_traits! { - pub union mount_info { - pub ufs_args: ufs_args, - pub mfs_args: mfs_args, - pub nfs_args: nfs_args, - pub iso_args: iso_args, - pub msdosfs_args: msdosfs_args, - pub ntfs_args: ntfs_args, - pub tmpfs_args: tmpfs_args, - align: [::c_char; 160], - } -} - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for mount_info { - fn eq(&self, other: &mount_info) -> bool { - unsafe { - self.align - .iter() - .zip(other.align.iter()) - .all(|(a,b)| a == b) - } - } - } - - impl Eq for mount_info { } - - impl ::fmt::Debug for mount_info { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("mount_info") - // FIXME: .field("align", &self.align) - .finish() - } - } - - impl ::hash::Hash for mount_info { - fn hash(&self, state: &mut H) { - unsafe { self.align.hash(state) }; - } - } - } -} - -cfg_if! { - if #[cfg(libc_union)] { - s_no_extra_traits! { - // This type uses the union mount_info: - pub struct statfs { - pub f_flags: ::uint32_t, - pub f_bsize: ::uint32_t, - pub f_iosize: ::uint32_t, - pub f_blocks: ::uint64_t, - pub f_bfree: ::uint64_t, - pub f_bavail: ::int64_t, - pub f_files: ::uint64_t, - pub f_ffree: ::uint64_t, - pub f_favail: ::int64_t, - pub f_syncwrites: ::uint64_t, - pub f_syncreads: ::uint64_t, - pub f_asyncwrites: ::uint64_t, - pub f_asyncreads: ::uint64_t, - pub f_fsid: ::fsid_t, - pub f_namemax: ::uint32_t, - pub f_owner: ::uid_t, - pub f_ctime: ::uint64_t, - pub f_fstypename: [::c_char; 16], - pub f_mntonname: [::c_char; 90], - pub f_mntfromname: [::c_char; 90], - pub f_mntfromspec: [::c_char; 90], - pub mount_info: mount_info, - } - } - - cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_flags == other.f_flags - && self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_favail == other.f_favail - && self.f_syncwrites == other.f_syncwrites - && self.f_syncreads == other.f_syncreads - && self.f_asyncwrites == other.f_asyncwrites - && self.f_asyncreads == other.f_asyncreads - && self.f_fsid == other.f_fsid - && self.f_namemax == other.f_namemax - && self.f_owner == other.f_owner - && self.f_ctime == other.f_ctime - && self.f_fstypename - .iter() - .zip(other.f_fstypename.iter()) - .all(|(a,b)| a == b) - && self.f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a,b)| a == b) - && self.f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a,b)| a == b) - && self.f_mntfromspec - .iter() - .zip(other.f_mntfromspec.iter()) - .all(|(a,b)| a == b) - && self.mount_info == other.mount_info - } - } - - impl Eq for statfs { } - - impl ::fmt::Debug for statfs { - fn fmt(&self, f: &mut ::fmt::Formatter) - -> ::fmt::Result { - f.debug_struct("statfs") - .field("f_flags", &self.f_flags) - .field("f_bsize", &self.f_bsize) - .field("f_iosize", &self.f_iosize) - .field("f_blocks", &self.f_blocks) - .field("f_bfree", &self.f_bfree) - .field("f_bavail", &self.f_bavail) - .field("f_files", &self.f_files) - .field("f_ffree", &self.f_ffree) - .field("f_favail", &self.f_favail) - .field("f_syncwrites", &self.f_syncwrites) - .field("f_syncreads", &self.f_syncreads) - .field("f_asyncwrites", &self.f_asyncwrites) - .field("f_asyncreads", &self.f_asyncreads) - .field("f_fsid", &self.f_fsid) - .field("f_namemax", &self.f_namemax) - .field("f_owner", &self.f_owner) - .field("f_ctime", &self.f_ctime) - // FIXME: .field("f_fstypename", &self.f_fstypename) - // FIXME: .field("f_mntonname", &self.f_mntonname) - // FIXME: .field("f_mntfromname", &self.f_mntfromname) - // FIXME: .field("f_mntfromspec", &self.f_mntfromspec) - .field("mount_info", &self.mount_info) - .finish() - } - } - - impl ::hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_flags.hash(state); - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_favail.hash(state); - self.f_syncwrites.hash(state); - self.f_syncreads.hash(state); - self.f_asyncwrites.hash(state); - self.f_asyncreads.hash(state); - self.f_fsid.hash(state); - self.f_namemax.hash(state); - self.f_owner.hash(state); - self.f_ctime.hash(state); - self.f_fstypename.hash(state); - self.f_mntonname.hash(state); - self.f_mntfromname.hash(state); - self.f_mntfromspec.hash(state); - self.mount_info.hash(state); - } - } - } - } - } -} - -//https://github.com/openbsd/src/blob/master/sys/sys/mount.h -pub const ISOFSMNT_NORRIP: ::c_int = 0x1; // disable Rock Ridge Ext -pub const ISOFSMNT_GENS: ::c_int = 0x2; // enable generation numbers -pub const ISOFSMNT_EXTATT: ::c_int = 0x4; // enable extended attr -pub const ISOFSMNT_NOJOLIET: ::c_int = 0x8; // disable Joliet Ext -pub const ISOFSMNT_SESS: ::c_int = 0x10; // use iso_args.sess - -pub const NFS_ARGSVERSION: ::c_int = 4; // change when nfs_args changes - -pub const NFSMNT_RESVPORT: ::c_int = 0; // always use reserved ports -pub const NFSMNT_SOFT: ::c_int = 0x1; // soft mount (hard is default) -pub const NFSMNT_WSIZE: ::c_int = 0x2; // set write size -pub const NFSMNT_RSIZE: ::c_int = 0x4; // set read size -pub const NFSMNT_TIMEO: ::c_int = 0x8; // set initial timeout -pub const NFSMNT_RETRANS: ::c_int = 0x10; // set number of request retries -pub const NFSMNT_MAXGRPS: ::c_int = 0x20; // set maximum grouplist size -pub const NFSMNT_INT: ::c_int = 0x40; // allow interrupts on hard mount -pub const NFSMNT_NOCONN: ::c_int = 0x80; // Don't Connect the socket -pub const NFSMNT_NQNFS: ::c_int = 0x100; // Use Nqnfs protocol -pub const NFSMNT_NFSV3: ::c_int = 0x200; // Use NFS Version 3 protocol -pub const NFSMNT_KERB: ::c_int = 0x400; // Use Kerberos authentication -pub const NFSMNT_DUMBTIMR: ::c_int = 0x800; // Don't estimate rtt dynamically -pub const NFSMNT_LEASETERM: ::c_int = 0x1000; // set lease term (nqnfs) -pub const NFSMNT_READAHEAD: ::c_int = 0x2000; // set read ahead -pub const NFSMNT_DEADTHRESH: ::c_int = 0x4000; // set dead server retry thresh -pub const NFSMNT_NOAC: ::c_int = 0x8000; // disable attribute cache -pub const NFSMNT_RDIRPLUS: ::c_int = 0x10000; // Use Readdirplus for V3 -pub const NFSMNT_READDIRSIZE: ::c_int = 0x20000; // Set readdir size - -/* Flags valid only in mount syscall arguments */ -pub const NFSMNT_ACREGMIN: ::c_int = 0x40000; // acregmin field valid -pub const NFSMNT_ACREGMAX: ::c_int = 0x80000; // acregmax field valid -pub const NFSMNT_ACDIRMIN: ::c_int = 0x100000; // acdirmin field valid -pub const NFSMNT_ACDIRMAX: ::c_int = 0x200000; // acdirmax field valid - -/* Flags valid only in kernel */ -pub const NFSMNT_INTERNAL: ::c_int = 0xfffc0000; // Bits set internally -pub const NFSMNT_HASWRITEVERF: ::c_int = 0x40000; // Has write verifier for V3 -pub const NFSMNT_GOTPATHCONF: ::c_int = 0x80000; // Got the V3 pathconf info -pub const NFSMNT_GOTFSINFO: ::c_int = 0x100000; // Got the V3 fsinfo -pub const NFSMNT_MNTD: ::c_int = 0x200000; // Mnt server for mnt point -pub const NFSMNT_DISMINPROG: ::c_int = 0x400000; // Dismount in progress -pub const NFSMNT_DISMNT: ::c_int = 0x800000; // Dismounted -pub const NFSMNT_SNDLOCK: ::c_int = 0x1000000; // Send socket lock -pub const NFSMNT_WANTSND: ::c_int = 0x2000000; // Want above -pub const NFSMNT_RCVLOCK: ::c_int = 0x4000000; // Rcv socket lock -pub const NFSMNT_WANTRCV: ::c_int = 0x8000000; // Want above -pub const NFSMNT_WAITAUTH: ::c_int = 0x10000000; // Wait for authentication -pub const NFSMNT_HASAUTH: ::c_int = 0x20000000; // Has authenticator -pub const NFSMNT_WANTAUTH: ::c_int = 0x40000000; // Wants an authenticator -pub const NFSMNT_AUTHERR: ::c_int = 0x80000000; // Authentication error - -pub const MSDOSFSMNT_SHORTNAME: ::c_int = 0x1; // Force old DOS short names only -pub const MSDOSFSMNT_LONGNAME: ::c_int = 0x2; // Force Win'95 long names -pub const MSDOSFSMNT_NOWIN95: ::c_int = 0x4; // Completely ignore Win95 entries - -pub const NTFS_MFLAG_CASEINS: ::c_int = 0x1; -pub const NTFS_MFLAG_ALLNAMES: ::c_int = 0x2; - -pub const TMPFS_ARGS_VERSION: ::c_int = 1; - -pub const MAP_STACK : ::c_int = 0x4000; - -// https://github.com/openbsd/src/blob/master/sys/net/if.h#L187 -pub const IFF_UP: ::c_int = 0x1; // interface is up -pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid -pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging -pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net -pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link -pub const IFF_STATICARP: ::c_int = 0x20; // only static ARP -pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated -pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol -pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets -pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets -pub const IFF_OACTIVE: ::c_int = 0x400; // transmission in progress -pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions -pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit -pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit -pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit -pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast - -pub const PTHREAD_STACK_MIN : ::size_t = 4096; -pub const SIGSTKSZ : ::size_t = 28672; - -pub const PT_FIRSTMACH: ::c_int = 32; - -fn _ALIGN(p: usize) -> usize { - (p + _ALIGNBYTES) & !_ALIGNBYTES -} - -f! { - pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar { - (cmsg as *mut ::c_uchar) - .offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize) - } - - pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { - _ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length - } - - pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr) - -> *mut ::cmsghdr - { - if cmsg.is_null() { - return ::CMSG_FIRSTHDR(mhdr); - }; - let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) - + _ALIGN(::mem::size_of::<::cmsghdr>()); - let max = (*mhdr).msg_control as usize - + (*mhdr).msg_controllen as usize; - if next > max { - 0 as *mut ::cmsghdr - } else { - (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) - as *mut ::cmsghdr - } - } - - pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { - (_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize)) - as ::c_uint - } - - pub fn WSTOPSIG(status: ::c_int) -> ::c_int { - status >> 8 - } - - pub fn WIFSIGNALED(status: ::c_int) -> bool { - (status & 0o177) != 0o177 && (status & 0o177) != 0 - } - - pub fn WIFSTOPPED(status: ::c_int) -> bool { - (status & 0o177) == 0o177 - } -} - -extern { - pub fn accept4(s: ::c_int, addr: *mut ::sockaddr, - addrlen: *mut ::socklen_t, flags: ::c_int) -> ::c_int; - pub fn execvpe(file: *const ::c_char, argv: *const *const ::c_char, - envp: *const *const ::c_char) -> ::c_int; - pub fn pledge(promises: *const ::c_char, - execpromises: *const ::c_char) -> ::c_int; - pub fn strtonum(nptr: *const ::c_char, minval: ::c_longlong, - maxval: ::c_longlong, - errstr: *mut *const ::c_char) -> ::c_longlong; - pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int; -} - -cfg_if! { - if #[cfg(libc_union)] { - extern { - // these functions use statfs which uses the union mount_info: - pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; - pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; - } - } -} - -cfg_if! { - if #[cfg(target_arch = "x86")] { - mod x86; - pub use self::x86::*; - } else if #[cfg(target_arch = "x86_64")] { - mod x86_64; - pub use self::x86_64::*; - } else if #[cfg(target_arch = "aarch64")] { - mod aarch64; - pub use self::aarch64::*; - } else { - // Unknown target_arch - } -} diff --git a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86.rs b/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86.rs deleted file mode 100644 index 05538cd..0000000 --- a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86.rs +++ /dev/null @@ -1,14 +0,0 @@ -pub type c_long = i32; -pub type c_ulong = u32; -pub type c_char = i8; - -// should be pub(crate), but that requires Rust 1.18.0 -cfg_if! { - if #[cfg(libc_const_size_of)] { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; - } else { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = 4 - 1; - } -} diff --git a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs b/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs deleted file mode 100644 index 7daa9d8..0000000 --- a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs +++ /dev/null @@ -1,22 +0,0 @@ -use PT_FIRSTMACH; - -pub type c_long = i64; -pub type c_ulong = u64; -pub type c_char = i8; - -// should be pub(crate), but that requires Rust 1.18.0 -cfg_if! { - if #[cfg(libc_const_size_of)] { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; - } else { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = 8 - 1; - } -} - -pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0; -pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; -pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; -pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 3; -pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 4; diff --git a/libc/src/unix/haiku/mod.rs b/libc/src/unix/haiku/mod.rs index 26519a4..be9a6cf 100644 --- a/libc/src/unix/haiku/mod.rs +++ b/libc/src/unix/haiku/mod.rs @@ -770,6 +770,12 @@ pub const AF_NOTIFY: ::c_int = 8; pub const AF_LOCAL: ::c_int = 9; pub const AF_UNIX: ::c_int = AF_LOCAL; pub const AF_BLUETOOTH: ::c_int = 10; +#[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] pub const AF_MAX: ::c_int = 11; pub const IP_OPTIONS: ::c_int = 1; @@ -1209,6 +1215,11 @@ f! { } extern { + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, + buflen: ::size_t) -> ::c_int; + pub fn abs(i: ::c_int) -> ::c_int; pub fn atof(s: *const ::c_char) -> ::c_double; pub fn labs(i: ::c_long) -> ::c_long; @@ -1264,7 +1275,8 @@ extern { errno: ::c_int) -> ::c_int>, pglob: *mut ::glob_t) -> ::c_int; pub fn globfree(pglob: *mut ::glob_t); - + pub fn gettimeofday(tp: *mut ::timeval, + tz: *mut ::c_void) -> ::c_int; pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; diff --git a/libc/src/unix/hermit/mod.rs b/libc/src/unix/hermit/mod.rs index 288cc46..4bc03ef 100644 --- a/libc/src/unix/hermit/mod.rs +++ b/libc/src/unix/hermit/mod.rs @@ -964,6 +964,11 @@ f! { } extern { + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, + buflen: ::size_t) -> ::c_int; + pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, @@ -981,6 +986,8 @@ extern { pub fn clock_gettime(clock_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn gettimeofday(tp: *mut ::timeval, + tz: *mut ::c_void) -> ::c_int; pub fn getpwuid_r(uid: ::uid_t, pwd: *mut passwd, buf: *mut ::c_char, buflen: ::size_t, result: *mut *mut passwd) -> ::c_int; diff --git a/libc/src/unix/mod.rs b/libc/src/unix/mod.rs index 1565b63..efaad41 100644 --- a/libc/src/unix/mod.rs +++ b/libc/src/unix/mod.rs @@ -3,15 +3,6 @@ //! More functions and definitions can be found in the more specific modules //! according to the platform in question. -pub type int8_t = i8; -pub type int16_t = i16; -pub type int32_t = i32; -pub type int64_t = i64; -pub type uint8_t = u8; -pub type uint16_t = u16; -pub type uint32_t = u32; -pub type uint64_t = u64; - pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; @@ -45,12 +36,7 @@ impl ::Copy for DIR {} impl ::Clone for DIR { fn clone(&self) -> DIR { *self } } -#[cfg_attr(feature = "extra_traits", derive(Debug))] -pub enum locale_t {} -impl ::Copy for locale_t {} -impl ::Clone for locale_t { - fn clone(&self) -> locale_t { *self } -} +pub type locale_t = *mut :: c_void; s! { pub struct group { @@ -234,9 +220,9 @@ pub const GRPQUOTA: ::c_int = 1; pub const SIGIOT: ::c_int = 6; -pub const S_ISUID: ::c_int = 0x800; -pub const S_ISGID: ::c_int = 0x400; -pub const S_ISVTX: ::c_int = 0x200; +pub const S_ISUID: ::mode_t = 0x800; +pub const S_ISGID: ::mode_t = 0x400; +pub const S_ISVTX: ::mode_t = 0x200; pub const IF_NAMESIZE: ::size_t = 16; pub const IFNAMSIZ: ::size_t = IF_NAMESIZE; @@ -307,7 +293,7 @@ pub const ATF_USETRAILERS: ::c_int = 0x10; cfg_if! { if #[cfg(target_os = "l4re")] { // required libraries for L4Re are linked externally, ATM - } else if #[cfg(feature = "use_std")] { + } else if #[cfg(feature = "std")] { // cargo build, don't pull in anything extra as the libstd dep // already pulls in all libs. } else if #[cfg(target_env = "musl")] { @@ -580,14 +566,20 @@ extern { #[cfg_attr(target_os = "macos", link_name = "fstat$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")] - #[cfg_attr(target_os = "freebsd", link_name = "fstat@FBSD_1.0")] + #[cfg_attr( + all(target_os = "freebsd", not(freebsd12)), + link_name = "fstat@FBSD_1.0" + )] pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int; #[cfg_attr(target_os = "macos", link_name = "stat$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__stat50")] - #[cfg_attr(target_os = "freebsd", link_name = "stat@FBSD_1.0")] + #[cfg_attr( + all(target_os = "freebsd", not(freebsd12)), + link_name = "stat@FBSD_1.0" + )] pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int; pub fn pclose(stream: *mut ::FILE) -> ::c_int; @@ -621,11 +613,17 @@ extern { #[cfg_attr(target_os = "macos", link_name = "readdir$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__readdir30")] - #[cfg_attr(target_os = "freebsd", link_name = "readdir@FBSD_1.0")] + #[cfg_attr( + all(target_os = "freebsd", not(freebsd12)), + link_name = "readdir@FBSD_1.0" + )] pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent; #[cfg_attr(target_os = "macos", link_name = "readdir_r$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")] - #[cfg_attr(target_os = "freebsd", link_name = "readdir_r@FBSD_1.0")] + #[cfg_attr( + all(target_os = "freebsd", not(freebsd12)), + link_name = "readdir_r@FBSD_1.0" + )] /// The 64-bit libc on Solaris and illumos only has readdir_r. If a /// 32-bit Solaris or illumos target is ever created, it should use /// __posix_readdir_r. See libc(3LIB) on Solaris or illumos: @@ -654,7 +652,10 @@ extern { owner: ::uid_t, group: ::gid_t, flags: ::c_int) -> ::c_int; #[cfg_attr(target_os = "macos", link_name = "fstatat$INODE64")] - #[cfg_attr(target_os = "freebsd", link_name = "fstatat@FBSD_1.1")] + #[cfg_attr( + all(target_os = "freebsd", not(freebsd12)), + link_name = "fstatat@FBSD_1.1" + )] pub fn fstatat(dirfd: ::c_int, pathname: *const ::c_char, buf: *mut stat, flags: ::c_int) -> ::c_int; pub fn linkat(olddirfd: ::c_int, oldpath: *const ::c_char, @@ -809,7 +810,10 @@ extern { #[cfg_attr(target_os = "macos", link_name = "lstat$INODE64")] #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")] - #[cfg_attr(target_os = "freebsd", link_name = "lstat@FBSD_1.0")] + #[cfg_attr( + all(target_os = "freebsd", not(freebsd12)), + link_name = "lstat@FBSD_1.0" + )] pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), @@ -833,12 +837,6 @@ extern { pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "getrlimit$UNIX2003")] - pub fn getrlimit(resource: ::c_int, rlim: *mut rlimit) -> ::c_int; - #[cfg_attr(all(target_os = "macos", target_arch = "x86"), - link_name = "setrlimit$UNIX2003")] - pub fn setrlimit(resource: ::c_int, rlim: *const rlimit) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")] pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int; @@ -849,17 +847,6 @@ extern { pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int; - #[cfg_attr(target_os = "netbsd", link_name = "__gettimeofday50")] - #[deprecated( - since="0.2.54", - note= - "The signature of this function is incorrect. \ - If you are using it, please report that in the following issue \ - so that we can evaluate the impact of fixing it: \ - https://github.com/rust-lang/libc/issues/1338" - )] - pub fn gettimeofday(tp: *mut ::timeval, - tz: *mut ::c_void) -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__times13")] pub fn times(buf: *mut ::tms) -> ::clock_t; @@ -942,10 +929,6 @@ extern { pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> ::c_int; pub fn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t) -> ::c_int; - #[cfg_attr(all(target_os = "linux", not(target_env = "musl")), - link_name = "__xpg_strerror_r")] - pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, - buflen: ::size_t) -> ::c_int; #[cfg_attr(target_os = "illumos", link_name = "__xnet_getsockopt")] pub fn getsockopt(sockfd: ::c_int, @@ -1004,7 +987,10 @@ extern { pub fn difftime(time1: time_t, time0: time_t) -> ::c_double; #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")] - #[cfg_attr(target_os = "freebsd", link_name = "mknod@FBSD_1.0")] + #[cfg_attr( + all(target_os = "freebsd", not(freebsd12)), + link_name = "mknod@FBSD_1.0" + )] pub fn mknod(pathname: *const ::c_char, mode: ::mode_t, dev: ::dev_t) -> ::c_int; pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int; diff --git a/libc/src/unix/newlib/mod.rs b/libc/src/unix/newlib/mod.rs index c9a25a3..f27874c 100644 --- a/libc/src/unix/newlib/mod.rs +++ b/libc/src/unix/newlib/mod.rs @@ -598,6 +598,14 @@ f! { } extern { + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + + #[cfg_attr(target_os = "linux", + link_name = "__xpg_strerror_r")] + pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, + buflen: ::size_t) -> ::c_int; + pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, @@ -623,6 +631,8 @@ extern { pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char, envp: *const *const ::c_char) -> ::c_int; + pub fn gettimeofday(tp: *mut ::timeval, + tz: *mut ::c_void) -> ::c_int; #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")] pub fn getgrgid_r(gid: ::gid_t, grp: *mut ::group, diff --git a/libc/src/unix/notbsd/android/b32/mod.rs b/libc/src/unix/notbsd/android/b32/mod.rs index a8cc51b..e8fd20e 100644 --- a/libc/src/unix/notbsd/android/b32/mod.rs +++ b/libc/src/unix/notbsd/android/b32/mod.rs @@ -13,7 +13,7 @@ s! { pub struct sigaction { pub sa_sigaction: ::sighandler_t, pub sa_mask: ::sigset_t, - pub sa_flags: ::c_ulong, + pub sa_flags: ::c_int, pub sa_restorer: ::Option, } @@ -35,12 +35,12 @@ s! { pub st_size: ::c_longlong, pub st_blksize: ::blksize_t, pub st_blocks: ::c_ulonglong, - pub st_atime: ::c_ulong, - pub st_atime_nsec: ::c_ulong, - pub st_mtime: ::c_ulong, - pub st_mtime_nsec: ::c_ulong, - pub st_ctime: ::c_ulong, - pub st_ctime_nsec: ::c_ulong, + pub st_atime: ::c_long, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::c_long, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::c_long, + pub st_ctime_nsec: ::c_long, pub st_ino: ::c_ulonglong, } @@ -57,12 +57,12 @@ s! { pub st_size: ::c_longlong, pub st_blksize: ::blksize_t, pub st_blocks: ::c_ulonglong, - pub st_atime: ::c_ulong, - pub st_atime_nsec: ::c_ulong, - pub st_mtime: ::c_ulong, - pub st_mtime_nsec: ::c_ulong, - pub st_ctime: ::c_ulong, - pub st_ctime_nsec: ::c_ulong, + pub st_atime: ::c_long, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::c_long, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::c_long, + pub st_ctime_nsec: ::c_long, pub st_ino: ::c_ulonglong, } @@ -96,12 +96,12 @@ s! { } pub struct pthread_attr_t { - pub flags: ::uint32_t, + pub flags: u32, pub stack_base: *mut ::c_void, pub stack_size: ::size_t, pub guard_size: ::size_t, - pub sched_policy: ::int32_t, - pub sched_priority: ::int32_t, + pub sched_policy: i32, + pub sched_priority: i32, } pub struct pthread_mutex_t { value: ::c_int } @@ -129,18 +129,18 @@ s! { } pub struct statfs { - pub f_type: ::uint32_t, - pub f_bsize: ::uint32_t, - pub f_blocks: ::uint64_t, - pub f_bfree: ::uint64_t, - pub f_bavail: ::uint64_t, - pub f_files: ::uint64_t, - pub f_ffree: ::uint64_t, + pub f_type: u32, + pub f_bsize: u32, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, pub f_fsid: ::__fsid_t, - pub f_namelen: ::uint32_t, - pub f_frsize: ::uint32_t, - pub f_flags: ::uint32_t, - pub f_spare: [::uint32_t; 4], + pub f_namelen: u32, + pub f_frsize: u32, + pub f_flags: u32, + pub f_spare: [u32; 4], } pub struct sysinfo { @@ -161,6 +161,15 @@ s! { } } +// These constants must be of the same type of sigaction.sa_flags +pub const SA_NOCLDSTOP: ::c_int = 0x00000001; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; +pub const SA_NODEFER: ::c_int = 0x40000000; +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_RESETHAND: ::c_int = 0x80000000; +pub const SA_RESTART: ::c_int = 0x10000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; + pub const RTLD_GLOBAL: ::c_int = 2; pub const RTLD_NOW: ::c_int = 0; pub const RTLD_DEFAULT: *mut ::c_void = -1isize as *mut ::c_void; diff --git a/libc/src/unix/notbsd/android/b64/aarch64.rs b/libc/src/unix/notbsd/android/b64/aarch64.rs index 44dfee6..cb1c81b 100644 --- a/libc/src/unix/notbsd/android/b64/aarch64.rs +++ b/libc/src/unix/notbsd/android/b64/aarch64.rs @@ -16,11 +16,11 @@ s! { __pad2: ::c_int, pub st_blocks: ::c_long, pub st_atime: ::time_t, - pub st_atime_nsec: ::c_ulong, + pub st_atime_nsec: ::c_long, pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_ulong, + pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_ulong, + pub st_ctime_nsec: ::c_long, __unused4: ::c_uint, __unused5: ::c_uint, } @@ -39,11 +39,11 @@ s! { __pad2: ::c_int, pub st_blocks: ::c_long, pub st_atime: ::time_t, - pub st_atime_nsec: ::c_ulong, + pub st_atime_nsec: ::c_long, pub st_mtime: ::time_t, - pub st_mtime_nsec: ::c_ulong, + pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, - pub st_ctime_nsec: ::c_ulong, + pub st_ctime_nsec: ::c_long, __unused4: ::c_uint, __unused5: ::c_uint, } @@ -322,4 +322,4 @@ pub const SYS_pwritev2: ::c_long = 287; pub const SYS_pkey_mprotect: ::c_long = 288; pub const SYS_pkey_alloc: ::c_long = 289; pub const SYS_pkey_free: ::c_long = 290; -pub const SYS_syscalls: ::c_long = 291; +pub const SYS_syscalls: ::c_long = 292; diff --git a/libc/src/unix/notbsd/android/b64/mod.rs b/libc/src/unix/notbsd/android/b64/mod.rs index 46becc5..d9759bd 100644 --- a/libc/src/unix/notbsd/android/b64/mod.rs +++ b/libc/src/unix/notbsd/android/b64/mod.rs @@ -13,7 +13,7 @@ s! { } pub struct sigaction { - pub sa_flags: ::c_uint, + pub sa_flags: ::c_int, pub sa_sigaction: ::sighandler_t, pub sa_mask: ::sigset_t, pub sa_restorer: ::Option, @@ -25,12 +25,12 @@ s! { } pub struct pthread_attr_t { - pub flags: ::uint32_t, + pub flags: u32, pub stack_base: *mut ::c_void, pub stack_size: ::size_t, pub guard_size: ::size_t, - pub sched_policy: ::int32_t, - pub sched_priority: ::int32_t, + pub sched_policy: i32, + pub sched_priority: i32, __reserved: [::c_char; 16], } @@ -45,18 +45,18 @@ s! { } pub struct statfs { - pub f_type: ::uint64_t, - pub f_bsize: ::uint64_t, - pub f_blocks: ::uint64_t, - pub f_bfree: ::uint64_t, - pub f_bavail: ::uint64_t, - pub f_files: ::uint64_t, - pub f_ffree: ::uint64_t, + pub f_type: u64, + pub f_bsize: u64, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, pub f_fsid: ::__fsid_t, - pub f_namelen: ::uint64_t, - pub f_frsize: ::uint64_t, - pub f_flags: ::uint64_t, - pub f_spare: [::uint64_t; 4], + pub f_namelen: u64, + pub f_frsize: u64, + pub f_flags: u64, + pub f_spare: [u64; 4], } pub struct sysinfo { @@ -231,6 +231,15 @@ cfg_if! { } } +// These constants must be of the same type of sigaction.sa_flags +pub const SA_NOCLDSTOP: ::c_int = 0x00000001; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; +pub const SA_NODEFER: ::c_int = 0x40000000; +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_RESETHAND: ::c_int = 0x80000000; +pub const SA_RESTART: ::c_int = 0x10000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; + pub const RTLD_GLOBAL: ::c_int = 0x00100; pub const RTLD_NOW: ::c_int = 2; pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void; diff --git a/libc/src/unix/notbsd/android/b64/x86_64.rs b/libc/src/unix/notbsd/android/b64/x86_64.rs index c813e7d..2ab6080 100644 --- a/libc/src/unix/notbsd/android/b64/x86_64.rs +++ b/libc/src/unix/notbsd/android/b64/x86_64.rs @@ -13,12 +13,12 @@ s! { pub st_size: ::off64_t, pub st_blksize: ::c_long, pub st_blocks: ::c_long, - pub st_atime: ::c_ulong, - pub st_atime_nsec: ::c_ulong, - pub st_mtime: ::c_ulong, - pub st_mtime_nsec: ::c_ulong, - pub st_ctime: ::c_ulong, - pub st_ctime_nsec: ::c_ulong, + pub st_atime: ::c_long, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::c_long, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::c_long, + pub st_ctime_nsec: ::c_long, __unused: [::c_long; 3], } @@ -33,12 +33,12 @@ s! { pub st_size: ::off64_t, pub st_blksize: ::c_long, pub st_blocks: ::c_long, - pub st_atime: ::c_ulong, - pub st_atime_nsec: ::c_ulong, - pub st_mtime: ::c_ulong, - pub st_mtime_nsec: ::c_ulong, - pub st_ctime: ::c_ulong, - pub st_ctime_nsec: ::c_ulong, + pub st_atime: ::c_long, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::c_long, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::c_long, + pub st_ctime_nsec: ::c_long, __unused: [::c_long; 3], } } diff --git a/libc/src/unix/notbsd/android/mod.rs b/libc/src/unix/notbsd/android/mod.rs index a430b1a..f4fb83d 100644 --- a/libc/src/unix/notbsd/android/mod.rs +++ b/libc/src/unix/notbsd/android/mod.rs @@ -12,6 +12,7 @@ pub type pthread_t = ::c_long; pub type pthread_mutexattr_t = ::c_long; pub type pthread_rwlockattr_t = ::c_long; pub type pthread_condattr_t = ::c_long; +pub type pthread_key_t = ::c_int; pub type fsfilcnt_t = ::c_ulong; pub type fsblkcnt_t = ::c_ulong; pub type nfds_t = ::c_uint; @@ -112,28 +113,28 @@ s! { } pub struct signalfd_siginfo { - pub ssi_signo: ::uint32_t, - pub ssi_errno: ::int32_t, - pub ssi_code: ::int32_t, - pub ssi_pid: ::uint32_t, - pub ssi_uid: ::uint32_t, - pub ssi_fd: ::int32_t, - pub ssi_tid: ::uint32_t, - pub ssi_band: ::uint32_t, - pub ssi_overrun: ::uint32_t, - pub ssi_trapno: ::uint32_t, - pub ssi_status: ::int32_t, - pub ssi_int: ::int32_t, + pub ssi_signo: u32, + pub ssi_errno: i32, + pub ssi_code: i32, + pub ssi_pid: u32, + pub ssi_uid: u32, + pub ssi_fd: i32, + pub ssi_tid: u32, + pub ssi_band: u32, + pub ssi_overrun: u32, + pub ssi_trapno: u32, + pub ssi_status: i32, + pub ssi_int: i32, pub ssi_ptr: ::c_ulonglong, pub ssi_utime: ::c_ulonglong, pub ssi_stime: ::c_ulonglong, pub ssi_addr: ::c_ulonglong, - pub ssi_addr_lsb: ::uint16_t, - _pad2: ::uint16_t, - pub ssi_syscall: ::int32_t, - pub ssi_call_addr: ::uint64_t, - pub ssi_arch: ::uint32_t, - _pad: [::uint8_t; 28], + pub ssi_addr_lsb: u16, + _pad2: u16, + pub ssi_syscall: i32, + pub ssi_call_addr: u64, + pub ssi_arch: u32, + _pad: [u8; 28], } pub struct ucred { @@ -193,13 +194,20 @@ s! { pub struct inotify_event { pub wd: ::c_int, - pub mask: ::uint32_t, - pub cookie: ::uint32_t, - pub len: ::uint32_t + pub mask: u32, + pub cookie: u32, + pub len: u32 } } s_no_extra_traits!{ + pub struct sockaddr_nl { + pub nl_family: ::sa_family_t, + nl_pad: ::c_ushort, + pub nl_pid: u32, + pub nl_groups: u32 + } + pub struct dirent { pub d_ino: u64, pub d_off: i64, @@ -240,7 +248,7 @@ s_no_extra_traits!{ pub ut_exit: exit_status, pub ut_session: ::c_long, pub ut_tv: ::timeval, - pub ut_addr_v6: [::int32_t; 4], + pub ut_addr_v6: [i32; 4], unused: [::c_char; 20], } @@ -260,6 +268,31 @@ s_no_extra_traits!{ cfg_if! { if #[cfg(feature = "extra_traits")] { + impl PartialEq for sockaddr_nl { + fn eq(&self, other: &sockaddr_nl) -> bool { + self.nl_family == other.nl_family && + self.nl_pid == other.nl_pid && + self.nl_groups == other.nl_groups + } + } + impl Eq for sockaddr_nl {} + impl ::fmt::Debug for sockaddr_nl { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_nl") + .field("nl_family", &self.nl_family) + .field("nl_pid", &self.nl_pid) + .field("nl_groups", &self.nl_groups) + .finish() + } + } + impl ::hash::Hash for sockaddr_nl { + fn hash(&self, state: &mut H) { + self.nl_family.hash(state); + self.nl_pid.hash(state); + self.nl_groups.hash(state); + } + } + impl PartialEq for dirent { fn eq(&self, other: &dirent) -> bool { self.d_ino == other.d_ino @@ -547,6 +580,10 @@ cfg_if! { } } +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MS_NOUSER: ::c_ulong = 0xffffffff80000000; +pub const MS_RMT_MASK: ::c_ulong = 0x02800051; + pub const O_TRUNC: ::c_int = 512; pub const O_CLOEXEC: ::c_int = 0x80000; pub const O_PATH: ::c_int = 0o10000000; @@ -567,11 +604,6 @@ pub const ECOMM: ::c_int = 70; pub const EPROTO: ::c_int = 71; pub const EDOTDOT: ::c_int = 73; -pub const SA_NODEFER: ::c_int = 0x40000000; -pub const SA_RESETHAND: ::c_int = 0x80000000; -pub const SA_RESTART: ::c_int = 0x10000000; -pub const SA_NOCLDSTOP: ::c_int = 0x00000001; - pub const EPOLL_CLOEXEC: ::c_int = 0x80000; pub const EPOLLONESHOT: ::c_int = 0x40000000; pub const EPOLLRDHUP: ::c_int = 0x00002000; @@ -581,12 +613,14 @@ pub const EFD_CLOEXEC: ::c_int = 0x80000; pub const USER_PROCESS: ::c_short = 7; +pub const FALLOC_FL_COLLAPSE_RANGE: ::c_int = 0x08; + pub const BUFSIZ: ::c_uint = 1024; -pub const FILENAME_MAX: ::c_uint = 1024; +pub const FILENAME_MAX: ::c_uint = 4096; pub const FOPEN_MAX: ::c_uint = 20; pub const POSIX_FADV_DONTNEED: ::c_int = 4; pub const POSIX_FADV_NOREUSE: ::c_int = 5; -pub const L_tmpnam: ::c_uint = 1024; +pub const L_tmpnam: ::c_uint = 4096; pub const TMP_MAX: ::c_uint = 308915776; pub const _PC_LINK_MAX: ::c_int = 1; pub const _PC_MAX_CANON: ::c_int = 2; @@ -752,9 +786,6 @@ pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL; pub const FIOCLEX: ::c_int = 0x5451; -pub const SA_ONSTACK: ::c_ulong = 0x08000000; -pub const SA_SIGINFO: ::c_ulong = 0x00000004; -pub const SA_NOCLDWAIT: ::c_ulong = 0x00000002; pub const SIGCHLD: ::c_int = 17; pub const SIGBUS: ::c_int = 7; pub const SIGUSR1: ::c_int = 10; @@ -766,6 +797,10 @@ pub const SIGURG: ::c_int = 23; pub const SIGIO: ::c_int = 29; pub const SIGSYS: ::c_int = 31; pub const SIGSTKFLT: ::c_int = 16; +#[deprecated( + since = "0.2.55", + note = "Use SIGSYS instead" +)] pub const SIGUNUSED: ::c_int = 31; pub const SIGTTIN: ::c_int = 21; pub const SIGTTOU: ::c_int = 22; @@ -917,8 +952,19 @@ pub const SOL_NETROM: ::c_int = 259; pub const SOL_ROSE: ::c_int = 260; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] pub const AF_MAX: ::c_int = 43; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +#[allow(deprecated)] pub const PF_MAX: ::c_int = AF_MAX; /* DCCP socket options */ @@ -1056,11 +1102,21 @@ pub const F_GETOWN: ::c_int = 9; pub const F_SETOWN: ::c_int = 8; pub const F_SETLK: ::c_int = 6; pub const F_SETLKW: ::c_int = 7; - pub const F_RDLCK: ::c_int = 0; pub const F_WRLCK: ::c_int = 1; pub const F_UNLCK: ::c_int = 2; +pub const RLIMIT_CPU: ::c_int = 0; +pub const RLIMIT_FSIZE: ::c_int = 1; +pub const RLIMIT_DATA: ::c_int = 2; +pub const RLIMIT_STACK: ::c_int = 3; +pub const RLIMIT_CORE: ::c_int = 4; +pub const RLIMIT_LOCKS: ::c_int = 10; +pub const RLIMIT_SIGPENDING: ::c_int = 11; +pub const RLIMIT_MSGQUEUE: ::c_int = 12; +pub const RLIMIT_NICE: ::c_int = 13; +pub const RLIMIT_RTPRIO: ::c_int = 14; + pub const TCGETS: ::c_int = 0x5401; pub const TCSETS: ::c_int = 0x5402; pub const TCSETSW: ::c_int = 0x5403; @@ -1126,15 +1182,15 @@ pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; pub const CBAUD: ::tcflag_t = 0o0010017; -pub const TAB1: ::c_int = 0x00000800; -pub const TAB2: ::c_int = 0x00001000; -pub const TAB3: ::c_int = 0x00001800; -pub const CR1: ::c_int = 0x00000200; -pub const CR2: ::c_int = 0x00000400; -pub const CR3: ::c_int = 0x00000600; -pub const FF1: ::c_int = 0x00008000; -pub const BS1: ::c_int = 0x00002000; -pub const VT1: ::c_int = 0x00004000; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const FF1: ::tcflag_t = 0x00008000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VT1: ::tcflag_t = 0x00004000; pub const VWERASE: usize = 14; pub const VREPRINT: usize = 12; pub const VSUSP: usize = 10; @@ -1459,10 +1515,10 @@ pub const NF_IP6_PRI_CONNTRACK_HELPER: ::c_int = 300; pub const NF_IP6_PRI_LAST: ::c_int = ::INT_MAX; // linux/netfilter/nf_tables.h -pub const NFT_TABLE_MAXNAMELEN: ::c_int = 32; -pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 32; -pub const NFT_SET_MAXNAMELEN: ::c_int = 32; -pub const NFT_OBJ_MAXNAMELEN: ::c_int = 32; +pub const NFT_TABLE_MAXNAMELEN: ::c_int = 256; +pub const NFT_CHAIN_MAXNAMELEN: ::c_int = 256; +pub const NFT_SET_MAXNAMELEN: ::c_int = 256; +pub const NFT_OBJ_MAXNAMELEN: ::c_int = 256; pub const NFT_USERDATA_MAXLEN: ::c_int = 256; pub const NFT_REG_VERDICT: ::c_int = 0; @@ -1519,7 +1575,7 @@ pub const NFT_MSG_NEWOBJ: ::c_int = 18; pub const NFT_MSG_GETOBJ: ::c_int = 19; pub const NFT_MSG_DELOBJ: ::c_int = 20; pub const NFT_MSG_GETOBJ_RESET: ::c_int = 21; -pub const NFT_MSG_MAX: ::c_int = 22; +pub const NFT_MSG_MAX: ::c_int = 25; pub const NFT_SET_ANONYMOUS: ::c_int = 0x1; pub const NFT_SET_CONSTANT: ::c_int = 0x2; @@ -1789,7 +1845,10 @@ pub const SIOCSIFMAP: ::c_ulong = 0x00008971; pub const MODULE_INIT_IGNORE_MODVERSIONS: ::c_uint = 0x0001; pub const MODULE_INIT_IGNORE_VERMAGIC: ::c_uint = 0x0002; -// Similarity to Linux it's not used but defined for compatibility. +#[deprecated( + since = "0.2.55", + note = "ENOATTR is not available on Android; use ENODATA instead" +)] pub const ENOATTR: ::c_int = ::ENODATA; // linux/if_alg.h @@ -1803,33 +1862,33 @@ pub const ALG_OP_DECRYPT: ::c_int = 0; pub const ALG_OP_ENCRYPT: ::c_int = 1; // uapi/linux/inotify.h -pub const IN_ACCESS: ::uint32_t = 0x0000_0001; -pub const IN_MODIFY: ::uint32_t = 0x0000_0002; -pub const IN_ATTRIB: ::uint32_t = 0x0000_0004; -pub const IN_CLOSE_WRITE: ::uint32_t = 0x0000_0008; -pub const IN_CLOSE_NOWRITE: ::uint32_t = 0x0000_0010; -pub const IN_CLOSE: ::uint32_t = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE); -pub const IN_OPEN: ::uint32_t = 0x0000_0020; -pub const IN_MOVED_FROM: ::uint32_t = 0x0000_0040; -pub const IN_MOVED_TO: ::uint32_t = 0x0000_0080; -pub const IN_MOVE: ::uint32_t = (IN_MOVED_FROM | IN_MOVED_TO); -pub const IN_CREATE: ::uint32_t = 0x0000_0100; -pub const IN_DELETE: ::uint32_t = 0x0000_0200; -pub const IN_DELETE_SELF: ::uint32_t = 0x0000_0400; -pub const IN_MOVE_SELF: ::uint32_t = 0x0000_0800; -pub const IN_UNMOUNT: ::uint32_t = 0x0000_2000; -pub const IN_Q_OVERFLOW: ::uint32_t = 0x0000_4000; -pub const IN_IGNORED: ::uint32_t = 0x0000_8000; -pub const IN_ONLYDIR: ::uint32_t = 0x0100_0000; -pub const IN_DONT_FOLLOW: ::uint32_t = 0x0200_0000; -// pub const IN_EXCL_UNLINK: ::uint32_t = 0x0400_0000; - -// pub const IN_MASK_CREATE: ::uint32_t = 0x1000_0000; -// pub const IN_MASK_ADD: ::uint32_t = 0x2000_0000; -pub const IN_ISDIR: ::uint32_t = 0x4000_0000; -pub const IN_ONESHOT: ::uint32_t = 0x8000_0000; - -pub const IN_ALL_EVENTS: ::uint32_t = ( +pub const IN_ACCESS: u32 = 0x0000_0001; +pub const IN_MODIFY: u32 = 0x0000_0002; +pub const IN_ATTRIB: u32 = 0x0000_0004; +pub const IN_CLOSE_WRITE: u32 = 0x0000_0008; +pub const IN_CLOSE_NOWRITE: u32 = 0x0000_0010; +pub const IN_CLOSE: u32 = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE); +pub const IN_OPEN: u32 = 0x0000_0020; +pub const IN_MOVED_FROM: u32 = 0x0000_0040; +pub const IN_MOVED_TO: u32 = 0x0000_0080; +pub const IN_MOVE: u32 = (IN_MOVED_FROM | IN_MOVED_TO); +pub const IN_CREATE: u32 = 0x0000_0100; +pub const IN_DELETE: u32 = 0x0000_0200; +pub const IN_DELETE_SELF: u32 = 0x0000_0400; +pub const IN_MOVE_SELF: u32 = 0x0000_0800; +pub const IN_UNMOUNT: u32 = 0x0000_2000; +pub const IN_Q_OVERFLOW: u32 = 0x0000_4000; +pub const IN_IGNORED: u32 = 0x0000_8000; +pub const IN_ONLYDIR: u32 = 0x0100_0000; +pub const IN_DONT_FOLLOW: u32 = 0x0200_0000; +// pub const IN_EXCL_UNLINK: u32 = 0x0400_0000; + +// pub const IN_MASK_CREATE: u32 = 0x1000_0000; +// pub const IN_MASK_ADD: u32 = 0x2000_0000; +pub const IN_ISDIR: u32 = 0x4000_0000; +pub const IN_ONESHOT: u32 = 0x8000_0000; + +pub const IN_ALL_EVENTS: u32 = ( IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | @@ -1920,19 +1979,26 @@ f! { } extern { - static mut __progname: *mut ::c_char; -} - -extern { - pub fn madvise(addr: *const ::c_void, len: ::size_t, advice: ::c_int) + pub fn getrlimit64(resource: ::c_int, + rlim: *mut rlimit64) -> ::c_int; + pub fn setrlimit64(resource: ::c_int, + rlim: *const rlimit64) -> ::c_int; + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, + buflen: ::size_t) -> ::c_int; + + pub fn gettimeofday(tp: *mut ::timeval, + tz: *mut ::timezone) -> ::c_int; + pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; - pub fn msync(addr: *const ::c_void, len: ::size_t, + pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; - pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) + pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, - flags: ::c_int, addr: *const ::sockaddr, + flags: ::c_int, addr: *mut ::sockaddr, addrlen: *mut ::socklen_t) -> ::ssize_t; pub fn getnameinfo(sa: *const ::sockaddr, salen: ::socklen_t, @@ -1942,11 +2008,12 @@ extern { sevlen: ::size_t, flags: ::c_int) -> ::c_int; pub fn ptrace(request: ::c_int, ...) -> ::c_long; - pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int; - pub fn setpriority(which: ::c_int, who: ::c_int, prio: ::c_int) -> ::c_int; + 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 __sched_cpualloc(count: ::size_t) -> *mut ::cpu_set_t; pub fn __sched_cpufree(set: *mut ::cpu_set_t); - pub fn __sched_cpucount(setsize: ::size_t, set: *mut cpu_set_t) -> ::c_int; + pub fn __sched_cpucount(setsize: ::size_t, + set: *const cpu_set_t) -> ::c_int; pub fn sched_getcpu() -> ::c_int; pub fn utmpname(name: *const ::c_char) -> ::c_int; @@ -2009,7 +2076,7 @@ extern { fstype: *const ::c_char, flags: ::c_ulong, data: *const ::c_void) -> ::c_int; - pub fn personality(persona: ::c_ulong) -> ::c_int; + pub fn personality(persona: ::c_uint) -> ::c_int; pub fn prctl(option: ::c_int, ...) -> ::c_int; pub fn sched_getparam(pid: ::pid_t, param: *mut ::sched_param) -> ::c_int; pub fn ppoll(fds: *mut ::pollfd, @@ -2061,7 +2128,6 @@ extern { pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int; pub fn sem_close(sem: *mut sem_t) -> ::c_int; - pub fn getdtablesize() -> ::c_int; #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")] pub fn getgrnam_r(name: *const ::c_char, grp: *mut ::group, @@ -2118,7 +2184,7 @@ extern { f: extern fn(*mut ::c_void) -> *mut ::c_void, value: *mut ::c_void) -> ::c_int; pub fn __errno() -> *mut ::c_int; - pub fn inotify_rm_watch(fd: ::c_int, wd: ::uint32_t) -> ::c_int; + pub fn inotify_rm_watch(fd: ::c_int, wd: u32) -> ::c_int; pub fn sendmmsg(sockfd: ::c_int, msgvec: *const ::mmsghdr, vlen: ::c_uint, flags: ::c_int) -> ::c_int; pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, @@ -2127,7 +2193,7 @@ extern { pub fn inotify_init1(flags: ::c_int) -> ::c_int; pub fn inotify_add_watch(fd: ::c_int, path: *const ::c_char, - mask: ::uint32_t) -> ::c_int; + mask: u32) -> ::c_int; } cfg_if! { diff --git a/libc/src/unix/notbsd/emscripten/mod.rs b/libc/src/unix/notbsd/emscripten/mod.rs index 0f8c76e..ba13d8e 100644 --- a/libc/src/unix/notbsd/emscripten/mod.rs +++ b/libc/src/unix/notbsd/emscripten/mod.rs @@ -17,6 +17,7 @@ pub type nfds_t = ::c_ulong; pub type nl_item = ::c_int; pub type idtype_t = ::c_uint; pub type loff_t = i32; +pub type pthread_key_t = ::c_uint; pub type clock_t = c_long; pub type time_t = c_long; @@ -98,54 +99,46 @@ s! { } pub struct dqblk { - pub dqb_bhardlimit: ::uint64_t, - pub dqb_bsoftlimit: ::uint64_t, - pub dqb_curspace: ::uint64_t, - pub dqb_ihardlimit: ::uint64_t, - pub dqb_isoftlimit: ::uint64_t, - pub dqb_curinodes: ::uint64_t, - pub dqb_btime: ::uint64_t, - pub dqb_itime: ::uint64_t, - pub dqb_valid: ::uint32_t, + pub dqb_bhardlimit: u64, + pub dqb_bsoftlimit: u64, + pub dqb_curspace: u64, + pub dqb_ihardlimit: u64, + pub dqb_isoftlimit: u64, + pub dqb_curinodes: u64, + pub dqb_btime: u64, + pub dqb_itime: u64, + pub dqb_valid: u32, } pub struct signalfd_siginfo { - pub ssi_signo: ::uint32_t, - pub ssi_errno: ::int32_t, - pub ssi_code: ::int32_t, - pub ssi_pid: ::uint32_t, - pub ssi_uid: ::uint32_t, - pub ssi_fd: ::int32_t, - pub ssi_tid: ::uint32_t, - pub ssi_band: ::uint32_t, - pub ssi_overrun: ::uint32_t, - pub ssi_trapno: ::uint32_t, - pub ssi_status: ::int32_t, - pub ssi_int: ::int32_t, - pub ssi_ptr: ::uint64_t, - pub ssi_utime: ::uint64_t, - pub ssi_stime: ::uint64_t, - pub ssi_addr: ::uint64_t, - pub ssi_addr_lsb: ::uint16_t, - _pad2: ::uint16_t, - pub ssi_syscall: ::int32_t, - pub ssi_call_addr: ::uint64_t, - pub ssi_arch: ::uint32_t, - _pad: [::uint8_t; 28], + pub ssi_signo: u32, + pub ssi_errno: i32, + pub ssi_code: i32, + pub ssi_pid: u32, + pub ssi_uid: u32, + pub ssi_fd: i32, + pub ssi_tid: u32, + pub ssi_band: u32, + pub ssi_overrun: u32, + pub ssi_trapno: u32, + pub ssi_status: i32, + pub ssi_int: i32, + pub ssi_ptr: u64, + pub ssi_utime: u64, + pub ssi_stime: u64, + pub ssi_addr: u64, + pub ssi_addr_lsb: u16, + _pad2: u16, + pub ssi_syscall: i32, + pub ssi_call_addr: u64, + pub ssi_arch: u32, + _pad: [u8; 28], } pub struct fsid_t { __val: [::c_int; 2], } - pub struct mq_attr { - pub mq_flags: ::c_long, - pub mq_maxmsg: ::c_long, - pub mq_msgsize: ::c_long, - pub mq_curmsgs: ::c_long, - pad: [::c_long; 4] - } - pub struct cpu_set_t { bits: [u32; 32], } @@ -435,6 +428,14 @@ s_no_extra_traits! { pub mem_unit: ::c_uint, pub __reserved: [::c_char; 256], } + + pub struct mq_attr { + pub mq_flags: ::c_long, + pub mq_maxmsg: ::c_long, + pub mq_msgsize: ::c_long, + pub mq_curmsgs: ::c_long, + pad: [::c_long; 4] + } } cfg_if! { @@ -570,9 +571,41 @@ cfg_if! { self.__reserved.hash(state); } } + + impl PartialEq for mq_attr { + fn eq(&self, other: &mq_attr) -> bool { + self.mq_flags == other.mq_flags && + self.mq_maxmsg == other.mq_maxmsg && + self.mq_msgsize == other.mq_msgsize && + self.mq_curmsgs == other.mq_curmsgs + } + } + impl Eq for mq_attr {} + impl ::fmt::Debug for mq_attr { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mq_attr") + .field("mq_flags", &self.mq_flags) + .field("mq_maxmsg", &self.mq_maxmsg) + .field("mq_msgsize", &self.mq_msgsize) + .field("mq_curmsgs", &self.mq_curmsgs) + .finish() + } + } + impl ::hash::Hash for mq_attr { + fn hash(&self, state: &mut H) { + self.mq_flags.hash(state); + self.mq_maxmsg.hash(state); + self.mq_msgsize.hash(state); + self.mq_curmsgs.hash(state); + } + } } } +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MS_NOUSER: ::c_ulong = 0x80000000; +pub const MS_RMT_MASK: ::c_ulong = 0x02800051; + pub const ABDAY_1: ::nl_item = 0x20000; pub const ABDAY_2: ::nl_item = 0x20001; pub const ABDAY_3: ::nl_item = 0x20002; @@ -889,12 +922,23 @@ pub const AF_MPLS: ::c_int = 28; pub const AF_NFC: ::c_int = 39; pub const AF_VSOCK: ::c_int = 40; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] pub const AF_MAX: ::c_int = 42; pub const PF_IB: ::c_int = AF_IB; pub const PF_MPLS: ::c_int = AF_MPLS; pub const PF_NFC: ::c_int = AF_NFC; pub const PF_VSOCK: ::c_int = AF_VSOCK; #[doc(hidden)] +#[allow(deprecated)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] pub const PF_MAX: ::c_int = AF_MAX; // System V IPC @@ -913,7 +957,6 @@ pub const MSG_INFO: ::c_int = 12; pub const MSG_NOERROR: ::c_int = 0o10000; pub const MSG_EXCEPT: ::c_int = 0o20000; -pub const MSG_COPY: ::c_int = 0o40000; pub const SHM_R: ::c_int = 0o400; pub const SHM_W: ::c_int = 0o200; @@ -1124,10 +1167,6 @@ pub const _POSIX_VDISABLE: ::cc_t = 0; pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01; pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02; -pub const FALLOC_FL_COLLAPSE_RANGE: ::c_int = 0x08; -pub const FALLOC_FL_ZERO_RANGE: ::c_int = 0x10; -pub const FALLOC_FL_INSERT_RANGE: ::c_int = 0x20; -pub const FALLOC_FL_UNSHARE_RANGE: ::c_int = 0x40; // On Linux, libc doesn't define this constant, libattr does instead. // We still define it for Linux as it's defined by libc on other platforms, @@ -1180,12 +1219,10 @@ pub const POSIX_FADV_NOREUSE: ::c_int = 5; pub const POSIX_MADV_DONTNEED: ::c_int = 0; pub const RLIM_INFINITY: ::rlim_t = !0; -pub const RLIMIT_RTTIME: ::c_int = 15; -pub const RLIMIT_NLIMITS: ::c_int = 16; +pub const RLIMIT_NLIMITS: ::c_int = 15; pub const MAP_ANONYMOUS: ::c_int = MAP_ANON; -pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16; pub const TCP_THIN_DUPACK: ::c_int = 17; pub const TCP_USER_TIMEOUT: ::c_int = 18; @@ -1196,6 +1233,11 @@ pub const TCP_REPAIR_OPTIONS: ::c_int = 22; pub const TCP_FASTOPEN: ::c_int = 23; pub const TCP_TIMESTAMP: ::c_int = 24; +#[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "Use SIGSYS instead" +)] pub const SIGUNUSED: ::c_int = ::SIGSYS; pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; @@ -1368,6 +1410,16 @@ pub const RLIMIT_NOFILE: ::c_int = 7; pub const RLIMIT_AS: ::c_int = 9; pub const RLIMIT_NPROC: ::c_int = 6; pub const RLIMIT_MEMLOCK: ::c_int = 8; +pub const RLIMIT_CPU: ::c_int = 0; +pub const RLIMIT_FSIZE: ::c_int = 1; +pub const RLIMIT_DATA: ::c_int = 2; +pub const RLIMIT_STACK: ::c_int = 3; +pub const RLIMIT_CORE: ::c_int = 4; +pub const RLIMIT_LOCKS: ::c_int = 10; +pub const RLIMIT_SIGPENDING: ::c_int = 11; +pub const RLIMIT_MSGQUEUE: ::c_int = 12; +pub const RLIMIT_NICE: ::c_int = 13; +pub const RLIMIT_RTPRIO: ::c_int = 14; pub const O_APPEND: ::c_int = 1024; pub const O_CREAT: ::c_int = 64; @@ -1683,12 +1735,24 @@ f! { } extern { + pub fn getrlimit64(resource: ::c_int, + rlim: *mut rlimit64) -> ::c_int; + pub fn setrlimit64(resource: ::c_int, + rlim: *const rlimit64) -> ::c_int; + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, + buflen: ::size_t) -> ::c_int; + pub fn abs(i: ::c_int) -> ::c_int; pub fn atof(s: *const ::c_char) -> ::c_double; pub fn labs(i: ::c_long) -> ::c_long; pub fn rand() -> ::c_int; pub fn srand(seed: ::c_uint); + pub fn gettimeofday(tp: *mut ::timeval, + tz: *mut ::c_void) -> ::c_int; + pub fn setpwent(); pub fn endpwent(); pub fn getpwent() -> *mut passwd; @@ -1777,9 +1841,9 @@ extern { pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int; pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int; pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, - flags: ::c_int) -> ::c_int; + flags: ::c_uint) -> ::c_int; pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, - flags: ::c_int, timeout: *mut ::timespec) -> ::c_int; + flags: ::c_uint, timeout: *mut ::timespec) -> ::c_int; pub fn sync(); pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; diff --git a/libc/src/unix/notbsd/linux/mips/mod.rs b/libc/src/unix/notbsd/linux/mips/mod.rs index 35534b4..46c49ff 100644 --- a/libc/src/unix/notbsd/linux/mips/mod.rs +++ b/libc/src/unix/notbsd/linux/mips/mod.rs @@ -1,3 +1,4 @@ +pub type pthread_t = c_ulong; pub type shmatt_t = ::c_ulong; pub type msgqnum_t = ::c_ulong; pub type msglen_t = ::c_ulong; @@ -5,6 +6,7 @@ pub type fsblkcnt_t = ::c_ulong; pub type fsfilcnt_t = ::c_ulong; pub type rlim_t = c_ulong; pub type __priority_which_t = ::c_uint; +pub type __rlimit_resource_t = ::c_uint; s! { pub struct glob64_t { @@ -70,6 +72,8 @@ s! { } } +pub const MS_RMT_MASK: ::c_ulong = 0x02800051; + pub const SFD_CLOEXEC: ::c_int = 0x080000; pub const NCCS: usize = 32; @@ -334,6 +338,8 @@ pub const MAP_LOCKED: ::c_int = 0x8000; pub const MAP_POPULATE: ::c_int = 0x10000; pub const MAP_NONBLOCK: ::c_int = 0x20000; pub const MAP_STACK: ::c_int = 0x40000; +pub const MAP_SHARED_VALIDATE: ::c_int = 0x3; +pub const MAP_FIXED_NOREPLACE: ::c_int = 0x100000; pub const SOCK_STREAM: ::c_int = 2; pub const SOCK_DGRAM: ::c_int = 1; @@ -591,15 +597,15 @@ pub const MCL_FUTURE: ::c_int = 0x0002; pub const SIGSTKSZ: ::size_t = 8192; pub const MINSIGSTKSZ: ::size_t = 2048; pub const CBAUD: ::tcflag_t = 0o0010017; -pub const TAB1: ::c_int = 0x00000800; -pub const TAB2: ::c_int = 0x00001000; -pub const TAB3: ::c_int = 0x00001800; -pub const CR1: ::c_int = 0x00000200; -pub const CR2: ::c_int = 0x00000400; -pub const CR3: ::c_int = 0x00000600; -pub const FF1: ::c_int = 0x00008000; -pub const BS1: ::c_int = 0x00002000; -pub const VT1: ::c_int = 0x00004000; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const FF1: ::tcflag_t = 0x00008000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VT1: ::tcflag_t = 0x00004000; pub const VWERASE: usize = 14; pub const VREPRINT: usize = 12; pub const VSUSP: usize = 10; @@ -888,9 +894,31 @@ pub const NFT_TRACETYPE_RULE: ::c_int = 3; pub const NFT_NG_INCREMENTAL: ::c_int = 0; pub const NFT_NG_RANDOM: ::c_int = 1; +pub const RLIMIT_CPU: ::__rlimit_resource_t = 0; +pub const RLIMIT_FSIZE: ::__rlimit_resource_t = 1; +pub const RLIMIT_DATA: ::__rlimit_resource_t = 2; +pub const RLIMIT_STACK: ::__rlimit_resource_t = 3; +pub const RLIMIT_CORE: ::__rlimit_resource_t = 4; +pub const RLIMIT_LOCKS: ::__rlimit_resource_t = 10; +pub const RLIMIT_SIGPENDING: ::__rlimit_resource_t = 11; +pub const RLIMIT_MSGQUEUE: ::__rlimit_resource_t = 12; +pub const RLIMIT_NICE: ::__rlimit_resource_t = 13; +pub const RLIMIT_RTPRIO: ::__rlimit_resource_t = 14; + #[doc(hidden)] -pub const AF_MAX: ::c_int = 42; +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +pub const AF_MAX: ::c_int = 45; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +#[allow(deprecated)] pub const PF_MAX: ::c_int = AF_MAX; f! { @@ -901,6 +929,26 @@ f! { #[link(name = "util")] extern { + pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, + flags: ::c_int) -> ::c_int; + pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, + flags: ::c_int, timeout: *mut ::timespec) -> ::c_int; + + pub fn getrlimit64(resource: ::__rlimit_resource_t, + rlim: *mut ::rlimit64) -> ::c_int; + pub fn setrlimit64(resource: ::__rlimit_resource_t, + rlim: *const ::rlimit64) -> ::c_int; + pub fn getrlimit(resource: ::__rlimit_resource_t, + rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::__rlimit_resource_t, + rlim: *const ::rlimit) -> ::c_int; + pub fn prlimit(pid: ::pid_t, + resource: ::__rlimit_resource_t, new_limit: *const ::rlimit, + old_limit: *mut ::rlimit) -> ::c_int; + pub fn prlimit64(pid: ::pid_t, + resource: ::__rlimit_resource_t, + new_limit: *const ::rlimit64, + old_limit: *mut ::rlimit64) -> ::c_int; pub fn sysctl(name: *mut ::c_int, namelen: ::c_int, oldp: *mut ::c_void, diff --git a/libc/src/unix/notbsd/linux/mod.rs b/libc/src/unix/notbsd/linux/mod.rs index 2419a41..3b7bc29 100644 --- a/libc/src/unix/notbsd/linux/mod.rs +++ b/libc/src/unix/notbsd/linux/mod.rs @@ -3,7 +3,6 @@ pub type useconds_t = u32; pub type dev_t = u64; pub type socklen_t = u32; -pub type pthread_t = c_ulong; pub type mode_t = u32; pub type ino64_t = u64; pub type off64_t = i64; @@ -14,6 +13,7 @@ pub type nfds_t = ::c_ulong; pub type nl_item = ::c_int; pub type idtype_t = ::c_uint; pub type loff_t = ::c_longlong; +pub type pthread_key_t = ::c_uint; pub type __u8 = ::c_uchar; pub type __u16 = ::c_ushort; @@ -85,40 +85,40 @@ s! { } pub struct dqblk { - pub dqb_bhardlimit: ::uint64_t, - pub dqb_bsoftlimit: ::uint64_t, - pub dqb_curspace: ::uint64_t, - pub dqb_ihardlimit: ::uint64_t, - pub dqb_isoftlimit: ::uint64_t, - pub dqb_curinodes: ::uint64_t, - pub dqb_btime: ::uint64_t, - pub dqb_itime: ::uint64_t, - pub dqb_valid: ::uint32_t, + pub dqb_bhardlimit: u64, + pub dqb_bsoftlimit: u64, + pub dqb_curspace: u64, + pub dqb_ihardlimit: u64, + pub dqb_isoftlimit: u64, + pub dqb_curinodes: u64, + pub dqb_btime: u64, + pub dqb_itime: u64, + pub dqb_valid: u32, } pub struct signalfd_siginfo { - pub ssi_signo: ::uint32_t, - pub ssi_errno: ::int32_t, - pub ssi_code: ::int32_t, - pub ssi_pid: ::uint32_t, - pub ssi_uid: ::uint32_t, - pub ssi_fd: ::int32_t, - pub ssi_tid: ::uint32_t, - pub ssi_band: ::uint32_t, - pub ssi_overrun: ::uint32_t, - pub ssi_trapno: ::uint32_t, - pub ssi_status: ::int32_t, - pub ssi_int: ::int32_t, - pub ssi_ptr: ::uint64_t, - pub ssi_utime: ::uint64_t, - pub ssi_stime: ::uint64_t, - pub ssi_addr: ::uint64_t, - pub ssi_addr_lsb: ::uint16_t, - _pad2: ::uint16_t, - pub ssi_syscall: ::int32_t, - pub ssi_call_addr: ::uint64_t, - pub ssi_arch: ::uint32_t, - _pad: [::uint8_t; 28], + pub ssi_signo: u32, + pub ssi_errno: i32, + pub ssi_code: i32, + pub ssi_pid: u32, + pub ssi_uid: u32, + pub ssi_fd: i32, + pub ssi_tid: u32, + pub ssi_band: u32, + pub ssi_overrun: u32, + pub ssi_trapno: u32, + pub ssi_status: i32, + pub ssi_int: i32, + pub ssi_ptr: u64, + pub ssi_utime: u64, + pub ssi_stime: u64, + pub ssi_addr: u64, + pub ssi_addr_lsb: u16, + _pad2: u16, + pub ssi_syscall: i32, + pub ssi_call_addr: u64, + pub ssi_arch: u32, + _pad: [u8; 28], } pub struct itimerspec { @@ -130,32 +130,6 @@ s! { __val: [::c_int; 2], } - // x32 compatibility - // See https://sourceware.org/bugzilla/show_bug.cgi?id=21279 - pub struct mq_attr { - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub mq_flags: i64, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub mq_maxmsg: i64, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub mq_msgsize: i64, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pub mq_curmsgs: i64, - #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] - pad: [i64; 4], - - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub mq_flags: ::c_long, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub mq_maxmsg: ::c_long, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub mq_msgsize: ::c_long, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pub mq_curmsgs: ::c_long, - #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] - pad: [::c_long; 4], - } - pub struct packet_mreq { pub mr_ifindex: ::c_int, pub mr_type: ::c_ushort, @@ -496,13 +470,20 @@ s! { pub struct inotify_event { pub wd: ::c_int, - pub mask: ::uint32_t, - pub cookie: ::uint32_t, - pub len: ::uint32_t + pub mask: u32, + pub cookie: u32, + pub len: u32 } } s_no_extra_traits!{ + pub struct sockaddr_nl { + pub nl_family: ::sa_family_t, + nl_pad: ::c_ushort, + pub nl_pid: u32, + pub nl_groups: u32 + } + pub struct dirent { pub d_ino: ::ino_t, pub d_off: ::off_t, @@ -531,10 +512,61 @@ s_no_extra_traits!{ pub ivlen: u32, pub iv: [::c_uchar; 0], } + + // x32 compatibility + // See https://sourceware.org/bugzilla/show_bug.cgi?id=21279 + pub struct mq_attr { + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_flags: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_maxmsg: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_msgsize: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_curmsgs: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pad: [i64; 4], + + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_flags: ::c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_maxmsg: ::c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_msgsize: ::c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_curmsgs: ::c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pad: [::c_long; 4], + } } cfg_if! { if #[cfg(feature = "extra_traits")] { + impl PartialEq for sockaddr_nl { + fn eq(&self, other: &sockaddr_nl) -> bool { + self.nl_family == other.nl_family && + self.nl_pid == other.nl_pid && + self.nl_groups == other.nl_groups + } + } + impl Eq for sockaddr_nl {} + impl ::fmt::Debug for sockaddr_nl { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_nl") + .field("nl_family", &self.nl_family) + .field("nl_pid", &self.nl_pid) + .field("nl_groups", &self.nl_groups) + .finish() + } + } + impl ::hash::Hash for sockaddr_nl { + fn hash(&self, state: &mut H) { + self.nl_family.hash(state); + self.nl_pid.hash(state); + self.nl_groups.hash(state); + } + } + impl PartialEq for dirent { fn eq(&self, other: &dirent) -> bool { self.d_ino == other.d_ino @@ -751,6 +783,34 @@ cfg_if! { self.as_slice().hash(state); } } + + impl PartialEq for mq_attr { + fn eq(&self, other: &mq_attr) -> bool { + self.mq_flags == other.mq_flags && + self.mq_maxmsg == other.mq_maxmsg && + self.mq_msgsize == other.mq_msgsize && + self.mq_curmsgs == other.mq_curmsgs + } + } + impl Eq for mq_attr {} + impl ::fmt::Debug for mq_attr { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mq_attr") + .field("mq_flags", &self.mq_flags) + .field("mq_maxmsg", &self.mq_maxmsg) + .field("mq_msgsize", &self.mq_msgsize) + .field("mq_curmsgs", &self.mq_curmsgs) + .finish() + } + } + impl ::hash::Hash for mq_attr { + fn hash(&self, state: &mut H) { + self.mq_flags.hash(state); + self.mq_maxmsg.hash(state); + self.mq_msgsize.hash(state); + self.mq_curmsgs.hash(state); + } + } } } @@ -849,6 +909,8 @@ pub const _PC_ALLOC_SIZE_MIN: ::c_int = 18; pub const _PC_SYMLINK_MAX: ::c_int = 19; pub const _PC_2_SYMLINKS: ::c_int = 20; +pub const MS_NOUSER: ::c_ulong = 0xffffffff80000000; + pub const _SC_ARG_MAX: ::c_int = 0; pub const _SC_CHILD_MAX: ::c_int = 1; pub const _SC_CLK_TCK: ::c_int = 2; @@ -1020,30 +1082,62 @@ pub const F_TEST: ::c_int = 3; pub const F_TLOCK: ::c_int = 2; pub const F_ULOCK: ::c_int = 0; +pub const F_SEAL_FUTURE_WRITE: ::c_int = 0x0010; + pub const IFF_LOWER_UP: ::c_int = 0x10000; pub const IFF_DORMANT: ::c_int = 0x20000; pub const IFF_ECHO: ::c_int = 0x40000; +// linux/if_addr.h +pub const IFA_UNSPEC: ::c_ushort = 0; +pub const IFA_ADDRESS: ::c_ushort = 1; +pub const IFA_LOCAL: ::c_ushort = 2; +pub const IFA_LABEL: ::c_ushort = 3; +pub const IFA_BROADCAST: ::c_ushort = 4; +pub const IFA_ANYCAST: ::c_ushort = 5; +pub const IFA_CACHEINFO: ::c_ushort = 6; +pub const IFA_MULTICAST: ::c_ushort = 7; + +pub const IFA_F_SECONDARY: u32 = 0x01; +pub const IFA_F_TEMPORARY: u32 = 0x01; +pub const IFA_F_NODAD: u32 = 0x02; +pub const IFA_F_OPTIMISTIC: u32 = 0x04; +pub const IFA_F_DADFAILED: u32 = 0x08; +pub const IFA_F_HOMEADDRESS: u32 = 0x10; +pub const IFA_F_DEPRECATED: u32 = 0x20; +pub const IFA_F_TENTATIVE: u32 = 0x40; +pub const IFA_F_PERMANENT: u32 = 0x80; + +// linux/if_link.h +pub const IFLA_UNSPEC: ::c_ushort = 0; +pub const IFLA_ADDRESS: ::c_ushort = 1; +pub const IFLA_BROADCAST: ::c_ushort = 2; +pub const IFLA_IFNAME: ::c_ushort = 3; +pub const IFLA_MTU: ::c_ushort = 4; +pub const IFLA_LINK: ::c_ushort = 5; +pub const IFLA_QDISC: ::c_ushort = 6; +pub const IFLA_STATS: ::c_ushort = 7; + // linux/if_tun.h -pub const IFF_TUN: ::c_short = 0x0001; -pub const IFF_TAP: ::c_short = 0x0002; -pub const IFF_NO_PI: ::c_short = 0x1000; +pub const IFF_TUN: ::c_int = 0x0001; +pub const IFF_TAP: ::c_int = 0x0002; +pub const IFF_NO_PI: ::c_int = 0x1000; // Read queue size pub const TUN_READQ_SIZE: ::c_short = 500; // TUN device type flags: deprecated. Use IFF_TUN/IFF_TAP instead. -pub const TUN_TUN_DEV: ::c_short = ::IFF_TUN; -pub const TUN_TAP_DEV: ::c_short = ::IFF_TAP; +pub const TUN_TUN_DEV: ::c_short = ::IFF_TUN as ::c_short; +pub const TUN_TAP_DEV: ::c_short = ::IFF_TAP as ::c_short; pub const TUN_TYPE_MASK: ::c_short = 0x000f; // This flag has no real effect -pub const IFF_ONE_QUEUE: ::c_short = 0x2000; -pub const IFF_VNET_HDR: ::c_short = 0x4000; -pub const IFF_TUN_EXCL: ::c_short = 0x8000; -pub const IFF_MULTI_QUEUE: ::c_short = 0x0100; -pub const IFF_ATTACH_QUEUE: ::c_short = 0x0200; -pub const IFF_DETACH_QUEUE: ::c_short = 0x0400; +pub const IFF_ONE_QUEUE: ::c_int = 0x2000; +pub const IFF_VNET_HDR: ::c_int = 0x4000; +pub const IFF_TUN_EXCL: ::c_int = 0x8000; +pub const IFF_MULTI_QUEUE: ::c_int = 0x0100; +pub const IFF_ATTACH_QUEUE: ::c_int = 0x0200; +pub const IFF_DETACH_QUEUE: ::c_int = 0x0400; // read-only flag -pub const IFF_PERSIST: ::c_short = 0x0800; -pub const IFF_NOFILTER: ::c_short = 0x1000; +pub const IFF_PERSIST: ::c_int = 0x0800; +pub const IFF_NOFILTER: ::c_int = 0x1000; pub const ST_RDONLY: ::c_ulong = 1; pub const ST_NOSUID: ::c_ulong = 2; @@ -1406,9 +1500,10 @@ pub const FALLOC_FL_ZERO_RANGE: ::c_int = 0x10; pub const FALLOC_FL_INSERT_RANGE: ::c_int = 0x20; pub const FALLOC_FL_UNSHARE_RANGE: ::c_int = 0x40; -// On Linux, libc doesn't define this constant, libattr does instead. -// We still define it for Linux as it's defined by libc on other platforms, -// and it's mentioned in the man pages for getxattr and setxattr. +#[deprecated( + since = "0.2.55", + note = "ENOATTR is not available on Linux; use ENODATA instead" +)] pub const ENOATTR: ::c_int = ::ENODATA; pub const SO_ORIGINAL_DST: ::c_int = 80; @@ -1767,6 +1862,99 @@ pub const RT_CLASS_MAIN: u8 = 254; pub const RT_CLASS_LOCAL: u8 = 255; pub const RT_CLASS_MAX: u8 = 255; +// linux/neighbor.h +pub const NUD_NONE: u16 = 0x00; +pub const NUD_INCOMPLETE: u16 = 0x01; +pub const NUD_REACHABLE: u16 = 0x02; +pub const NUD_STALE: u16 = 0x04; +pub const NUD_DELAY: u16 = 0x08; +pub const NUD_PROBE: u16 = 0x10; +pub const NUD_FAILED: u16 = 0x20; +pub const NUD_NOARP: u16 = 0x40; +pub const NUD_PERMANENT: u16 = 0x80; + +pub const NTF_USE: u8 = 0x01; +pub const NTF_SELF: u8 = 0x02; +pub const NTF_MASTER: u8 = 0x04; +pub const NTF_PROXY: u8 = 0x08; +pub const NTF_ROUTER: u8 = 0x80; + +pub const NDA_UNSPEC: ::c_ushort = 0; +pub const NDA_DST: ::c_ushort = 1; +pub const NDA_LLADDR: ::c_ushort = 2; +pub const NDA_CACHEINFO: ::c_ushort = 3; +pub const NDA_PROBES: ::c_ushort = 4; +pub const NDA_VLAN: ::c_ushort = 5; +pub const NDA_PORT: ::c_ushort = 6; +pub const NDA_VNI: ::c_ushort = 7; +pub const NDA_IFINDEX: ::c_ushort = 8; + +// linux/rtnetlink.h +pub const TCA_UNSPEC: ::c_ushort = 0; +pub const TCA_KIND: ::c_ushort = 1; +pub const TCA_OPTIONS: ::c_ushort = 2; +pub const TCA_STATS: ::c_ushort = 3; +pub const TCA_XSTATS: ::c_ushort = 4; +pub const TCA_RATE: ::c_ushort = 5; +pub const TCA_FCNT: ::c_ushort = 6; +pub const TCA_STATS2: ::c_ushort = 7; +pub const TCA_STAB: ::c_ushort = 8; + +pub const RTM_F_NOTIFY: ::c_uint = 0x100; +pub const RTM_F_CLONED: ::c_uint = 0x200; +pub const RTM_F_EQUALIZE: ::c_uint = 0x400; +pub const RTM_F_PREFIX: ::c_uint = 0x800; + +pub const RTA_UNSPEC: ::c_ushort = 0; +pub const RTA_DST: ::c_ushort = 1; +pub const RTA_SRC: ::c_ushort = 2; +pub const RTA_IIF: ::c_ushort = 3; +pub const RTA_OIF: ::c_ushort = 4; +pub const RTA_GATEWAY: ::c_ushort = 5; +pub const RTA_PRIORITY: ::c_ushort = 6; +pub const RTA_PREFSRC: ::c_ushort = 7; +pub const RTA_METRICS: ::c_ushort = 8; +pub const RTA_MULTIPATH: ::c_ushort = 9; +pub const RTA_PROTOINFO: ::c_ushort = 10; // No longer used +pub const RTA_FLOW: ::c_ushort = 11; +pub const RTA_CACHEINFO: ::c_ushort = 12; +pub const RTA_SESSION: ::c_ushort = 13; // No longer used +pub const RTA_MP_ALGO: ::c_ushort = 14; // No longer used +pub const RTA_TABLE: ::c_ushort = 15; +pub const RTA_MARK: ::c_ushort = 16; +pub const RTA_MFC_STATS: ::c_ushort = 17; + +pub const RTN_UNSPEC: ::c_uchar = 0; +pub const RTN_UNICAST: ::c_uchar = 1; +pub const RTN_LOCAL: ::c_uchar = 2; +pub const RTN_BROADCAST: ::c_uchar = 3; +pub const RTN_ANYCAST: ::c_uchar = 4; +pub const RTN_MULTICAST: ::c_uchar = 5; +pub const RTN_BLACKHOLE: ::c_uchar = 6; +pub const RTN_UNREACHABLE: ::c_uchar = 7; +pub const RTN_PROHIBIT: ::c_uchar = 8; +pub const RTN_THROW: ::c_uchar = 9; +pub const RTN_NAT: ::c_uchar = 10; +pub const RTN_XRESOLVE: ::c_uchar = 11; + +pub const RTPROT_UNSPEC: ::c_uchar = 0; +pub const RTPROT_REDIRECT: ::c_uchar = 1; +pub const RTPROT_KERNEL: ::c_uchar = 2; +pub const RTPROT_BOOT: ::c_uchar = 3; +pub const RTPROT_STATIC: ::c_uchar = 4; + +pub const RT_SCOPE_UNIVERSE: ::c_uchar = 0; +pub const RT_SCOPE_SITE: ::c_uchar = 200; +pub const RT_SCOPE_LINK: ::c_uchar = 253; +pub const RT_SCOPE_HOST: ::c_uchar = 254; +pub const RT_SCOPE_NOWHERE: ::c_uchar = 255; + +pub const RT_TABLE_UNSPEC: ::c_uchar = 0; +pub const RT_TABLE_COMPAT: ::c_uchar = 252; +pub const RT_TABLE_DEFAULT: ::c_uchar = 253; +pub const RT_TABLE_MAIN: ::c_uchar = 254; +pub const RT_TABLE_LOCAL: ::c_uchar = 255; + pub const RTMSG_OVERRUN: u32 = ::NLMSG_OVERRUN as u32; pub const RTMSG_NEWDEVICE: u32 = 0x11; pub const RTMSG_DELDEVICE: u32 = 0x12; @@ -1813,33 +2001,33 @@ pub const ALG_OP_DECRYPT: ::c_int = 0; pub const ALG_OP_ENCRYPT: ::c_int = 1; // uapi/linux/inotify.h -pub const IN_ACCESS: ::uint32_t = 0x0000_0001; -pub const IN_MODIFY: ::uint32_t = 0x0000_0002; -pub const IN_ATTRIB: ::uint32_t = 0x0000_0004; -pub const IN_CLOSE_WRITE: ::uint32_t = 0x0000_0008; -pub const IN_CLOSE_NOWRITE: ::uint32_t = 0x0000_0010; -pub const IN_CLOSE: ::uint32_t = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE); -pub const IN_OPEN: ::uint32_t = 0x0000_0020; -pub const IN_MOVED_FROM: ::uint32_t = 0x0000_0040; -pub const IN_MOVED_TO: ::uint32_t = 0x0000_0080; -pub const IN_MOVE: ::uint32_t = (IN_MOVED_FROM | IN_MOVED_TO); -pub const IN_CREATE: ::uint32_t = 0x0000_0100; -pub const IN_DELETE: ::uint32_t = 0x0000_0200; -pub const IN_DELETE_SELF: ::uint32_t = 0x0000_0400; -pub const IN_MOVE_SELF: ::uint32_t = 0x0000_0800; -pub const IN_UNMOUNT: ::uint32_t = 0x0000_2000; -pub const IN_Q_OVERFLOW: ::uint32_t = 0x0000_4000; -pub const IN_IGNORED: ::uint32_t = 0x0000_8000; -pub const IN_ONLYDIR: ::uint32_t = 0x0100_0000; -pub const IN_DONT_FOLLOW: ::uint32_t = 0x0200_0000; -// pub const IN_EXCL_UNLINK: ::uint32_t = 0x0400_0000; - -// pub const IN_MASK_CREATE: ::uint32_t = 0x1000_0000; -// pub const IN_MASK_ADD: ::uint32_t = 0x2000_0000; -pub const IN_ISDIR: ::uint32_t = 0x4000_0000; -pub const IN_ONESHOT: ::uint32_t = 0x8000_0000; - -pub const IN_ALL_EVENTS: ::uint32_t = ( +pub const IN_ACCESS: u32 = 0x0000_0001; +pub const IN_MODIFY: u32 = 0x0000_0002; +pub const IN_ATTRIB: u32 = 0x0000_0004; +pub const IN_CLOSE_WRITE: u32 = 0x0000_0008; +pub const IN_CLOSE_NOWRITE: u32 = 0x0000_0010; +pub const IN_CLOSE: u32 = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE); +pub const IN_OPEN: u32 = 0x0000_0020; +pub const IN_MOVED_FROM: u32 = 0x0000_0040; +pub const IN_MOVED_TO: u32 = 0x0000_0080; +pub const IN_MOVE: u32 = (IN_MOVED_FROM | IN_MOVED_TO); +pub const IN_CREATE: u32 = 0x0000_0100; +pub const IN_DELETE: u32 = 0x0000_0200; +pub const IN_DELETE_SELF: u32 = 0x0000_0400; +pub const IN_MOVE_SELF: u32 = 0x0000_0800; +pub const IN_UNMOUNT: u32 = 0x0000_2000; +pub const IN_Q_OVERFLOW: u32 = 0x0000_4000; +pub const IN_IGNORED: u32 = 0x0000_8000; +pub const IN_ONLYDIR: u32 = 0x0100_0000; +pub const IN_DONT_FOLLOW: u32 = 0x0200_0000; +// pub const IN_EXCL_UNLINK: u32 = 0x0400_0000; + +// pub const IN_MASK_CREATE: u32 = 0x1000_0000; +// pub const IN_MASK_ADD: u32 = 0x2000_0000; +pub const IN_ISDIR: u32 = 0x4000_0000; +pub const IN_ONESHOT: u32 = 0x8000_0000; + +pub const IN_ALL_EVENTS: u32 = ( IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | @@ -1967,6 +2155,11 @@ f! { } extern { + #[cfg_attr(not(target_env = "musl"), + link_name = "__xpg_strerror_r")] + pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, + buflen: ::size_t) -> ::c_int; + pub fn abs(i: ::c_int) -> ::c_int; pub fn atof(s: *const ::c_char) -> ::c_double; pub fn labs(i: ::c_long) -> ::c_long; @@ -2134,12 +2327,6 @@ extern { flags: ::c_int) -> ::c_int; pub fn pthread_setschedprio(native: ::pthread_t, priority: ::c_int) -> ::c_int; - pub fn prlimit(pid: ::pid_t, resource: ::c_int, new_limit: *const ::rlimit, - old_limit: *mut ::rlimit) -> ::c_int; - pub fn prlimit64(pid: ::pid_t, - resource: ::c_int, - new_limit: *const ::rlimit64, - old_limit: *mut ::rlimit64) -> ::c_int; pub fn getloadavg(loadavg: *mut ::c_double, nelem: ::c_int) -> ::c_int; pub fn process_vm_readv(pid: ::pid_t, local_iov: *const ::iovec, @@ -2201,10 +2388,6 @@ extern { pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int; pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int; pub fn vhangup() -> ::c_int; - pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, - flags: ::c_int) -> ::c_int; - pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, - flags: ::c_int, timeout: *mut ::timespec) -> ::c_int; pub fn sync(); pub fn syscall(num: ::c_long, ...) -> ::c_long; pub fn sched_getaffinity(pid: ::pid_t, @@ -2457,7 +2640,7 @@ extern { pub fn inotify_init1(flags: ::c_int) -> ::c_int; pub fn inotify_add_watch(fd: ::c_int, path: *const ::c_char, - mask: ::uint32_t) -> ::c_int; + mask: u32) -> ::c_int; } cfg_if! { diff --git a/libc/src/unix/notbsd/linux/musl/b32/arm.rs b/libc/src/unix/notbsd/linux/musl/b32/arm.rs index 88d8798..7162fdf 100644 --- a/libc/src/unix/notbsd/linux/musl/b32/arm.rs +++ b/libc/src/unix/notbsd/linux/musl/b32/arm.rs @@ -150,17 +150,6 @@ s! { pub f_namemax: ::c_ulong, __f_spare: [::c_int; 6], } - - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } } pub const SIGSTKSZ: ::size_t = 8192; @@ -180,8 +169,9 @@ pub const RLIMIT_NOFILE: ::c_int = 7; pub const RLIMIT_AS: ::c_int = 9; pub const RLIMIT_NPROC: ::c_int = 6; pub const RLIMIT_MEMLOCK: ::c_int = 8; -pub const RLIMIT_NLIMITS: ::c_int = 16; +pub const RLIMIT_NLIMITS: ::c_int = 15; +pub const MADV_SOFT_OFFLINE: ::c_int = 101; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; pub const CBAUD: ::tcflag_t = 0o0010017; @@ -838,6 +828,17 @@ pub const SYS_pkey_alloc: ::c_long = 395; pub const SYS_pkey_free: ::c_long = 396; #[doc(hidden)] -pub const AF_MAX: ::c_int = 43; +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +pub const AF_MAX: ::c_int = 45; #[doc(hidden)] +#[allow(deprecated)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] pub const PF_MAX: ::c_int = AF_MAX; diff --git a/libc/src/unix/notbsd/linux/musl/b32/mips.rs b/libc/src/unix/notbsd/linux/musl/b32/mips.rs index 37430af..fbecb49 100644 --- a/libc/src/unix/notbsd/linux/musl/b32/mips.rs +++ b/libc/src/unix/notbsd/linux/musl/b32/mips.rs @@ -161,17 +161,6 @@ s! { pub f_namemax: ::c_ulong, __f_spare: [::c_int; 6], } - - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 23], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } } pub const SIGSTKSZ: ::size_t = 8192; @@ -191,7 +180,7 @@ pub const RLIMIT_NOFILE: ::c_int = 5; pub const RLIMIT_AS: ::c_int = 6; pub const RLIMIT_NPROC: ::c_int = 8; pub const RLIMIT_MEMLOCK: ::c_int = 9; -pub const RLIMIT_NLIMITS: ::c_int = 16; +pub const RLIMIT_NLIMITS: ::c_int = 15; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; @@ -848,6 +837,17 @@ pub const SYS_preadv2: ::c_long = 4000 + 361; pub const SYS_pwritev2: ::c_long = 4000 + 362; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] pub const AF_MAX: ::c_int = 42; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +#[allow(deprecated)] pub const PF_MAX: ::c_int = AF_MAX; diff --git a/libc/src/unix/notbsd/linux/musl/b32/powerpc.rs b/libc/src/unix/notbsd/linux/musl/b32/powerpc.rs index d0f2d68..eafd7a6 100644 --- a/libc/src/unix/notbsd/linux/musl/b32/powerpc.rs +++ b/libc/src/unix/notbsd/linux/musl/b32/powerpc.rs @@ -153,19 +153,9 @@ s! { pub f_namemax: ::c_ulong, __f_spare: [::c_int; 6], } - - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_cc: [::cc_t; 19], - pub c_line: ::cc_t, - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } } +pub const MADV_SOFT_OFFLINE: ::c_int = 101; pub const SIGSTKSZ: ::size_t = 10240; pub const MINSIGSTKSZ: ::size_t = 4096; @@ -864,6 +854,17 @@ pub const SYS_pkey_free: ::c_long = 385; pub const SYS_pkey_mprotect: ::c_long = 386; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] pub const AF_MAX: ::c_int = 43; #[doc(hidden)] +#[allow(deprecated)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] pub const PF_MAX: ::c_int = AF_MAX; diff --git a/libc/src/unix/notbsd/linux/musl/b32/x86.rs b/libc/src/unix/notbsd/linux/musl/b32/x86.rs index 8bfb60b..3e8579a 100644 --- a/libc/src/unix/notbsd/linux/musl/b32/x86.rs +++ b/libc/src/unix/notbsd/linux/musl/b32/x86.rs @@ -154,17 +154,6 @@ s! { pub f_namemax: ::c_ulong, __f_spare: [::c_int; 6], } - - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } } s_no_extra_traits!{ @@ -240,8 +229,9 @@ pub const RLIMIT_NOFILE: ::c_int = 7; pub const RLIMIT_AS: ::c_int = 9; pub const RLIMIT_NPROC: ::c_int = 6; pub const RLIMIT_MEMLOCK: ::c_int = 8; -pub const RLIMIT_NLIMITS: ::c_int = 16; +pub const RLIMIT_NLIMITS: ::c_int = 15; +pub const MADV_SOFT_OFFLINE: ::c_int = 101; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; pub const CBAUD: ::tcflag_t = 0o0010017; @@ -946,6 +936,17 @@ pub const UESP: ::c_int = 15; pub const SS: ::c_int = 16; #[doc(hidden)] -pub const AF_MAX: ::c_int = 42; +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +pub const AF_MAX: ::c_int = 45; #[doc(hidden)] +#[allow(deprecated)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] pub const PF_MAX: ::c_int = AF_MAX; diff --git a/libc/src/unix/notbsd/linux/musl/b64/aarch64.rs b/libc/src/unix/notbsd/linux/musl/b64/aarch64.rs index f01a5c4..16cb46d 100644 --- a/libc/src/unix/notbsd/linux/musl/b64/aarch64.rs +++ b/libc/src/unix/notbsd/linux/musl/b64/aarch64.rs @@ -71,10 +71,22 @@ pub const MINSIGSTKSZ: ::size_t = 6144; pub const SIGSTKSZ: ::size_t = 12288; #[doc(hidden)] -pub const PF_MAX: ::c_int = 43; +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +pub const PF_MAX: ::c_int = 45; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +#[allow(deprecated)] pub const AF_MAX: ::c_int = PF_MAX; +pub const MADV_SOFT_OFFLINE: ::c_int = 101; pub const SYS_io_setup: ::c_long = 0; pub const SYS_io_destroy: ::c_long = 1; pub const SYS_io_submit: ::c_long = 2; @@ -340,7 +352,7 @@ pub const SYS_pkey_mprotect: ::c_long = 288; pub const SYS_pkey_alloc: ::c_long = 289; pub const SYS_pkey_free: ::c_long = 290; -pub const RLIMIT_NLIMITS: ::c_int = 16; +pub const RLIMIT_NLIMITS: ::c_int = 15; pub const TIOCINQ: ::c_int = ::FIONREAD; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; diff --git a/libc/src/unix/notbsd/linux/musl/b64/mod.rs b/libc/src/unix/notbsd/linux/musl/b64/mod.rs index 043ca8d..34b3766 100644 --- a/libc/src/unix/notbsd/linux/musl/b64/mod.rs +++ b/libc/src/unix/notbsd/linux/musl/b64/mod.rs @@ -127,17 +127,6 @@ s! { pub _pad: [::c_int; 29], _align: [usize; 0], } - - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } } pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; diff --git a/libc/src/unix/notbsd/linux/musl/b64/powerpc64.rs b/libc/src/unix/notbsd/linux/musl/b64/powerpc64.rs index 04eba48..4a8df27 100644 --- a/libc/src/unix/notbsd/linux/musl/b64/powerpc64.rs +++ b/libc/src/unix/notbsd/linux/musl/b64/powerpc64.rs @@ -60,6 +60,7 @@ s! { } } +pub const MADV_SOFT_OFFLINE: ::c_int = 101; pub const MAP_32BIT: ::c_int = 0x0040; pub const O_DIRECT: ::c_int = 0x20000; pub const O_DIRECTORY: ::c_int = 0x4000; @@ -70,8 +71,19 @@ pub const SIGSTKSZ: ::size_t = 10240; pub const MINSIGSTKSZ: ::size_t = 4096; #[doc(hidden)] -pub const AF_MAX: ::c_int = 43; +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +pub const AF_MAX: ::c_int = 45; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +#[allow(deprecated)] pub const PF_MAX: ::c_int = AF_MAX; // Syscall table diff --git a/libc/src/unix/notbsd/linux/musl/b64/x86_64.rs b/libc/src/unix/notbsd/linux/musl/b64/x86_64.rs index 94c5d88..df0ce40 100644 --- a/libc/src/unix/notbsd/linux/musl/b64/x86_64.rs +++ b/libc/src/unix/notbsd/linux/musl/b64/x86_64.rs @@ -483,21 +483,36 @@ pub const ES: ::c_int = 24; pub const FS: ::c_int = 25; pub const GS: ::c_int = 26; +pub const MADV_SOFT_OFFLINE: ::c_int = 101; pub const MAP_32BIT: ::c_int = 0x0040; pub const O_DIRECT: ::c_int = 0x4000; pub const O_DIRECTORY: ::c_int = 0x10000; pub const O_LARGEFILE: ::c_int = 0; pub const O_NOFOLLOW: ::c_int = 0x20000; +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; + pub const SIGSTKSZ: ::size_t = 8192; pub const MINSIGSTKSZ: ::size_t = 2048; #[doc(hidden)] -pub const AF_MAX: ::c_int = 42; +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +pub const AF_MAX: ::c_int = 45; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +#[allow(deprecated)] pub const PF_MAX: ::c_int = AF_MAX; -pub const RLIMIT_NLIMITS: ::c_int = 16; +pub const RLIMIT_NLIMITS: ::c_int = 15; pub const TIOCINQ: ::c_int = ::FIONREAD; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; diff --git a/libc/src/unix/notbsd/linux/musl/mod.rs b/libc/src/unix/notbsd/linux/musl/mod.rs index 4f4a3d8..99d3ed8 100644 --- a/libc/src/unix/notbsd/linux/musl/mod.rs +++ b/libc/src/unix/notbsd/linux/musl/mod.rs @@ -1,3 +1,4 @@ +pub type pthread_t = *mut ::c_void; pub type clock_t = c_long; pub type time_t = c_long; pub type suseconds_t = c_long; @@ -168,6 +169,8 @@ cfg_if! { } } +pub const MS_RMT_MASK: ::c_ulong = 0x02800051; + pub const SFD_CLOEXEC: ::c_int = 0x080000; pub const NCCS: usize = 32; @@ -239,6 +242,10 @@ pub const TCP_REPAIR_OPTIONS: ::c_int = 22; pub const TCP_FASTOPEN: ::c_int = 23; pub const TCP_TIMESTAMP: ::c_int = 24; +#[deprecated( + since = "0.2.55", + note = "Use SIGSYS instead" +)] pub const SIGUNUSED: ::c_int = ::SIGSYS; pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; @@ -279,6 +286,9 @@ pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209; pub const EPOLLWAKEUP: ::c_int = 0x20000000; +pub const SEEK_DATA: ::c_int = 3; +pub const SEEK_HOLE: ::c_int = 4; + pub const EFD_NONBLOCK: ::c_int = ::O_NONBLOCK; pub const SFD_NONBLOCK: ::c_int = ::O_NONBLOCK; @@ -321,7 +331,41 @@ pub const SO_RXQ_OVFL: ::c_int = 40; pub const SO_PEEK_OFF: ::c_int = 42; pub const SO_BUSY_POLL: ::c_int = 46; +pub const RLIMIT_CPU: ::c_int = 0; +pub const RLIMIT_FSIZE: ::c_int = 1; +pub const RLIMIT_DATA: ::c_int = 2; +pub const RLIMIT_STACK: ::c_int = 3; +pub const RLIMIT_CORE: ::c_int = 4; +pub const RLIMIT_LOCKS: ::c_int = 10; +pub const RLIMIT_SIGPENDING: ::c_int = 11; +pub const RLIMIT_MSGQUEUE: ::c_int = 12; +pub const RLIMIT_NICE: ::c_int = 13; +pub const RLIMIT_RTPRIO: ::c_int = 14; + extern { + pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, + flags: ::c_uint) -> ::c_int; + pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, + flags: ::c_uint, timeout: *mut ::timespec) -> ::c_int; + + pub fn getrlimit64(resource: ::c_int, + rlim: *mut ::rlimit64) -> ::c_int; + pub fn setrlimit64(resource: ::c_int, + rlim: *const ::rlimit64) -> ::c_int; + pub fn getrlimit(resource: ::c_int, + rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::c_int, + rlim: *const ::rlimit) -> ::c_int; + pub fn prlimit(pid: ::pid_t, + resource: ::c_int, new_limit: *const ::rlimit, + old_limit: *mut ::rlimit) -> ::c_int; + pub fn prlimit64(pid: ::pid_t, + resource: ::c_int, + new_limit: *const ::rlimit64, + old_limit: *mut ::rlimit64) -> ::c_int; + + pub fn gettimeofday(tp: *mut ::timeval, + tz: *mut ::c_void) -> ::c_int; pub fn ptrace(request: ::c_int, ...) -> ::c_long; 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; diff --git a/libc/src/unix/notbsd/linux/other/b32/arm.rs b/libc/src/unix/notbsd/linux/other/b32/arm.rs index 7f00d9a..a2d190d 100644 --- a/libc/src/unix/notbsd/linux/other/b32/arm.rs +++ b/libc/src/unix/notbsd/linux/other/b32/arm.rs @@ -142,15 +142,15 @@ pub const MCL_FUTURE: ::c_int = 0x0002; pub const SIGSTKSZ: ::size_t = 8192; pub const MINSIGSTKSZ: ::size_t = 2048; pub const CBAUD: ::tcflag_t = 0o0010017; -pub const TAB1: ::c_int = 0x00000800; -pub const TAB2: ::c_int = 0x00001000; -pub const TAB3: ::c_int = 0x00001800; -pub const CR1: ::c_int = 0x00000200; -pub const CR2: ::c_int = 0x00000400; -pub const CR3: ::c_int = 0x00000600; -pub const FF1: ::c_int = 0x00008000; -pub const BS1: ::c_int = 0x00002000; -pub const VT1: ::c_int = 0x00004000; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const FF1: ::tcflag_t = 0x00008000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VT1: ::tcflag_t = 0x00004000; pub const VWERASE: usize = 14; pub const VREPRINT: usize = 12; pub const VSUSP: usize = 10; @@ -252,6 +252,8 @@ pub const TIOCSPGRP: ::c_ulong = 0x5410; pub const TIOCOUTQ: ::c_ulong = 0x5411; pub const TIOCGWINSZ: ::c_ulong = 0x5413; pub const TIOCSWINSZ: ::c_ulong = 0x5414; +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; pub const FIONREAD: ::c_ulong = 0x541B; // Syscall table @@ -607,3 +609,4 @@ pub const SYS_pwritev2: ::c_long = 393; pub const SYS_pkey_mprotect: ::c_long = 394; pub const SYS_pkey_alloc: ::c_long = 395; pub const SYS_pkey_free: ::c_long = 396; +pub const SYS_statx: ::c_long = 397; diff --git a/libc/src/unix/notbsd/linux/other/b32/mod.rs b/libc/src/unix/notbsd/linux/other/b32/mod.rs index d078f75..32e510e 100644 --- a/libc/src/unix/notbsd/linux/other/b32/mod.rs +++ b/libc/src/unix/notbsd/linux/other/b32/mod.rs @@ -228,6 +228,10 @@ pub const SIGURG: ::c_int = 23; pub const SIGIO: ::c_int = 29; pub const SIGSYS: ::c_int = 31; pub const SIGSTKFLT: ::c_int = 16; +#[deprecated( + since = "0.2.55", + note = "Use SIGSYS instead" +)] pub const SIGUNUSED: ::c_int = 31; pub const SIGPOLL: ::c_int = 29; pub const SIGPWR: ::c_int = 30; diff --git a/libc/src/unix/notbsd/linux/other/b32/powerpc.rs b/libc/src/unix/notbsd/linux/other/b32/powerpc.rs index 0ea9034..a64f075 100644 --- a/libc/src/unix/notbsd/linux/other/b32/powerpc.rs +++ b/libc/src/unix/notbsd/linux/other/b32/powerpc.rs @@ -9,10 +9,10 @@ s! { pub cuid: ::uid_t, pub cgid: ::gid_t, pub mode: ::mode_t, - __seq: ::uint32_t, - __pad1: ::uint32_t, - __glibc_reserved1: ::uint64_t, - __glibc_reserved2: ::uint64_t, + __seq: u32, + __pad1: u32, + __glibc_reserved1: u64, + __glibc_reserved2: u64, } pub struct stat64 { @@ -132,15 +132,15 @@ pub const MCL_FUTURE: ::c_int = 0x4000; pub const SIGSTKSZ: ::size_t = 0x4000; pub const MINSIGSTKSZ: ::size_t = 4096; pub const CBAUD: ::tcflag_t = 0xff; -pub const TAB1: ::c_int = 0x400; -pub const TAB2: ::c_int = 0x800; -pub const TAB3: ::c_int = 0xc00; -pub const CR1: ::c_int = 0x1000; -pub const CR2: ::c_int = 0x2000; -pub const CR3: ::c_int = 0x3000; -pub const FF1: ::c_int = 0x4000; -pub const BS1: ::c_int = 0x8000; -pub const VT1: ::c_int = 0x10000; +pub const TAB1: ::tcflag_t = 0x400; +pub const TAB2: ::tcflag_t = 0x800; +pub const TAB3: ::tcflag_t = 0xc00; +pub const CR1: ::tcflag_t = 0x1000; +pub const CR2: ::tcflag_t = 0x2000; +pub const CR3: ::tcflag_t = 0x3000; +pub const FF1: ::tcflag_t = 0x4000; +pub const BS1: ::tcflag_t = 0x8000; +pub const VT1: ::tcflag_t = 0x10000; pub const VWERASE: usize = 0xa; pub const VREPRINT: usize = 0xb; pub const VSUSP: usize = 0xc; @@ -241,6 +241,8 @@ pub const TIOCSPGRP: ::c_ulong = 0x80047476; pub const TIOCOUTQ: ::c_ulong = 0x40047473; pub const TIOCGWINSZ: ::c_ulong = 0x40087468; pub const TIOCSWINSZ: ::c_ulong = 0x80087467; +pub const TIOCGRS485: ::c_int = 0x542e; +pub const TIOCSRS485: ::c_int = 0x542f; pub const FIONREAD: ::c_ulong = 0x4004667f; pub const SYS_restart_syscall: ::c_long = 0; @@ -612,3 +614,4 @@ pub const SYS_copy_file_range: ::c_long = 379; pub const SYS_preadv2: ::c_long = 380; pub const SYS_pwritev2: ::c_long = 381; pub const SYS_kexec_file_load: ::c_long = 382; +pub const SYS_statx: ::c_long = 383; diff --git a/libc/src/unix/notbsd/linux/other/b32/x86.rs b/libc/src/unix/notbsd/linux/other/b32/x86.rs index e7c3b9a..00f1f1a 100644 --- a/libc/src/unix/notbsd/linux/other/b32/x86.rs +++ b/libc/src/unix/notbsd/linux/other/b32/x86.rs @@ -348,15 +348,15 @@ pub const MCL_FUTURE: ::c_int = 0x0002; pub const SIGSTKSZ: ::size_t = 8192; pub const MINSIGSTKSZ: ::size_t = 2048; pub const CBAUD: ::tcflag_t = 0o0010017; -pub const TAB1: ::c_int = 0x00000800; -pub const TAB2: ::c_int = 0x00001000; -pub const TAB3: ::c_int = 0x00001800; -pub const CR1: ::c_int = 0x00000200; -pub const CR2: ::c_int = 0x00000400; -pub const CR3: ::c_int = 0x00000600; -pub const FF1: ::c_int = 0x00008000; -pub const BS1: ::c_int = 0x00002000; -pub const VT1: ::c_int = 0x00004000; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const FF1: ::tcflag_t = 0x00008000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VT1: ::tcflag_t = 0x00004000; pub const VWERASE: usize = 14; pub const VREPRINT: usize = 12; pub const VSUSP: usize = 10; @@ -458,6 +458,8 @@ pub const TIOCSPGRP: ::c_ulong = 0x5410; pub const TIOCOUTQ: ::c_ulong = 0x5411; pub const TIOCGWINSZ: ::c_ulong = 0x5413; pub const TIOCSWINSZ: ::c_ulong = 0x5414; +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; pub const FIONREAD: ::c_ulong = 0x541B; // Syscall table @@ -840,6 +842,7 @@ pub const SYS_pwritev2: ::c_long = 379; pub const SYS_pkey_mprotect: ::c_long = 380; pub const SYS_pkey_alloc: ::c_long = 381; pub const SYS_pkey_free: ::c_long = 382; +pub const SYS_statx: ::c_long = 383; // offsets in user_regs_structs, from sys/reg.h pub const EBX: ::c_int = 0; diff --git a/libc/src/unix/notbsd/linux/other/b64/aarch64.rs b/libc/src/unix/notbsd/linux/other/b64/aarch64.rs index 3bd2e02..090f893 100644 --- a/libc/src/unix/notbsd/linux/other/b64/aarch64.rs +++ b/libc/src/unix/notbsd/linux/other/b64/aarch64.rs @@ -147,6 +147,8 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; pub const RLIMIT_NOFILE: ::c_int = 7; pub const RLIMIT_NPROC: ::c_int = 6; @@ -315,6 +317,10 @@ pub const SIGURG: ::c_int = 23; pub const SIGIO: ::c_int = 29; pub const SIGSYS: ::c_int = 31; pub const SIGSTKFLT: ::c_int = 16; +#[deprecated( + since = "0.2.55", + note = "Use SIGSYS instead" +)] pub const SIGUNUSED: ::c_int = 31; pub const SIGPOLL: ::c_int = 29; pub const SIGPWR: ::c_int = 30; @@ -435,15 +441,15 @@ pub const MCL_FUTURE: ::c_int = 0x0002; pub const SIGSTKSZ: ::size_t = 16384; pub const MINSIGSTKSZ: ::size_t = 5120; pub const CBAUD: ::tcflag_t = 0o0010017; -pub const TAB1: ::c_int = 0x00000800; -pub const TAB2: ::c_int = 0x00001000; -pub const TAB3: ::c_int = 0x00001800; -pub const CR1: ::c_int = 0x00000200; -pub const CR2: ::c_int = 0x00000400; -pub const CR3: ::c_int = 0x00000600; -pub const FF1: ::c_int = 0x00008000; -pub const BS1: ::c_int = 0x00002000; -pub const VT1: ::c_int = 0x00004000; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const FF1: ::tcflag_t = 0x00008000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VT1: ::tcflag_t = 0x00004000; pub const VWERASE: usize = 14; pub const VREPRINT: usize = 12; pub const VSUSP: usize = 10; diff --git a/libc/src/unix/notbsd/linux/other/b64/not_x32.rs b/libc/src/unix/notbsd/linux/other/b64/not_x32.rs index e3e4498..97e21f2 100644 --- a/libc/src/unix/notbsd/linux/other/b64/not_x32.rs +++ b/libc/src/unix/notbsd/linux/other/b64/not_x32.rs @@ -408,6 +408,7 @@ pub const SYS_pwritev2: ::c_long = 328; pub const SYS_pkey_mprotect: ::c_long = 329; pub const SYS_pkey_alloc: ::c_long = 330; pub const SYS_pkey_free: ::c_long = 331; +pub const SYS_statx: ::c_long = 332; #[link(name = "util")] extern { diff --git a/libc/src/unix/notbsd/linux/other/b64/powerpc64.rs b/libc/src/unix/notbsd/linux/other/b64/powerpc64.rs index bc5b01c..b31248b 100644 --- a/libc/src/unix/notbsd/linux/other/b64/powerpc64.rs +++ b/libc/src/unix/notbsd/linux/other/b64/powerpc64.rs @@ -110,9 +110,9 @@ s! { pub cuid: ::uid_t, pub cgid: ::gid_t, pub mode: ::mode_t, - pub __seq: ::uint32_t, - __pad1: ::uint32_t, - __unused1: ::uint64_t, + pub __seq: u32, + __pad1: u32, + __unused1: u64, __unused2: ::c_ulong, } @@ -302,6 +302,10 @@ pub const SIGURG: ::c_int = 23; pub const SIGIO: ::c_int = 29; pub const SIGSYS: ::c_int = 31; pub const SIGSTKFLT: ::c_int = 16; +#[deprecated( + since = "0.2.55", + note = "Use SIGSYS instead" +)] pub const SIGUNUSED: ::c_int = 31; pub const SIGPOLL: ::c_int = 29; pub const SIGPWR: ::c_int = 30; @@ -340,6 +344,8 @@ pub const TIOCMBIS: ::c_ulong = 0x5416; pub const TIOCMBIC: ::c_ulong = 0x5417; pub const TIOCMSET: ::c_ulong = 0x5418; pub const TIOCCONS: ::c_ulong = 0x541D; +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; pub const SFD_CLOEXEC: ::c_int = 0x080000; @@ -446,15 +452,15 @@ pub const MCL_FUTURE: ::c_int = 0x4000; pub const SIGSTKSZ: ::size_t = 0x4000; pub const MINSIGSTKSZ: ::size_t = 4096; pub const CBAUD: ::tcflag_t = 0xff; -pub const TAB1: ::c_int = 0x400; -pub const TAB2: ::c_int = 0x800; -pub const TAB3: ::c_int = 0xc00; -pub const CR1: ::c_int = 0x1000; -pub const CR2: ::c_int = 0x2000; -pub const CR3: ::c_int = 0x3000; -pub const FF1: ::c_int = 0x4000; -pub const BS1: ::c_int = 0x8000; -pub const VT1: ::c_int = 0x10000; +pub const TAB1: ::tcflag_t = 0x400; +pub const TAB2: ::tcflag_t = 0x800; +pub const TAB3: ::tcflag_t = 0xc00; +pub const CR1: ::tcflag_t = 0x1000; +pub const CR2: ::tcflag_t = 0x2000; +pub const CR3: ::tcflag_t = 0x3000; +pub const FF1: ::tcflag_t = 0x4000; +pub const BS1: ::tcflag_t = 0x8000; +pub const VT1: ::tcflag_t = 0x10000; pub const VWERASE: usize = 0xa; pub const VREPRINT: usize = 0xb; pub const VSUSP: usize = 0xc; @@ -917,6 +923,7 @@ pub const SYS_copy_file_range: ::c_long = 379; pub const SYS_preadv2: ::c_long = 380; pub const SYS_pwritev2: ::c_long = 381; pub const SYS_kexec_file_load: ::c_long = 382; +pub const SYS_statx: ::c_long = 383; #[link(name = "util")] extern { diff --git a/libc/src/unix/notbsd/linux/other/b64/sparc64.rs b/libc/src/unix/notbsd/linux/other/b64/sparc64.rs index 5d26865..f54504a 100644 --- a/libc/src/unix/notbsd/linux/other/b64/sparc64.rs +++ b/libc/src/unix/notbsd/linux/other/b64/sparc64.rs @@ -404,15 +404,15 @@ pub const MCL_FUTURE: ::c_int = 0x4000; pub const SIGSTKSZ: ::size_t = 16384; pub const MINSIGSTKSZ: ::size_t = 4096; pub const CBAUD: ::tcflag_t = 0x0000100f; -pub const TAB1: ::c_int = 0x800; -pub const TAB2: ::c_int = 0x1000; -pub const TAB3: ::c_int = 0x1800; -pub const CR1: ::c_int = 0x200; -pub const CR2: ::c_int = 0x400; -pub const CR3: ::c_int = 0x600; -pub const FF1: ::c_int = 0x8000; -pub const BS1: ::c_int = 0x2000; -pub const VT1: ::c_int = 0x4000; +pub const TAB1: ::tcflag_t = 0x800; +pub const TAB2: ::tcflag_t = 0x1000; +pub const TAB3: ::tcflag_t = 0x1800; +pub const CR1: ::tcflag_t = 0x200; +pub const CR2: ::tcflag_t = 0x400; +pub const CR3: ::tcflag_t = 0x600; +pub const FF1: ::tcflag_t = 0x8000; +pub const BS1: ::tcflag_t = 0x2000; +pub const VT1: ::tcflag_t = 0x4000; pub const VWERASE: usize = 0xe; pub const VREPRINT: usize = 0xc; pub const VSUSP: usize = 0xa; @@ -855,6 +855,7 @@ pub const SYS_mlock2: ::c_long = 356; pub const SYS_copy_file_range: ::c_long = 357; pub const SYS_preadv2: ::c_long = 358; pub const SYS_pwritev2: ::c_long = 359; +pub const SYS_statx: ::c_long = 360; #[link(name = "util")] extern { diff --git a/libc/src/unix/notbsd/linux/other/b64/x32.rs b/libc/src/unix/notbsd/linux/other/b64/x32.rs index d88dbaf..3746881 100644 --- a/libc/src/unix/notbsd/linux/other/b64/x32.rs +++ b/libc/src/unix/notbsd/linux/other/b64/x32.rs @@ -336,6 +336,7 @@ pub const SYS_copy_file_range: ::c_long = __X32_SYSCALL_BIT + 326; pub const SYS_pkey_mprotect: ::c_long = __X32_SYSCALL_BIT + 329; pub const SYS_pkey_alloc: ::c_long = __X32_SYSCALL_BIT + 330; pub const SYS_pkey_free: ::c_long = __X32_SYSCALL_BIT + 331; +pub const SYS_statx: ::c_long = __X32_SYSCALL_BIT + 332; pub const SYS_rt_sigaction: ::c_long = __X32_SYSCALL_BIT + 512; pub const SYS_rt_sigreturn: ::c_long = __X32_SYSCALL_BIT + 513; pub const SYS_ioctl: ::c_long = __X32_SYSCALL_BIT + 514; diff --git a/libc/src/unix/notbsd/linux/other/b64/x86_64.rs b/libc/src/unix/notbsd/linux/other/b64/x86_64.rs index 79f27e0..fb39bf3 100644 --- a/libc/src/unix/notbsd/linux/other/b64/x86_64.rs +++ b/libc/src/unix/notbsd/linux/other/b64/x86_64.rs @@ -332,6 +332,8 @@ cfg_if! { pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; +pub const TIOCGRS485: ::c_int = 0x542E; +pub const TIOCSRS485: ::c_int = 0x542F; pub const RLIMIT_NOFILE: ::c_int = 7; pub const RLIMIT_NPROC: ::c_int = 6; @@ -500,6 +502,10 @@ pub const SIGURG: ::c_int = 23; pub const SIGIO: ::c_int = 29; pub const SIGSYS: ::c_int = 31; pub const SIGSTKFLT: ::c_int = 16; +#[deprecated( + since = "0.2.55", + note = "Use SIGSYS instead" +)] pub const SIGUNUSED: ::c_int = 31; pub const SIGPOLL: ::c_int = 29; pub const SIGPWR: ::c_int = 30; @@ -601,15 +607,15 @@ pub const MCL_FUTURE: ::c_int = 0x0002; pub const SIGSTKSZ: ::size_t = 8192; pub const MINSIGSTKSZ: ::size_t = 2048; pub const CBAUD: ::tcflag_t = 0o0010017; -pub const TAB1: ::c_int = 0x00000800; -pub const TAB2: ::c_int = 0x00001000; -pub const TAB3: ::c_int = 0x00001800; -pub const CR1: ::c_int = 0x00000200; -pub const CR2: ::c_int = 0x00000400; -pub const CR3: ::c_int = 0x00000600; -pub const FF1: ::c_int = 0x00008000; -pub const BS1: ::c_int = 0x00002000; -pub const VT1: ::c_int = 0x00004000; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const FF1: ::tcflag_t = 0x00008000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VT1: ::tcflag_t = 0x00004000; pub const VWERASE: usize = 14; pub const VREPRINT: usize = 12; pub const VSUSP: usize = 10; diff --git a/libc/src/unix/notbsd/linux/other/mod.rs b/libc/src/unix/notbsd/linux/other/mod.rs index 1a97d1c..7ce58ad 100644 --- a/libc/src/unix/notbsd/linux/other/mod.rs +++ b/libc/src/unix/notbsd/linux/other/mod.rs @@ -1,6 +1,38 @@ +pub type pthread_t = c_ulong; pub type __priority_which_t = ::c_uint; +pub type __rlimit_resource_t = ::c_uint; s! { + pub struct statx { + pub stx_mask: u32, + pub stx_blksize: u32, + pub stx_attributes: u64, + pub stx_nlink: u32, + pub stx_uid: u32, + pub stx_gid: u32, + pub stx_mode: u16, + pub __statx_pad1: [u16; 1], + pub stx_ino: u64, + pub stx_size: u64, + pub stx_blocks: u64, + pub stx_attributes_mask: u64, + pub stx_atime: ::statx_timestamp, + pub stx_btime: ::statx_timestamp, + pub stx_ctime: ::statx_timestamp, + pub stx_mtime: ::statx_timestamp, + pub stx_rdev_major: u32, + pub stx_rdev_minor: u32, + pub stx_dev_major: u32, + pub stx_dev_minor: u32, + pub __statx_pad2: [u64; 14], + } + + pub struct statx_timestamp { + pub tv_sec: i64, + pub tv_nsec: u32, + pub __statx_timestamp_pad1: [i32; 1], + } + pub struct aiocb { pub aio_fildes: ::c_int, pub aio_lio_opcode: ::c_int, @@ -25,8 +57,8 @@ s! { } pub struct __timeval { - pub tv_sec: ::int32_t, - pub tv_usec: ::int32_t, + pub tv_sec: i32, + pub tv_usec: i32, } pub struct sigaction { @@ -48,6 +80,7 @@ s! { pub si_signo: ::c_int, pub si_errno: ::c_int, pub si_code: ::c_int, + #[doc(hidden)] #[deprecated( since="0.2.54", note="Please leave a comment on \ @@ -236,13 +269,13 @@ s_no_extra_traits! { #[cfg(not(any(target_arch = "aarch64", all(target_pointer_width = "32", not(target_arch = "x86_64")))))] - pub ut_session: ::int32_t, + pub ut_session: i32, #[cfg(not(any(target_arch = "aarch64", all(target_pointer_width = "32", not(target_arch = "x86_64")))))] pub ut_tv: __timeval, - pub ut_addr_v6: [::int32_t; 4], + pub ut_addr_v6: [i32; 4], __glibc_reserved: [::c_char; 20], } } @@ -307,6 +340,20 @@ cfg_if! { } } +pub const RLIMIT_CPU: ::__rlimit_resource_t = 0; +pub const RLIMIT_FSIZE: ::__rlimit_resource_t = 1; +pub const RLIMIT_DATA: ::__rlimit_resource_t = 2; +pub const RLIMIT_STACK: ::__rlimit_resource_t = 3; +pub const RLIMIT_CORE: ::__rlimit_resource_t = 4; +pub const RLIMIT_LOCKS: ::__rlimit_resource_t = 10; +pub const RLIMIT_SIGPENDING: ::__rlimit_resource_t = 11; +pub const RLIMIT_MSGQUEUE: ::__rlimit_resource_t = 12; +pub const RLIMIT_NICE: ::__rlimit_resource_t = 13; +pub const RLIMIT_RTPRIO: ::__rlimit_resource_t = 14; + +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MS_RMT_MASK: ::c_ulong = 0x02800051; + pub const __UT_LINESIZE: usize = 32; pub const __UT_NAMESIZE: usize = 32; pub const __UT_HOSTSIZE: usize = 256; @@ -373,6 +420,8 @@ pub const MAP_EXECUTABLE: ::c_int = 0x01000; pub const MAP_POPULATE: ::c_int = 0x08000; pub const MAP_NONBLOCK: ::c_int = 0x010000; pub const MAP_STACK: ::c_int = 0x020000; +pub const MAP_SHARED_VALIDATE: ::c_int = 0x3; +pub const MAP_FIXED_NOREPLACE: ::c_int = 0x100000; pub const ENOTSUP: ::c_int = EOPNOTSUPP; pub const EUCLEAN: ::c_int = 117; @@ -601,6 +650,41 @@ pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4; pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2; pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543; +// linux/rtnetlink.h +pub const TCA_PAD: ::c_ushort = 9; +pub const TCA_DUMP_INVISIBLE: ::c_ushort = 10; +pub const TCA_CHAIN: ::c_ushort = 11; +pub const TCA_HW_OFFLOAD: ::c_ushort = 12; + +pub const RTM_F_LOOKUP_TABLE: ::c_uint = 0x1000; +pub const RTM_F_FIB_MATCH: ::c_uint = 0x2000; + +pub const RTA_VIA: ::c_ushort = 18; +pub const RTA_NEWDST: ::c_ushort = 19; +pub const RTA_PREF: ::c_ushort = 20; +pub const RTA_ENCAP_TYPE: ::c_ushort = 21; +pub const RTA_ENCAP: ::c_ushort = 22; +pub const RTA_EXPIRES: ::c_ushort = 23; +pub const RTA_PAD: ::c_ushort = 24; +pub const RTA_UID: ::c_ushort = 25; +pub const RTA_TTL_PROPAGATE: ::c_ushort = 26; + +// linux/neighbor.h +pub const NTF_EXT_LEARNED: u8 = 0x10; +pub const NTF_OFFLOADED: u8 = 0x20; + +pub const NDA_MASTER: ::c_ushort = 9; +pub const NDA_LINK_NETNSID: ::c_ushort = 10; +pub const NDA_SRC_VNI: ::c_ushort = 11; + +// linux/if_addr.h +pub const IFA_FLAGS: ::c_ushort = 8; + +pub const IFA_F_MANAGETEMPADDR: u32 = 0x100; +pub const IFA_F_NOPREFIXROUTE: u32 = 0x200; +pub const IFA_F_MCAUTOJOIN: u32 = 0x400; +pub const IFA_F_STABLE_PRIVACY: u32 = 0x800; + pub const NETLINK_ROUTE: ::c_int = 0; pub const NETLINK_UNUSED: ::c_int = 1; pub const NETLINK_USERSOCK: ::c_int = 2; @@ -884,10 +968,47 @@ pub const M_ARENA_TEST: ::c_int = -7; pub const M_ARENA_MAX: ::c_int = -8; #[doc(hidden)] -pub const AF_MAX: ::c_int = 42; +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +pub const AF_MAX: ::c_int = 45; #[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] +#[allow(deprecated)] pub const PF_MAX: ::c_int = AF_MAX; +pub const AT_STATX_SYNC_TYPE: ::c_int = 0x6000; +pub const AT_STATX_SYNC_AS_STAT: ::c_int = 0x0000; +pub const AT_STATX_FORCE_SYNC: ::c_int = 0x2000; +pub const AT_STATX_DONT_SYNC: ::c_int = 0x4000; +pub const STATX_TYPE: ::c_uint = 0x0001; +pub const STATX_MODE: ::c_uint = 0x0002; +pub const STATX_NLINK: ::c_uint = 0x0004; +pub const STATX_UID: ::c_uint = 0x0008; +pub const STATX_GID: ::c_uint = 0x0010; +pub const STATX_ATIME: ::c_uint = 0x0020; +pub const STATX_MTIME: ::c_uint = 0x0040; +pub const STATX_CTIME: ::c_uint = 0x0080; +pub const STATX_INO: ::c_uint = 0x0100; +pub const STATX_SIZE: ::c_uint = 0x0200; +pub const STATX_BLOCKS: ::c_uint = 0x0400; +pub const STATX_BASIC_STATS: ::c_uint = 0x07ff; +pub const STATX_BTIME: ::c_uint = 0x0800; +pub const STATX_ALL: ::c_uint = 0x0fff; +pub const STATX__RESERVED: ::c_int = 0x80000000; +pub const STATX_ATTR_COMPRESSED: ::c_int = 0x0004; +pub const STATX_ATTR_IMMUTABLE: ::c_int = 0x0010; +pub const STATX_ATTR_APPEND: ::c_int = 0x0020; +pub const STATX_ATTR_NODUMP: ::c_int = 0x0040; +pub const STATX_ATTR_ENCRYPTED: ::c_int = 0x0800; +pub const STATX_ATTR_AUTOMOUNT: ::c_int = 0x1000; + cfg_if! { if #[cfg(any(target_arch = "arm", target_arch = "x86", target_arch = "x86_64"))] { @@ -907,6 +1028,26 @@ f! { } extern { + pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, + flags: ::c_int) -> ::c_int; + pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, + flags: ::c_int, timeout: *mut ::timespec) -> ::c_int; + + pub fn getrlimit64(resource: ::__rlimit_resource_t, + rlim: *mut ::rlimit64) -> ::c_int; + pub fn setrlimit64(resource: ::__rlimit_resource_t, + rlim: *const ::rlimit64) -> ::c_int; + pub fn getrlimit(resource: ::__rlimit_resource_t, + rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::__rlimit_resource_t, + rlim: *const ::rlimit) -> ::c_int; + pub fn prlimit(pid: ::pid_t, + resource: ::__rlimit_resource_t, new_limit: *const ::rlimit, + old_limit: *mut ::rlimit) -> ::c_int; + pub fn prlimit64(pid: ::pid_t, + resource: ::__rlimit_resource_t, + new_limit: *const ::rlimit64, + old_limit: *mut ::rlimit64) -> ::c_int; pub fn utmpxname(file: *const ::c_char) -> ::c_int; pub fn getutxent() -> *mut utmpx; pub fn getutxid(ut: *const utmpx) -> *mut utmpx; @@ -916,6 +1057,10 @@ extern { pub fn endutxent(); pub fn getpt() -> ::c_int; pub fn mallopt(param: ::c_int, value: ::c_int) -> ::c_int; + pub fn gettimeofday(tp: *mut ::timeval, + tz: *mut ::timezone) -> ::c_int; + pub fn statx(dirfd: ::c_int, pathname: *const c_char, flags: ::c_int, + mask: ::c_uint, statxbuf: *mut statx) -> ::c_int; } #[link(name = "util")] diff --git a/libc/src/unix/notbsd/linux/s390x/mod.rs b/libc/src/unix/notbsd/linux/s390x/mod.rs index d4cf956..5572094 100644 --- a/libc/src/unix/notbsd/linux/s390x/mod.rs +++ b/libc/src/unix/notbsd/linux/s390x/mod.rs @@ -1,5 +1,7 @@ use ::pthread_mutex_t; +pub type __rlimit_resource_t = ::c_uint; +pub type pthread_t = c_ulong; pub type blkcnt_t = i64; pub type blksize_t = i64; pub type c_char = u8; @@ -352,6 +354,9 @@ cfg_if! { } } +pub const MADV_SOFT_OFFLINE: ::c_int = 101; +pub const MS_RMT_MASK: ::c_ulong = 0x02800051; + pub const SFD_CLOEXEC: ::c_int = 0x080000; pub const NCCS: usize = 32; @@ -517,6 +522,8 @@ pub const MAP_NORESERVE: ::c_int = 0x04000; pub const MAP_POPULATE: ::c_int = 0x08000; pub const MAP_NONBLOCK: ::c_int = 0x010000; pub const MAP_STACK: ::c_int = 0x020000; +pub const MAP_SHARED_VALIDATE: ::c_int = 0x3; +pub const MAP_FIXED_NOREPLACE: ::c_int = 0x100000; pub const EDEADLOCK: ::c_int = 35; pub const ENAMETOOLONG: ::c_int = 36; @@ -636,6 +643,10 @@ pub const SIGURG: ::c_int = 23; pub const SIGIO: ::c_int = 29; pub const SIGSYS: ::c_int = 31; pub const SIGSTKFLT: ::c_int = 16; +#[deprecated( + since = "0.2.55", + note = "Use SIGSYS instead" +)] pub const SIGUNUSED: ::c_int = 31; pub const SIGTTIN: ::c_int = 21; pub const SIGTTOU: ::c_int = 22; @@ -981,6 +992,17 @@ pub const POLLWRBAND: ::c_short = 0x200; pub const IXON: ::tcflag_t = 0o002000; pub const IXOFF: ::tcflag_t = 0o010000; +pub const RLIMIT_CPU: ::__rlimit_resource_t = 0; +pub const RLIMIT_FSIZE: ::__rlimit_resource_t = 1; +pub const RLIMIT_DATA: ::__rlimit_resource_t = 2; +pub const RLIMIT_STACK: ::__rlimit_resource_t = 3; +pub const RLIMIT_CORE: ::__rlimit_resource_t = 4; +pub const RLIMIT_LOCKS: ::__rlimit_resource_t = 10; +pub const RLIMIT_SIGPENDING: ::__rlimit_resource_t = 11; +pub const RLIMIT_MSGQUEUE: ::__rlimit_resource_t = 12; +pub const RLIMIT_NICE: ::__rlimit_resource_t = 13; +pub const RLIMIT_RTPRIO: ::__rlimit_resource_t = 14; + pub const SYS_exit: ::c_long = 1; pub const SYS_fork: ::c_long = 2; pub const SYS_read: ::c_long = 3; @@ -1306,6 +1328,27 @@ pub const SYS_newfstatat: ::c_long = 293; #[link(name = "util")] extern { + pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, + flags: ::c_int) -> ::c_int; + pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint, + flags: ::c_int, timeout: *mut ::timespec) -> ::c_int; + + pub fn getrlimit64(resource: ::__rlimit_resource_t, + rlim: *mut ::rlimit64) -> ::c_int; + pub fn setrlimit64(resource: ::__rlimit_resource_t, + rlim: *const ::rlimit64) -> ::c_int; + pub fn getrlimit(resource: ::__rlimit_resource_t, + rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::__rlimit_resource_t, + rlim: *const ::rlimit) -> ::c_int; + pub fn prlimit(pid: ::pid_t, + resource: ::__rlimit_resource_t, new_limit: *const ::rlimit, + old_limit: *mut ::rlimit) -> ::c_int; + pub fn prlimit64(pid: ::pid_t, + resource: ::__rlimit_resource_t, + new_limit: *const ::rlimit64, + old_limit: *mut ::rlimit64) -> ::c_int; + pub fn sysctl(name: *mut ::c_int, namelen: ::c_int, oldp: *mut ::c_void, diff --git a/libc/src/unix/notbsd/mod.rs b/libc/src/unix/notbsd/mod.rs index d0905e1..2706466 100644 --- a/libc/src/unix/notbsd/mod.rs +++ b/libc/src/unix/notbsd/mod.rs @@ -1,5 +1,4 @@ pub type sa_family_t = u16; -pub type pthread_key_t = ::c_uint; pub type speed_t = ::c_uint; pub type tcflag_t = ::c_uint; pub type clockid_t = ::c_int; @@ -62,13 +61,6 @@ s! { pub ai_next: *mut addrinfo, } - pub struct sockaddr_nl { - pub nl_family: ::sa_family_t, - nl_pad: ::c_ushort, - pub nl_pid: u32, - pub nl_groups: u32 - } - pub struct sockaddr_ll { pub sll_family: ::c_ushort, pub sll_protocol: ::c_ushort, @@ -224,8 +216,8 @@ s_no_extra_traits!{ target_arch = "x86_64"), repr(packed))] pub struct epoll_event { - pub events: ::uint32_t, - pub u64: ::uint64_t, + pub events: u32, + pub u64: u64, } pub struct sockaddr_un { @@ -465,17 +457,6 @@ pub const CLOCK_BOOTTIME_ALARM: ::clockid_t = 9; // pub const CLOCK_TAI: ::clockid_t = 11; pub const TIMER_ABSTIME: ::c_int = 1; -pub const RLIMIT_CPU: ::c_int = 0; -pub const RLIMIT_FSIZE: ::c_int = 1; -pub const RLIMIT_DATA: ::c_int = 2; -pub const RLIMIT_STACK: ::c_int = 3; -pub const RLIMIT_CORE: ::c_int = 4; -pub const RLIMIT_LOCKS: ::c_int = 10; -pub const RLIMIT_SIGPENDING: ::c_int = 11; -pub const RLIMIT_MSGQUEUE: ::c_int = 12; -pub const RLIMIT_NICE: ::c_int = 13; -pub const RLIMIT_RTPRIO: ::c_int = 14; - pub const RUSAGE_SELF: ::c_int = 0; pub const O_RDONLY: ::c_int = 0; @@ -580,10 +561,8 @@ pub const MS_KERNMOUNT: ::c_ulong = 0x400000; pub const MS_I_VERSION: ::c_ulong = 0x800000; pub const MS_STRICTATIME: ::c_ulong = 0x1000000; pub const MS_ACTIVE: ::c_ulong = 0x40000000; -pub const MS_NOUSER: ::c_ulong = 0x80000000; pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000; pub const MS_MGC_MSK: ::c_ulong = 0xffff0000; -pub const MS_RMT_MASK: ::c_ulong = 0x800051; pub const EPERM: ::c_int = 1; pub const ENOENT: ::c_int = 2; @@ -645,7 +624,6 @@ pub const MADV_NOHUGEPAGE: ::c_int = 15; pub const MADV_DONTDUMP: ::c_int = 16; pub const MADV_DODUMP: ::c_int = 17; pub const MADV_HWPOISON: ::c_int = 100; -pub const MADV_SOFT_OFFLINE: ::c_int = 101; pub const IFF_UP: ::c_int = 0x1; pub const IFF_BROADCAST: ::c_int = 0x2; @@ -866,16 +844,16 @@ pub const MNT_EXPIRE: ::c_int = 0x4; pub const Q_GETFMT: ::c_int = 0x800004; pub const Q_GETINFO: ::c_int = 0x800005; pub const Q_SETINFO: ::c_int = 0x800006; -pub const QIF_BLIMITS: ::uint32_t = 1; -pub const QIF_SPACE: ::uint32_t = 2; -pub const QIF_ILIMITS: ::uint32_t = 4; -pub const QIF_INODES: ::uint32_t = 8; -pub const QIF_BTIME: ::uint32_t = 16; -pub const QIF_ITIME: ::uint32_t = 32; -pub const QIF_LIMITS: ::uint32_t = 5; -pub const QIF_USAGE: ::uint32_t = 10; -pub const QIF_TIMES: ::uint32_t = 48; -pub const QIF_ALL: ::uint32_t = 63; +pub const QIF_BLIMITS: u32 = 1; +pub const QIF_SPACE: u32 = 2; +pub const QIF_ILIMITS: u32 = 4; +pub const QIF_INODES: u32 = 8; +pub const QIF_BTIME: u32 = 16; +pub const QIF_ITIME: u32 = 32; +pub const QIF_LIMITS: u32 = 5; +pub const QIF_USAGE: u32 = 10; +pub const QIF_TIMES: u32 = 48; +pub const QIF_ALL: u32 = 63; pub const MNT_FORCE: ::c_int = 0x1; @@ -892,13 +870,13 @@ pub const TCOON: ::c_int = 1; pub const TCIFLUSH: ::c_int = 0; pub const TCOFLUSH: ::c_int = 1; pub const TCIOFLUSH: ::c_int = 2; -pub const NL0: ::c_int = 0x00000000; -pub const NL1: ::c_int = 0x00000100; -pub const TAB0: ::c_int = 0x00000000; -pub const CR0: ::c_int = 0x00000000; -pub const FF0: ::c_int = 0x00000000; -pub const BS0: ::c_int = 0x00000000; -pub const VT0: ::c_int = 0x00000000; +pub const NL0: ::tcflag_t = 0x00000000; +pub const NL1: ::tcflag_t = 0x00000100; +pub const TAB0: ::tcflag_t = 0x00000000; +pub const CR0: ::tcflag_t = 0x00000000; +pub const FF0: ::tcflag_t = 0x00000000; +pub const BS0: ::tcflag_t = 0x00000000; +pub const VT0: ::tcflag_t = 0x00000000; pub const VERASE: usize = 2; pub const VKILL: usize = 3; pub const VINTR: usize = 0; @@ -1265,7 +1243,6 @@ extern { pshared: ::c_int, value: ::c_uint) -> ::c_int; - pub fn fdatasync(fd: ::c_int) -> ::c_int; pub fn mincore(addr: *mut ::c_void, len: ::size_t, vec: *mut ::c_uchar) -> ::c_int; @@ -1309,7 +1286,6 @@ extern { pub fn fstatat64(dirfd: ::c_int, pathname: *const c_char, buf: *mut stat64, flags: ::c_int) -> ::c_int; pub fn ftruncate64(fd: ::c_int, length: off64_t) -> ::c_int; - pub fn getrlimit64(resource: ::c_int, rlim: *mut rlimit64) -> ::c_int; pub fn lseek64(fd: ::c_int, offset: off64_t, whence: ::c_int) -> off64_t; pub fn lstat64(path: *const c_char, buf: *mut stat64) -> ::c_int; pub fn mmap64(addr: *mut ::c_void, @@ -1338,7 +1314,6 @@ extern { pub fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64; pub fn readdir64_r(dirp: *mut ::DIR, entry: *mut ::dirent64, result: *mut *mut ::dirent64) -> ::c_int; - pub fn setrlimit64(resource: ::c_int, rlim: *const rlimit64) -> ::c_int; pub fn stat64(path: *const c_char, buf: *mut stat64) -> ::c_int; pub fn truncate64(path: *const c_char, length: off64_t) -> ::c_int; diff --git a/libc/src/unix/redox/mod.rs b/libc/src/unix/redox/mod.rs index 4bb1ab4..388918e 100644 --- a/libc/src/unix/redox/mod.rs +++ b/libc/src/unix/redox/mod.rs @@ -534,6 +534,12 @@ cfg_if! { } extern { + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + + pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, + buflen: ::size_t) -> ::c_int; + // malloc.h pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; @@ -584,5 +590,7 @@ extern { iovcnt: ::c_int) -> ::ssize_t; // time.h + pub fn gettimeofday(tp: *mut ::timeval, + tz: *mut ::timezone) -> ::c_int; pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; } diff --git a/libc/src/unix/solarish/mod.rs b/libc/src/unix/solarish/mod.rs index 1092d15..49f76ea 100644 --- a/libc/src/unix/solarish/mod.rs +++ b/libc/src/unix/solarish/mod.rs @@ -343,8 +343,8 @@ s! { s_no_extra_traits! { #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed))] pub struct epoll_event { - pub events: ::uint32_t, - pub u64: ::uint64_t, + pub events: u32, + pub u64: u64, } pub struct sockaddr_un { @@ -1175,6 +1175,13 @@ pub const AF_INET_OFFLOAD: ::c_int = 30; pub const AF_TRILL: ::c_int = 31; pub const AF_PACKET: ::c_int = 32; pub const AF_LX_NETLINK: ::c_int = 33; + +#[doc(hidden)] +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] pub const AF_MAX: ::c_int = 33; pub const SOCK_DGRAM: ::c_int = 1; pub const SOCK_STREAM: ::c_int = 2; @@ -1786,6 +1793,12 @@ f! { } extern { + pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int; + + pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, + buflen: ::size_t) -> ::c_int; + pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, @@ -1800,6 +1813,8 @@ extern { pub fn rand() -> ::c_int; pub fn srand(seed: ::c_uint); + pub fn gettimeofday(tp: *mut ::timeval, + tz: *mut ::c_void) -> ::c_int; pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; pub fn freeifaddrs(ifa: *mut ::ifaddrs); diff --git a/libc/src/unix/uclibc/arm/mod.rs b/libc/src/unix/uclibc/arm/mod.rs index b250fb5..1651285 100644 --- a/libc/src/unix/uclibc/arm/mod.rs +++ b/libc/src/unix/uclibc/arm/mod.rs @@ -462,16 +462,16 @@ pub const POLLRDBAND: ::c_short = 0x80; pub const POLLRDNORM: ::c_short = 0x40; pub const POLLWRBAND: ::c_short = 0x200; pub const POLLWRNORM: ::c_short = 0x100; -pub const QIF_ALL: ::uint32_t = 0x3f; -pub const QIF_BLIMITS: ::uint32_t = 0x1; -pub const QIF_BTIME: ::uint32_t = 0x10; -pub const QIF_ILIMITS: ::uint32_t = 0x4; -pub const QIF_INODES: ::uint32_t = 0x8; -pub const QIF_ITIME: ::uint32_t = 0x20; -pub const QIF_LIMITS: ::uint32_t = 0x5; -pub const QIF_SPACE: ::uint32_t = 0x2; -pub const QIF_TIMES: ::uint32_t = 0x30; -pub const QIF_USAGE: ::uint32_t = 0xa; +pub const QIF_ALL: u32 = 0x3f; +pub const QIF_BLIMITS: u32 = 0x1; +pub const QIF_BTIME: u32 = 0x10; +pub const QIF_ILIMITS: u32 = 0x4; +pub const QIF_INODES: u32 = 0x8; +pub const QIF_ITIME: u32 = 0x20; +pub const QIF_LIMITS: u32 = 0x5; +pub const QIF_SPACE: u32 = 0x2; +pub const QIF_TIMES: u32 = 0x30; +pub const QIF_USAGE: u32 = 0xa; pub const SA_NOCLDSTOP: ::c_int = 0x1; pub const SA_NOCLDWAIT: ::c_int = 0x2; pub const SA_NODEFER: ::c_int = 0x40000000; diff --git a/libc/src/unix/uclibc/mips/mod.rs b/libc/src/unix/uclibc/mips/mod.rs index 27f6fe5..fa4b0cb 100644 --- a/libc/src/unix/uclibc/mips/mod.rs +++ b/libc/src/unix/uclibc/mips/mod.rs @@ -391,15 +391,15 @@ pub const MCL_FUTURE: ::c_int = 0x0002; pub const SIGSTKSZ: ::size_t = 8192; pub const CBAUD: ::tcflag_t = 0o0010017; -pub const TAB1: ::c_int = 0x00000800; -pub const TAB2: ::c_int = 0x00001000; -pub const TAB3: ::c_int = 0x00001800; -pub const CR1: ::c_int = 0x00000200; -pub const CR2: ::c_int = 0x00000400; -pub const CR3: ::c_int = 0x00000600; -pub const FF1: ::c_int = 0x00008000; -pub const BS1: ::c_int = 0x00002000; -pub const VT1: ::c_int = 0x00004000; +pub const TAB1: ::tcflag_t = 0x00000800; +pub const TAB2: ::tcflag_t = 0x00001000; +pub const TAB3: ::tcflag_t = 0x00001800; +pub const CR1: ::tcflag_t = 0x00000200; +pub const CR2: ::tcflag_t = 0x00000400; +pub const CR3: ::tcflag_t = 0x00000600; +pub const FF1: ::tcflag_t = 0x00008000; +pub const BS1: ::tcflag_t = 0x00002000; +pub const VT1: ::tcflag_t = 0x00004000; pub const VWERASE: usize = 14; pub const VREPRINT: usize = 12; pub const VSUSP: usize = 10; diff --git a/libc/src/unix/uclibc/mod.rs b/libc/src/unix/uclibc/mod.rs index e3baba0..568e0bc 100644 --- a/libc/src/unix/uclibc/mod.rs +++ b/libc/src/unix/uclibc/mod.rs @@ -80,13 +80,6 @@ s! { pub ai_next: *mut addrinfo, } - pub struct sockaddr_nl { - pub nl_family: ::sa_family_t, - nl_pad: ::c_ushort, - pub nl_pid: u32, - pub nl_groups: u32 - } - pub struct sockaddr_ll { pub sll_family: ::c_ushort, pub sll_protocol: ::c_ushort, @@ -242,53 +235,45 @@ s! { } pub struct dqblk { - pub dqb_bhardlimit: ::uint32_t, - pub dqb_bsoftlimit: ::uint32_t, - pub dqb_curblocks: ::uint32_t, - pub dqb_ihardlimit: ::uint32_t, - pub dqb_isoftlimit: ::uint32_t, - pub dqb_curinodes: ::uint32_t, + pub dqb_bhardlimit: u32, + pub dqb_bsoftlimit: u32, + pub dqb_curblocks: u32, + pub dqb_ihardlimit: u32, + pub dqb_isoftlimit: u32, + pub dqb_curinodes: u32, pub dqb_btime: ::time_t, pub dqb_itime: ::time_t, } pub struct signalfd_siginfo { - pub ssi_signo: ::uint32_t, - pub ssi_errno: ::int32_t, - pub ssi_code: ::int32_t, - pub ssi_pid: ::uint32_t, - pub ssi_uid: ::uint32_t, - pub ssi_fd: ::int32_t, - pub ssi_tid: ::uint32_t, - pub ssi_band: ::uint32_t, - pub ssi_overrun: ::uint32_t, - pub ssi_trapno: ::uint32_t, - pub ssi_status: ::int32_t, - pub ssi_int: ::int32_t, - pub ssi_ptr: ::uint64_t, - pub ssi_utime: ::uint64_t, - pub ssi_stime: ::uint64_t, - pub ssi_addr: ::uint64_t, - pub ssi_addr_lsb: ::uint16_t, - _pad2: ::uint16_t, - pub ssi_syscall: ::int32_t, - pub ssi_call_addr: ::uint64_t, - pub ssi_arch: ::uint32_t, - _pad: [::uint8_t; 28], + pub ssi_signo: u32, + pub ssi_errno: i32, + pub ssi_code: i32, + pub ssi_pid: u32, + pub ssi_uid: u32, + pub ssi_fd: i32, + pub ssi_tid: u32, + pub ssi_band: u32, + pub ssi_overrun: u32, + pub ssi_trapno: u32, + pub ssi_status: i32, + pub ssi_int: i32, + pub ssi_ptr: u64, + pub ssi_utime: u64, + pub ssi_stime: u64, + pub ssi_addr: u64, + pub ssi_addr_lsb: u16, + _pad2: u16, + pub ssi_syscall: i32, + pub ssi_call_addr: u64, + pub ssi_arch: u32, + _pad: [u8; 28], } pub struct fsid_t { __val: [::c_int; 2], } - pub struct mq_attr { - pub mq_flags: ::c_long, - pub mq_maxmsg: ::c_long, - pub mq_msgsize: ::c_long, - pub mq_curmsgs: ::c_long, - pad: [::c_long; 4] - } - pub struct cpu_set_t { #[cfg(target_pointer_width = "32")] bits: [u32; 32], @@ -321,8 +306,8 @@ s_no_extra_traits! { )] #[allow(missing_debug_implementations)] pub struct epoll_event { - pub events: ::uint32_t, - pub u64: ::uint64_t, + pub events: u32, + pub u64: u64, } #[allow(missing_debug_implementations)] @@ -368,6 +353,78 @@ s_no_extra_traits! { pub d_type: ::c_uchar, pub d_name: [::c_char; 256], } + + pub struct mq_attr { + pub mq_flags: ::c_long, + pub mq_maxmsg: ::c_long, + pub mq_msgsize: ::c_long, + pub mq_curmsgs: ::c_long, + pad: [::c_long; 4] + } + + pub struct sockaddr_nl { + pub nl_family: ::sa_family_t, + nl_pad: ::c_ushort, + pub nl_pid: u32, + pub nl_groups: u32 + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for mq_attr { + fn eq(&self, other: &mq_attr) -> bool { + self.mq_flags == other.mq_flags && + self.mq_maxmsg == other.mq_maxmsg && + self.mq_msgsize == other.mq_msgsize && + self.mq_curmsgs == other.mq_curmsgs + } + } + impl Eq for mq_attr {} + impl ::fmt::Debug for mq_attr { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mq_attr") + .field("mq_flags", &self.mq_flags) + .field("mq_maxmsg", &self.mq_maxmsg) + .field("mq_msgsize", &self.mq_msgsize) + .field("mq_curmsgs", &self.mq_curmsgs) + .finish() + } + } + impl ::hash::Hash for mq_attr { + fn hash(&self, state: &mut H) { + self.mq_flags.hash(state); + self.mq_maxmsg.hash(state); + self.mq_msgsize.hash(state); + self.mq_curmsgs.hash(state); + } + } + + impl PartialEq for sockaddr_nl { + fn eq(&self, other: &sockaddr_nl) -> bool { + self.nl_family == other.nl_family && + self.nl_pid == other.nl_pid && + self.nl_groups == other.nl_groups + } + } + impl Eq for sockaddr_nl {} + impl ::fmt::Debug for sockaddr_nl { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("sockaddr_nl") + .field("nl_family", &self.nl_family) + .field("nl_pid", &self.nl_pid) + .field("nl_groups", &self.nl_groups) + .finish() + } + } + impl ::hash::Hash for sockaddr_nl { + fn hash(&self, state: &mut H) { + self.nl_family.hash(state); + self.nl_pid.hash(state); + self.nl_groups.hash(state); + } + } + } } // intentionally not public, only used for fd_set @@ -853,13 +910,13 @@ pub const TCOON: ::c_int = 1; pub const TCIFLUSH: ::c_int = 0; pub const TCOFLUSH: ::c_int = 1; pub const TCIOFLUSH: ::c_int = 2; -pub const NL0: ::c_int = 0x00000000; -pub const NL1: ::c_int = 0x00000100; -pub const TAB0: ::c_int = 0x00000000; -pub const CR0: ::c_int = 0x00000000; -pub const FF0: ::c_int = 0x00000000; -pub const BS0: ::c_int = 0x00000000; -pub const VT0: ::c_int = 0x00000000; +pub const NL0: ::tcflag_t = 0x00000000; +pub const NL1: ::tcflag_t = 0x00000100; +pub const TAB0: ::tcflag_t = 0x00000000; +pub const CR0: ::tcflag_t = 0x00000000; +pub const FF0: ::tcflag_t = 0x00000000; +pub const BS0: ::tcflag_t = 0x00000000; +pub const VT0: ::tcflag_t = 0x00000000; pub const VERASE: usize = 2; pub const VKILL: usize = 3; pub const VINTR: usize = 0; @@ -1388,6 +1445,11 @@ pub const NOSTR: ::nl_item = 0x503; pub const FILENAME_MAX: ::c_uint = 4095; +#[deprecated( + since = "0.2.55", + note = "If you are using this report to: \ + https://github.com/rust-lang/libc/issues/665" +)] pub const AF_MAX: ::c_int = 39; f! { @@ -1487,6 +1549,11 @@ f! { } extern { + #[cfg_attr(target_os = "linux", + link_name = "__xpg_strerror_r")] + pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, + buflen: ::size_t) -> ::c_int; + pub fn sem_destroy(sem: *mut sem_t) -> ::c_int; pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, @@ -1500,6 +1567,8 @@ extern { pub fn srand(seed: ::c_uint); pub fn fdatasync(fd: ::c_int) -> ::c_int; + pub fn gettimeofday(tp: *mut ::timeval, + tz: *mut ::timezone) -> ::c_int; pub fn mincore(addr: *mut ::c_void, len: ::size_t, vec: *mut ::c_uchar) -> ::c_int; pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; @@ -1576,6 +1645,8 @@ extern { pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, advise: ::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; pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; pub fn utimensat(dirfd: ::c_int, path: *const ::c_char, times: *const ::timespec, flag: ::c_int) -> ::c_int; diff --git a/libc/src/wasi.rs b/libc/src/wasi.rs index b934861..95a0837 100644 --- a/libc/src/wasi.rs +++ b/libc/src/wasi.rs @@ -19,14 +19,6 @@ pub type intptr_t = isize; pub type uintptr_t = usize; pub type off_t = i64; pub type pid_t = i32; -pub type int8_t = i8; -pub type uint8_t = u8; -pub type int16_t = i16; -pub type uint16_t = u16; -pub type int32_t = i32; -pub type uint32_t = u32; -pub type int64_t = i64; -pub type uint64_t = u64; pub type clock_t = c_longlong; pub type time_t = c_longlong; pub type c_double = f64; diff --git a/libc/src/windows/mod.rs b/libc/src/windows/mod.rs index 70ca675..be28b70 100644 --- a/libc/src/windows/mod.rs +++ b/libc/src/windows/mod.rs @@ -1,14 +1,5 @@ //! Windows CRT definitions -pub type int8_t = i8; -pub type int16_t = i16; -pub type int32_t = i32; -pub type int64_t = i64; -pub type uint8_t = u8; -pub type uint16_t = u16; -pub type uint32_t = u32; -pub type uint64_t = u64; - pub type c_schar = i8; pub type c_uchar = u8; pub type c_short = i16; diff --git a/nitrocli/CHANGELOG.md b/nitrocli/CHANGELOG.md index 71a54df..e826004 100644 --- a/nitrocli/CHANGELOG.md +++ b/nitrocli/CHANGELOG.md @@ -7,7 +7,7 @@ Unreleased secrets - Clear cached PIN entry as part of `pin set` command to prevent spurious authentication failures -- Bumped `libc` dependency to `0.2.55` +- Bumped `libc` dependency to `0.2.57` - Bumped `cc` dependency to `1.0.37` diff --git a/nitrocli/Cargo.lock b/nitrocli/Cargo.lock index 4e3fe37..0cec5e1 100644 --- a/nitrocli/Cargo.lock +++ b/nitrocli/Cargo.lock @@ -59,7 +59,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.55" +version = "0.2.57" [[package]] name = "memchr" @@ -67,7 +67,7 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55", + "libc 0.2.57", ] [[package]] @@ -76,7 +76,7 @@ version = "0.2.3" dependencies = [ "argparse 0.2.2", "base32 0.4.0", - "libc 0.2.55", + "libc 0.2.57", "nitrokey 0.3.4", "nitrokey-test 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -86,7 +86,7 @@ dependencies = [ name = "nitrokey" version = "0.3.4" dependencies = [ - "libc 0.2.55", + "libc 0.2.57", "nitrokey-sys 3.4.3", "rand_core 0.3.0", "rand_os 0.1.1", @@ -135,7 +135,7 @@ version = "0.1.1" dependencies = [ "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55", + "libc 0.2.57", "rand_core 0.3.0", "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", -- cgit v1.2.1