summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml211
-rw-r--r--CHANGELOG.md24
-rw-r--r--README.md33
-rw-r--r--ci/README.md48
-rw-r--r--ci/before_deploy.ps123
-rw-r--r--ci/before_deploy.sh33
-rw-r--r--ci/cargo-config18
-rw-r--r--ci/install.sh24
-rwxr-xr-xci/run-all.sh29
-rwxr-xr-xci/run-docker.sh15
-rw-r--r--ci/run-travis.sh41
-rwxr-xr-xci/run.sh137
-rw-r--r--ci/script.sh22
-rw-r--r--src/errno.rs544
-rw-r--r--src/sys/event.rs14
-rw-r--r--src/sys/socket/consts.rs69
-rw-r--r--src/sys/socket/sockopt.rs6
-rw-r--r--src/sys/syscall.rs10
-rw-r--r--src/sys/termios.rs24
-rw-r--r--test/sys/test_ioctl.rs32
20 files changed, 637 insertions, 720 deletions
diff --git a/.travis.yml b/.travis.yml
index e08e05e4..8f250501 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,102 +1,131 @@
-#
-# Operating Environment
-#
-language: rust
-sudo: false
+# Based on the "trust" template v0.1.1
+# https://github.com/japaric/trust/tree/v0.1.1
+
dist: trusty
-services:
- - docker
-addons:
- apt:
- packages:
- - gcc-multilib
- - libcurl4-openssl-dev
- - libelf-dev
- - libdw-dev
- - binutils-dev
-
-rust:
- - 1.7.0 # Oldest supported version
- - stable
- - beta
- - nightly
-
-#
-# Environment Variables and Build Matrix
-#
+language: rust
+services: docker
+sudo: required
+
+# This is the Rust channel that build jobs will use by default but can be
+# overridden on a case by case basis down below
+rust: 1.13.0
+
env:
global:
- - PATH=$HOME/.local/bin:$PATH
- - TRAVIS_CARGO_NIGHTLY_FEATURE=""
- matrix:
- - ARCH=x86_64
- - ARCH=i686
+ - CRATE_NAME=nix
+ - CARGO_TEST_THREADS=1
-os: # OSX included in build matrix explicitly
- - linux
+ # default job
+ - TARGET=x86_64-unknown-linux-gnu
-# Failures on nightly shouldn't fail the overall build.
matrix:
- fast_finish: true
+ # These are all the build jobs. Adjust as necessary. Comment out what you
+ # don't need
include:
- # 32-bit and 64-bit OSX builds on oldest/stable
- - os: osx
- env: ARCH=x86_64
- rust: stable
- - os: osx
- env: ARCH=i686
- rust: stable
- # Docker builds for other targets
- - os: linux
- env: TARGET=aarch64-unknown-linux-gnu DOCKER_IMAGE=posborne/rust-cross:arm
- rust: 1.7.0
- sudo: true
- - os: linux
- env: TARGET=arm-unknown-linux-gnueabihf DOCKER_IMAGE=posborne/rust-cross:arm
- rust: 1.7.0
- sudo: true
- - os: linux
- env: TARGET=mips-unknown-linux-gnu DOCKER_IMAGE=posborne/rust-cross:mips
- rust: 1.7.0
- sudo: true
- - os: linux
- env: TARGET=mipsel-unknown-linux-gnu DOCKER_IMAGE=posborne/rust-cross:mips
- rust: 1.7.0
- sudo: true
- - os: linux
- env: TARGET=arm-linux-androideabi DOCKER_IMAGE=posborne/rust-cross:android
- rust: 1.7.0
- sudo: true
- allow_failures:
- - rust: nightly
- # We need to upgrade the lowest supported version. However, the build
- # infrastructure for arm/mips/android is not ready yet.
- - rust: 1.7.0
- - env: TARGET=mips-unknown-linux-gnu DOCKER_IMAGE=posborne/rust-cross:mips
- - env: TARGET=mipsel-unknown-linux-gnu DOCKER_IMAGE=posborne/rust-cross:mips
- - env: TARGET=arm-linux-androideabi DOCKER_IMAGE=posborne/rust-cross:android
+ # Linux
+ - env: TARGET=i686-unknown-linux-gnu
+ - env: TARGET=i686-unknown-linux-musl
+ # - env: TARGET=x86_64-unknown-linux-gnu # this is the default job
+ - env: TARGET=x86_64-unknown-linux-musl
+
+ # OSX
+ - env: TARGET=i686-apple-darwin
+ os: osx
+ - env: TARGET=x86_64-apple-darwin
+ os: osx
+
+ # *BSD
+ - env: TARGET=i686-unknown-freebsd DISABLE_TESTS=1
+ - env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1
+ - env: TARGET=x86_64-unknown-netbsd DISABLE_TESTS=1
+
+ # Other architectures
+ - env: TARGET=aarch64-unknown-linux-gnu
+ - env: TARGET=armv7-unknown-linux-gnueabihf
+ - env: TARGET=mips-unknown-linux-gnu
+ # - env: TARGET=mips64-unknown-linux-gnuabi64
+ # - env: TARGET=mips64el-unknown-linux-gnuabi64
+ - env: TARGET=mipsel-unknown-linux-gnu
+ - env: TARGET=powerpc-unknown-linux-gnu
+ # - env: TARGET=powerpc64-unknown-linux-gnu
+ # - env: TARGET=powerpc64le-unknown-linux-gnu
+ # - env: TARGET=s390x-unknown-linux-gnu
+ - env: TARGET=arm-unknown-linux-gnueabi
+ # - env: TARGET=arm-unknown-linux-musleabi
+ # Testing beta on main targets
+ - env: TARGET=x86_64-unknown-linux-gnu
+ rust: beta
+ - env: TARGET=x86_64-apple-darwin
+ os: osx
+ rust: beta
-#
-# Build/Test/Deploy Steps
-#
-before_script:
- - pip install 'travis-cargo<0.2' --user
+ # Testing nightly on main targets (allowed to fail)
+ - env: TARGET=x86_64-unknown-linux-gnu
+ rust: nightly
+ - env: TARGET=x86_64-apple-darwin
+ os: osx
+ rust: nightly
+
+ # Testing nightlies on main targets. These might fail because of issues
+ # with the compiler, so we allow failures here.
+ allow_failures:
+ # Failures for nightlies may be because of compiler bugs, so don't fail the
+ # build if these fail.
+ - env: TARGET=x86_64-unknown-linux-gnu
+ rust: nightly
+ - env: TARGET=x86_64-apple-darwin
+ os: osx
+ rust: nightly
+ # FIXME: targets that should pass but are currently failing
+ - env: TARGET=i686-unknown-linux-musl
+ - env: TARGET=x86_64-unknown-linux-musl
+ - env: TARGET=mips-unknown-linux-gnu
+ - env: TARGET=mipsel-unknown-linux-gnu
+ - env: TARGET=powerpc-unknown-linux-gnu
+
+install:
+ - sh ci/install.sh
+ - source ~/.cargo/env || true
script:
- - bash ci/run-travis.sh
- - |
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then
- travis-cargo --only stable doc
- fi
-
-after_success:
- - |
- if [ "$TRAVIS_OS_NAME" = "linux" ] && \
- [ "$TRAVIS_RUST_VERSION" = "stable" ] && \
- [ "$ARCH" = "x86_64" ]; then
- # Upload docs for stable (on master) to gh-pages
- travis-cargo --only stable doc-upload
- # Measure code coverage using kcov and upload to coveralls.io
- travis-cargo coveralls --no-sudo --verify
- fi
+ - bash ci/script.sh
+
+before_deploy:
+ - sh ci/before_deploy.sh
+
+deploy:
+ # TODO update `api_key.secure`
+ # - Create a `public_repo` GitHub token. Go to: https://github.com/settings/tokens/new
+ # - Encrypt it: `travis encrypt GH_TOKEN=0123456789012345678901234567890123456789`
+ # - Paste the output down here
+ api_key:
+ secure: S1ktt0eqmfrEHnYPf4WO7mZtatz/FWfYWBp8nwdc0nd8H6UNZ9Dwy3tJpVe0N9rpB9vAFnkdw6R4jdkIcgxfory2F3F8k/mh8cWn0mkvh2N34YjHMYLnuVzOoFrWai7IcPfROpdlY0tGBlwNj5KMkeBnHUJzd2q4j/4j/tlrfmg=
+ file_glob: true
+ file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.*
+ on:
+ # Here you can pick which targets will generate binary releases
+ # In this example, there are some targets that are tested using the stable
+ # and nightly channels. This condition makes sure there is only one release
+ # for such targets and that's generated using the stable channel
+ #
+ # Here we make it so we never generate binary releases
+ condition: $DEPLOY = never
+ tags: true
+ provider: releases
+ skip_cleanup: true
+
+cache: cargo
+before_cache:
+ # Travis can't cache files that are not readable by "others"
+ - chmod -R a+r $HOME/.cargo
+
+branches:
+ only:
+ # release tags
+ - /^v\d+\.\d+\.\d+.*$/
+ - master
+
+notifications:
+ email:
+ on_success: never
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 045756dd..eac3072a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,15 +5,24 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
-<!--### Added-->
+### Added
- Added `nix::unistd::{openat, fstatat, readlink, readlinkat}`
- ([#497](https://github.com/nix-rust/nix/pull/551))
+ ([#551](https://github.com/nix-rust/nix/pull/551))
### Changed
- Marked `sys::mman::{ mmap, munmap, madvise, munlock, msync }` as unsafe.
([#559](https://github.com/nix-rust/nix/pull/559))
-
-<!--### Fixed-->
+- Minimum supported Rust version is now 1.13
+- Removed `revents` argument from `PollFd::new()` as it's an output argument and
+ will be overwritten regardless of value.
+ ([#542](https://github.com/nix-rust/nix/pull/542)
+
+### Fixed
+- Fixed multiple issues compiling under different archetectures and OSes.
+ Now compiles on Linux/MIPS ([#538](https://github.com/nix-rust/nix/pull/538)),
+ `Linux/PPC` ([#553](https://github.com/nix-rust/nix/pull/553)),
+ `MacOS/x86_64,i686` ([#553](https://github.com/nix-rust/nix/pull/553),
+ and `NetBSD/x64_64` ([#538](https://github.com/nix-rust/nix/pull/538).
## [0.8.0] 2017-03-02
@@ -60,8 +69,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
([#540](https://github.com/nix-rust/nix/pull/540)
### Changed
-- `::nix::sys::termios::{cfgetispeed, cfsetispeed, cfgetospeed, cfsetospeed}`
- switched to use `BaudRate` enum from `speed_t`.
+- `::nix::sys::termios::{cfgetispeed, cfsetispeed, cfgetospeed, cfsetospeed}`
+ switched to use `BaudRate` enum from `speed_t`.
([#518](https://github.com/nix-rust/nix/pull/518))
- `epoll_ctl` now could accept None as argument `event`
when op is `EpollOp::EpollCtlDel`.
@@ -107,9 +116,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Exposed all fcntl(2) operations at the module level, so they can be
imported direclty instead of via `FcntlArg` enum.
([#541](https://github.com/nix-rust/nix/pull/541))
-- Removed `revents` argument from `PollFd::new()` as it's an output argument and
- will be overwritten regardless of value.
- ([#542](https://github.com/nix-rust/nix/pull/542)
### Fixed
- Fixed multiple issues with Unix domain sockets on non-Linux OSes
diff --git a/README.md b/README.md
index 577a0fb2..88e96394 100644
--- a/README.md
+++ b/README.md
@@ -30,8 +30,37 @@ pub unsafe extern fn gethostname(name: *mut c_char, len: size_t) -> c_int;
pub fn gethostname(name: &mut [u8]) -> Result<()>;
```
-## Requirements
-Rust >= 1.9.0
+## Supported Platforms
+
+nix target support consists of three tiers:
+
+ * Tier 1 - Target is supported and CI both builds and tests
+ * Tier 2 - Target is supported and CI builds the target
+ * Tier 3 - Target is supported and CI both builds and tests but test failures
+ do not block merging code
+
+The following targets are all supported by nix on Rust 1.13.0 or newer:
+
+Tier 1:
+ * i686-unknown-linux-gnu
+ * x86_64-unknown-linux-gnu
+ * i686-apple-darwin
+ * x86_64-apple-darwin
+ * aarch64-unknown-linux-gnu
+ * armv7-unknown-linux-gnueabihf
+ * arm-unknown-linux-gnueabi
+
+Tier 2:
+ * i686-unknown-freebsd
+ * x86_64-unknown-freebsd
+ * x86_64-unknown-netbsd
+
+Tier 3:
+ * i686-unknown-linux-musl
+ * x86_64-unknown-linux-musl
+ * mips-unknown-linux-gnu
+ * mipsel-unknown-linux-gnu
+ * powerpc-unknown-linux-gnu
## Usage
diff --git a/ci/README.md b/ci/README.md
deleted file mode 100644
index c86fd715..00000000
--- a/ci/README.md
+++ /dev/null
@@ -1,48 +0,0 @@
-Test Infrastructure
-===================
-
-The ci directory contains scripts that aid in the testing of nix both
-in our continuous integration environment (Travis CI) but also for
-developers working locally.
-
-Nix interfaces very directly with the underlying platform (usually via
-libc) and changes need to be tested on a large number of platforms to
-avoid problems.
-
-Running Tests For Host Architecture
------------------------------------
-
-Running the tests for one's host architecture can be done by simply
-doing the following:
-
- $ cargo test
-
-Running Tests Against All Architectures/Versions
-------------------------------------------------
-
-Testing for other architectures is more involved. Currently,
-developers may run tests against several architectures and versions of
-rust by running the `ci/run-all.sh` script. This scripts requires
-that docker be set up. This will take some time:
-
- $ ci/run-all.sh
-
-The list of versions and architectures tested by this can be
-determined by looking at the contents of the script. The docker image
-used is [posborne/rust-cross][posborne/rust-cross].
-
-[posborne/rust-cross]: https://github.com/rust-embedded/docker-rust-cross
-
-Running Test for Specific Architectures/Versions
-------------------------------------------------
-
-Suppose we have a failing test with Rust 1.7 on the raspberry pi. In
-that case, we can run the following:
-
- $ DOCKER_IMAGE=posborne/rust-cross:arm \
- RUST_VERSION=1.7.0 \
- RUST_TARGET=arm-unknown-linux-gnueabihf ci/run-docker.sh
-
-Currently, the docker images only support Rust 1.7. To get a better
-idea of combinations that might work, look at the contents of the
-[travis configuration](../.travis.yml) or [run-all.sh](run-all.sh).
diff --git a/ci/before_deploy.ps1 b/ci/before_deploy.ps1
new file mode 100644
index 00000000..191a30b8
--- /dev/null
+++ b/ci/before_deploy.ps1
@@ -0,0 +1,23 @@
+# This script takes care of packaging the build artifacts that will go in the
+# release zipfile
+
+$SRC_DIR = $PWD.Path
+$STAGE = [System.Guid]::NewGuid().ToString()
+
+Set-Location $ENV:Temp
+New-Item -Type Directory -Name $STAGE
+Set-Location $STAGE
+
+$ZIP = "$SRC_DIR\$($Env:CRATE_NAME)-$($Env:APPVEYOR_REPO_TAG_NAME)-$($Env:TARGET).zip"
+
+# TODO Update this to package the right artifacts
+Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\hello.exe" '.\'
+
+7z a "$ZIP" *
+
+Push-AppveyorArtifact "$ZIP"
+
+Remove-Item *.* -Force
+Set-Location ..
+Remove-Item $STAGE
+Set-Location $SRC_DIR
diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh
new file mode 100644
index 00000000..026dc289
--- /dev/null
+++ b/ci/before_deploy.sh
@@ -0,0 +1,33 @@
+# This script takes care of building your crate and packaging it for release
+
+set -ex
+
+main() {
+ local src=$(pwd) \
+ stage=
+
+ case $TRAVIS_OS_NAME in
+ linux)
+ stage=$(mktemp -d)
+ ;;
+ osx)
+ stage=$(mktemp -d -t tmp)
+ ;;
+ esac
+
+ test -f Cargo.lock || cargo generate-lockfile
+
+ # TODO Update this to build the artifacts that matter to you
+ cross rustc --bin hello --target $TARGET --release -- -C lto
+
+ # TODO Update this to package the right artifacts
+ cp target/$TARGET/release/hello $stage/
+
+ cd $stage
+ tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz *
+ cd $src
+
+ rm -rf $stage
+}
+
+main
diff --git a/ci/cargo-config b/ci/cargo-config
deleted file mode 100644
index 6fee5be7..00000000
--- a/ci/cargo-config
+++ /dev/null
@@ -1,18 +0,0 @@
-# Configuration of which linkers to call on Travis for various architectures
-[target.arm-linux-androideabi]
-linker = "arm-linux-androideabi-gcc"
-
-[target.arm-unknown-linux-gnueabihf]
-linker = "arm-linux-gnueabihf-gcc-4.7"
-
-[target.mips-unknown-linux-gnu]
-linker = "mips-linux-gnu-gcc-5"
-
-[target.mipsel-unknown-linux-gnu]
-linker = "mipsel-linux-gnu-gcc-5"
-
-[target.aarch64-unknown-linux-gnu]
-linker = "aarch64-linux-gnu-gcc-4.8"
-
-[target.powerpc-unknown-linux-gnu]
-linker = "powerpc-linux-gnu-gcc-4.8"
diff --git a/ci/install.sh b/ci/install.sh
new file mode 100644
index 00000000..4093c9b2
--- /dev/null
+++ b/ci/install.sh
@@ -0,0 +1,24 @@
+set -ex
+
+main() {
+ curl https://sh.rustup.rs -sSf | \
+ sh -s -- -y --default-toolchain $TRAVIS_RUST_VERSION
+
+ local target=
+ if [ $TRAVIS_OS_NAME = linux ]; then
+ target=x86_64-unknown-linux-gnu
+ else
+ target=x86_64-apple-darwin
+ fi
+
+ # TODO At some point you'll probably want to use a newer release of `cross`,
+ # simply change the argument to `--tag`.
+ curl -LSfs https://japaric.github.io/trust/install.sh | \
+ sh -s -- \
+ --force \
+ --git japaric/cross \
+ --tag v0.1.4 \
+ --target $target
+}
+
+main
diff --git a/ci/run-all.sh b/ci/run-all.sh
deleted file mode 100755
index a7d1ece9..00000000
--- a/ci/run-all.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/bash
-#
-# Build nix and all tests for as many versions and platforms as can be
-# managed. This requires docker.
-#
-
-set -e
-
-BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
-RUN_DOCKER="${BASE_DIR}/ci/run-docker.sh"
-
-export RUST_VERSION=1.7.0
-
-export DOCKER_IMAGE=posborne/rust-cross:x86
-RUST_TARGET=i686-unknown-linux-gnu ${RUN_DOCKER}
-RUST_TARGET=x86_64-unknown-linux-gnu ${RUN_DOCKER}
-RUST_TARGET=x86_64-unknown-linux-musl ${RUN_DOCKER}
-
-export DOCKER_IMAGE=posborne/rust-cross:arm
-RUST_TARGET=aarch64-unknown-linux-gnu ${RUN_DOCKER}
-RUST_TARGET=arm-linux-gnueabi ${RUN_DOCKER}
-RUST_TARGET=arm-linux-gnueabihf ${RUN_DOCKER}
-
-export DOCKER_IMAGE=posborne/rust-cross:mips
-RUST_TARGET=mips-unknown-linux-gnu ${RUN_DOCKER}
-RUST_TARGET=mipsel-unknown-linux-gnu ${RUN_DOCKER}
-
-export DOCKER_IMAGE=posborne/rust-cross:android ${RUN_DOCKER}
-RUST_TARGET=arm-linux-androideabi ${RUN_DOCKER}
diff --git a/ci/run-docker.sh b/ci/run-docker.sh
deleted file mode 100755
index 3ef831c3..00000000
--- a/ci/run-docker.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/bash
-#
-# Run the nix tests in a docker container. This script expects the following
-# environment variables to be set:
-# - DOCKER_IMAGE : Docker image to use for testing (e.g. posborne/rust-cross:arm)
-# - RUST_VERSION : Rust Version to test against (e.g. 1.7.0)
-# - RUST_TARGET : Target Triple to test
-
-BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
-
-docker run -i -t \
- -v ${BASE_DIR}:/source \
- -e CARGO_TARGET_DIR=/build \
- ${DOCKER_IMAGE} \
- /source/ci/run.sh ${RUST_VERSION} ${RUST_TARGET}
diff --git a/ci/run-travis.sh b/ci/run-travis.sh
deleted file mode 100644
index 5be6372e..00000000
--- a/ci/run-travis.sh
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-#
-# Entry point for all travis builds, this will set up the Travis environment by
-# downloading any dependencies. It will then execute the `run.sh` script to
-# build and execute all tests.
-#
-# Much of this script was liberally stolen from rust-lang/libc
-#
-# Key variables that may be set from Travis:
-# - TRAVIS_RUST_VERSION: 1.1.0 ... stable/nightly/beta
-# - TRAVIS_OS_NAME: linux/osx
-# - DOCKER_IMAGE: posborne/rust-cross:arm
-# - TARGET: e.g. arm-unknown-linux-gnueabihf
-
-set -ex
-
-BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
-
-if [ "$TRAVIS_OS_NAME" = "linux" ]; then
- OS=unknown-linux-gnu
-elif [ "$TRAVIS_OS_NAME" = "osx" ]; then
- OS=apple-darwin
-else
- echo "Unexpected TRAVIS_OS_NAME: $TRAVIS_OS_NAME"
- exit 1
-fi
-
-export HOST=$ARCH-$OS
-if [ "$TARGET" = "" ]; then
- TARGET=$HOST
-fi
-
-if [ "$DOCKER_IMAGE" = "" ]; then
- export RUST_TEST_THREADS=1
- curl -sSL "https://raw.githubusercontent.com/carllerche/travis-rust-matrix/master/test" | bash
-else
- export RUST_VERSION=${TRAVIS_RUST_VERSION}
- export RUST_TARGET=${TARGET}
- export DOCKER_IMAGE=${DOCKER_IMAGE}
- ${BASE_DIR}/ci/run-docker.sh
-fi
diff --git a/ci/run.sh b/ci/run.sh
deleted file mode 100755
index 770f5aa7..00000000
--- a/ci/run.sh
+++ /dev/null
@@ -1,137 +0,0 @@
-#!/bin/bash
-
-# Builds and runs tests for a particular target passed as an argument to this
-# script.
-
-set -e
-
-# This should only be run in a docker container, so verify that
-if [ ! $(pidof $0) = "1" ]; then
- echo "run.sh should only be executed in a docker container"
- echo "and that does not appear to be the case. Maybe you meant"
- echo "to execute the tests via run-all.sh or run-docker.sh."
- echo ""
- echo "For more instructions, please refer to ci/README.md"
- exit 1
-fi
-
-BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
-MANIFEST_PATH="${BASE_DIR}/Cargo.toml"
-BUILD_DIR="."
-
-VERSION="$1"
-TARGET="$2"
-
-export DOCKER_ENVIRONMENT=1
-export RUST_TEST_THREADS=1
-export RUST_BACKTRACE=1
-
-#
-# Tell cargo what linker to use and whatever else is required
-#
-configure_cargo() {
- mkdir -p .cargo
- cp -b "${BASE_DIR}/ci/cargo-config" .cargo/config
-}
-
-#
-# We need to export CC for the tests to build properly (some C code is
-# compiled) to work. We already tell Cargo about the compiler in the
-# cargo config, so we just parse that info out of the cargo config
-#
-cc_for_target() {
- awk "/\[target\.${TARGET}\]/{getline; print}" .cargo/config |
- cut -d '=' -f2 | \
- tr -d '"' | tr -d ' '
-}
-
-cross_compile_tests() {
- case "$TARGET" in
- *-apple-ios)
- cargo test --no-run --manifest-path="${MANIFEST_PATH}" --target "$TARGET" -- \
- -C link-args=-mios-simulator-version-min=7.0
- ;;
-
- *)
- cargo test --no-run --verbose \
- --manifest-path="${MANIFEST_PATH}" \
- --target "$TARGET"
- ;;
- esac
-}
-
-# This is a hack as we cannot currently
-# ask cargo what test files it generated:
-# https://github.com/rust-lang/cargo/issues/1924
-find_binaries() {
- target_base_dir="${BUILD_DIR}/${TARGET}/debug"
-
- # find [[test]] sections and print the first line and
- # hack it to what we want from there. Also "nix" for
- # tests that are implicitly prsent
- for test_base in $( awk '/\[\[test\]\]/{getline; print}' "${MANIFEST_PATH}" | \
- cut -d '=' -f2 | \
- tr -d '"' | \
- tr '-' '_' | \
- tr -d ' '; echo "nix" ); do
- for path in ${target_base_dir}/${test_base}-* ; do
- echo "${path} "
- done
- done
-}
-
-test_binary() {
- binary=$1
-
- case "$TARGET" in
- arm-linux-gnueabi-gcc)
- qemu-arm -L /usr/arm-linux-gnueabihf "$binary"
- ;;
-
- arm-unknown-linux-gnueabihf)
- qemu-arm -L /usr/arm-linux-gnueabihf "$binary"
- ;;
-
- mips-unknown-linux-gnu)
- qemu-mips -L /usr/mips-linux-gnu "$binary"
- ;;
-
- aarch64-unknown-linux-gnu)
- qemu-aarch64 -L /usr/aarch64-linux-gnu "$binary"
- ;;
-
- *-rumprun-netbsd)
- rumprun-bake hw_virtio /tmp/nix-test.img "${binary}"
- qemu-system-x86_64 -nographic -vga none -m 64 \
- -kernel /tmp/nix-test.img 2>&1 | tee /tmp/out &
- sleep 5
- grep "^PASSED .* tests" /tmp/out
- ;;
-
- *)
- echo "Running binary: ${binary}"
- ${binary}
- ;;
- esac
-}
-
-echo "======================================================="
-echo "TESTING VERSION: ${VERSION}, TARGET: ${TARGET}"
-echo "======================================================="
-
-configure_cargo
-export CC="$(cc_for_target)"
-if [ "${CC}" = "" ]; then
- unset CC
-fi
-
-# select the proper version
-multirust override ${VERSION}
-
-# build the tests
-cross_compile_tests
-
-# and run the tests
-for bin in $(find_binaries); do
- test_binary "${bin}"
-done
diff --git a/ci/script.sh b/ci/script.sh
new file mode 100644
index 00000000..39c3aeec
--- /dev/null
+++ b/ci/script.sh
@@ -0,0 +1,22 @@
+# This script takes care of testing your crate
+
+set -ex
+
+main() {
+ # Build debug and release targets
+ cross build --target $TARGET
+ cross build --target $TARGET --release
+
+ if [ ! -z $DISABLE_TESTS ]; then
+ return
+ fi
+
+ # Run tests on debug and release targets.
+ cross test --target $TARGET
+ cross test --target $TARGET --release
+}
+
+# we don't run the "test phase" when doing deploys
+if [ -z $TRAVIS_TAG ]; then
+ main
+fi
diff --git a/src/errno.rs b/src/errno.rs
index 4218bf9c..a27abaa7 100644
--- a/src/errno.rs
+++ b/src/errno.rs
@@ -374,10 +374,10 @@ fn desc(errno: Errno) -> &'static str {
#[cfg(any(target_os = "linux", target_os = "android"))]
ENOTRECOVERABLE => "State not recoverable",
- #[cfg(target_os = "linux")]
+ #[cfg(all(target_os = "linux", not(target_arch="mips")))]
ERFKILL => "Operation not possible due to RF-kill",
- #[cfg(target_os = "linux")]
+ #[cfg(all(target_os = "linux", not(target_arch="mips")))]
EHWPOISON => "Memory page has hardware error",
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
@@ -522,143 +522,145 @@ fn desc(errno: Errno) -> &'static str {
#[cfg(any(target_os = "linux", target_os = "android"))]
mod consts {
+ use libc;
+
#[derive(Debug, Clone, PartialEq, Copy)]
pub enum Errno {
UnknownErrno = 0,
- EPERM = 1,
- ENOENT = 2,
- ESRCH = 3,
- EINTR = 4,
- EIO = 5,
- ENXIO = 6,
- E2BIG = 7,
- ENOEXEC = 8,
- EBADF = 9,
- ECHILD = 10,
- EAGAIN = 11,
- ENOMEM = 12,
- EACCES = 13,
- EFAULT = 14,
- ENOTBLK = 15,
- EBUSY = 16,
- EEXIST = 17,
- EXDEV = 18,
- ENODEV = 19,
- ENOTDIR = 20,
- EISDIR = 21,
- EINVAL = 22,
- ENFILE = 23,
- EMFILE = 24,
- ENOTTY = 25,
- ETXTBSY = 26,
- EFBIG = 27,
- ENOSPC = 28,
- ESPIPE = 29,
- EROFS = 30,
- EMLINK = 31,
- EPIPE = 32,
- EDOM = 33,
- ERANGE = 34,
- EDEADLK = 35,
- ENAMETOOLONG = 36,
- ENOLCK = 37,
- ENOSYS = 38,
- ENOTEMPTY = 39,
- ELOOP = 40,
- ENOMSG = 42,
- EIDRM = 43,
- ECHRNG = 44,
- EL2NSYNC = 45,
- EL3HLT = 46,
- EL3RST = 47,
- ELNRNG = 48,
- EUNATCH = 49,
- ENOCSI = 50,
- EL2HLT = 51,
- EBADE = 52,
- EBADR = 53,
- EXFULL = 54,
- ENOANO = 55,
- EBADRQC = 56,
- EBADSLT = 57,
- EBFONT = 59,
- ENOSTR = 60,
- ENODATA = 61,
- ETIME = 62,
- ENOSR = 63,
- ENONET = 64,
- ENOPKG = 65,
- EREMOTE = 66,
- ENOLINK = 67,
- EADV = 68,
- ESRMNT = 69,
- ECOMM = 70,
- EPROTO = 71,
- EMULTIHOP = 72,
- EDOTDOT = 73,
- EBADMSG = 74,
- EOVERFLOW = 75,
- ENOTUNIQ = 76,
- EBADFD = 77,
- EREMCHG = 78,
- ELIBACC = 79,
- ELIBBAD = 80,
- ELIBSCN = 81,
- ELIBMAX = 82,
- ELIBEXEC = 83,
- EILSEQ = 84,
- ERESTART = 85,
- ESTRPIPE = 86,
- EUSERS = 87,
- ENOTSOCK = 88,
- EDESTADDRREQ = 89,
- EMSGSIZE = 90,
- EPROTOTYPE = 91,
- ENOPROTOOPT = 92,
- EPROTONOSUPPORT = 93,
- ESOCKTNOSUPPORT = 94,
- EOPNOTSUPP = 95,
- EPFNOSUPPORT = 96,
- EAFNOSUPPORT = 97,
- EADDRINUSE = 98,
- EADDRNOTAVAIL = 99,
- ENETDOWN = 100,
- ENETUNREACH = 101,
- ENETRESET = 102,
- ECONNABORTED = 103,
- ECONNRESET = 104,
- ENOBUFS = 105,
- EISCONN = 106,
- ENOTCONN = 107,
- ESHUTDOWN = 108,
- ETOOMANYREFS = 109,
- ETIMEDOUT = 110,
- ECONNREFUSED = 111,
- EHOSTDOWN = 112,
- EHOSTUNREACH = 113,
- EALREADY = 114,
- EINPROGRESS = 115,
- ESTALE = 116,
- EUCLEAN = 117,
- ENOTNAM = 118,
- ENAVAIL = 119,
- EISNAM = 120,
- EREMOTEIO = 121,
- EDQUOT = 122,
- ENOMEDIUM = 123,
- EMEDIUMTYPE = 124,
- ECANCELED = 125,
- ENOKEY = 126,
- EKEYEXPIRED = 127,
- EKEYREVOKED = 128,
- EKEYREJECTED = 129,
- EOWNERDEAD = 130,
- ENOTRECOVERABLE = 131,
-
- #[cfg(not(target_os = "android"))]
- ERFKILL = 132,
- #[cfg(not(target_os = "android"))]
- EHWPOISON = 133,
+ EPERM = libc::EPERM as isize,
+ ENOENT = libc::ENOENT as isize,
+ ESRCH = libc::ESRCH as isize,
+ EINTR = libc::EINTR as isize,
+ EIO = libc::EIO as isize,
+ ENXIO = libc::ENXIO as isize,
+ E2BIG = libc::E2BIG as isize,
+ ENOEXEC = libc::ENOEXEC as isize,
+ EBADF = libc::EBADF as isize,
+ ECHILD = libc::ECHILD as isize,
+ EAGAIN = libc::EAGAIN as isize,
+ ENOMEM = libc::ENOMEM as isize,
+ EACCES = libc::EACCES as isize,
+ EFAULT = libc::EFAULT as isize,
+ ENOTBLK = libc::ENOTBLK as isize,
+ EBUSY = libc::EBUSY as isize,
+ EEXIST = libc::EEXIST as isize,
+ EXDEV = libc::EXDEV as isize,
+ ENODEV = libc::ENODEV as isize,
+ ENOTDIR = libc::ENOTDIR as isize,
+ EISDIR = libc::EISDIR as isize,
+ EINVAL = libc::EINVAL as isize,
+ ENFILE = libc::ENFILE as isize,
+ EMFILE = libc::EMFILE as isize,
+ ENOTTY = libc::ENOTTY as isize,
+ ETXTBSY = libc::ETXTBSY as isize,
+ EFBIG = libc::EFBIG as isize,
+ ENOSPC = libc::ENOSPC as isize,
+ ESPIPE = libc::ESPIPE as isize,
+ EROFS = libc::EROFS as isize,
+ EMLINK = libc::EMLINK as isize,
+ EPIPE = libc::EPIPE as isize,
+ EDOM = libc::EDOM as isize,
+ ERANGE = libc::ERANGE as isize,
+ EDEADLK = libc::EDEADLK as isize,
+ ENAMETOOLONG = libc::ENAMETOOLONG as isize,
+ ENOLCK = libc::ENOLCK as isize,
+ ENOSYS = libc::ENOSYS as isize,
+ ENOTEMPTY = libc::ENOTEMPTY as isize,
+ ELOOP = libc::ELOOP as isize,
+ ENOMSG = libc::ENOMSG as isize,
+ EIDRM = libc::EIDRM as isize,
+ ECHRNG = libc::ECHRNG as isize,
+ EL2NSYNC = libc::EL2NSYNC as isize,
+ EL3HLT = libc::EL3HLT as isize,
+ EL3RST = libc::EL3RST as isize,
+ ELNRNG = libc::ELNRNG as isize,
+ EUNATCH = libc::EUNATCH as isize,
+ ENOCSI = libc::ENOCSI as isize,
+ EL2HLT = libc::EL2HLT as isize,
+ EBADE = libc::EBADE as isize,
+ EBADR = libc::EBADR as isize,
+ EXFULL = libc::EXFULL as isize,
+ ENOANO = libc::ENOANO as isize,
+ EBADRQC = libc::EBADRQC as isize,
+ EBADSLT = libc::EBADSLT as isize,
+ EBFONT = libc::EBFONT as isize,
+ ENOSTR = libc::ENOSTR as isize,
+ ENODATA = libc::ENODATA as isize,
+ ETIME = libc::ETIME as isize,
+ ENOSR = libc::ENOSR as isize,
+ ENONET = libc::ENONET as isize,
+ ENOPKG = libc::ENOPKG as isize,
+ EREMOTE = libc::EREMOTE as isize,
+ ENOLINK = libc::ENOLINK as isize,
+ EADV = libc::EADV as isize,
+ ESRMNT = libc::ESRMNT as isize,
+ ECOMM = libc::ECOMM as isize,
+ EPROTO = libc::EPROTO as isize,
+ EMULTIHOP = libc::EMULTIHOP as isize,
+ EDOTDOT = libc::EDOTDOT as isize,
+ EBADMSG = libc::EBADMSG as isize,
+ EOVERFLOW = libc::EOVERFLOW as isize,
+ ENOTUNIQ = libc::ENOTUNIQ as isize,
+ EBADFD = libc::EBADFD as isize,
+ EREMCHG = libc::EREMCHG as isize,
+ ELIBACC = libc::ELIBACC as isize,
+ ELIBBAD = libc::ELIBBAD as isize,
+ ELIBSCN = libc::ELIBSCN as isize,
+ ELIBMAX = libc::ELIBMAX as isize,
+ ELIBEXEC = libc::ELIBEXEC as isize,
+ EILSEQ = libc::EILSEQ as isize,
+ ERESTART = libc::ERESTART as isize,
+ ESTRPIPE = libc::ESTRPIPE as isize,
+ EUSERS = libc::EUSERS as isize,
+ ENOTSOCK = libc::ENOTSOCK as isize,
+ EDESTADDRREQ = libc::EDESTADDRREQ as isize,
+ EMSGSIZE = libc::EMSGSIZE as isize,
+ EPROTOTYPE = libc::EPROTOTYPE as isize,
+ ENOPROTOOPT = libc::ENOPROTOOPT as isize,
+ EPROTONOSUPPORT = libc::EPROTONOSUPPORT as isize,
+ ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT as isize,
+ EOPNOTSUPP = libc::EOPNOTSUPP as isize,
+ EPFNOSUPPORT = libc::EPFNOSUPPORT as isize,
+ EAFNOSUPPORT = libc::EAFNOSUPPORT as isize,
+ EADDRINUSE = libc::EADDRINUSE as isize,
+ EADDRNOTAVAIL = libc::EADDRNOTAVAIL as isize,
+ ENETDOWN = libc::ENETDOWN as isize,
+ ENETUNREACH = libc::ENETUNREACH as isize,
+ ENETRESET = libc::ENETRESET as isize,
+ ECONNABORTED = libc::ECONNABORTED as isize,
+ ECONNRESET = libc::ECONNRESET as isize,
+ ENOBUFS = libc::ENOBUFS as isize,
+ EISCONN = libc::EISCONN as isize,
+ ENOTCONN = libc::ENOTCONN as isize,
+ ESHUTDOWN = libc::ESHUTDOWN as isize,
+ ETOOMANYREFS = libc::ETOOMANYREFS as isize,
+ ETIMEDOUT = libc::ETIMEDOUT as isize,
+ ECONNREFUSED = libc::ECONNREFUSED as isize,
+ EHOSTDOWN = libc::EHOSTDOWN as isize,
+ EHOSTUNREACH = libc::EHOSTUNREACH as isize,
+ EALREADY = libc::EALREADY as isize,
+ EINPROGRESS = libc::EINPROGRESS as isize,
+ ESTALE = libc::ESTALE as isize,
+ EUCLEAN = libc::EUCLEAN as isize,
+ ENOTNAM = libc::ENOTNAM as isize,
+ ENAVAIL = libc::ENAVAIL as isize,
+ EISNAM = libc::EISNAM as isize,
+ EREMOTEIO = libc::EREMOTEIO as isize,
+ EDQUOT = libc::EDQUOT as isize,
+ ENOMEDIUM = libc::ENOMEDIUM as isize,
+ EMEDIUMTYPE = libc::EMEDIUMTYPE as isize,
+ ECANCELED = libc::ECANCELED as isize,
+ ENOKEY = libc::ENOKEY as isize,
+ EKEYEXPIRED = libc::EKEYEXPIRED as isize,
+ EKEYREVOKED = libc::EKEYREVOKED as isize,
+ EKEYREJECTED = libc::EKEYREJECTED as isize,
+ EOWNERDEAD = libc::EOWNERDEAD as isize,
+ ENOTRECOVERABLE = libc::ENOTRECOVERABLE as isize,
+
+ #[cfg(not(any(target_os = "android", target_arch="mips")))]
+ ERFKILL = libc::ERFKILL as isize,
+ #[cfg(not(any(target_os = "android", target_arch="mips")))]
+ EHWPOISON = libc::EHWPOISON as isize,
}
pub const EWOULDBLOCK: Errno = Errno::EAGAIN;
@@ -669,140 +671,140 @@ mod consts {
match e {
0 => UnknownErrno,
- 1 => EPERM,
- 2 => ENOENT,
- 3 => ESRCH,
- 4 => EINTR,
- 5 => EIO,
- 6 => ENXIO,
- 7 => E2BIG,
- 8 => ENOEXEC,
- 9 => EBADF,
- 10 => ECHILD,
- 11 => EAGAIN,
- 12 => ENOMEM,
- 13 => EACCES,
- 14 => EFAULT,
- 15 => ENOTBLK,
- 16 => EBUSY,
- 17 => EEXIST,
- 18 => EXDEV,
- 19 => ENODEV,
- 20 => ENOTDIR,
- 21 => EISDIR,
- 22 => EINVAL,
- 23 => ENFILE,
- 24 => EMFILE,
- 25 => ENOTTY,
- 26 => ETXTBSY,
- 27 => EFBIG,
- 28 => ENOSPC,
- 29 => ESPIPE,
- 30 => EROFS,
- 31 => EMLINK,
- 32 => EPIPE,
- 33 => EDOM,
- 34 => ERANGE,
- 35 => EDEADLK,
- 36 => ENAMETOOLONG,
- 37 => ENOLCK,
- 38 => ENOSYS,
- 39 => ENOTEMPTY,
- 40 => ELOOP,
- 42 => ENOMSG,
- 43 => EIDRM,
- 44 => ECHRNG,
- 45 => EL2NSYNC,
- 46 => EL3HLT,
- 47 => EL3RST,
- 48 => ELNRNG,
- 49 => EUNATCH,
- 50 => ENOCSI,
- 51 => EL2HLT,
- 52 => EBADE,
- 53 => EBADR,
- 54 => EXFULL,
- 55 => ENOANO,
- 56 => EBADRQC,
- 57 => EBADSLT,
- 59 => EBFONT,
- 60 => ENOSTR,
- 61 => ENODATA,
- 62 => ETIME,
- 63 => ENOSR,
- 64 => ENONET,
- 65 => ENOPKG,
- 66 => EREMOTE,
- 67 => ENOLINK,
- 68 => EADV,
- 69 => ESRMNT,
- 70 => ECOMM,
- 71 => EPROTO,
- 72 => EMULTIHOP,
- 73 => EDOTDOT,
- 74 => EBADMSG,
- 75 => EOVERFLOW,
- 76 => ENOTUNIQ,
- 77 => EBADFD,
- 78 => EREMCHG,
- 79 => ELIBACC,
- 80 => ELIBBAD,
- 81 => ELIBSCN,
- 82 => ELIBMAX,
- 83 => ELIBEXEC,
- 84 => EILSEQ,
- 85 => ERESTART,
- 86 => ESTRPIPE,
- 87 => EUSERS,
- 88 => ENOTSOCK,
- 89 => EDESTADDRREQ,
- 90 => EMSGSIZE,
- 91 => EPROTOTYPE,
- 92 => ENOPROTOOPT,
- 93 => EPROTONOSUPPORT,
- 94 => ESOCKTNOSUPPORT,
- 95 => EOPNOTSUPP,
- 96 => EPFNOSUPPORT,
- 97 => EAFNOSUPPORT,
- 98 => EADDRINUSE,
- 99 => EADDRNOTAVAIL,
- 100 => ENETDOWN,
- 101 => ENETUNREACH,
- 102 => ENETRESET,
- 103 => ECONNABORTED,
- 104 => ECONNRESET,
- 105 => ENOBUFS,
- 106 => EISCONN,
- 107 => ENOTCONN,
- 108 => ESHUTDOWN,
- 109 => ETOOMANYREFS,
- 110 => ETIMEDOUT,
- 111 => ECONNREFUSED,
- 112 => EHOSTDOWN,
- 113 => EHOSTUNREACH,
- 114 => EALREADY,
- 115 => EINPROGRESS,
- 116 => ESTALE,
- 117 => EUCLEAN,
- 118 => ENOTNAM,
- 119 => ENAVAIL,
- 120 => EISNAM,
- 121 => EREMOTEIO,
- 122 => EDQUOT,
- 123 => ENOMEDIUM,
- 124 => EMEDIUMTYPE,
- 125 => ECANCELED,
- 126 => ENOKEY,
- 127 => EKEYEXPIRED,
- 128 => EKEYREVOKED,
- 129 => EKEYREJECTED,
- 130 => EOWNERDEAD,
- 131 => ENOTRECOVERABLE,
-
- #[cfg(not(target_os = "android"))]
- 132 => ERFKILL,
- #[cfg(not(target_os = "android"))]
- 133 => EHWPOISON,
+ libc::EPERM => EPERM,
+ libc::ENOENT => ENOENT,
+ libc::ESRCH => ESRCH,
+ libc::EINTR => EINTR,
+ libc::EIO => EIO,
+ libc::ENXIO => ENXIO,
+ libc::E2BIG => E2BIG,
+ libc::ENOEXEC => ENOEXEC,
+ libc::EBADF => EBADF,
+ libc::ECHILD => ECHILD,
+ libc::EAGAIN => EAGAIN,
+ libc::ENOMEM => ENOMEM,
+ libc::EACCES => EACCES,
+ libc::EFAULT => EFAULT,
+ libc::ENOTBLK => ENOTBLK,
+ libc::EBUSY => EBUSY,
+ libc::EEXIST => EEXIST,
+ libc::EXDEV => EXDEV,
+ libc::ENODEV => ENODEV,
+ libc::ENOTDIR => ENOTDIR,
+ libc::EISDIR => EISDIR,
+ libc::EINVAL => EINVAL,
+ libc::ENFILE => ENFILE,
+ libc::EMFILE => EMFILE,
+ libc::ENOTTY => ENOTTY,
+ libc::ETXTBSY => ETXTBSY,
+ libc::EFBIG => EFBIG,
+ libc::ENOSPC => ENOSPC,
+ libc::ESPIPE => ESPIPE,
+ libc::EROFS => EROFS,
+ libc::EMLINK => EMLINK,
+ libc::EPIPE => EPIPE,
+ libc::EDOM => EDOM,
+ libc::ERANGE => ERANGE,
+ libc::EDEADLK => EDEADLK,
+ libc::ENAMETOOLONG => ENAMETOOLONG,
+ libc::ENOLCK => ENOLCK,
+ libc::ENOSYS => ENOSYS,
+ libc::ENOTEMPTY => ENOTEMPTY,
+ libc::ELOOP => ELOOP,
+ libc::ENOMSG => ENOMSG,
+ libc::EIDRM => EIDRM,
+ libc::ECHRNG => ECHRNG,
+ libc::EL2NSYNC => EL2NSYNC,
+ libc::EL3HLT => EL3HLT,
+ libc::EL3RST => EL3RST,
+ libc::ELNRNG => ELNRNG,
+ libc::EUNATCH => EUNATCH,
+ libc::ENOCSI => ENOCSI,
+ libc::EL2HLT => EL2HLT,
+ libc::EBADE => EBADE,
+ libc::EBADR => EBADR,
+ libc::EXFULL => EXFULL,
+ libc::ENOANO => ENOANO,
+ libc::EBADRQC => EBADRQC,
+ libc::EBADSLT => EBADSLT,
+ libc::EBFONT => EBFONT,
+ libc::ENOSTR => ENOSTR,
+ libc::ENODATA => ENODATA,
+ libc::ETIME => ETIME,
+ libc::ENOSR => ENOSR,
+ libc::ENONET => ENONET,
+ libc::ENOPKG => ENOPKG,
+ libc::EREMOTE => EREMOTE,
+ libc::ENOLINK => ENOLINK,
+ libc::EADV => EADV,
+ libc::ESRMNT => ESRMNT,
+ libc::ECOMM => ECOMM,
+ libc::EPROTO => EPROTO,
+ libc::EMULTIHOP => EMULTIHOP,
+ libc::EDOTDOT => EDOTDOT,
+ libc::EBADMSG => EBADMSG,
+ libc::EOVERFLOW => EOVERFLOW,
+ libc::ENOTUNIQ => ENOTUNIQ,
+ libc::EBADFD => EBADFD,
+ libc::EREMCHG => EREMCHG,
+ libc::ELIBACC => ELIBACC,
+ libc::ELIBBAD => ELIBBAD,
+ libc::ELIBSCN => ELIBSCN,
+ libc::ELIBMAX => ELIBMAX,
+ libc::ELIBEXEC => ELIBEXEC,
+ libc::EILSEQ => EILSEQ,
+ libc::ERESTART => ERESTART,
+ libc::ESTRPIPE => ESTRPIPE,
+ libc::EUSERS => EUSERS,
+ libc::ENOTSOCK => ENOTSOCK,
+ libc::EDESTADDRREQ => EDESTADDRREQ,
+ libc::EMSGSIZE => EMSGSIZE,
+ libc::EPROTOTYPE => EPROTOTYPE,
+ libc::ENOPROTOOPT => ENOPROTOOPT,
+ libc::EPROTONOSUPPORT => EPROTONOSUPPORT,
+ libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT,
+ libc::EOPNOTSUPP => EOPNOTSUPP,
+ libc::EPFNOSUPPORT => EPFNOSUPPORT,
+ libc::EAFNOSUPPORT => EAFNOSUPPORT,
+ libc::EADDRINUSE => EADDRINUSE,
+ libc::EADDRNOTAVAIL => EADDRNOTAVAIL,
+ libc::ENETDOWN => ENETDOWN,
+ libc::ENETUNREACH => ENETUNREACH,
+ libc::ENETRESET => ENETRESET,
+ libc::ECONNABORTED => ECONNABORTED,
+ libc::ECONNRESET => ECONNRESET,
+ libc::ENOBUFS => ENOBUFS,
+ libc::EISCONN => EISCONN,
+ libc::ENOTCONN => ENOTCONN,
+ libc::ESHUTDOWN => ESHUTDOWN,
+ libc::ETOOMANYREFS => ETOOMANYREFS,
+ libc::ETIMEDOUT => ETIMEDOUT,
+ libc::ECONNREFUSED => ECONNREFUSED,
+ libc::EHOSTDOWN => EHOSTDOWN,
+ libc::EHOSTUNREACH => EHOSTUNREACH,
+ libc::EALREADY => EALREADY,
+ libc::EINPROGRESS => EINPROGRESS,
+ libc::ESTALE => ESTALE,
+ libc::EUCLEAN => EUCLEAN,
+ libc::ENOTNAM => ENOTNAM,
+ libc::ENAVAIL => ENAVAIL,
+ libc::EISNAM => EISNAM,
+ libc::EREMOTEIO => EREMOTEIO,
+ libc::EDQUOT => EDQUOT,
+ libc::ENOMEDIUM => ENOMEDIUM,
+ libc::EMEDIUMTYPE => EMEDIUMTYPE,
+ libc::ECANCELED => ECANCELED,
+ libc::ENOKEY => ENOKEY,
+ libc::EKEYEXPIRED => EKEYEXPIRED,
+ libc::EKEYREVOKED => EKEYREVOKED,
+ libc::EKEYREJECTED => EKEYREJECTED,
+ libc::EOWNERDEAD => EOWNERDEAD,
+ libc::ENOTRECOVERABLE => ENOTRECOVERABLE,
+
+ #[cfg(not(any(target_os = "android", target_arch="mips")))]
+ libc::ERFKILL => ERFKILL,
+ #[cfg(not(any(target_os = "android", target_arch="mips")))]
+ libc::EHWPOISON => EHWPOISON,
_ => UnknownErrno,
}
}
@@ -2058,7 +2060,7 @@ mod test {
}
#[test]
- #[cfg(target_os = "linux")]
+ #[cfg(all(target_os = "linux", not(target_arch = "mips")))]
pub fn test_linux_not_android_errnos() {
check_errno!(
ERFKILL /*,
diff --git a/src/sys/event.rs b/src/sys/event.rs
index 3e2a6d43..494c12dd 100644
--- a/src/sys/event.rs
+++ b/src/sys/event.rs
@@ -22,8 +22,14 @@ pub struct KEvent {
target_os = "dragonfly", target_os = "macos",
target_os = "ios"))]
type type_of_udata = *mut ::c_void;
+#[cfg(any(target_os = "openbsd", target_os = "freebsd",
+ target_os = "dragonfly", target_os = "macos",
+ target_os = "ios"))]
+type type_of_data = libc::intptr_t;
#[cfg(any(target_os = "netbsd"))]
type type_of_udata = intptr_t;
+#[cfg(any(target_os = "netbsd"))]
+type type_of_data = libc::int64_t;
#[cfg(not(target_os = "netbsd"))]
type type_of_event_filter = i16;
@@ -58,9 +64,9 @@ pub enum EventFilter {
}
#[cfg(target_os = "netbsd")]
-type type_of_event_filter = i32;
+type type_of_event_filter = libc::uint32_t;
#[cfg(target_os = "netbsd")]
-#[repr(u32)]
+#[repr(i32)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum EventFilter {
EVFILT_READ = libc::EVFILT_READ,
@@ -216,7 +222,7 @@ impl KEvent {
filter: filter as type_of_event_filter,
flags: flags.bits(),
fflags: fflags.bits(),
- data: data,
+ data: data as type_of_data,
udata: udata as type_of_udata
} }
}
@@ -238,7 +244,7 @@ impl KEvent {
}
pub fn data(&self) -> intptr_t {
- self.kevent.data
+ self.kevent.data as intptr_t
}
pub fn udata(&self) -> intptr_t {
diff --git a/src/sys/socket/consts.rs b/src/sys/socket/consts.rs
index 9a1861fa..54213ef1 100644
--- a/src/sys/socket/consts.rs
+++ b/src/sys/socket/consts.rs
@@ -11,14 +11,14 @@ mod os {
pub const AF_NETLINK: c_int = 16;
pub const AF_PACKET: c_int = 17;
- pub const SOCK_STREAM: c_int = 1;
- pub const SOCK_DGRAM: c_int = 2;
- pub const SOCK_SEQPACKET: c_int = 5;
- pub const SOCK_RAW: c_int = 3;
+ pub const SOCK_STREAM: c_int = libc::SOCK_STREAM;
+ pub const SOCK_DGRAM: c_int = libc::SOCK_DGRAM;
+ pub const SOCK_SEQPACKET: c_int = libc::SOCK_SEQPACKET;
+ pub const SOCK_RAW: c_int = libc::SOCK_RAW;
pub const SOCK_RDM: c_int = 4;
pub const SOL_IP: c_int = 0;
- pub const SOL_SOCKET: c_int = 1;
+ pub const SOL_SOCKET: c_int = libc::SOL_SOCKET;
pub const SOL_TCP: c_int = 6;
pub const SOL_UDP: c_int = 17;
pub const SOL_IPV6: c_int = 41;
@@ -28,36 +28,39 @@ mod os {
pub const IPPROTO_TCP: c_int = SOL_TCP;
pub const IPPROTO_UDP: c_int = SOL_UDP;
- pub const SO_ACCEPTCONN: c_int = 30;
+ pub const SO_ACCEPTCONN: c_int = libc::SO_ACCEPTCONN;
pub const SO_BINDTODEVICE: c_int = 25;
- pub const SO_BROADCAST: c_int = 6;
+ pub const SO_BROADCAST: c_int = libc::SO_BROADCAST;
pub const SO_BSDCOMPAT: c_int = 14;
pub const SO_DEBUG: c_int = 1;
pub const SO_DOMAIN: c_int = 39;
- pub const SO_ERROR: c_int = 4;
- pub const SO_DONTROUTE: c_int = 5;
- pub const SO_KEEPALIVE: c_int = 9;
- pub const SO_LINGER: c_int = 13;
+ pub const SO_ERROR: c_int = libc::SO_ERROR;
+ pub const SO_DONTROUTE: c_int = libc::SO_DONTROUTE;
+ pub const SO_KEEPALIVE: c_int = libc::SO_KEEPALIVE;
+ pub const SO_LINGER: c_int = libc::SO_LINGER;
pub const SO_MARK: c_int = 36;
- pub const SO_OOBINLINE: c_int = 10;
- pub const SO_PASSCRED: c_int = 16;
+ pub const SO_OOBINLINE: c_int = libc::SO_OOBINLINE;
+ #[cfg(not(target_arch="arm"))]
+ pub const SO_PASSCRED: c_int = libc::SO_PASSCRED;
pub const SO_PEEK_OFF: c_int = 42;
- pub const SO_PEERCRED: c_int = 17;
+ #[cfg(not(target_arch="arm"))]
+ pub const SO_PEERCRED: c_int = libc::SO_PEERCRED;
pub const SO_PRIORITY: c_int = 12;
pub const SO_PROTOCOL: c_int = 38;
- pub const SO_RCVBUF: c_int = 8;
+ pub const SO_RCVBUF: c_int = libc::SO_RCVBUF;
pub const SO_RCVBUFFORCE: c_int = 33;
- pub const SO_RCVLOWAT: c_int = 18;
- pub const SO_SNDLOWAT: c_int = 19;
- pub const SO_RCVTIMEO: c_int = 20;
- pub const SO_SNDTIMEO: c_int = 21;
- pub const SO_REUSEADDR: c_int = 2;
- pub const SO_REUSEPORT: c_int = 15;
+ pub const SO_RCVLOWAT: c_int = libc::SO_RCVLOWAT;
+ pub const SO_SNDLOWAT: c_int = libc::SO_SNDLOWAT;
+ pub const SO_RCVTIMEO: c_int = libc::SO_RCVTIMEO;
+ pub const SO_SNDTIMEO: c_int = libc::SO_SNDTIMEO;
+ pub const SO_REUSEADDR: c_int = libc::SO_REUSEADDR;
+ pub const SO_REUSEPORT: c_int = libc::SO_REUSEPORT;
pub const SO_RXQ_OVFL: c_int = 40;
- pub const SO_SNDBUF: c_int = 7;
- pub const SO_SNDBUFFORCE: c_int = 32;
+ pub const SO_SNDBUF: c_int = libc::SO_SNDBUF;
+ #[cfg(not(target_arch="arm"))]
+ pub const SO_SNDBUFFORCE: c_int = libc::SO_SNDBUFFORCE;
pub const SO_TIMESTAMP: c_int = 29;
- pub const SO_TYPE: c_int = 3;
+ pub const SO_TYPE: c_int = libc::SO_TYPE;
pub const SO_BUSY_POLL: c_int = 46;
#[cfg(target_os = "linux")]
pub const SO_ORIGINAL_DST: c_int = 80;
@@ -152,7 +155,7 @@ mod os {
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub const SYSPROTO_CONTROL: c_int = 2;
- pub const SO_ACCEPTCONN: c_int = 0x0002;
+ pub const SO_ACCEPTCONN: c_int = libc::SO_ACCEPTCONN;
pub const SO_BROADCAST: c_int = 0x0020;
pub const SO_DEBUG: c_int = 0x0001;
#[cfg(not(target_os = "netbsd"))]
@@ -417,7 +420,7 @@ mod test {
#[cfg(target_os = "linux")]
#[test]
- pub fn test_linux_consts() {
+ pub fn test_general_linux_consts() {
// TODO Figure out how to test new constants
check_const!(
SOL_IP,
@@ -431,13 +434,21 @@ mod test {
TCP_CORK,
// SO_BUSY_POLL,
// SO_RXQ_OVFL,
- SO_PASSCRED,
SO_PRIORITY,
// SO_PROTOCOL,
SO_RCVBUFFORCE,
// SO_PEEK_OFF,
- SO_PEERCRED,
- SO_SNDBUFFORCE,
MSG_ERRQUEUE);
}
+
+ #[cfg(all(target_os = "linux", not(target_arch="arm")))]
+ #[test]
+ pub fn test_linux_not_arm_consts() {
+ // TODO Figure out how to test new constants
+ check_const!(
+ SO_PASSCRED,
+ SO_PEERCRED,
+ SO_SNDBUFFORCE);
+ }
+
}
diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs
index bf17347c..61d85ec3 100644
--- a/src/sys/socket/sockopt.rs
+++ b/src/sys/socket/sockopt.rs
@@ -152,7 +152,7 @@ sockopt_impl!(Both, Broadcast, consts::SOL_SOCKET, consts::SO_BROADCAST, bool);
sockopt_impl!(Both, OobInline, consts::SOL_SOCKET, consts::SO_OOBINLINE, bool);
sockopt_impl!(GetOnly, SocketError, consts::SOL_SOCKET, consts::SO_ERROR, i32);
sockopt_impl!(Both, KeepAlive, consts::SOL_SOCKET, consts::SO_KEEPALIVE, bool);
-#[cfg(target_os = "linux")]
+#[cfg(all(target_os = "linux", not(target_arch="arm")))]
sockopt_impl!(GetOnly, PeerCredentials, consts::SOL_SOCKET, consts::SO_PEERCRED, super::ucred);
#[cfg(any(target_os = "macos",
target_os = "ios"))]
@@ -167,7 +167,7 @@ sockopt_impl!(Both, RcvBuf, consts::SOL_SOCKET, consts::SO_RCVBUF, usize);
sockopt_impl!(Both, SndBuf, consts::SOL_SOCKET, consts::SO_SNDBUF, usize);
#[cfg(target_os = "linux")]
sockopt_impl!(SetOnly, RcvBufForce, consts::SOL_SOCKET, consts::SO_RCVBUFFORCE, usize);
-#[cfg(target_os = "linux")]
+#[cfg(all(target_os = "linux", not(target_arch="arm")))]
sockopt_impl!(SetOnly, SndBufForce, consts::SOL_SOCKET, consts::SO_SNDBUFFORCE, usize);
sockopt_impl!(GetOnly, SockType, consts::SOL_SOCKET, consts::SO_TYPE, super::SockType);
#[cfg(any(target_os = "freebsd",
@@ -378,7 +378,7 @@ impl<'a> Set<'a, usize> for SetUsize {
#[cfg(test)]
mod test {
- #[cfg(target_os = "linux")]
+ #[cfg(all(target_os = "linux", not(target_arch = "arm")))]
#[test]
fn can_get_peercred_on_unix_socket() {
use super::super::*;
diff --git a/src/sys/syscall.rs b/src/sys/syscall.rs
index c2d9e51c..692b4cef 100644
--- a/src/sys/syscall.rs
+++ b/src/sys/syscall.rs
@@ -54,6 +54,16 @@ mod arch {
pub static MEMFD_CREATE: Syscall = 354;
}
+#[cfg(target_arch = "powerpc")]
+mod arch {
+ use libc::c_long;
+
+ pub type Syscall = c_long;
+
+ pub static SYSPIVOTROOT: Syscall = 203;
+ pub static MEMFD_CREATE: Syscall = 360;
+}
+
extern {
pub fn syscall(num: Syscall, ...) -> c_int;
}
diff --git a/src/sys/termios.rs b/src/sys/termios.rs
index e8df1ed9..126d149c 100644
--- a/src/sys/termios.rs
+++ b/src/sys/termios.rs
@@ -96,22 +96,14 @@ mod ffi {
#[cfg(any(target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", target_os = "netbsd"))]
pub mod consts {
- #[cfg(not(any(target_os = "dragonfly", target_os = "netbsd")))]
- use libc::{c_int, c_ulong, c_uchar};
- #[cfg(any(target_os = "dragonfly", target_os = "netbsd"))]
- use libc::{c_int, c_uint, c_uchar};
- #[cfg(not(any(target_os = "dragonfly", target_os = "netbsd")))]
- pub type tcflag_t = c_ulong;
- #[cfg(any(target_os = "dragonfly", target_os = "netbsd"))]
- pub type tcflag_t = c_uint;
+ use libc;
- pub type cc_t = c_uchar;
+ use libc::c_int;
- #[cfg(not(any(target_os = "dragonfly", target_os = "netbsd")))]
- pub type speed_t = c_ulong;
- #[cfg(any(target_os = "dragonfly", target_os = "netbsd"))]
- pub type speed_t = c_uint;
+ pub type tcflag_t = libc::tcflag_t;
+ pub type cc_t = libc::cc_t;
+ pub type speed_t = libc::speed_t;
#[repr(C)]
#[derive(Clone, Copy)]
@@ -166,7 +158,7 @@ mod ffi {
B7200, B14400, B28800, B57600,
B76800, B115200, B230400};
- #[cfg(any(target_os = "netbsd", target_os = "freebsd"))]
+ #[cfg(target_os = "freebsd")]
use libc::{B460800, B921600};
match s {
@@ -193,9 +185,9 @@ mod ffi {
B76800 => BaudRate::B76800,
B115200 => BaudRate::B115200,
B230400 => BaudRate::B230400,
- #[cfg(any(target_os = "netbsd", target_os = "freebsd"))]
+ #[cfg(target_os = "freebsd")]
B460800 => BaudRate::B460800,
- #[cfg(any(target_os = "netbsd", target_os = "freebsd"))]
+ #[cfg(target_os = "freebsd")]
B921600 => BaudRate::B921600,
b @ _ => unreachable!("Invalid baud constant: {}", b),
}
diff --git a/test/sys/test_ioctl.rs b/test/sys/test_ioctl.rs
index 1d9fbcc8..b68622d1 100644
--- a/test/sys/test_ioctl.rs
+++ b/test/sys/test_ioctl.rs
@@ -10,21 +10,34 @@ ioctl!(read buf readbuf_test with 0, 0; u32);
ioctl!(write buf writebuf_test with 0, 0; u32);
ioctl!(readwrite buf readwritebuf_test with 0, 0; u32);
-// See C code for source of values for op calculations:
+// See C code for source of values for op calculations (does NOT work for mips/powerpc):
// https://gist.github.com/posborne/83ea6880770a1aef332e
+//
+// TODO: Need a way to compute these constants at test time. Using precomputed
+// values is fragile and needs to be maintained.
#[cfg(any(target_os = "linux", target_os = "android"))]
mod linux {
#[test]
fn test_op_none() {
- assert_eq!(io!(b'q', 10), 0x0000710A);
- assert_eq!(io!(b'a', 255), 0x000061FF);
+ if cfg!(any(target_arch = "mips", target_arch="powerpc")){
+ assert_eq!(io!(b'q', 10), 0x2000710A);
+ assert_eq!(io!(b'a', 255), 0x200061FF);
+ } else {
+ assert_eq!(io!(b'q', 10), 0x0000710A);
+ assert_eq!(io!(b'a', 255), 0x000061FF);
+ }
}
#[test]
fn test_op_write() {
- assert_eq!(iow!(b'z', 10, 1), 0x40017A0A);
- assert_eq!(iow!(b'z', 10, 512), 0x42007A0A);
+ if cfg!(any(target_arch = "mips", target_arch="powerpc")){
+ assert_eq!(iow!(b'z', 10, 1), 0x80017A0A);
+ assert_eq!(iow!(b'z', 10, 512), 0x82007A0A);
+ } else {
+ assert_eq!(iow!(b'z', 10, 1), 0x40017A0A);
+ assert_eq!(iow!(b'z', 10, 512), 0x42007A0A);
+ }
}
#[cfg(target_pointer_width = "64")]
@@ -35,8 +48,13 @@ mod linux {
#[test]
fn test_op_read() {
- assert_eq!(ior!(b'z', 10, 1), 0x80017A0A);
- assert_eq!(ior!(b'z', 10, 512), 0x82007A0A);
+ if cfg!(any(target_arch = "mips", target_arch="powerpc")){
+ assert_eq!(ior!(b'z', 10, 1), 0x40017A0A);
+ assert_eq!(ior!(b'z', 10, 512), 0x42007A0A);
+ } else {
+ assert_eq!(ior!(b'z', 10, 1), 0x80017A0A);
+ assert_eq!(ior!(b'z', 10, 512), 0x82007A0A);
+ }
}
#[cfg(target_pointer_width = "64")]