Overhaul tests
* Move everything to azure pipelines * Inline docker configuration in this repo (no `cross`) * Delete `no-panic` example, use `#[no_panic]` instead.
This commit is contained in:
parent
7cb4a204a2
commit
8d79795d70
96 changed files with 313 additions and 385 deletions
|
|
@ -1,58 +0,0 @@
|
|||
language: rust
|
||||
services: docker
|
||||
sudo: required
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- env: TARGET=aarch64-unknown-linux-gnu
|
||||
rust: nightly
|
||||
- env: TARGET=armv7-unknown-linux-gnueabihf
|
||||
rust: nightly
|
||||
- env: TARGET=i686-unknown-linux-gnu
|
||||
rust: nightly
|
||||
- env: TARGET=mips-unknown-linux-gnu
|
||||
rust: nightly
|
||||
- env: TARGET=mips64-unknown-linux-gnuabi64
|
||||
rust: nightly
|
||||
- env: TARGET=mips64el-unknown-linux-gnuabi64
|
||||
rust: nightly
|
||||
- env: TARGET=mipsel-unknown-linux-gnu
|
||||
rust: nightly
|
||||
- env: TARGET=powerpc-unknown-linux-gnu
|
||||
rust: nightly
|
||||
- env: TARGET=powerpc64-unknown-linux-gnu
|
||||
rust: nightly
|
||||
- env: TARGET=powerpc64le-unknown-linux-gnu
|
||||
rust: nightly
|
||||
- env: TARGET=x86_64-unknown-linux-gnu
|
||||
rust: nightly
|
||||
- env: TARGET=cargo-fmt
|
||||
rust: beta
|
||||
|
||||
- env: TARGET=wasm32-unknown-unknown
|
||||
rust: nightly
|
||||
install: rustup target add $TARGET
|
||||
script:
|
||||
- cargo build --target $TARGET
|
||||
- cargo build --no-default-features --target $TARGET
|
||||
|
||||
before_install: set -e
|
||||
|
||||
install:
|
||||
- bash ci/install.sh
|
||||
|
||||
script:
|
||||
- export PATH=$HOME/.local/bin:$PATH
|
||||
- bash ci/script.sh
|
||||
|
||||
after_script: set +e
|
||||
|
||||
cache: cargo
|
||||
|
||||
before_cache:
|
||||
- chmod -R a+r $HOME/.cargo;
|
||||
|
||||
branches:
|
||||
only:
|
||||
- staging
|
||||
- trying
|
||||
|
|
@ -6,21 +6,30 @@ documentation = "https://docs.rs/libm"
|
|||
keywords = ["libm", "math"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
name = "libm"
|
||||
repository = "https://github.com/japaric/libm"
|
||||
repository = "https://github.com/rust-lang-nursery/libm"
|
||||
version = "0.1.2"
|
||||
edition = "2018"
|
||||
|
||||
[features]
|
||||
# only used to run our test suite
|
||||
checked = []
|
||||
default = ['stable']
|
||||
stable = []
|
||||
|
||||
# Generate tests which are random inputs and the outputs are calculated with
|
||||
# musl libc.
|
||||
musl-reference-tests = ['rand']
|
||||
|
||||
# Used checked array indexing instead of unchecked array indexing in this
|
||||
# library.
|
||||
checked = []
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"crates/compiler-builtins-smoke-test",
|
||||
]
|
||||
|
||||
[dev-dependencies]
|
||||
no-panic = "0.1.8"
|
||||
|
||||
[build-dependencies]
|
||||
rand = { version = "0.6.5", optional = true }
|
||||
|
|
|
|||
|
|
@ -10,26 +10,18 @@ jobs:
|
|||
env:
|
||||
TOOLCHAIN: nightly
|
||||
- bash: rustup target add $TARGET
|
||||
displayName: "Install rust cross target"
|
||||
- bash: |
|
||||
set -e
|
||||
mkdir cross
|
||||
curl -L https://github.com/rust-embedded/cross/releases/download/v0.1.14/cross-v0.1.14-x86_64-unknown-linux-musl.tar.gz | tar xzf - -C $HOME/.cargo/bin
|
||||
displayName: "Install cross"
|
||||
- bash: cross test --lib --features checked --target $TARGET --release
|
||||
displayName: "Run lib tests"
|
||||
- bash: cross test --tests --features checked --target $TARGET --release
|
||||
displayName: "Run integration tests"
|
||||
- template: ci/azure-install-rust.yml
|
||||
- bash: cargo generate-lockfile && ./ci/run-docker.sh $TARGET
|
||||
strategy:
|
||||
matrix:
|
||||
aarch64:
|
||||
TARGET: aarch64-unknown-linux-gnu
|
||||
armhv:
|
||||
arm:
|
||||
TARGET: arm-unknown-linux-gnueabi
|
||||
armhf:
|
||||
TARGET: arm-unknown-linux-gnueabihf
|
||||
armv7:
|
||||
TARGET: armv7-unknown-linux-gnueabihf
|
||||
i586:
|
||||
TARGET: i586-unknown-linux-gnu
|
||||
i686:
|
||||
TARGET: i686-unknown-linux-gnu
|
||||
mips:
|
||||
|
|
@ -47,97 +39,31 @@ jobs:
|
|||
x86_64:
|
||||
TARGET: x86_64-unknown-linux-gnu
|
||||
|
||||
# - job: Linux
|
||||
# pool:
|
||||
# vmImage: ubuntu-16.04
|
||||
# steps:
|
||||
# - template: ci/azure-test-all.yml
|
||||
# strategy:
|
||||
# matrix:
|
||||
# stable:
|
||||
# TOOLCHAIN: stable
|
||||
# beta:
|
||||
# TOOLCHAIN: beta
|
||||
# nightly:
|
||||
# TOOLCHAIN: nightly
|
||||
#
|
||||
# - job: macOS
|
||||
# pool:
|
||||
# vmImage: macos-10.13
|
||||
# steps:
|
||||
# - template: ci/azure-test-all.yml
|
||||
# strategy:
|
||||
# matrix:
|
||||
# x86_64:
|
||||
# TARGET: x86_64-apple-darwin
|
||||
#
|
||||
# - job: iOS
|
||||
# pool:
|
||||
# vmImage: macos-10.13
|
||||
# steps:
|
||||
# - checkout: self
|
||||
# submodules: true
|
||||
# - template: ci/azure-install-rust.yml
|
||||
# - script: rustup target add $TARGET
|
||||
# displayName: "Install rust cross target"
|
||||
# - bash: |
|
||||
# set -e
|
||||
# export SDK_PATH=`xcrun --show-sdk-path --sdk $SDK`
|
||||
# export RUSTFLAGS="-C link-arg=-isysroot -C link-arg=$SDK_PATH"
|
||||
# cargo test --no-run --target $TARGET
|
||||
# displayName: "Build for iOS"
|
||||
# strategy:
|
||||
# matrix:
|
||||
# aarch64:
|
||||
# TARGET: aarch64-apple-ios
|
||||
# SDK: iphoneos
|
||||
# armv7:
|
||||
# TARGET: armv7-apple-ios
|
||||
# SDK: iphoneos
|
||||
# armv7s:
|
||||
# TARGET: armv7s-apple-ios
|
||||
# SDK: iphoneos
|
||||
# i386:
|
||||
# TARGET: i386-apple-ios
|
||||
# SDK: iphonesimulator
|
||||
# x86_64:
|
||||
# TARGET: x86_64-apple-ios
|
||||
# SDK: iphonesimulator
|
||||
#
|
||||
# - job: wasm
|
||||
# pool:
|
||||
# vmImage: ubuntu-16.04
|
||||
# steps:
|
||||
# - checkout: self
|
||||
# submodules: true
|
||||
# - template: ci/azure-install-rust.yml
|
||||
# - script: rustup target add wasm32-unknown-unknown
|
||||
# displayName: "Install rust cross target"
|
||||
# - script: cargo build --target wasm32-unknown-unknown
|
||||
# displayName: "Build for wasm"
|
||||
#
|
||||
# - job: Windows
|
||||
# pool:
|
||||
# vmImage: vs2017-win2016
|
||||
# steps:
|
||||
# - template: ci/azure-test-all.yml
|
||||
# strategy:
|
||||
# matrix:
|
||||
# x86_64-msvc:
|
||||
# TARGET: x86_64-pc-windows-msvc
|
||||
# i686-msvc:
|
||||
# TARGET: i686-pc-windows-msvc
|
||||
# x86_64-gnu:
|
||||
# TARGET: x86_64-pc-windows-gnu
|
||||
# i686-gnu:
|
||||
# TARGET: i686-pc-windows-gnu
|
||||
#
|
||||
# - job: Windows_arm64
|
||||
# pool:
|
||||
# vmImage: windows-2019
|
||||
# steps:
|
||||
# - template: ci/azure-install-rust.yml
|
||||
# - script: rustup target add aarch64-pc-windows-msvc
|
||||
# displayName: "Install rust cross target"
|
||||
# - script: cargo test --no-run --target aarch64-pc-windows-msvc
|
||||
# displayName: "Build for arm64"
|
||||
- job: wasm
|
||||
pool:
|
||||
vmImage: ubuntu-16.04
|
||||
steps:
|
||||
- template: ci/azure-install-rust.yml
|
||||
env:
|
||||
TOOLCHAIN: nightly
|
||||
- script: rustup target add wasm32-unknown-unknown
|
||||
displayName: "Install rust wasm target"
|
||||
- script: cargo build --target wasm32-unknown-unknown
|
||||
displayName: "Build for wasm"
|
||||
- script: cargo build --target wasm32-unknown-unknown --no-default-features
|
||||
displayName: "Build for wasm (no default features)"
|
||||
|
||||
- job: rustfmt
|
||||
pool:
|
||||
vmImage: ubuntu-16.04
|
||||
steps:
|
||||
- template: ci/azure-install-rust.yml
|
||||
- bash: rustup component add rustfmt
|
||||
- bash: cargo fmt --all -- --check
|
||||
|
||||
- job: compiler_builtins_works
|
||||
pool:
|
||||
vmImage: ubuntu-16.04
|
||||
steps:
|
||||
- template: ci/azure-install-rust.yml
|
||||
- bash: cargo build -p cb
|
||||
|
|
|
|||
|
|
@ -1,8 +1,17 @@
|
|||
use std::env;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
|
||||
#[cfg(feature = "musl-reference-tests")]
|
||||
musl_reference_tests::generate();
|
||||
|
||||
if !cfg!(feature = "checked") {
|
||||
let lvl = env::var("OPT_LEVEL").unwrap();
|
||||
if lvl != "0" {
|
||||
println!("cargo:rustc-cfg=assert_no_panic");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "musl-reference-tests")]
|
||||
|
|
@ -335,7 +344,7 @@ mod musl_reference_tests {
|
|||
src.push_str("}");
|
||||
}
|
||||
|
||||
let path = format!("{}/tests.rs", dst);
|
||||
let path = format!("{}/musl-tests.rs", dst);
|
||||
fs::write(&path, src).unwrap();
|
||||
|
||||
// Try to make it somewhat pretty
|
||||
|
|
|
|||
|
|
@ -1,41 +1,4 @@
|
|||
steps:
|
||||
- checkout: self
|
||||
submodules: true
|
||||
- template: azure-install-rust.yml
|
||||
|
||||
- bash: cargo build --manifest-path backtrace-sys/Cargo.toml
|
||||
displayName: "Build backtrace-sys"
|
||||
- bash: cargo build
|
||||
displayName: "Build backtrace"
|
||||
- bash: cargo test
|
||||
displayName: "Test backtrace"
|
||||
- bash: cargo test --no-default-features
|
||||
displayName: "Test backtrace (-default)"
|
||||
- bash: cargo test --no-default-features --features 'std'
|
||||
displayName: "Test backtrace (-default + std)"
|
||||
- bash: cargo test --no-default-features --features 'libunwind std'
|
||||
displayName: "Test backtrace (-default + libunwind)"
|
||||
- bash: cargo test --no-default-features --features 'libunwind dladdr std'
|
||||
displayName: "Test backtrace (-default + libunwind + dladdr)"
|
||||
- bash: cargo test --no-default-features --features 'libunwind libbacktrace std'
|
||||
displayName: "Test backtrace (-default + libunwind + libbacktrace)"
|
||||
- bash: cargo test --no-default-features --features 'unix-backtrace std'
|
||||
displayName: "Test backtrace (-default + unix-backtrace)"
|
||||
- bash: cargo test --no-default-features --features 'unix-backtrace dladdr std'
|
||||
displayName: "Test backtrace (-default + unix-backtrace + dladdr)"
|
||||
- bash: cargo test --no-default-features --features 'unix-backtrace libbacktrace std'
|
||||
displayName: "Test backtrace (-default + unix-backtrace + libbacktrace)"
|
||||
- bash: cargo test --no-default-features --features 'serialize-serde std'
|
||||
displayName: "Test backtrace (-default + serialize-serde + std)"
|
||||
- bash: cargo test --no-default-features --features 'serialize-rustc std'
|
||||
displayName: "Test backtrace (-default + serialize-rustc + std)"
|
||||
- bash: cargo test --no-default-features --features 'serialize-rustc serialize-serde std'
|
||||
displayName: "Test backtrace (-default + serialize-rustc + serialize-serde + std)"
|
||||
- bash: cargo test --no-default-features --features 'cpp_demangle std'
|
||||
displayName: "Test backtrace (-default + cpp_demangle + std)"
|
||||
- bash: cargo test --no-default-features --features 'gimli-symbolize std'
|
||||
displayName: "Test backtrace (-default + gimli-symbolize + std)"
|
||||
- bash: cargo test --no-default-features --features 'dbghelp std'
|
||||
displayName: "Test backtrace (-default + dbghelp + std)"
|
||||
- bash: cd ./cpp_smoke_test && cargo test
|
||||
displayName: "Test cpp_smoke_test"
|
||||
- bash: cargo generate-lockfile && ./ci/run-docker.sh $TARGET
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
FROM ubuntu:18.04
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
gcc libc6-dev ca-certificates \
|
||||
gcc-aarch64-linux-gnu libc6-dev-arm64-cross \
|
||||
qemu-user-static
|
||||
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
|
||||
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER=qemu-aarch64-static \
|
||||
QEMU_LD_PREFIX=/usr/aarch64-linux-gnu \
|
||||
RUST_TEST_THREADS=1
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
FROM ubuntu:18.04
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
gcc libc6-dev ca-certificates \
|
||||
gcc-arm-linux-gnueabi libc6-dev-armel-cross qemu-user-static
|
||||
ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_LINKER=arm-linux-gnueabi-gcc \
|
||||
CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABI_RUNNER=qemu-arm-static \
|
||||
QEMU_LD_PREFIX=/usr/arm-linux-gnueabi \
|
||||
RUST_TEST_THREADS=1
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
FROM ubuntu:18.04
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
gcc libc6-dev ca-certificates \
|
||||
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user-static
|
||||
ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \
|
||||
CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER=qemu-arm-static \
|
||||
QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf \
|
||||
RUST_TEST_THREADS=1
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
FROM ubuntu:18.04
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
gcc libc6-dev ca-certificates \
|
||||
gcc-arm-linux-gnueabihf libc6-dev-armhf-cross qemu-user-static
|
||||
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \
|
||||
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_RUNNER=qemu-arm-static \
|
||||
QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf \
|
||||
RUST_TEST_THREADS=1
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
FROM ubuntu:18.04
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
gcc-multilib libc6-dev ca-certificates
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
FROM ubuntu:18.04
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
gcc libc6-dev ca-certificates \
|
||||
gcc-mips-linux-gnu libc6-dev-mips-cross \
|
||||
binfmt-support qemu-user-static qemu-system-mips
|
||||
|
||||
ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc \
|
||||
CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_RUNNER=qemu-mips-static \
|
||||
QEMU_LD_PREFIX=/usr/mips-linux-gnu \
|
||||
RUST_TEST_THREADS=1
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
FROM ubuntu:18.04
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
gcc \
|
||||
gcc-mips64-linux-gnuabi64 \
|
||||
libc6-dev \
|
||||
libc6-dev-mips64-cross \
|
||||
qemu-user-static \
|
||||
qemu-system-mips
|
||||
ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc \
|
||||
CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_RUNNER=qemu-mips64-static \
|
||||
CC_mips64_unknown_linux_gnuabi64=mips64-linux-gnuabi64-gcc \
|
||||
QEMU_LD_PREFIX=/usr/mips64-linux-gnuabi64 \
|
||||
RUST_TEST_THREADS=1
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
FROM ubuntu:18.04
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
gcc \
|
||||
gcc-mips64el-linux-gnuabi64 \
|
||||
libc6-dev \
|
||||
libc6-dev-mips64el-cross \
|
||||
qemu-user-static
|
||||
ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER=mips64el-linux-gnuabi64-gcc \
|
||||
CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_RUNNER=qemu-mips64el-static \
|
||||
CC_mips64el_unknown_linux_gnuabi64=mips64el-linux-gnuabi64-gcc \
|
||||
QEMU_LD_PREFIX=/usr/mips64el-linux-gnuabi64 \
|
||||
RUST_TEST_THREADS=1
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
FROM ubuntu:18.04
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
gcc libc6-dev ca-certificates \
|
||||
gcc-mipsel-linux-gnu libc6-dev-mipsel-cross \
|
||||
binfmt-support qemu-user-static
|
||||
|
||||
ENV CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_LINKER=mipsel-linux-gnu-gcc \
|
||||
CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_GNU_RUNNER=qemu-mipsel-static \
|
||||
QEMU_LD_PREFIX=/usr/mipsel-linux-gnu \
|
||||
RUST_TEST_THREADS=1
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
FROM ubuntu:18.04
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
gcc libc6-dev qemu-user-static ca-certificates \
|
||||
gcc-powerpc-linux-gnu libc6-dev-powerpc-cross \
|
||||
qemu-system-ppc
|
||||
|
||||
ENV CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER=powerpc-linux-gnu-gcc \
|
||||
CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_RUNNER=qemu-ppc-static \
|
||||
QEMU_LD_PREFIX=/usr/powerpc-linux-gnu \
|
||||
RUST_TEST_THREADS=1
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
FROM ubuntu:18.04
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
gcc libc6-dev ca-certificates \
|
||||
gcc-powerpc64-linux-gnu libc6-dev-ppc64-cross \
|
||||
binfmt-support qemu-user-static qemu-system-ppc
|
||||
|
||||
ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-linux-gnu-gcc \
|
||||
CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_RUNNER=qemu-ppc64-static \
|
||||
CC_powerpc64_unknown_linux_gnu=powerpc64-linux-gnu-gcc \
|
||||
QEMU_LD_PREFIX=/usr/powerpc64-linux-gnu \
|
||||
RUST_TEST_THREADS=1
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
FROM ubuntu:18.04
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
gcc libc6-dev qemu-user-static ca-certificates \
|
||||
gcc-powerpc64le-linux-gnu libc6-dev-ppc64el-cross \
|
||||
qemu-system-ppc
|
||||
|
||||
ENV CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc \
|
||||
CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_RUNNER=qemu-ppc64le-static \
|
||||
QEMU_CPU=POWER8 \
|
||||
QEMU_LD_PREFIX=/usr/powerpc64le-linux-gnu \
|
||||
RUST_TEST_THREADS=1
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
FROM ubuntu:18.04
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
gcc libc6-dev ca-certificates
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
set -euxo pipefail
|
||||
|
||||
main() {
|
||||
if [ $TARGET = cargo-fmt ]; then
|
||||
rustup component add rustfmt-preview
|
||||
return
|
||||
fi
|
||||
|
||||
if ! hash cross >/dev/null 2>&1; then
|
||||
cargo install cross
|
||||
fi
|
||||
|
||||
rustup target add x86_64-unknown-linux-musl
|
||||
|
||||
if [ $TARGET != x86_64-unknown-linux-gnu ]; then
|
||||
rustup target add $TARGET
|
||||
fi
|
||||
|
||||
mkdir -p ~/.local/bin
|
||||
curl -L https://github.com/japaric/qemu-bin/raw/master/14.04/qemu-arm-2.12.0 > ~/.local/bin/qemu-arm
|
||||
chmod +x ~/.local/bin/qemu-arm
|
||||
qemu-arm --version
|
||||
}
|
||||
|
||||
main
|
||||
36
library/compiler-builtins/libm/ci/run-docker.sh
Executable file
36
library/compiler-builtins/libm/ci/run-docker.sh
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
# Small script to run tests for a target (or all targets) inside all the
|
||||
# respective docker images.
|
||||
|
||||
set -ex
|
||||
|
||||
run() {
|
||||
local target=$1
|
||||
|
||||
echo $target
|
||||
|
||||
# This directory needs to exist before calling docker, otherwise docker will create it but it
|
||||
# will be owned by root
|
||||
mkdir -p target
|
||||
|
||||
docker build -t $target ci/docker/$target
|
||||
docker run \
|
||||
--rm \
|
||||
--user $(id -u):$(id -g) \
|
||||
-e CARGO_HOME=/cargo \
|
||||
-e CARGO_TARGET_DIR=/target \
|
||||
-v $HOME/.cargo:/cargo \
|
||||
-v `pwd`/target:/target \
|
||||
-v `pwd`:/checkout:ro \
|
||||
-v `rustc --print sysroot`:/rust:ro \
|
||||
-w /checkout \
|
||||
$target \
|
||||
sh -c "HOME=/tmp PATH=\$PATH:/rust/bin ci/run.sh $target"
|
||||
}
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
for d in `ls ci/docker/`; do
|
||||
run $d
|
||||
done
|
||||
else
|
||||
run $1
|
||||
fi
|
||||
12
library/compiler-builtins/libm/ci/run.sh
Executable file
12
library/compiler-builtins/libm/ci/run.sh
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
TARGET=$1
|
||||
|
||||
cargo build --target $TARGET
|
||||
cargo test --target $TARGET
|
||||
cargo build --target $TARGET --release
|
||||
cargo test --target $TARGET --release
|
||||
|
||||
cargo test --features 'checked musl-reference-tests' --target $TARGET
|
||||
cargo test --features 'checked musl-reference-tests' --target $TARGET --release
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
set -euxo pipefail
|
||||
|
||||
main() {
|
||||
if [ $TARGET = cargo-fmt ]; then
|
||||
cargo fmt -- --check
|
||||
return
|
||||
fi
|
||||
|
||||
# quick check
|
||||
cargo check
|
||||
|
||||
# check that we can source import libm into compiler-builtins
|
||||
cargo check --package cb
|
||||
|
||||
# generate tests
|
||||
cargo run -p input-generator --target x86_64-unknown-linux-musl
|
||||
cargo run -p musl-generator --target x86_64-unknown-linux-musl
|
||||
cargo run -p newlib-generator
|
||||
|
||||
# test that the functions don't contain invocations of `panic!`
|
||||
case $TARGET in
|
||||
armv7-unknown-linux-gnueabihf)
|
||||
cross build --release --target $TARGET --example no-panic
|
||||
;;
|
||||
esac
|
||||
|
||||
# run unit tests
|
||||
cross test --lib --features checked --target $TARGET --release
|
||||
|
||||
# run generated tests
|
||||
cross test --tests --features checked --target $TARGET --release
|
||||
|
||||
# TODO need to fix overflow issues (cf. issue #4)
|
||||
# cross test --target $TARGET
|
||||
}
|
||||
|
||||
main
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
#![feature(lang_items)]
|
||||
#![feature(panic_implementation)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
extern crate libm;
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
use core::ptr;
|
||||
|
||||
macro_rules! force_eval {
|
||||
($e:expr) => {
|
||||
unsafe {
|
||||
core::ptr::read_volatile(&$e);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub fn main() {
|
||||
force_eval!(libm::acos(random()));
|
||||
force_eval!(libm::acosf(random()));
|
||||
force_eval!(libm::asin(random()));
|
||||
force_eval!(libm::asinf(random()));
|
||||
force_eval!(libm::atan(random()));
|
||||
force_eval!(libm::atan2(random(), random()));
|
||||
force_eval!(libm::atan2f(random(), random()));
|
||||
force_eval!(libm::atanf(random()));
|
||||
force_eval!(libm::cbrt(random()));
|
||||
force_eval!(libm::cbrtf(random()));
|
||||
force_eval!(libm::ceil(random()));
|
||||
force_eval!(libm::ceilf(random()));
|
||||
force_eval!(libm::cos(random()));
|
||||
force_eval!(libm::cosf(random()));
|
||||
force_eval!(libm::cosh(random()));
|
||||
force_eval!(libm::coshf(random()));
|
||||
force_eval!(libm::exp(random()));
|
||||
force_eval!(libm::exp2(random()));
|
||||
force_eval!(libm::exp2f(random()));
|
||||
force_eval!(libm::expf(random()));
|
||||
force_eval!(libm::expm1(random()));
|
||||
force_eval!(libm::expm1f(random()));
|
||||
force_eval!(libm::fabs(random()));
|
||||
force_eval!(libm::fabsf(random()));
|
||||
force_eval!(libm::fdim(random(), random()));
|
||||
force_eval!(libm::fdimf(random(), random()));
|
||||
force_eval!(libm::floor(random()));
|
||||
force_eval!(libm::floorf(random()));
|
||||
force_eval!(libm::fma(random(), random(), random()));
|
||||
force_eval!(libm::fmaf(random(), random(), random()));
|
||||
force_eval!(libm::fmod(random(), random()));
|
||||
force_eval!(libm::fmodf(random(), random()));
|
||||
force_eval!(libm::hypot(random(), random()));
|
||||
force_eval!(libm::hypotf(random(), random()));
|
||||
force_eval!(libm::log(random()));
|
||||
force_eval!(libm::log2(random()));
|
||||
force_eval!(libm::log10(random()));
|
||||
force_eval!(libm::log10f(random()));
|
||||
force_eval!(libm::log1p(random()));
|
||||
force_eval!(libm::log1pf(random()));
|
||||
force_eval!(libm::log2f(random()));
|
||||
force_eval!(libm::logf(random()));
|
||||
force_eval!(libm::pow(random(), random()));
|
||||
force_eval!(libm::powf(random(), random()));
|
||||
force_eval!(libm::round(random()));
|
||||
force_eval!(libm::roundf(random()));
|
||||
force_eval!(libm::scalbn(random(), random()));
|
||||
force_eval!(libm::scalbnf(random(), random()));
|
||||
force_eval!(libm::sin(random()));
|
||||
force_eval!(libm::sinf(random()));
|
||||
force_eval!(libm::sinh(random()));
|
||||
force_eval!(libm::sinhf(random()));
|
||||
force_eval!(libm::sqrt(random()));
|
||||
force_eval!(libm::sqrtf(random()));
|
||||
force_eval!(libm::tan(random()));
|
||||
force_eval!(libm::tanf(random()));
|
||||
force_eval!(libm::tanh(random()));
|
||||
force_eval!(libm::tanhf(random()));
|
||||
force_eval!(libm::trunc(random()));
|
||||
force_eval!(libm::truncf(random()));
|
||||
}
|
||||
|
||||
fn random<T>() -> T
|
||||
where
|
||||
T: Copy,
|
||||
{
|
||||
unsafe {
|
||||
static mut X: usize = 0;
|
||||
X += 8;
|
||||
ptr::read_volatile(X as *const T)
|
||||
}
|
||||
}
|
||||
|
||||
#[panic_implementation]
|
||||
#[no_mangle]
|
||||
pub fn panic(_info: &PanicInfo) -> ! {
|
||||
// loop {}
|
||||
extern "C" {
|
||||
fn thou_shalt_not_panic() -> !;
|
||||
}
|
||||
|
||||
unsafe { thou_shalt_not_panic() }
|
||||
}
|
||||
|
||||
#[link(name = "c")]
|
||||
extern "C" {}
|
||||
|
||||
#[lang = "eh_personality"]
|
||||
fn eh() {}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn __aeabi_unwind_cpp_pr0() {}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn __aeabi_unwind_cpp_pr1() {}
|
||||
|
|
@ -626,5 +626,5 @@ mod private {
|
|||
impl Sealed for f64 {}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
include!(concat!(env!("OUT_DIR"), "/tests.rs"));
|
||||
#[cfg(all(test, feature = "musl-reference-tests"))]
|
||||
include!(concat!(env!("OUT_DIR"), "/musl-tests.rs"));
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ fn r(z: f64) -> f64 {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn acos(x: f64) -> f64 {
|
||||
let x1p_120f = f64::from_bits(0x3870000000000000); // 0x1p-120 === 2 ^ -120
|
||||
let z: f64;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ fn r(z: f32) -> f32 {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn acosf(x: f32) -> f32 {
|
||||
let x1p_120 = f32::from_bits(0x03800000); // 0x1p-120 === 2 ^ (-120)
|
||||
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ fn comp_r(z: f64) -> f64 {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn asin(mut x: f64) -> f64 {
|
||||
let z: f64;
|
||||
let r: f64;
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ fn r(z: f32) -> f32 {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn asinf(mut x: f32) -> f32 {
|
||||
let x1p_120 = f64::from_bits(0x3870000000000000); // 0x1p-120 === 2 ^ (-120)
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ const AT: [f64; 11] = [
|
|||
];
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn atan(x: f64) -> f64 {
|
||||
let mut x = x;
|
||||
let mut ix = (x.to_bits() >> 32) as u32;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ const PI: f64 = 3.1415926535897931160E+00; /* 0x400921FB, 0x54442D18 */
|
|||
const PI_LO: f64 = 1.2246467991473531772E-16; /* 0x3CA1A626, 0x33145C07 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn atan2(y: f64, x: f64) -> f64 {
|
||||
if x.is_nan() || y.is_nan() {
|
||||
return x + y;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ const PI: f32 = 3.1415927410e+00; /* 0x40490fdb */
|
|||
const PI_LO: f32 = -8.7422776573e-08; /* 0xb3bbbd2e */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn atan2f(y: f32, x: f32) -> f32 {
|
||||
if x.is_nan() || y.is_nan() {
|
||||
return x + y;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ const A_T: [f32; 5] = [
|
|||
];
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn atanf(mut x: f32) -> f32 {
|
||||
let x1p_120 = f32::from_bits(0x03800000); // 0x1p-120 === 2 ^ (-120)
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ const P3: f64 = -0.758397934778766047437; /* 0xbfe844cb, 0xbee751d9 */
|
|||
const P4: f64 = 0.145996192886612446982; /* 0x3fc2b000, 0xd4e4edd7 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn cbrt(x: f64) -> f64 {
|
||||
let x1p54 = f64::from_bits(0x4350000000000000); // 0x1p54 === 2 ^ 54
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ const B1: u32 = 709958130; /* B1 = (127-127.0/3-0.03306235651)*2**23 */
|
|||
const B2: u32 = 642849266; /* B2 = (127-127.0/3-24/3-0.03306235651)*2**23 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn cbrtf(x: f32) -> f32 {
|
||||
let x1p24 = f32::from_bits(0x4b800000); // 0x1p24f === 2 ^ 24
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use core::f64;
|
|||
const TOINT: f64 = 1. / f64::EPSILON;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn ceil(x: f64) -> f64 {
|
||||
// On wasm32 we know that LLVM's intrinsic will compile to an optimized
|
||||
// `f64.ceil` native instruction, so we can leverage this for both code size
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use core::f32;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn ceilf(x: f32) -> f32 {
|
||||
// On wasm32 we know that LLVM's intrinsic will compile to an optimized
|
||||
// `f32.ceil` native instruction, so we can leverage this for both code size
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ use super::{k_cos, k_sin, rem_pio2};
|
|||
// TRIG(x) returns trig(x) nearly rounded
|
||||
//
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn cos(x: f64) -> f64 {
|
||||
let ix = (f64::to_bits(x) >> 32) as u32 & 0x7fffffff;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ const C3_PIO2: f64 = 3. * FRAC_PI_2; /* 0x4012D97C, 0x7F3321D2 */
|
|||
const C4_PIO2: f64 = 4. * FRAC_PI_2; /* 0x401921FB, 0x54442D18 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn cosf(x: f32) -> f32 {
|
||||
let x64 = x as f64;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use super::expm1;
|
|||
use super::k_expo2;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn cosh(mut x: f64) -> f64 {
|
||||
/* |x| */
|
||||
let mut ix = x.to_bits();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use super::expm1f;
|
|||
use super::k_expo2f;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn coshf(mut x: f32) -> f32 {
|
||||
let x1p120 = f32::from_bits(0x7b800000); // 0x1p120f === 2 ^ 120
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ const P4: f64 = -1.65339022054652515390e-06; /* 0xBEBBBD41, 0xC5D26BF1 */
|
|||
const P5: f64 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn exp(mut x: f64) -> f64 {
|
||||
let x1p1023 = f64::from_bits(0x7fe0000000000000); // 0x1p1023 === 2 ^ 1023
|
||||
let x1p_149 = f64::from_bits(0x36a0000000000000); // 0x1p-149 === 2 ^ -149
|
||||
|
|
|
|||
|
|
@ -319,6 +319,7 @@ static TBL: [u64; TBLSIZE * 2] = [
|
|||
// Gal, S. and Bachelis, B. An Accurate Elementary Mathematical Library
|
||||
// for the IEEE Floating Point Standard. TOMS 17(1), 26-46 (1991).
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn exp2(mut x: f64) -> f64 {
|
||||
let redux = f64::from_bits(0x4338000000000000) / TBLSIZE as f64;
|
||||
let p1 = f64::from_bits(0x3fe62e42fefa39ef);
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ static EXP2FT: [u64; TBLSIZE] = [
|
|||
// Tang, P. Table-driven Implementation of the Exponential Function
|
||||
// in IEEE Floating-Point Arithmetic. TOMS 15(2), 144-157 (1989).
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn exp2f(mut x: f32) -> f32 {
|
||||
let redux = f32::from_bits(0x4b400000) / TBLSIZE as f32;
|
||||
let p1 = f32::from_bits(0x3f317218);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ const P1: f32 = 1.6666625440e-1; /* 0xaaaa8f.0p-26 */
|
|||
const P2: f32 = -2.7667332906e-3; /* -0xb55215.0p-32 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn expf(mut x: f32) -> f32 {
|
||||
let x1p127 = f32::from_bits(0x7f000000); // 0x1p127f === 2 ^ 127
|
||||
let x1p_126 = f32::from_bits(0x800000); // 0x1p-126f === 2 ^ -126 /*original 0x1p-149f ??????????? */
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ const Q4: f64 = 4.00821782732936239552e-06; /* 3ED0CFCA 86E65239 */
|
|||
const Q5: f64 = -2.01099218183624371326e-07; /* BE8AFDB7 6E09C32D */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn expm1(mut x: f64) -> f64 {
|
||||
let hi: f64;
|
||||
let lo: f64;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ const Q1: f32 = -3.3333212137e-2; /* -0x888868.0p-28 */
|
|||
const Q2: f32 = 1.5807170421e-3; /* 0xcf3010.0p-33 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn expm1f(mut x: f32) -> f32 {
|
||||
let x1p127 = f32::from_bits(0x7f000000); // 0x1p127f === 2 ^ 127
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ use super::{combine_words, exp};
|
|||
|
||||
/* exp(x)/2 for x >= log(DBL_MAX), slightly better than 0.5*exp(x/2)*exp(x/2) */
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn expo2(x: f64) -> f64 {
|
||||
/* k is such that k*ln2 has minimal relative error and x - kln2 > log(DBL_MIN) */
|
||||
const K: i32 = 2043;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use core::u64;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn fabs(x: f64) -> f64 {
|
||||
// On wasm32 we know that LLVM's intrinsic will compile to an optimized
|
||||
// `f64.abs` native instruction, so we can leverage this for both code size
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn fabsf(x: f32) -> f32 {
|
||||
// On wasm32 we know that LLVM's intrinsic will compile to an optimized
|
||||
// `f32.abs` native instruction, so we can leverage this for both code size
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use core::f64;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn fdim(x: f64, y: f64) -> f64 {
|
||||
if x.is_nan() {
|
||||
x
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use core::f32;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn fdimf(x: f32, y: f32) -> f32 {
|
||||
if x.is_nan() {
|
||||
x
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use core::f64;
|
|||
const TOINT: f64 = 1. / f64::EPSILON;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn floor(x: f64) -> f64 {
|
||||
// On wasm32 we know that LLVM's intrinsic will compile to an optimized
|
||||
// `f64.floor` native instruction, so we can leverage this for both code size
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use core::f32;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn floorf(x: f32) -> f32 {
|
||||
// On wasm32 we know that LLVM's intrinsic will compile to an optimized
|
||||
// `f32.floor` native instruction, so we can leverage this for both code size
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ fn mul(x: u64, y: u64) -> (u64, u64) {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn fma(x: f64, y: f64, z: f64) -> f64 {
|
||||
let x1p63: f64 = f64::from_bits(0x43e0000000000000); // 0x1p63 === 2 ^ 63
|
||||
let x0_ffffff8p_63 = f64::from_bits(0x3bfffffff0000000); // 0x0.ffffff8p-63
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ use super::fenv::{
|
|||
* rounding occurs.
|
||||
*/
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn fmaf(x: f32, y: f32, mut z: f32) -> f32 {
|
||||
let xy: f64;
|
||||
let mut result: f64;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use core::u64;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn fmod(x: f64, y: f64) -> f64 {
|
||||
let mut uxi = x.to_bits();
|
||||
let mut uyi = y.to_bits();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ use core::f32;
|
|||
use core::u32;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn fmodf(x: f32, y: f32) -> f32 {
|
||||
let mut uxi = x.to_bits();
|
||||
let mut uyi = y.to_bits();
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ fn sq(x: f64) -> (f64, f64) {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn hypot(mut x: f64, mut y: f64) -> f64 {
|
||||
let x1p700 = f64::from_bits(0x6bb0000000000000); // 0x1p700 === 2 ^ 700
|
||||
let x1p_700 = f64::from_bits(0x1430000000000000); // 0x1p-700 === 2 ^ -700
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use core::f32;
|
|||
use super::sqrtf;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn hypotf(mut x: f32, mut y: f32) -> f32 {
|
||||
let x1p90 = f32::from_bits(0x6c800000); // 0x1p90f === 2 ^ 90
|
||||
let x1p_90 = f32::from_bits(0x12800000); // 0x1p-90f === 2 ^ -90
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ const C6: f64 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */
|
|||
// under FreeBSD, so don't pessimize things by forcibly clipping
|
||||
// any extra precision in w.
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn k_cos(x: f64, y: f64) -> f64 {
|
||||
let z = x * x;
|
||||
let w = z * z;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ const C2: f64 = -0.00138867637746099294692; /* -0x16c087e80f1e27.0p-62 */
|
|||
const C3: f64 = 0.0000243904487962774090654; /* 0x199342e0ee5069.0p-68 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn k_cosf(x: f64) -> f32 {
|
||||
let z = x * x;
|
||||
let w = z * z;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ const K: i32 = 2043;
|
|||
|
||||
/* expf(x)/2 for x >= log(FLT_MAX), slightly better than 0.5f*expf(x/2)*expf(x/2) */
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub(crate) fn k_expo2(x: f64) -> f64 {
|
||||
let k_ln2 = f64::from_bits(0x40962066151add8b);
|
||||
/* note that k is odd and scale*scale overflows */
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ const K: i32 = 235;
|
|||
|
||||
/* expf(x)/2 for x >= log(FLT_MAX), slightly better than 0.5f*expf(x/2)*expf(x/2) */
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn k_expo2f(x: f32) -> f32 {
|
||||
let k_ln2 = f32::from_bits(0x4322e3bc);
|
||||
/* note that k is odd and scale*scale overflows */
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ const S6: f64 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */
|
|||
// then 3 2
|
||||
// sin(x) = x + (S1*x + (x *(r-y/2)+y))
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn k_sin(x: f64, y: f64, iy: i32) -> f64 {
|
||||
let z = x * x;
|
||||
let w = z * z;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ const S3: f64 = -0.000198393348360966317347; /* -0x1a00f9e2cae774.0p-65 */
|
|||
const S4: f64 = 0.0000027183114939898219064; /* 0x16cd878c3b46a7.0p-71 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn k_sinf(x: f64) -> f32 {
|
||||
let z = x * x;
|
||||
let w = z * z;
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ const PIO4: f64 = 7.85398163397448278999e-01; /* 3FE921FB, 54442D18 */
|
|||
const PIO4_LO: f64 = 3.06161699786838301793e-17; /* 3C81A626, 33145C07 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn k_tan(mut x: f64, mut y: f64, odd: i32) -> f64 {
|
||||
let hx = (f64::to_bits(x) >> 32) as u32;
|
||||
let big = (hx & 0x7fffffff) >= 0x3FE59428; /* |x| >= 0.6744 */
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ const T: [f64; 6] = [
|
|||
];
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn k_tanf(x: f64, odd: bool) -> f32 {
|
||||
let z = x * x;
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ const LG6: f64 = 1.531383769920937332e-01; /* 3FC39A09 D078C69F */
|
|||
const LG7: f64 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn log(mut x: f64) -> f64 {
|
||||
let x1p54 = f64::from_bits(0x4350000000000000); // 0x1p54 === 2 ^ 54
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ const LG6: f64 = 1.531383769920937332e-01; /* 3FC39A09 D078C69F */
|
|||
const LG7: f64 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn log10(mut x: f64) -> f64 {
|
||||
let x1p54 = f64::from_bits(0x4350000000000000); // 0x1p54 === 2 ^ 54
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ const LG3: f32 = 0.28498786688; /* 0x91e9ee.0p-25 */
|
|||
const LG4: f32 = 0.24279078841; /* 0xf89e26.0p-26 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn log10f(mut x: f32) -> f32 {
|
||||
let x1p25f = f32::from_bits(0x4c000000); // 0x1p25f === 2 ^ 25
|
||||
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ const LG6: f64 = 1.531383769920937332e-01; /* 3FC39A09 D078C69F */
|
|||
const LG7: f64 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn log1p(x: f64) -> f64 {
|
||||
let mut ui: u64 = x.to_bits();
|
||||
let hfsq: f64;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ const LG3: f32 = 0.28498786688; /* 0x91e9ee.0p-25 */
|
|||
const LG4: f32 = 0.24279078841; /* 0xf89e26.0p-26 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn log1pf(x: f32) -> f32 {
|
||||
let mut ui: u32 = x.to_bits();
|
||||
let hfsq: f32;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ const LG6: f64 = 1.531383769920937332e-01; /* 3FC39A09 D078C69F */
|
|||
const LG7: f64 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn log2(mut x: f64) -> f64 {
|
||||
let x1p54 = f64::from_bits(0x4350000000000000); // 0x1p54 === 2 ^ 54
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ const LG3: f32 = 0.28498786688; /* 0x91e9ee.0p-25 */
|
|||
const LG4: f32 = 0.24279078841; /* 0xf89e26.0p-26 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn log2f(mut x: f32) -> f32 {
|
||||
let x1p25f = f32::from_bits(0x4c000000); // 0x1p25f === 2 ^ 25
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ const LG3: f32 = 0.28498786688; /* 0x91e9ee.0p-25 */
|
|||
const LG4: f32 = 0.24279078841; /* 0xf89e26.0p-26 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn logf(mut x: f32) -> f32 {
|
||||
let x1p25 = f32::from_bits(0x4c000000); // 0x1p25f === 2 ^ 25
|
||||
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ const IVLN2_H: f64 = 1.44269502162933349609e+00; /* 0x3ff71547_60000000 =24b 1/l
|
|||
const IVLN2_L: f64 = 1.92596299112661746887e-08; /* 0x3e54ae0b_f85ddf44 =1/ln2 tail*/
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn pow(x: f64, y: f64) -> f64 {
|
||||
let t1: f64;
|
||||
let t2: f64;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ const IVLN2_H: f32 = 1.4426879883e+00;
|
|||
const IVLN2_L: f32 = 7.0526075433e-06;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn powf(x: f32, y: f32) -> f32 {
|
||||
let mut z: f32;
|
||||
let mut ax: f32;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ const PIO2_3T: f64 = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */
|
|||
//
|
||||
// caller must handle the case when reduction is not needed: |x| ~<= pi/4 */
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn rem_pio2(x: f64) -> (i32, f64, f64) {
|
||||
let x1p24 = f64::from_bits(0x4170000000000000);
|
||||
|
||||
|
|
|
|||
|
|
@ -223,6 +223,7 @@ const PIO2: [f64; 8] = [
|
|||
/// more accurately, = 0 mod 8 ). Thus the number of operations are
|
||||
/// independent of the exponent of the input.
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn rem_pio2_large(x: &[f64], y: &mut [f64], e0: i32, prec: usize) -> i32 {
|
||||
let x1p24 = f64::from_bits(0x4170000000000000); // 0x1p24 === 2 ^ 24
|
||||
let x1p_24 = f64::from_bits(0x3e70000000000000); // 0x1p_24 === 2 ^ (-24)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ const PIO2_1T: f64 = 1.58932547735281966916e-08; /* 0x3E5110b4, 0x611A6263 */
|
|||
/// use double precision for everything except passing x
|
||||
/// use __rem_pio2_large() for large x
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn rem_pio2f(x: f32) -> (i32, f64) {
|
||||
let x64 = x as f64;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use core::f64;
|
|||
const TOINT: f64 = 1.0 / f64::EPSILON;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn round(mut x: f64) -> f64 {
|
||||
let (f, i) = (x, x.to_bits());
|
||||
let e: u64 = i >> 52 & 0x7ff;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use core::f32;
|
|||
const TOINT: f32 = 1.0 / f32::EPSILON;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn roundf(mut x: f32) -> f32 {
|
||||
let i = x.to_bits();
|
||||
let e: u32 = i >> 23 & 0xff;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn scalbn(x: f64, mut n: i32) -> f64 {
|
||||
let x1p1023 = f64::from_bits(0x7fe0000000000000); // 0x1p1023 === 2 ^ 1023
|
||||
let x1p53 = f64::from_bits(0x4340000000000000); // 0x1p53 === 2 ^ 53
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn scalbnf(mut x: f32, mut n: i32) -> f32 {
|
||||
let x1p127 = f32::from_bits(0x7f000000); // 0x1p127f === 2 ^ 127
|
||||
let x1p_126 = f32::from_bits(0x800000); // 0x1p-126f === 2 ^ -126
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ use super::{k_cos, k_sin, rem_pio2};
|
|||
// Accuracy:
|
||||
// TRIG(x) returns trig(x) nearly rounded
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn sin(x: f64) -> f64 {
|
||||
let x1p120 = f64::from_bits(0x4770000000000000); // 0x1p120f === 2 ^ 120
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ const S3_PIO2: f64 = 3. * FRAC_PI_2; /* 0x4012D97C, 0x7F3321D2 */
|
|||
const S4_PIO2: f64 = 4. * FRAC_PI_2; /* 0x401921FB, 0x54442D18 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn sinf(x: f32) -> f32 {
|
||||
let x64 = x as f64;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use super::{expm1, expo2};
|
|||
// = x + x^3/6 + o(x^5)
|
||||
//
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn sinh(x: f64) -> f64 {
|
||||
// union {double f; uint64_t i;} u = {.f = x};
|
||||
// uint32_t w;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ use super::expm1f;
|
|||
use super::k_expo2f;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn sinhf(x: f32) -> f32 {
|
||||
let mut h = 0.5f32;
|
||||
let mut ix = x.to_bits();
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ use core::f64;
|
|||
const TINY: f64 = 1.0e-300;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn sqrt(x: f64) -> f64 {
|
||||
// On wasm32 we know that LLVM's intrinsic will compile to an optimized
|
||||
// `f64.sqrt` native instruction, so we can leverage this for both code size
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
const TINY: f32 = 1.0e-30;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn sqrtf(x: f32) -> f32 {
|
||||
// On wasm32 we know that LLVM's intrinsic will compile to an optimized
|
||||
// `f32.sqrt` native instruction, so we can leverage this for both code size
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ use super::{k_tan, rem_pio2};
|
|||
// Accuracy:
|
||||
// TRIG(x) returns trig(x) nearly rounded
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn tan(x: f64) -> f64 {
|
||||
let x1p120 = f32::from_bits(0x7b800000); // 0x1p120f === 2 ^ 120
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ const T3_PIO2: f64 = 3. * FRAC_PI_2; /* 0x4012D97C, 0x7F3321D2 */
|
|||
const T4_PIO2: f64 = 4. * FRAC_PI_2; /* 0x401921FB, 0x54442D18 */
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn tanf(x: f32) -> f32 {
|
||||
let x64 = x as f64;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use super::expm1;
|
|||
* = (1 - exp(-2*x))/(exp(-2*x) - 1 + 2)
|
||||
*/
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn tanh(mut x: f64) -> f64 {
|
||||
let mut uf: f64 = x;
|
||||
let mut ui: u64 = f64::to_bits(uf);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use super::expm1f;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn tanhf(mut x: f32) -> f32 {
|
||||
/* x = |x| */
|
||||
let mut ix = x.to_bits();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use core::f64;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn trunc(x: f64) -> f64 {
|
||||
// On wasm32 we know that LLVM's intrinsic will compile to an optimized
|
||||
// `f64.trunc` native instruction, so we can leverage this for both code size
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use core::f32;
|
||||
|
||||
#[inline]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
pub fn truncf(x: f32) -> f32 {
|
||||
// On wasm32 we know that LLVM's intrinsic will compile to an optimized
|
||||
// `f32.trunc` native instruction, so we can leverage this for both code size
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue