commit
a9b3f97d44
65
.travis.yml
65
.travis.yml
|
@ -2,43 +2,30 @@ language: rust
|
|||
rust: stable
|
||||
sudo: required
|
||||
dist: trusty
|
||||
services:
|
||||
- docker
|
||||
install:
|
||||
- if [ -z "$NO_ADD" ]; then rustup target add $TARGET; fi
|
||||
script:
|
||||
- cargo build $OPT
|
||||
- cargo build $OPT --no-default-features
|
||||
- cargo generate-lockfile --manifest-path libc-test/Cargo.toml
|
||||
- if [[ $TRAVIS_OS_NAME = "linux" ]]; then
|
||||
sh ci/run-docker.sh $TARGET;
|
||||
else
|
||||
export CARGO_TARGET_DIR=`pwd`/target;
|
||||
sh ci/run.sh $TARGET;
|
||||
fi
|
||||
- rustc ci/style.rs && ./style src
|
||||
env:
|
||||
global:
|
||||
secure: "e2/3QjgRN9atOuSHp22TrYG7QVKcYUWY48Hi9b60w+r1+BhPkTseIJLte7WefRhdXtqpjjUJTooKDhnurFOeHaCT+nmBgiv+FPU893sBl4bhesY4m0vgUJVbNZcs6lTImYekWVb+aqjGdgV/XAgCw7c3kPmrZV0MzGDWL64Xaps="
|
||||
services: docker
|
||||
|
||||
matrix:
|
||||
include:
|
||||
# 1.13.0 compat
|
||||
- env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
|
||||
- env: TARGET=x86_64-unknown-linux-gnu
|
||||
rust: 1.13.0
|
||||
script: rm -f Cargo.lock && cargo build
|
||||
install:
|
||||
install: true
|
||||
|
||||
# build documentation
|
||||
- env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
|
||||
- env: TARGET=x86_64-unknown-linux-gnu
|
||||
rust: nightly
|
||||
script: sh ci/dox.sh
|
||||
install: true
|
||||
|
||||
# stable compat
|
||||
- env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
|
||||
- env: TARGET=x86_64-unknown-linux-gnu
|
||||
install: true
|
||||
- env: TARGET=i686-unknown-linux-gnu
|
||||
- os: osx
|
||||
env: TARGET=x86_64-apple-darwin NO_ADD=1
|
||||
env: TARGET=x86_64-apple-darwin
|
||||
osx_image: xcode10
|
||||
install: true
|
||||
- os: osx
|
||||
env: TARGET=i686-apple-darwin
|
||||
osx_image: xcode10
|
||||
|
@ -67,20 +54,24 @@ matrix:
|
|||
- env: TARGET=wasm32-unknown-emscripten
|
||||
|
||||
# beta
|
||||
- env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
|
||||
- env: TARGET=x86_64-unknown-linux-gnu
|
||||
rust: beta
|
||||
install: true
|
||||
- os: osx
|
||||
env: TARGET=x86_64-apple-darwin NO_ADD=1
|
||||
env: TARGET=x86_64-apple-darwin
|
||||
osx_image: xcode10
|
||||
rust: beta
|
||||
install: true
|
||||
|
||||
# nightly
|
||||
- env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
|
||||
- env: TARGET=x86_64-unknown-linux-gnu
|
||||
rust: nightly
|
||||
install: true
|
||||
- os: osx
|
||||
env: TARGET=x86_64-apple-darwin NO_ADD=1
|
||||
env: TARGET=x86_64-apple-darwin
|
||||
osx_image: xcode10
|
||||
rust: nightly
|
||||
install: true
|
||||
# not available on stable
|
||||
# without --release the build fails
|
||||
# see https://github.com/rust-lang/rust/issues/45417
|
||||
|
@ -90,6 +81,26 @@ matrix:
|
|||
# QEMU based targets that compile in an emulator
|
||||
- env: TARGET=x86_64-unknown-freebsd
|
||||
|
||||
- name: "Shellcheck"
|
||||
install: true
|
||||
script:
|
||||
- shellcheck --version
|
||||
- shellcheck ci/*.sh
|
||||
|
||||
install: rustup target add $TARGET
|
||||
script:
|
||||
- cargo generate-lockfile --manifest-path libc-test/Cargo.toml
|
||||
- if [[ $TRAVIS_OS_NAME = "linux" ]]; then
|
||||
sh ci/run-docker.sh $TARGET;
|
||||
else
|
||||
export CARGO_TARGET_DIR=`pwd`/target;
|
||||
sh ci/run.sh $TARGET;
|
||||
fi
|
||||
- rustc ci/style.rs && ./style src
|
||||
env:
|
||||
global:
|
||||
secure: "e2/3QjgRN9atOuSHp22TrYG7QVKcYUWY48Hi9b60w+r1+BhPkTseIJLte7WefRhdXtqpjjUJTooKDhnurFOeHaCT+nmBgiv+FPU893sBl4bhesY4m0vgUJVbNZcs6lTImYekWVb+aqjGdgV/XAgCw7c3kPmrZV0MzGDWL64Xaps="
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
#!/usr/bin/env sh
|
||||
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
# file at the top-level directory of this distribution and at
|
||||
# http://rust-lang.org/COPYRIGHT.
|
||||
|
@ -30,8 +30,8 @@ esac;
|
|||
|
||||
android-ndk-r15b/build/tools/make_standalone_toolchain.py \
|
||||
--unified-headers \
|
||||
--install-dir /android/ndk-$1 \
|
||||
--arch $arch \
|
||||
--install-dir "/android/ndk-${1}" \
|
||||
--arch "${arch}" \
|
||||
--api 24
|
||||
|
||||
rm -rf ./android-ndk-r15b-linux-x86_64.zip ./android-ndk-r15b
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
#!/usr/bin/env sh
|
||||
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
# file at the top-level directory of this distribution and at
|
||||
# http://rust-lang.org/COPYRIGHT.
|
||||
|
@ -56,5 +56,5 @@ echo "yes" | \
|
|||
|
||||
echo "no" |
|
||||
./sdk/tools/bin/avdmanager create avd \
|
||||
--name $1 \
|
||||
--name "${1}" \
|
||||
--package "system-images;android-24;default;$abi"
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
# file at the top-level directory of this distribution and at
|
||||
# http://rust-lang.org/COPYRIGHT.
|
||||
|
@ -13,32 +15,34 @@ set -ex
|
|||
URL=https://dl.google.com/android/repository/sys-img/android
|
||||
|
||||
main() {
|
||||
local arch=$1
|
||||
local name=$2
|
||||
local arch="${1}"
|
||||
local name="${2}"
|
||||
local dest=/system
|
||||
local td=$(mktemp -d)
|
||||
local td
|
||||
td="$(mktemp -d)"
|
||||
|
||||
apt-get install --no-install-recommends e2tools
|
||||
|
||||
pushd $td
|
||||
curl -O $URL/$name
|
||||
unzip -q $name
|
||||
pushd "${td}"
|
||||
curl -O "${URL}/${name}"
|
||||
unzip -q "${name}"
|
||||
|
||||
local system=$(find . -name system.img)
|
||||
mkdir -p $dest/{bin,lib,lib64}
|
||||
local system
|
||||
system="$(find . -name system.img)"
|
||||
mkdir -p ${dest}/{bin,lib,lib64}
|
||||
|
||||
# Extract android linker and libraries to /system
|
||||
# This allows android executables to be run directly (or with qemu)
|
||||
if [ $arch = "x86_64" -o $arch = "arm64" ]; then
|
||||
e2cp -p $system:/bin/linker64 $dest/bin/
|
||||
e2cp -p $system:/lib64/libdl.so $dest/lib64/
|
||||
e2cp -p $system:/lib64/libc.so $dest/lib64/
|
||||
e2cp -p $system:/lib64/libm.so $dest/lib64/
|
||||
if [ "${arch}" = "x86_64" ] || [ "${arch}" = "arm64" ]; then
|
||||
e2cp -p "${system}:/bin/linker64" "${dest}/bin/"
|
||||
e2cp -p "${system}:/lib64/libdl.so" "${dest}/lib64/"
|
||||
e2cp -p "${system}:/lib64/libc.so" "${dest}/lib64/"
|
||||
e2cp -p "${system}:/lib64/libm.so" "${dest}/lib64/"
|
||||
else
|
||||
e2cp -p $system:/bin/linker $dest/bin/
|
||||
e2cp -p $system:/lib/libdl.so $dest/lib/
|
||||
e2cp -p $system:/lib/libc.so $dest/lib/
|
||||
e2cp -p $system:/lib/libm.so $dest/lib/
|
||||
e2cp -p "${system}:/bin/linker" "${dest}/bin/"
|
||||
e2cp -p "${system}:/lib/libdl.so" "${dest}/lib/"
|
||||
e2cp -p "${system}:/lib/libc.so" "${dest}/lib/"
|
||||
e2cp -p "${system}:/lib/libm.so" "${dest}/lib/"
|
||||
fi
|
||||
|
||||
# clean up
|
||||
|
@ -46,7 +50,7 @@ main() {
|
|||
|
||||
popd
|
||||
|
||||
rm -rf $td
|
||||
rm -rf "${td}"
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
|
|
16
ci/dox.sh
16
ci/dox.sh
|
@ -1,12 +1,12 @@
|
|||
#!/bin/sh
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# Builds documentation for all target triples that we have a registered URL for
|
||||
# in liblibc. This scrapes the list of triples to document from `src/lib.rs`
|
||||
# which has a bunch of `html_root_url` directives we pick up.
|
||||
|
||||
set -e
|
||||
set -ex
|
||||
|
||||
TARGETS=`grep html_root_url src/lib.rs | sed 's/.*".*\/\(.*\)"/\1/'`
|
||||
TARGETS=$(grep html_root_url src/lib.rs | sed 's/.*".*\/\(.*\)"/\1/'| sed 's/)//')
|
||||
|
||||
rm -rf target/doc
|
||||
mkdir -p target/doc
|
||||
|
@ -14,12 +14,12 @@ mkdir -p target/doc
|
|||
cp ci/landing-page-head.html target/doc/index.html
|
||||
|
||||
for target in $TARGETS; do
|
||||
echo documenting $target
|
||||
echo "documenting ${target}"
|
||||
|
||||
rustdoc -o target/doc/$target --target $target src/lib.rs --cfg cross_platform_docs \
|
||||
rustdoc -o "target/doc/${target}" --target "${target}" src/lib.rs --cfg cross_platform_docs \
|
||||
--crate-name libc
|
||||
|
||||
echo "<li><a href="/libc/$target/libc/index.html">$target</a></li>" \
|
||||
echo "<li><a href=\"/libc/${target}/libc/index.html\">${target}</a></li>" \
|
||||
>> target/doc/index.html
|
||||
done
|
||||
|
||||
|
@ -28,6 +28,6 @@ cat ci/landing-page-footer.html >> target/doc/index.html
|
|||
# If we're on travis, not a PR, and on the right branch, publish!
|
||||
if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then
|
||||
pip install ghp_import --install-option="--prefix=$HOME/.local"
|
||||
$HOME/.local/bin/ghp-import -n target/doc
|
||||
git push -qf https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages
|
||||
"${HOME}/.local/bin/ghp-import" -n target/doc
|
||||
git push -qf "https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git" gh-pages
|
||||
fi
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
set -ex
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
source /emsdk-portable/emsdk_env.sh &> /dev/null
|
||||
|
||||
# emsdk-portable provides a node binary, but we need version 8 to run wasm
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
||||
# file at the top-level directory of this distribution and at
|
||||
# http://rust-lang.org/COPYRIGHT.
|
||||
|
@ -17,10 +18,10 @@ echo ERROR: An error was encountered with the build.
|
|||
cat /tmp/build.log
|
||||
exit 1
|
||||
"
|
||||
trap "$on_err" ERR
|
||||
trap '$on_err' ERR
|
||||
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
|
||||
PING_LOOP_PID=$!
|
||||
$@ &> /tmp/build.log
|
||||
"${@}" &> /tmp/build.log
|
||||
trap - ERR
|
||||
kill $PING_LOOP_PID
|
||||
rm -f /tmp/build.log
|
||||
|
@ -37,6 +38,7 @@ hide_output ./emsdk install sdk-1.37.20-64bit
|
|||
./emsdk activate sdk-1.37.20-64bit
|
||||
|
||||
# Compile and cache libc
|
||||
# shellcheck disable=SC1091
|
||||
source ./emsdk_env.sh
|
||||
echo "main(){}" > a.c
|
||||
HOME=/emsdk-portable/ emcc a.c
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
set -ex
|
||||
|
||||
mkdir -m 777 /qemu
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
set -ex
|
||||
|
||||
mkdir -m 777 /qemu
|
||||
|
|
|
@ -1,36 +1,41 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# Small script to run tests for a target (or all targets) inside all the
|
||||
# respective docker images.
|
||||
|
||||
set -ex
|
||||
|
||||
run() {
|
||||
echo $1
|
||||
echo "Building docker container for target ${1}"
|
||||
# use -f so we can use ci/ as build context
|
||||
docker build -t libc -f ci/docker/$1/Dockerfile ci/
|
||||
docker build -t libc -f "ci/docker/${1}/Dockerfile" ci/
|
||||
mkdir -p target
|
||||
if [ -w /dev/kvm ]; then
|
||||
kvm="--volume /dev/kvm:/dev/kvm"
|
||||
kvm="--volume /dev/kvm:/dev/kvm"
|
||||
else
|
||||
kvm=""
|
||||
fi
|
||||
|
||||
docker run \
|
||||
--user `id -u`:`id -g` \
|
||||
--user "$(id -u)":"$(id -g)" \
|
||||
--rm \
|
||||
--init \
|
||||
--volume $HOME/.cargo:/cargo \
|
||||
--volume "${HOME}/.cargo":/cargo \
|
||||
$kvm \
|
||||
--env CARGO_HOME=/cargo \
|
||||
--volume `rustc --print sysroot`:/rust:ro \
|
||||
--volume `pwd`:/checkout:ro \
|
||||
--volume `pwd`/target:/checkout/target \
|
||||
--volume "$(rustc --print sysroot)":/rust:ro \
|
||||
--volume "$(pwd)":/checkout:ro \
|
||||
--volume "$(pwd)"/target:/checkout/target \
|
||||
--env CARGO_TARGET_DIR=/checkout/target \
|
||||
--workdir /checkout \
|
||||
libc \
|
||||
ci/run.sh $1
|
||||
ci/run.sh "${1}"
|
||||
}
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
for d in `ls ci/docker/`; do
|
||||
run $d
|
||||
if [ -z "${1}" ]; then
|
||||
for d in ci/docker/*; do
|
||||
run "${d}"
|
||||
done
|
||||
else
|
||||
run $1
|
||||
run "${1}"
|
||||
fi
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
# Initial script which is run inside of all qemu images. The first argument to
|
||||
# this script (as arranged by the qemu image itself) is the path to where the
|
||||
# libc crate is mounted.
|
||||
|
@ -10,11 +12,11 @@
|
|||
|
||||
set -ex
|
||||
|
||||
ROOT=$1
|
||||
cp -r $ROOT/libc /tmp/libc
|
||||
ROOT="${1}"
|
||||
cp -r "${ROOT}/libc" /tmp/libc
|
||||
cd /tmp/libc
|
||||
|
||||
TARGET=$(cat $ROOT/TARGET)
|
||||
TARGET="$(cat "${ROOT}/TARGET")"
|
||||
export CARGO_TARGET_DIR=/tmp
|
||||
|
||||
case $TARGET in
|
||||
|
@ -24,9 +26,9 @@ case $TARGET in
|
|||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown target: $TARGET"
|
||||
echo "Unknown target: ${TARGET}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exec sh ci/run.sh $TARGET
|
||||
exec sh ci/run.sh "${TARGET}"
|
||||
|
|
65
ci/run.sh
65
ci/run.sh
|
@ -1,11 +1,11 @@
|
|||
#!/bin/sh
|
||||
#!/usr/bin/env sh
|
||||
|
||||
# Builds and runs tests for a particular target passed as an argument to this
|
||||
# script.
|
||||
|
||||
set -ex
|
||||
|
||||
TARGET=$1
|
||||
TARGET="${1}"
|
||||
|
||||
# If we're going to run tests inside of a qemu image, then we don't need any of
|
||||
# the scripts below. Instead, download the image, prepare a filesystem which has
|
||||
|
@ -15,52 +15,53 @@ TARGET=$1
|
|||
# script from the second which we place inside.
|
||||
if [ "$QEMU" != "" ]; then
|
||||
tmpdir=/tmp/qemu-img-creation
|
||||
mkdir -p $tmpdir
|
||||
mkdir -p "${tmpdir}"
|
||||
|
||||
if [ -z "${QEMU#*.gz}" ]; then
|
||||
# image is .gz : download and uncompress it
|
||||
qemufile=$(echo ${QEMU%.gz} | sed 's/\//__/g')
|
||||
if [ ! -f $tmpdir/$qemufile ]; then
|
||||
curl https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/$QEMU | \
|
||||
gunzip -d > $tmpdir/$qemufile
|
||||
qemufile="$(echo "${QEMU%.gz}" | sed 's/\//__/g')"
|
||||
if [ ! -f "${tmpdir}/${qemufile}" ]; then
|
||||
curl "https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/${QEMU}" | \
|
||||
gunzip -d > "${tmpdir}/${qemufile}"
|
||||
fi
|
||||
elif [ -z "${QEMU#*.xz}" ]; then
|
||||
# image is .xz : download and uncompress it
|
||||
qemufile=$(echo ${QEMU%.xz} | sed 's/\//__/g')
|
||||
if [ ! -f $tmpdir/$qemufile ]; then
|
||||
curl https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/$QEMU | \
|
||||
unxz > $tmpdir/$qemufile
|
||||
qemufile="$(echo "${QEMU%.xz}" | sed 's/\//__/g')"
|
||||
if [ ! -f "${tmpdir}/${qemufile}" ]; then
|
||||
curl "https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/${QEMU}" | \
|
||||
unxz > "${tmpdir}/${qemufile}"
|
||||
fi
|
||||
else
|
||||
# plain qcow2 image: just download it
|
||||
qemufile=$(echo ${QEMU} | sed 's/\//__/g')
|
||||
if [ ! -f $tmpdir/$qemufile ]; then
|
||||
curl https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/$QEMU \
|
||||
> $tmpdir/$qemufile
|
||||
qemufile="$(echo "${QEMU}" | sed 's/\//__/g')"
|
||||
if [ ! -f "${tmpdir}/${qemufile}" ]; then
|
||||
curl "https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/${QEMU}" \
|
||||
> "${tmpdir}/${qemufile}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create a mount a fresh new filesystem image that we'll later pass to QEMU.
|
||||
# This will have a `run.sh` script will which use the artifacts inside to run
|
||||
# on the host.
|
||||
rm -f $tmpdir/libc-test.img
|
||||
mkdir $tmpdir/mount
|
||||
rm -f "${tmpdir}/libc-test.img"
|
||||
mkdir "${tmpdir}/mount"
|
||||
|
||||
# Do the standard rigamarole of cross-compiling an executable and then the
|
||||
# script to run just executes the binary.
|
||||
cargo build \
|
||||
--manifest-path libc-test/Cargo.toml \
|
||||
--target $TARGET \
|
||||
--target "${TARGET}" \
|
||||
--test main
|
||||
rm $CARGO_TARGET_DIR/$TARGET/debug/main-*.d
|
||||
cp $CARGO_TARGET_DIR/$TARGET/debug/main-* $tmpdir/mount/libc-test
|
||||
echo 'exec $1/libc-test' > $tmpdir/mount/run.sh
|
||||
rm "${CARGO_TARGET_DIR}/${TARGET}"/debug/main-*.d
|
||||
cp "${CARGO_TARGET_DIR}/${TARGET}"/debug/main-* "${tmpdir}"/mount/libc-test
|
||||
# shellcheck disable=SC2016
|
||||
echo 'exec $1/libc-test' > "${tmpdir}/mount/run.sh"
|
||||
|
||||
du -sh $tmpdir/mount
|
||||
du -sh "${tmpdir}/mount"
|
||||
genext2fs \
|
||||
--root $tmpdir/mount \
|
||||
--root "${tmpdir}/mount" \
|
||||
--size-in-blocks 100000 \
|
||||
$tmpdir/libc-test.img
|
||||
"${tmpdir}/libc-test.img"
|
||||
|
||||
# Pass -snapshot to prevent tampering with the disk images, this helps when
|
||||
# running this script in development. The two drives are then passed next,
|
||||
|
@ -70,13 +71,13 @@ if [ "$QEMU" != "" ]; then
|
|||
qemu-system-x86_64 \
|
||||
-m 1024 \
|
||||
-snapshot \
|
||||
-drive if=virtio,file=$tmpdir/$qemufile \
|
||||
-drive if=virtio,file=$tmpdir/libc-test.img \
|
||||
-drive if=virtio,file="${tmpdir}/${qemufile}" \
|
||||
-drive if=virtio,file="${tmpdir}/libc-test.img" \
|
||||
-net nic,model=virtio \
|
||||
-net user \
|
||||
-nographic \
|
||||
-vga none 2>&1 | tee $CARGO_TARGET_DIR/out.log
|
||||
exec grep "^PASSED .* tests" $CARGO_TARGET_DIR/out.log
|
||||
-vga none 2>&1 | tee "${CARGO_TARGET_DIR}/out.log"
|
||||
exec grep "^PASSED .* tests" "${CARGO_TARGET_DIR}/out.log"
|
||||
fi
|
||||
|
||||
# FIXME: x86_64-unknown-linux-gnux32 fail to compile without --release
|
||||
|
@ -89,10 +90,10 @@ fi
|
|||
# Building with --no-default-features is currently broken on rumprun because we
|
||||
# need cfg(target_vendor), which is currently unstable.
|
||||
if [ "$TARGET" != "x86_64-rumprun-netbsd" ]; then
|
||||
cargo test $opt --no-default-features --manifest-path libc-test/Cargo.toml --target $TARGET
|
||||
cargo test $opt --no-default-features --manifest-path libc-test/Cargo.toml --target "${TARGET}"
|
||||
fi
|
||||
# Test the #[repr(align(x))] feature if this is building on Rust >= 1.25
|
||||
if [ $(rustc --version | sed -E 's/^rustc 1\.([0-9]*)\..*/\1/') -ge 25 ]; then
|
||||
cargo test $opt --features align --manifest-path libc-test/Cargo.toml --target $TARGET
|
||||
if [ "$(rustc --version | sed -E 's/^rustc 1\.([0-9]*)\..*/\1/')" -ge 25 ]; then
|
||||
cargo test $opt --features align --manifest-path libc-test/Cargo.toml --target "${TARGET}"
|
||||
fi
|
||||
exec cargo test $opt --manifest-path libc-test/Cargo.toml --target $TARGET
|
||||
exec cargo test $opt --manifest-path libc-test/Cargo.toml --target "${TARGET}"
|
||||
|
|
|
@ -51,17 +51,17 @@ fn main() {
|
|||
}
|
||||
|
||||
cfg.header("errno.h")
|
||||
.header("fcntl.h")
|
||||
.header("limits.h")
|
||||
.header("locale.h")
|
||||
.header("stddef.h")
|
||||
.header("stdint.h")
|
||||
.header("stdio.h")
|
||||
.header("stdlib.h")
|
||||
.header("sys/stat.h")
|
||||
.header("sys/types.h")
|
||||
.header("time.h")
|
||||
.header("wchar.h");
|
||||
.header("fcntl.h")
|
||||
.header("limits.h")
|
||||
.header("locale.h")
|
||||
.header("stddef.h")
|
||||
.header("stdint.h")
|
||||
.header("stdio.h")
|
||||
.header("stdlib.h")
|
||||
.header("sys/stat.h")
|
||||
.header("sys/types.h")
|
||||
.header("time.h")
|
||||
.header("wchar.h");
|
||||
|
||||
if windows {
|
||||
cfg.header("winsock2.h"); // must be before windows.h
|
||||
|
@ -157,7 +157,6 @@ fn main() {
|
|||
}
|
||||
|
||||
if !musl && !uclibc {
|
||||
|
||||
if !netbsd && !openbsd && !uclibc {
|
||||
cfg.header("execinfo.h");
|
||||
}
|
||||
|
@ -355,20 +354,9 @@ fn main() {
|
|||
cfg.type_name(move |ty, is_struct, is_union| {
|
||||
match ty {
|
||||
// Just pass all these through, no need for a "struct" prefix
|
||||
"FILE" |
|
||||
"fd_set" |
|
||||
"Dl_info" |
|
||||
"DIR" |
|
||||
"Elf32_Phdr" |
|
||||
"Elf64_Phdr" |
|
||||
"Elf32_Shdr" |
|
||||
"Elf64_Shdr" |
|
||||
"Elf32_Sym" |
|
||||
"Elf64_Sym" |
|
||||
"Elf32_Ehdr" |
|
||||
"Elf64_Ehdr" |
|
||||
"Elf32_Chdr" |
|
||||
"Elf64_Chdr" => ty.to_string(),
|
||||
"FILE" | "fd_set" | "Dl_info" | "DIR" | "Elf32_Phdr" | "Elf64_Phdr" | "Elf32_Shdr"
|
||||
| "Elf64_Shdr" | "Elf32_Sym" | "Elf64_Sym" | "Elf32_Ehdr" | "Elf64_Ehdr"
|
||||
| "Elf32_Chdr" | "Elf64_Chdr" => ty.to_string(),
|
||||
|
||||
// Fixup a few types on windows that don't actually exist.
|
||||
"time64_t" if windows => "__time64_t".to_string(),
|
||||
|
@ -377,9 +365,7 @@ fn main() {
|
|||
// OSX calls this something else
|
||||
"sighandler_t" if bsdlike => "sig_t".to_string(),
|
||||
|
||||
t if is_union => {
|
||||
format!("union {}", t)
|
||||
}
|
||||
t if is_union => format!("union {}", t),
|
||||
|
||||
t if t.ends_with("_t") => t.to_string(),
|
||||
|
||||
|
@ -405,7 +391,7 @@ fn main() {
|
|||
let target2 = target.clone();
|
||||
cfg.field_name(move |struct_, field| {
|
||||
match field {
|
||||
"st_birthtime" if openbsd && struct_ == "stat" => "__st_birthtime".to_string(),
|
||||
"st_birthtime" if openbsd && struct_ == "stat" => "__st_birthtime".to_string(),
|
||||
"st_birthtime_nsec" if openbsd && struct_ == "stat" => "__st_birthtimensec".to_string(),
|
||||
// Our stat *_nsec fields normally don't actually exist but are part
|
||||
// of a timeval struct
|
||||
|
@ -419,9 +405,15 @@ fn main() {
|
|||
}
|
||||
}
|
||||
"u64" if struct_ == "epoll_event" => "data.u64".to_string(),
|
||||
"type_" if (linux || freebsd || dragonfly) &&
|
||||
(struct_ == "input_event" || struct_ == "input_mask" ||
|
||||
struct_ == "ff_effect" || struct_ == "rtprio") => "type".to_string(),
|
||||
"type_"
|
||||
if (linux || freebsd || dragonfly)
|
||||
&& (struct_ == "input_event"
|
||||
|| struct_ == "input_mask"
|
||||
|| struct_ == "ff_effect"
|
||||
|| struct_ == "rtprio") =>
|
||||
{
|
||||
"type".to_string()
|
||||
}
|
||||
s => s.to_string(),
|
||||
}
|
||||
});
|
||||
|
@ -431,7 +423,7 @@ fn main() {
|
|||
// sighandler_t is crazy across platforms
|
||||
"sighandler_t" => true,
|
||||
|
||||
_ => false
|
||||
_ => false,
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -467,25 +459,20 @@ fn main() {
|
|||
|
||||
// Present on historical versions of iOS but missing in more recent
|
||||
// SDKs
|
||||
"bpf_hdr" |
|
||||
"proc_taskinfo" |
|
||||
"proc_taskallinfo" |
|
||||
"proc_bsdinfo" |
|
||||
"proc_threadinfo" |
|
||||
"sockaddr_inarp" |
|
||||
"sockaddr_ctl" |
|
||||
"arphdr" if ios => true,
|
||||
"bpf_hdr" | "proc_taskinfo" | "proc_taskallinfo" | "proc_bsdinfo"
|
||||
| "proc_threadinfo" | "sockaddr_inarp" | "sockaddr_ctl" | "arphdr"
|
||||
if ios =>
|
||||
{
|
||||
true
|
||||
}
|
||||
|
||||
_ => false
|
||||
_ => false,
|
||||
}
|
||||
});
|
||||
|
||||
cfg.skip_signededness(move |c| {
|
||||
match c {
|
||||
"LARGE_INTEGER" |
|
||||
"mach_timebase_info_data_t" |
|
||||
"float" |
|
||||
"double" => true,
|
||||
"LARGE_INTEGER" | "mach_timebase_info_data_t" | "float" | "double" => true,
|
||||
// uuid_t is a struct, not an integer.
|
||||
"uuid_t" if dragonfly => true,
|
||||
n if n.starts_with("pthread") => true,
|
||||
|
@ -495,8 +482,7 @@ fn main() {
|
|||
"mqd_t" if freebsd || dragonfly => true,
|
||||
|
||||
// Just some typedefs on osx, no need to check their sign
|
||||
"posix_spawnattr_t" |
|
||||
"posix_spawn_file_actions_t" => true,
|
||||
"posix_spawnattr_t" | "posix_spawn_file_actions_t" => true,
|
||||
|
||||
// windows-isms
|
||||
n if n.starts_with("P") => true,
|
||||
|
@ -509,25 +495,26 @@ fn main() {
|
|||
cfg.skip_const(move |name| {
|
||||
match name {
|
||||
// Apparently these don't exist in mingw headers?
|
||||
"MEM_RESET_UNDO" |
|
||||
"FILE_ATTRIBUTE_NO_SCRUB_DATA" |
|
||||
"FILE_ATTRIBUTE_INTEGRITY_STREAM" |
|
||||
"ERROR_NOTHING_TO_TERMINATE" if mingw => true,
|
||||
"MEM_RESET_UNDO"
|
||||
| "FILE_ATTRIBUTE_NO_SCRUB_DATA"
|
||||
| "FILE_ATTRIBUTE_INTEGRITY_STREAM"
|
||||
| "ERROR_NOTHING_TO_TERMINATE"
|
||||
if mingw =>
|
||||
{
|
||||
true
|
||||
}
|
||||
|
||||
"SIG_DFL" |
|
||||
"SIG_ERR" |
|
||||
"SIG_IGN" => true, // sighandler_t weirdness
|
||||
"SIGUNUSED" => true, // removed in glibc 2.26
|
||||
"SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness
|
||||
"SIGUNUSED" => true, // removed in glibc 2.26
|
||||
|
||||
// types on musl are defined a little differently
|
||||
n if musl && n.contains("__SIZEOF_PTHREAD") => true,
|
||||
|
||||
// Skip constants not defined in MUSL but just passed down to the
|
||||
// kernel regardless
|
||||
"RLIMIT_NLIMITS" |
|
||||
"TCP_COOKIE_TRANSACTIONS" |
|
||||
"RLIMIT_RTTIME" |
|
||||
"MSG_COPY" if musl => true,
|
||||
"RLIMIT_NLIMITS" | "TCP_COOKIE_TRANSACTIONS" | "RLIMIT_RTTIME" | "MSG_COPY" if musl => {
|
||||
true
|
||||
}
|
||||
// work around super old mips toolchain
|
||||
"SCHED_IDLE" | "SHM_NORESERVE" => mips,
|
||||
|
||||
|
@ -536,30 +523,27 @@ fn main() {
|
|||
"MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13
|
||||
|
||||
// These OSX constants are flagged as deprecated
|
||||
"NOTE_EXIT_REPARENTED" |
|
||||
"NOTE_REAP" if apple => true,
|
||||
"NOTE_EXIT_REPARENTED" | "NOTE_REAP" if apple => true,
|
||||
|
||||
// These constants were removed in FreeBSD 11 (svn r273250) but will
|
||||
// still be accepted and ignored at runtime.
|
||||
"MAP_RENAME" |
|
||||
"MAP_NORESERVE" if freebsd => true,
|
||||
"MAP_RENAME" | "MAP_NORESERVE" if freebsd => true,
|
||||
|
||||
// These constants were removed in FreeBSD 11 (svn r262489),
|
||||
// and they've never had any legitimate use outside of the
|
||||
// base system anyway.
|
||||
"CTL_MAXID" |
|
||||
"KERN_MAXID" |
|
||||
"HW_MAXID" |
|
||||
"NET_MAXID" |
|
||||
"USER_MAXID" if freebsd => true,
|
||||
"CTL_MAXID" | "KERN_MAXID" | "HW_MAXID" | "NET_MAXID" | "USER_MAXID" if freebsd => true,
|
||||
|
||||
// These constants were added in FreeBSD 11
|
||||
"EVFILT_PROCDESC" | "EVFILT_SENDFILE" | "EVFILT_EMPTY" |
|
||||
"PD_CLOEXEC" | "PD_ALLOWED_AT_FORK" if freebsd => true,
|
||||
"EVFILT_PROCDESC" | "EVFILT_SENDFILE" | "EVFILT_EMPTY" | "PD_CLOEXEC"
|
||||
| "PD_ALLOWED_AT_FORK"
|
||||
if freebsd =>
|
||||
{
|
||||
true
|
||||
}
|
||||
|
||||
// These constants were added in FreeBSD 12
|
||||
"SF_USER_READAHEAD" |
|
||||
"SO_REUSEPORT_LB" if freebsd => true,
|
||||
"SF_USER_READAHEAD" | "SO_REUSEPORT_LB" if freebsd => true,
|
||||
|
||||
// These OSX constants are removed in Sierra.
|
||||
// https://developer.apple.com/library/content/releasenotes/General/APIDiffsMacOS10_12/Swift/Darwin.html
|
||||
|
@ -568,18 +552,43 @@ fn main() {
|
|||
|
||||
// These constants were removed in OpenBSD 6 (https://git.io/v7gBO
|
||||
// https://git.io/v7gBq)
|
||||
"KERN_USERMOUNT" |
|
||||
"KERN_ARND" if openbsd => true,
|
||||
"KERN_USERMOUNT" | "KERN_ARND" if openbsd => true,
|
||||
|
||||
// These are either unimplemented or optionally built into uClibc
|
||||
"LC_CTYPE_MASK" | "LC_NUMERIC_MASK" | "LC_TIME_MASK" | "LC_COLLATE_MASK" | "LC_MONETARY_MASK" | "LC_MESSAGES_MASK" |
|
||||
"MADV_MERGEABLE" | "MADV_UNMERGEABLE" | "MADV_HWPOISON" | "IPV6_ADD_MEMBERSHIP" | "IPV6_DROP_MEMBERSHIP" | "IPV6_MULTICAST_LOOP" | "IPV6_V6ONLY" |
|
||||
"MAP_STACK" | "RTLD_DEEPBIND" | "SOL_IPV6" | "SOL_ICMPV6" if uclibc => true,
|
||||
"LC_CTYPE_MASK"
|
||||
| "LC_NUMERIC_MASK"
|
||||
| "LC_TIME_MASK"
|
||||
| "LC_COLLATE_MASK"
|
||||
| "LC_MONETARY_MASK"
|
||||
| "LC_MESSAGES_MASK"
|
||||
| "MADV_MERGEABLE"
|
||||
| "MADV_UNMERGEABLE"
|
||||
| "MADV_HWPOISON"
|
||||
| "IPV6_ADD_MEMBERSHIP"
|
||||
| "IPV6_DROP_MEMBERSHIP"
|
||||
| "IPV6_MULTICAST_LOOP"
|
||||
| "IPV6_V6ONLY"
|
||||
| "MAP_STACK"
|
||||
| "RTLD_DEEPBIND"
|
||||
| "SOL_IPV6"
|
||||
| "SOL_ICMPV6"
|
||||
if uclibc =>
|
||||
{
|
||||
true
|
||||
}
|
||||
|
||||
// Musl uses old, patched kernel headers
|
||||
"FALLOC_FL_COLLAPSE_RANGE" | "FALLOC_FL_ZERO_RANGE" |
|
||||
"FALLOC_FL_INSERT_RANGE" | "FALLOC_FL_UNSHARE_RANGE" |
|
||||
"RENAME_NOREPLACE" | "RENAME_EXCHANGE" | "RENAME_WHITEOUT" if musl => true,
|
||||
"FALLOC_FL_COLLAPSE_RANGE"
|
||||
| "FALLOC_FL_ZERO_RANGE"
|
||||
| "FALLOC_FL_INSERT_RANGE"
|
||||
| "FALLOC_FL_UNSHARE_RANGE"
|
||||
| "RENAME_NOREPLACE"
|
||||
| "RENAME_EXCHANGE"
|
||||
| "RENAME_WHITEOUT"
|
||||
if musl =>
|
||||
{
|
||||
true
|
||||
}
|
||||
|
||||
// Both android and musl use old kernel headers
|
||||
// These are constants used in getrandom syscall
|
||||
|
@ -610,7 +619,11 @@ fn main() {
|
|||
|
||||
"MFD_CLOEXEC" | "MFD_ALLOW_SEALING" if !mips && musl => true,
|
||||
|
||||
"DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK" | "DT_SOCK" if solaris => true,
|
||||
"DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK" | "DT_SOCK"
|
||||
if solaris =>
|
||||
{
|
||||
true
|
||||
}
|
||||
"USRQUOTA" | "GRPQUOTA" if solaris => true,
|
||||
"PRIO_MIN" | "PRIO_MAX" if solaris => true,
|
||||
|
||||
|
@ -624,21 +637,25 @@ fn main() {
|
|||
|
||||
// Present on historical versions of iOS, but now removed in more
|
||||
// recent SDKs
|
||||
"ARPOP_REQUEST" |
|
||||
"ARPOP_REPLY" |
|
||||
"ATF_COM" |
|
||||
"ATF_PERM" |
|
||||
"ATF_PUBL" |
|
||||
"ATF_USETRAILERS" |
|
||||
"AF_SYS_CONTROL" |
|
||||
"SYSPROTO_EVENT" |
|
||||
"PROC_PIDTASKALLINFO" |
|
||||
"PROC_PIDTASKINFO" |
|
||||
"PROC_PIDTHREADINFO" |
|
||||
"UTUN_OPT_FLAGS" |
|
||||
"UTUN_OPT_IFNAME" |
|
||||
"BPF_ALIGNMENT" |
|
||||
"SYSPROTO_CONTROL" if ios => true,
|
||||
"ARPOP_REQUEST"
|
||||
| "ARPOP_REPLY"
|
||||
| "ATF_COM"
|
||||
| "ATF_PERM"
|
||||
| "ATF_PUBL"
|
||||
| "ATF_USETRAILERS"
|
||||
| "AF_SYS_CONTROL"
|
||||
| "SYSPROTO_EVENT"
|
||||
| "PROC_PIDTASKALLINFO"
|
||||
| "PROC_PIDTASKINFO"
|
||||
| "PROC_PIDTHREADINFO"
|
||||
| "UTUN_OPT_FLAGS"
|
||||
| "UTUN_OPT_IFNAME"
|
||||
| "BPF_ALIGNMENT"
|
||||
| "SYSPROTO_CONTROL"
|
||||
if ios =>
|
||||
{
|
||||
true
|
||||
}
|
||||
s if ios && s.starts_with("RTF_") => true,
|
||||
s if ios && s.starts_with("RTM_") => true,
|
||||
s if ios && s.starts_with("RTA_") => true,
|
||||
|
@ -865,8 +882,8 @@ fn main() {
|
|||
// fails on a lot of platforms.
|
||||
let mut cfg = ctest::TestGenerator::new();
|
||||
cfg.skip_type(|_| true)
|
||||
.skip_fn(|_| true)
|
||||
.skip_static(|_| true);
|
||||
.skip_fn(|_| true)
|
||||
.skip_static(|_| true);
|
||||
if android || linux {
|
||||
// musl defines these directly in `fcntl.h`
|
||||
if musl {
|
||||
|
@ -880,24 +897,18 @@ fn main() {
|
|||
}
|
||||
cfg.header("linux/quota.h");
|
||||
cfg.header("asm/termbits.h");
|
||||
cfg.skip_const(move |name| {
|
||||
match name {
|
||||
"F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false,
|
||||
"F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => false,
|
||||
"QFMT_VFS_OLD" | "QFMT_VFS_V0" | "QFMT_VFS_V1" if mips && linux => false,
|
||||
"BOTHER" => false,
|
||||
_ => true,
|
||||
}
|
||||
cfg.skip_const(move |name| match name {
|
||||
"F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false,
|
||||
"F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => false,
|
||||
"QFMT_VFS_OLD" | "QFMT_VFS_V0" | "QFMT_VFS_V1" if mips && linux => false,
|
||||
"BOTHER" => false,
|
||||
_ => true,
|
||||
});
|
||||
cfg.skip_struct(|s| {
|
||||
s != "termios2"
|
||||
});
|
||||
cfg.type_name(move |ty, is_struct, is_union| {
|
||||
match ty {
|
||||
t if is_struct => format!("struct {}", t),
|
||||
t if is_union => format!("union {}", t),
|
||||
t => t.to_string(),
|
||||
}
|
||||
cfg.skip_struct(|s| s != "termios2");
|
||||
cfg.type_name(move |ty, is_struct, is_union| match ty {
|
||||
t if is_struct => format!("struct {}", t),
|
||||
t if is_union => format!("union {}", t),
|
||||
t => t.to_string(),
|
||||
});
|
||||
} else {
|
||||
cfg.skip_const(|_| true);
|
||||
|
|
44
src/dox.rs
44
src/dox.rs
|
@ -2,10 +2,10 @@ pub use self::imp::*;
|
|||
|
||||
#[cfg(not(cross_platform_docs))]
|
||||
mod imp {
|
||||
pub use core::option::Option;
|
||||
pub use core::clone::Clone;
|
||||
pub use core::marker::Copy;
|
||||
pub use core::mem;
|
||||
pub use core::option::Option;
|
||||
}
|
||||
|
||||
#[cfg(cross_platform_docs)]
|
||||
|
@ -16,17 +16,23 @@ mod imp {
|
|||
}
|
||||
impl<T: Copy> Copy for Option<T> {}
|
||||
impl<T: Clone> Clone for Option<T> {
|
||||
fn clone(&self) -> Option<T> { loop {} }
|
||||
fn clone(&self) -> Option<T> {
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Copy for *mut T {}
|
||||
impl<T> Clone for *mut T {
|
||||
fn clone(&self) -> *mut T { loop {} }
|
||||
fn clone(&self) -> *mut T {
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Copy for *const T {}
|
||||
impl<T> Clone for *const T {
|
||||
fn clone(&self) -> *const T { loop {} }
|
||||
fn clone(&self) -> *const T {
|
||||
loop {}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Clone {
|
||||
|
@ -47,52 +53,52 @@ mod imp {
|
|||
pub trait Sized {}
|
||||
|
||||
macro_rules! each_int {
|
||||
($mac:ident) => (
|
||||
($mac:ident) => {
|
||||
$mac!(u8);
|
||||
$mac!(u16);
|
||||
$mac!(u32);
|
||||
$mac!(u64);
|
||||
$mac!(usize);
|
||||
each_signed_int!($mac);
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! each_signed_int {
|
||||
($mac:ident) => (
|
||||
($mac:ident) => {
|
||||
$mac!(i8);
|
||||
$mac!(i16);
|
||||
$mac!(i32);
|
||||
$mac!(i64);
|
||||
$mac!(isize);
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
#[lang = "div"]
|
||||
pub trait Div<RHS=Self> {
|
||||
pub trait Div<RHS = Self> {
|
||||
type Output;
|
||||
fn div(self, rhs: RHS) -> Self::Output;
|
||||
}
|
||||
|
||||
#[lang = "shl"]
|
||||
pub trait Shl<RHS=Self> {
|
||||
pub trait Shl<RHS = Self> {
|
||||
type Output;
|
||||
fn shl(self, rhs: RHS) -> Self::Output;
|
||||
}
|
||||
|
||||
#[lang = "mul"]
|
||||
pub trait Mul<RHS=Self> {
|
||||
pub trait Mul<RHS = Self> {
|
||||
type Output;
|
||||
fn mul(self, rhs: RHS) -> Self::Output;
|
||||
}
|
||||
|
||||
#[lang = "sub"]
|
||||
pub trait Sub<RHS=Self> {
|
||||
pub trait Sub<RHS = Self> {
|
||||
type Output;
|
||||
fn sub(self, rhs: RHS) -> Self::Output;
|
||||
}
|
||||
|
||||
#[lang = "bitand"]
|
||||
pub trait BitAnd<RHS=Self> {
|
||||
pub trait BitAnd<RHS = Self> {
|
||||
type Output;
|
||||
fn bitand(self, rhs: RHS) -> Self::Output;
|
||||
}
|
||||
|
@ -103,7 +109,7 @@ mod imp {
|
|||
}
|
||||
|
||||
#[lang = "bitor"]
|
||||
pub trait BitOr<RHS=Self> {
|
||||
pub trait BitOr<RHS = Self> {
|
||||
type Output;
|
||||
fn bitor(self, rhs: RHS) -> Self::Output;
|
||||
}
|
||||
|
@ -114,7 +120,7 @@ mod imp {
|
|||
}
|
||||
|
||||
#[lang = "bitxor"]
|
||||
pub trait BitXor<RHS=Self> {
|
||||
pub trait BitXor<RHS = Self> {
|
||||
type Output;
|
||||
fn bitxor(self, rhs: RHS) -> Self::Output;
|
||||
}
|
||||
|
@ -203,7 +209,11 @@ mod imp {
|
|||
each_int!(impl_traits);
|
||||
|
||||
pub mod mem {
|
||||
pub fn size_of_val<T>(_: &T) -> usize { 4 }
|
||||
pub const fn size_of<T>() -> usize { 4 }
|
||||
pub fn size_of_val<T>(_: &T) -> usize {
|
||||
4
|
||||
}
|
||||
pub const fn size_of<T>() -> usize {
|
||||
4
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
177
src/lib.rs
177
src/lib.rs
|
@ -15,90 +15,117 @@
|
|||
#![crate_name = "libc"]
|
||||
#![cfg_attr(cross_platform_docs, feature(no_core, lang_items, const_fn))]
|
||||
#![cfg_attr(cross_platform_docs, no_core)]
|
||||
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "https://doc.rust-lang.org/favicon.ico")]
|
||||
|
||||
#![cfg_attr(all(target_os = "linux", target_arch = "x86_64"), doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-linux-gnu"
|
||||
))]
|
||||
#![cfg_attr(all(target_os = "linux", target_arch = "x86"), doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/i686-unknown-linux-gnu"
|
||||
))]
|
||||
#![cfg_attr(all(target_os = "linux", target_arch = "arm"), doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/arm-unknown-linux-gnueabihf"
|
||||
))]
|
||||
#![cfg_attr(all(target_os = "linux", target_arch = "mips"), doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/mips-unknown-linux-gnu"
|
||||
))]
|
||||
#![cfg_attr(all(target_os = "linux", target_arch = "aarch64"), doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/aarch64-unknown-linux-gnu"
|
||||
))]
|
||||
#![cfg_attr(all(target_os = "linux", target_env = "musl"), doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-linux-musl"
|
||||
))]
|
||||
#![cfg_attr(all(target_os = "macos", target_arch = "x86_64"), doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/x86_64-apple-darwin"
|
||||
))]
|
||||
#![cfg_attr(all(target_os = "macos", target_arch = "x86"), doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/i686-apple-darwin"
|
||||
))]
|
||||
#![cfg_attr(all(windows, target_arch = "x86_64", target_env = "gnu"), doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/x86_64-pc-windows-gnu"
|
||||
))]
|
||||
#![cfg_attr(all(windows, target_arch = "x86", target_env = "gnu"), doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/i686-pc-windows-gnu"
|
||||
))]
|
||||
#![cfg_attr(all(windows, target_arch = "x86_64", target_env = "msvc"), doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/x86_64-pc-windows-msvc"
|
||||
))]
|
||||
#![cfg_attr(all(windows, target_arch = "x86", target_env = "msvc"), doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/i686-pc-windows-msvc"
|
||||
))]
|
||||
#![cfg_attr(target_os = "android", doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/arm-linux-androideabi"
|
||||
))]
|
||||
#![cfg_attr(target_os = "freebsd", doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-freebsd"
|
||||
))]
|
||||
#![cfg_attr(target_os = "openbsd", doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-openbsd"
|
||||
))]
|
||||
#![cfg_attr(target_os = "bitrig", doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-bitrig"
|
||||
))]
|
||||
#![cfg_attr(target_os = "netbsd", doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-netbsd"
|
||||
))]
|
||||
#![cfg_attr(target_os = "dragonfly", doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-dragonfly"
|
||||
))]
|
||||
#![cfg_attr(target_os = "solaris", doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/x86_64-sun-solaris"
|
||||
))]
|
||||
#![cfg_attr(all(target_os = "emscripten", target_arch = "asmjs"), doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/asmjs-unknown-emscripten"
|
||||
))]
|
||||
#![cfg_attr(all(target_os = "emscripten", target_arch = "wasm32"), doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/wasm32-unknown-emscripten"
|
||||
))]
|
||||
#![cfg_attr(all(target_os = "linux", target_arch = "sparc64"), doc(
|
||||
html_root_url = "https://rust-lang.github.io/libc/sparc64-unknown-linux-gnu"
|
||||
))]
|
||||
|
||||
#![doc(
|
||||
html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "https://doc.rust-lang.org/favicon.ico"
|
||||
)]
|
||||
#![cfg_attr(
|
||||
all(target_os = "linux", target_arch = "x86_64"),
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-linux-gnu")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
all(target_os = "linux", target_arch = "x86"),
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/i686-unknown-linux-gnu")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
all(target_os = "linux", target_arch = "arm"),
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/arm-unknown-linux-gnueabihf")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
all(target_os = "linux", target_arch = "mips"),
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/mips-unknown-linux-gnu")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
all(target_os = "linux", target_arch = "aarch64"),
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/aarch64-unknown-linux-gnu")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
all(target_os = "linux", target_env = "musl"),
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-linux-musl")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
all(target_os = "macos", target_arch = "x86_64"),
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/x86_64-apple-darwin")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
all(target_os = "macos", target_arch = "x86"),
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/i686-apple-darwin")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
all(windows, target_arch = "x86_64", target_env = "gnu"),
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/x86_64-pc-windows-gnu")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
all(windows, target_arch = "x86", target_env = "gnu"),
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/i686-pc-windows-gnu")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
all(windows, target_arch = "x86_64", target_env = "msvc"),
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/x86_64-pc-windows-msvc")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
all(windows, target_arch = "x86", target_env = "msvc"),
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/i686-pc-windows-msvc")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
target_os = "android",
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/arm-linux-androideabi")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
target_os = "freebsd",
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-freebsd")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
target_os = "openbsd",
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-openbsd")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
target_os = "bitrig",
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-bitrig")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
target_os = "netbsd",
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-netbsd")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
target_os = "dragonfly",
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/x86_64-unknown-dragonfly")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
target_os = "solaris",
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/x86_64-sun-solaris")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
all(target_os = "emscripten", target_arch = "asmjs"),
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/asmjs-unknown-emscripten")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
all(target_os = "emscripten", target_arch = "wasm32"),
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/wasm32-unknown-emscripten")
|
||||
)]
|
||||
#![cfg_attr(
|
||||
all(target_os = "linux", target_arch = "sparc64"),
|
||||
doc(html_root_url = "https://rust-lang.github.io/libc/sparc64-unknown-linux-gnu")
|
||||
)]
|
||||
// Attributes needed when building as part of the standard library
|
||||
#![cfg_attr(feature = "stdbuild", feature(staged_api, cfg_target_vendor))]
|
||||
#![cfg_attr(feature = "stdbuild", feature(link_cfg, repr_packed))]
|
||||
#![cfg_attr(feature = "stdbuild", allow(warnings))]
|
||||
#![cfg_attr(feature = "stdbuild", unstable(feature = "libc",
|
||||
reason = "use `libc` from crates.io",
|
||||
issue = "27783"))]
|
||||
|
||||
#![cfg_attr(
|
||||
feature = "stdbuild",
|
||||
unstable(
|
||||
feature = "libc",
|
||||
reason = "use `libc` from crates.io",
|
||||
issue = "27783"
|
||||
)
|
||||
)]
|
||||
#![cfg_attr(not(feature = "use_std"), no_std)]
|
||||
|
||||
#[cfg(all(not(cross_platform_docs), feature = "use_std"))]
|
||||
extern crate std as core;
|
||||
|
||||
#[macro_use] mod macros;
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
mod dox;
|
||||
|
||||
/*
|
||||
|
|
|
@ -68,7 +68,9 @@ macro_rules! f {
|
|||
}
|
||||
|
||||
macro_rules! __item {
|
||||
($i:item) => ($i)
|
||||
($i:item) => {
|
||||
$i
|
||||
};
|
||||
}
|
||||
|
||||
#[allow(unused_macros)]
|
||||
|
|
Loading…
Reference in New Issue