From 8806c2dce17438ae65e7a1606209af7563a4308c Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 29 Jan 2019 15:00:48 +0100 Subject: [PATCH 01/72] Test all targets with Rust nightly, beta, stable, and 1.13.0 --- .travis.yml | 63 +++++++++++++++-------------------------------------- ci/run.sh | 53 +++++++++++++++++++++++++++----------------- 2 files changed, 51 insertions(+), 65 deletions(-) diff --git a/.travis.yml b/.travis.yml index 52d2403cd5963..c24b3a67f88c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,31 +1,28 @@ language: rust -rust: stable +rust: nightly sudo: required dist: xenial services: docker matrix: include: - # 1.13.0 compat - - env: TARGET=x86_64-unknown-linux-gnu - rust: 1.13.0 - script: rm -f Cargo.lock && cargo build - install: true - - # build documentation - - env: TARGET=x86_64-unknown-linux-gnu + - name: "Documentation" + env: TARGET=x86_64-unknown-linux-gnu rust: nightly script: sh ci/dox.sh install: true + - name: "Shellcheck" + install: true + script: + - shellcheck --version + - shellcheck ci/*.sh - # stable compat - env: TARGET=x86_64-unknown-linux-gnu - install: true - env: TARGET=i686-unknown-linux-gnu + - env: TARGET=x86_64-unknown-linux-gnux32 OPT="--release" - os: osx env: TARGET=x86_64-apple-darwin osx_image: xcode10 - install: true - os: osx env: TARGET=i686-apple-darwin osx_image: xcode10 @@ -52,48 +49,24 @@ matrix: - env: TARGET=sparc64-unknown-linux-gnu - env: TARGET=asmjs-unknown-emscripten - env: TARGET=wasm32-unknown-emscripten - - # beta - - env: TARGET=x86_64-unknown-linux-gnu - rust: beta - install: true - - os: osx - env: TARGET=x86_64-apple-darwin - osx_image: xcode10 - rust: beta - install: true - - # nightly - - env: TARGET=x86_64-unknown-linux-gnu - rust: nightly - install: true - - os: osx - 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 - - env: TARGET=x86_64-unknown-linux-gnux32 OPT="--release" - rust: nightly - - env: TARGET=wasm32-unknown-unknown install: rustup target add $TARGET script: cargo build --no-default-features --target $TARGET --release - - name: "Shellcheck" - install: true - script: - - shellcheck --version - - shellcheck ci/*.sh - allow_failures: # FIXME: https://github.com/rust-lang/libc/issues/1226 - env: TARGET=asmjs-unknown-emscripten - env: TARGET=wasm32-unknown-emscripten -install: rustup target add $TARGET +install: + - rustup install beta + - rustup install stable + - rustup install 1.13.0 + - rustup target add $TARGET || true + - rustup target add $TARGET --toolchain beta || true + - rustup target add $TARGET --toolchain stable || true + - rustup target add $TARGET --toolchain 1.13.0 || true + script: - cargo generate-lockfile --manifest-path libc-test/Cargo.toml - if [[ $TRAVIS_OS_NAME = "linux" ]]; then diff --git a/ci/run.sh b/ci/run.sh index 1fb5e127a254e..a844f4f464b4b 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -80,24 +80,37 @@ if [ "$QEMU" != "" ]; then exec egrep "^(PASSED)|(test result: ok)" "${CARGO_TARGET_DIR}/out.log" fi -# FIXME: x86_64-unknown-linux-gnux32 fail to compile without --release -# See https://github.com/rust-lang/rust/issues/45417 -opt= -if [ "$TARGET" = "x86_64-unknown-linux-gnux32" ]; then - opt="--release" -fi +build_types="+nightly +beta +stable +1.13.0" +for build_type in $build_types; +do -# 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}" -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}" -fi -# Test the `extra_traits` 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 extra_traits --manifest-path libc-test/Cargo.toml --target "${TARGET}" -fi -exec cargo test $opt --manifest-path libc-test/Cargo.toml --target "${TARGET}" + opt= + if [ "$TARGET" = "x86_64-unknown-linux-gnux32" ]; then + # FIXME: x86_64-unknown-linux-gnux32 fail to compile without --release + # See https://github.com/rust-lang/rust/issues/45417 + opt="--release" + + # x86_64-unknown-linux-gnux32 is only available on nightly: + if [ "$build_type" != "nightly" ]; then + continue + fi + 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 "$build_type" test $opt --no-default-features --manifest-path libc-test/Cargo.toml --target "${TARGET}" + fi + + # Test the #[repr(align(x))] feature; requires Rust >= 1.25.0 + if [ "$build_type" != "+1.13.0" ]; then + cargo "$build_type" test $opt --features align --manifest-path libc-test/Cargo.toml --target "${TARGET}" + fi + + # Test the `extra_traits` feature; requires Rust >= 1.25.0 + if [ "$build_type" != "+1.13.0" ]; then + cargo "$build_type" test $opt --features extra_traits --manifest-path libc-test/Cargo.toml --target "${TARGET}" + fi + + exec cargo "$build_type" test $opt --manifest-path libc-test/Cargo.toml --target "${TARGET}" +done From 9ff771f75f687c64a5df7062a7e2db94ae629ec2 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 29 Jan 2019 15:27:11 +0100 Subject: [PATCH 02/72] Use unions and const size_of only if the Rust version supports them --- .travis.yml | 10 ++- build.rs | 21 ++++-- ci/run-docker.sh | 1 + ci/run.sh | 50 +++++++++----- src/unix/bsd/apple/mod.rs | 66 +++++++++++-------- .../bsd/netbsdlike/openbsdlike/openbsd/mod.rs | 1 + 6 files changed, 98 insertions(+), 51 deletions(-) diff --git a/.travis.yml b/.travis.yml index c24b3a67f88c3..3a0071b5db1b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,9 +49,7 @@ matrix: - env: TARGET=sparc64-unknown-linux-gnu - env: TARGET=asmjs-unknown-emscripten - env: TARGET=wasm32-unknown-emscripten - - env: TARGET=wasm32-unknown-unknown - install: rustup target add $TARGET - script: cargo build --no-default-features --target $TARGET --release + - env: TARGET=wasm32-unknown-unknown BUILD_ONLY=1 allow_failures: # FIXME: https://github.com/rust-lang/libc/issues/1226 @@ -62,10 +60,16 @@ install: - rustup install beta - rustup install stable - rustup install 1.13.0 + - rustup install 1.19.0 + - rustup install 1.24.0 + - rustup install 1.30.0 - rustup target add $TARGET || true - rustup target add $TARGET --toolchain beta || true - rustup target add $TARGET --toolchain stable || true - rustup target add $TARGET --toolchain 1.13.0 || true + - rustup target add $TARGET --toolchain 1.19.0 || true + - rustup target add $TARGET --toolchain 1.24.0 || true + - rustup target add $TARGET --toolchain 1.30.0 || true script: - cargo generate-lockfile --manifest-path libc-test/Cargo.toml diff --git a/build.rs b/build.rs index 1852ed27903bd..17d90ba35a42f 100644 --- a/build.rs +++ b/build.rs @@ -3,11 +3,22 @@ use std::process::Command; use std::str; fn main() { - /* - * If `core::ffi::c_void` exists, libc can just re-export it. Otherwise, it - * must define an incompatible type to retain backwards-compatibility. - */ - if rustc_minor_version().expect("Failed to get rustc version") >= 30 { + + let rustc_minor_ver = rustc_minor_version().expect("Failed to get rustc version"); + + // Rust >= 1.19 supports unions: + if rustc_minor_ver >= 19 { + println!("cargo:rustc-cfg=libc_union"); + } + + // Rust >= 1.24 supports const mem::size_of: + if rustc_minor_ver >= 24 { + println!("cargo:rustc-cfg=libc_const_size_of"); + } + + // If `core::ffi::c_void` exists, libc can just re-export it. Otherwise, it + // must define an incompatible type to retain backwards-compatibility. + if rustc_minor_ver >= 30 { println!("cargo:rustc-cfg=core_cvoid"); } } diff --git a/ci/run-docker.sh b/ci/run-docker.sh index c656f5904d684..ca9d2ed737667 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -28,6 +28,7 @@ run() { --volume "$(pwd)":/checkout:ro \ --volume "$(pwd)"/target:/checkout/target \ --env CARGO_TARGET_DIR=/checkout/target \ + --env BUILD_ONLY="$BUILD_ONLY" \ --workdir /checkout \ libc \ ci/run.sh "${1}" diff --git a/ci/run.sh b/ci/run.sh index a844f4f464b4b..e47b9d4f9c761 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -80,13 +80,14 @@ if [ "$QEMU" != "" ]; then exec egrep "^(PASSED)|(test result: ok)" "${CARGO_TARGET_DIR}/out.log" fi -build_types="+nightly +beta +stable +1.13.0" +build_types="+nightly +beta +stable +1.13.0 +1.19.0 +1.24.0 +1.30.0" for build_type in $build_types; do - opt= if [ "$TARGET" = "x86_64-unknown-linux-gnux32" ]; then - # FIXME: x86_64-unknown-linux-gnux32 fail to compile without --release + # FIXME: x86_64-unknown-linux-gnux32 fail to compile without + # --release + # # See https://github.com/rust-lang/rust/issues/45417 opt="--release" @@ -96,21 +97,36 @@ do fi 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 "$build_type" test $opt --no-default-features --manifest-path libc-test/Cargo.toml --target "${TARGET}" - fi + if [ "$BUILD_ONLY" = "1" ]; then + cargo "$build_type" build $opt --target "${TARGET}" + else + # 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 "$build_type" test $opt \ + --no-default-features \ + --manifest-path libc-test/Cargo.toml \ + --target "${TARGET}" + fi - # Test the #[repr(align(x))] feature; requires Rust >= 1.25.0 - if [ "$build_type" != "+1.13.0" ]; then - cargo "$build_type" test $opt --features align --manifest-path libc-test/Cargo.toml --target "${TARGET}" - fi + # Test the #[repr(align(x))] feature; requires Rust >= 1.25.0 + if [ "$build_type" != "+1.13.0" ]; then + cargo "$build_type" test $opt \ + --features align \ + --manifest-path libc-test/Cargo.toml \ + --target "${TARGET}" + fi - # Test the `extra_traits` feature; requires Rust >= 1.25.0 - if [ "$build_type" != "+1.13.0" ]; then - cargo "$build_type" test $opt --features extra_traits --manifest-path libc-test/Cargo.toml --target "${TARGET}" - fi + # Test the `extra_traits` feature; requires Rust >= 1.25.0 + if [ "$build_type" != "+1.13.0" ]; then + cargo "$build_type" test $opt \ + --features extra_traits \ + --manifest-path libc-test/Cargo.toml \ + --target "${TARGET}" + fi - exec cargo "$build_type" test $opt --manifest-path libc-test/Cargo.toml --target "${TARGET}" + cargo "$build_type" test $opt \ + --manifest-path libc-test/Cargo.toml \ + --target "${TARGET}" + fi done diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 85332180e015d..c8f39f5613313 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -513,12 +513,6 @@ s! { } s_no_extra_traits!{ - pub union semun { - pub val: ::c_int, - pub buf: *mut semid_ds, - pub array: *mut ::c_ushort, - } - pub struct proc_threadinfo { pub pth_user_time: u64, pub pth_system_time: u64, @@ -596,28 +590,41 @@ s_no_extra_traits!{ } } -#[cfg(feature = "extra_traits")] -impl PartialEq for semun { - fn eq(&self, other: &semun) -> bool { - unsafe { self.val == other.val } - } -} -#[cfg(feature = "extra_traits")] -impl Eq for semun {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for semun { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("semun") - .field("val", unsafe { &self.val }) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for semun { - fn hash(&self, state: &mut H) { - unsafe { self.val.hash(state) }; +cfg_if! { + if #[cfg(libc_union)] { + s_no_extra_traits! { + pub union semun { + pub val: ::c_int, + pub buf: *mut semid_ds, + pub array: *mut ::c_ushort, + } + } + + cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for semun { + fn eq(&self, other: &semun) -> bool { + unsafe { self.val == other.val } + } + } + impl Eq for semun {} + impl std::fmt::Debug for semun { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("semun") + .field("val", unsafe { &self.val }) + .finish() + } + } + impl std::hash::Hash for semun { + fn hash(&self, state: &mut H) { + unsafe { self.val.hash(state) }; + } + } + } + } } } + #[cfg(feature = "extra_traits")] impl PartialEq for proc_threadinfo { fn eq(&self, other: &proc_threadinfo) -> bool { @@ -2765,11 +2772,18 @@ pub const SF_IMMUTABLE: ::c_uint = 0x00020000; pub const SF_APPEND: ::c_uint = 0x00040000; pub const UF_HIDDEN: ::c_uint = 0x00008000; +#[cfg(libc_const_size_of)] fn __DARWIN_ALIGN32(p: usize) -> usize { const __DARWIN_ALIGNBYTES32: usize = mem::size_of::() - 1; p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32 } +#[cfg(not(libc_const_size_of))] +fn __DARWIN_ALIGN32(p: usize) -> usize { + let __DARWIN_ALIGNBYTES32: usize = mem::size_of::() - 1; + p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32 +} + f! { pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr) -> *mut ::cmsghdr { diff --git a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs index a2a7a30a102a9..deb18f98e80b7 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs @@ -51,6 +51,7 @@ s! { pub mount_info: mount_info, } + #[cfg(libc_union)] pub union mount_info { pub ufs_args: ufs_args, pub mfs_args: mfs_args, From 35dfbae6c63264adf6c7da5b5c5d7410bb9370d4 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 29 Jan 2019 15:39:06 +0100 Subject: [PATCH 03/72] Handle unions in the s macro --- src/macros.rs | 49 +++++++++++++++++++++++++++++++++++---- src/unix/bsd/apple/mod.rs | 6 +++++ 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index aabe6e8e7001f..01455863ed058 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -36,31 +36,70 @@ macro_rules! __cfg_if_apply { macro_rules! s { ($($(#[$attr:meta])* pub $t:ident $i:ident { $($field:tt)* })*) => ($( + s!(it: $(#[$attr])* pub $t $i { $($field)* }); + )*); + (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => ( + cfg_if! { + if #[cfg(libc_union)] { + __item! { + #[repr(C)] + #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] + $(#[$attr])* + pub union $i { $($field)* } + } + + impl ::dox::Copy for $i {} + impl ::dox::Clone for $i { + fn clone(&self) -> $i { *self } + } + } + } + ); + (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => ( __item! { #[repr(C)] - $(#[$attr])* #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] - pub $t $i { $($field)* } + $(#[$attr])* + pub struct $i { $($field)* } } impl ::dox::Copy for $i {} impl ::dox::Clone for $i { fn clone(&self) -> $i { *self } } - )*) + ); } macro_rules! s_no_extra_traits { ($($(#[$attr:meta])* pub $t:ident $i:ident { $($field:tt)* })*) => ($( + s!(it: $(#[$attr])* pub $t $i { $($field)* }); + )*); + (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => ( + cfg_if! { + if #[cfg(libc_union)] { + __item! { + #[repr(C)] + $(#[$attr])* + pub union $i { $($field)* } + } + + impl ::dox::Copy for $i {} + impl ::dox::Clone for $i { + fn clone(&self) -> $i { *self } + } + } + } + ); + (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => ( __item! { #[repr(C)] $(#[$attr])* - pub $t $i { $($field)* } + pub struct $i { $($field)* } } impl ::dox::Copy for $i {} impl ::dox::Clone for $i { fn clone(&self) -> $i { *self } } - )*) + ); } #[allow(unused_macros)] diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index c8f39f5613313..519a6063df438 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -486,6 +486,12 @@ s! { pub sem_pad3: [::int32_t; 4], } + pub union semun { + pub val: ::c_int, + pub buf: *mut semid_ds, + pub array: *mut ::c_ushort, + } + // sys/shm.h #[cfg_attr(feature = "rustc-dep-of-std", repr(packed(4)))] From 096d6a8b540ed0e4eea902af46a73909e5e8555a Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 29 Jan 2019 15:46:27 +0100 Subject: [PATCH 04/72] Fix openbsd build without unions --- .../bsd/netbsdlike/openbsdlike/openbsd/mod.rs | 58 ++++++++++--------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs index deb18f98e80b7..03f5248365b86 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs @@ -26,32 +26,6 @@ s! { pub int_n_sign_posn: ::c_char, } - pub struct statfs { - pub f_flags: ::uint32_t, - pub f_bsize: ::uint32_t, - pub f_iosize: ::uint32_t, - pub f_blocks: ::uint64_t, - pub f_bfree: ::uint64_t, - pub f_bavail: ::int64_t, - pub f_files: ::uint64_t, - pub f_ffree: ::uint64_t, - pub f_favail: ::int64_t, - pub f_syncwrites: ::uint64_t, - pub f_syncreads: ::uint64_t, - pub f_asyncwrites: ::uint64_t, - pub f_asyncreads: ::uint64_t, - pub f_fsid: ::fsid_t, - pub f_namemax: ::uint32_t, - pub f_owner: ::uid_t, - pub f_ctime: ::uint64_t, - pub f_fstypename: [::c_char; 16], - pub f_mntonname: [::c_char; 90], - pub f_mntfromname: [::c_char; 90], - pub f_mntfromspec: [::c_char; 90], - pub mount_info: mount_info, - } - - #[cfg(libc_union)] pub union mount_info { pub ufs_args: ufs_args, pub mfs_args: mfs_args, @@ -166,6 +140,35 @@ s! { } } +// This type uses the union mount_info: +#[cfg(libc_union)] +s! { + pub struct statfs { + pub f_flags: ::uint32_t, + pub f_bsize: ::uint32_t, + pub f_iosize: ::uint32_t, + pub f_blocks: ::uint64_t, + pub f_bfree: ::uint64_t, + pub f_bavail: ::int64_t, + pub f_files: ::uint64_t, + pub f_ffree: ::uint64_t, + pub f_favail: ::int64_t, + pub f_syncwrites: ::uint64_t, + pub f_syncreads: ::uint64_t, + pub f_asyncwrites: ::uint64_t, + pub f_asyncreads: ::uint64_t, + pub f_fsid: ::fsid_t, + pub f_namemax: ::uint32_t, + pub f_owner: ::uid_t, + pub f_ctime: ::uint64_t, + pub f_fstypename: [::c_char; 16], + pub f_mntonname: [::c_char; 90], + pub f_mntfromname: [::c_char; 90], + pub f_mntfromspec: [::c_char; 90], + pub mount_info: mount_info, + } +} + //https://github.com/openbsd/src/blob/master/sys/sys/mount.h pub const ISOFSMNT_NORRIP: ::c_int = 0x1; // disable Rock Ridge Ext pub const ISOFSMNT_GENS: ::c_int = 0x2; // enable generation numbers @@ -262,7 +265,10 @@ extern { maxval: ::c_longlong, errstr: *mut *const ::c_char) -> ::c_longlong; + // these functions use statfs which uses the union mount_info: + #[cfg(libc_union)] pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; + #[cfg(libc_union)] pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int; From c9ed2654532b15b364a7d0a3b0aef4d5b01d937f Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 29 Jan 2019 15:50:24 +0100 Subject: [PATCH 05/72] Add build-only jobs for targets where libc-test does not run. Closes #1229 . --- .travis.yml | 12 +++++++++++- ci/run-docker.sh | 1 - 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3a0071b5db1b2..431230b409b2e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,6 +50,12 @@ matrix: - env: TARGET=asmjs-unknown-emscripten - env: TARGET=wasm32-unknown-emscripten - env: TARGET=wasm32-unknown-unknown BUILD_ONLY=1 + - env: TARGET=x86_64-unknown-freebsd BUILD_ONLY=1 + - env: TARGET=x86_64-unknown-openbsd BUILD_ONLY=1 + - env: TARGET=x86_64-unknown-bitrig BUILD_ONLY=1 + - env: TARGET=x86_64-unknown-netbsd BUILD_ONLY=1 + - env: TARGET=x86_64-unknown-dragonfly BUILD_ONLY=1 + - env: TARGET=x86_64-unknown-solaris BUILD_ONLY=1 allow_failures: # FIXME: https://github.com/rust-lang/libc/issues/1226 @@ -74,7 +80,11 @@ install: script: - cargo generate-lockfile --manifest-path libc-test/Cargo.toml - if [[ $TRAVIS_OS_NAME = "linux" ]]; then - sh ci/run-docker.sh $TARGET; + if [[ $BUILD_ONLY = "1" ]]; then + sh ci/run.sh $TARGET; + else + sh ci/run-docker.sh $TARGET; + fi else export CARGO_TARGET_DIR=`pwd`/target; sh ci/run.sh $TARGET; diff --git a/ci/run-docker.sh b/ci/run-docker.sh index ca9d2ed737667..c656f5904d684 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -28,7 +28,6 @@ run() { --volume "$(pwd)":/checkout:ro \ --volume "$(pwd)"/target:/checkout/target \ --env CARGO_TARGET_DIR=/checkout/target \ - --env BUILD_ONLY="$BUILD_ONLY" \ --workdir /checkout \ libc \ ci/run.sh "${1}" From 6d839ec03d669f8206a97bc2f7436c75189a47b0 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 29 Jan 2019 16:29:26 +0100 Subject: [PATCH 06/72] Update style to not use trim_left and trim_right deprecated methods --- ci/style.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/style.rs b/ci/style.rs index 747e26c0a091f..9353e07012f0d 100644 --- a/ci/style.rs +++ b/ci/style.rs @@ -117,7 +117,7 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) { } else { prev_blank = false; } - if line != line.trim_right() { + if line != line.trim_end() { err.error(path, i, "trailing whitespace"); } if line.contains("\t") { @@ -139,7 +139,7 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) { } } - let line = line.trim_left(); + let line = line.trim_start(); let is_pub = line.starts_with("pub "); let line = if is_pub {&line[4..]} else {line}; From 95330a0715c2827e6239a5e35860b7f73627bd5f Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 29 Jan 2019 16:30:06 +0100 Subject: [PATCH 07/72] Remove unnecesary rust version from travis.yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 431230b409b2e..4a6a57a56477a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ matrix: include: - name: "Documentation" env: TARGET=x86_64-unknown-linux-gnu - rust: nightly script: sh ci/dox.sh install: true - name: "Shellcheck" From 4cda89563a67d715ab1bf2f8cb412e2a533ac866 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 29 Jan 2019 16:37:07 +0100 Subject: [PATCH 08/72] Print path to cargo in ci/run.sh --- ci/run.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/run.sh b/ci/run.sh index e47b9d4f9c761..7a38f8fde750a 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -80,6 +80,8 @@ if [ "$QEMU" != "" ]; then exec egrep "^(PASSED)|(test result: ok)" "${CARGO_TARGET_DIR}/out.log" fi +command -v cargo + build_types="+nightly +beta +stable +1.13.0 +1.19.0 +1.24.0 +1.30.0" for build_type in $build_types; do From fa014a015f6be96e9920c30cd588fc72d04d1ab2 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 29 Jan 2019 16:37:23 +0100 Subject: [PATCH 09/72] Fix style issues in apple module --- src/unix/bsd/apple/mod.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 519a6063df438..d19af10a1c69b 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -2778,16 +2778,18 @@ pub const SF_IMMUTABLE: ::c_uint = 0x00020000; pub const SF_APPEND: ::c_uint = 0x00040000; pub const UF_HIDDEN: ::c_uint = 0x00008000; -#[cfg(libc_const_size_of)] -fn __DARWIN_ALIGN32(p: usize) -> usize { - const __DARWIN_ALIGNBYTES32: usize = mem::size_of::() - 1; - p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32 -} - -#[cfg(not(libc_const_size_of))] -fn __DARWIN_ALIGN32(p: usize) -> usize { - let __DARWIN_ALIGNBYTES32: usize = mem::size_of::() - 1; - p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32 +cfg_if! { + if #[cfg(libc_const_size_of)] { + fn __DARWIN_ALIGN32(p: usize) -> usize { + const __DARWIN_ALIGNBYTES32: usize = mem::size_of::() - 1; + p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32 + } + } else { + fn __DARWIN_ALIGN32(p: usize) -> usize { + let __DARWIN_ALIGNBYTES32: usize = mem::size_of::() - 1; + p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32 + } + } } f! { From 32bafd849267e6a6c6210c698158c21c27a50320 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 29 Jan 2019 16:45:13 +0100 Subject: [PATCH 10/72] Allow docker containers to use rustup --- ci/docker/aarch64-linux-android/Dockerfile | 3 +-- .../aarch64-unknown-linux-gnu/Dockerfile | 3 +-- .../aarch64-unknown-linux-musl/Dockerfile | 2 +- ci/docker/arm-linux-androideabi/Dockerfile | 3 +-- .../arm-unknown-linux-gnueabihf/Dockerfile | 3 +-- .../arm-unknown-linux-musleabihf/Dockerfile | 2 +- ci/docker/asmjs-unknown-emscripten/Dockerfile | 3 +-- ci/docker/i686-linux-android/Dockerfile | 3 +-- ci/docker/i686-unknown-linux-gnu/Dockerfile | 1 - ci/docker/i686-unknown-linux-musl/Dockerfile | 2 +- ci/docker/mips-unknown-linux-gnu/Dockerfile | 3 +-- ci/docker/mips-unknown-linux-musl/Dockerfile | 2 +- .../mips64-unknown-linux-gnuabi64/Dockerfile | 3 +-- .../Dockerfile | 3 +-- .../mipsel-unknown-linux-musl/Dockerfile | 2 +- .../powerpc-unknown-linux-gnu/Dockerfile | 3 +-- .../powerpc64-unknown-linux-gnu/Dockerfile | 3 +-- .../powerpc64le-unknown-linux-gnu/Dockerfile | 3 +-- ci/docker/s390x-unknown-linux-gnu/Dockerfile | 3 +-- .../sparc64-unknown-linux-gnu/Dockerfile | 3 +-- .../wasm32-unknown-emscripten/Dockerfile | 3 +-- ci/docker/x86_64-linux-android/Dockerfile | 2 +- ci/docker/x86_64-rumprun-netbsd/Dockerfile | 3 +-- ci/docker/x86_64-unknown-linux-gnu/Dockerfile | 3 +-- .../x86_64-unknown-linux-gnux32/Dockerfile | 3 +-- .../x86_64-unknown-linux-musl/Dockerfile | 2 +- ci/run-docker.sh | 3 +++ .../bsd/netbsdlike/openbsdlike/openbsd/mod.rs | 23 ++++++++++--------- 28 files changed, 40 insertions(+), 55 deletions(-) diff --git a/ci/docker/aarch64-linux-android/Dockerfile b/ci/docker/aarch64-linux-android/Dockerfile index 5fc83aadb333d..42a11b79cdece 100644 --- a/ci/docker/aarch64-linux-android/Dockerfile +++ b/ci/docker/aarch64-linux-android/Dockerfile @@ -27,8 +27,7 @@ RUN mv /root/.android /tmp RUN chmod 777 -R /tmp/.android RUN chmod 755 /android/sdk/tools/* /android/sdk/emulator/qemu/linux-x86_64/* -ENV PATH=$PATH:/rust/bin \ - CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android-gcc \ +ENV CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android-gcc \ CARGO_TARGET_AARCH64_LINUX_ANDROID_RUNNER=/tmp/runtest \ HOME=/tmp diff --git a/ci/docker/aarch64-unknown-linux-gnu/Dockerfile b/ci/docker/aarch64-unknown-linux-gnu/Dockerfile index 18214a3e646f9..ded4aa89ede47 100644 --- a/ci/docker/aarch64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/aarch64-unknown-linux-gnu/Dockerfile @@ -3,5 +3,4 @@ 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 ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ - CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64 -L /usr/aarch64-linux-gnu" \ - PATH=$PATH:/rust/bin + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64 -L /usr/aarch64-linux-gnu" diff --git a/ci/docker/aarch64-unknown-linux-musl/Dockerfile b/ci/docker/aarch64-unknown-linux-musl/Dockerfile index fbc47d9fef2de..d3de063598dbd 100644 --- a/ci/docker/aarch64-unknown-linux-musl/Dockerfile +++ b/ci/docker/aarch64-unknown-linux-musl/Dockerfile @@ -20,7 +20,7 @@ RUN curl --retry 5 -L https://github.com/sabotage-linux/kernel-headers/archive/v rm -rf kernel-headers-3.12.6-6 # FIXME: shouldn't need the `-lgcc` here, shouldn't that be in libstd? -ENV PATH=$PATH:/musl-aarch64/bin:/rust/bin \ +ENV PATH=$PATH:/musl-aarch64/bin \ CC_aarch64_unknown_linux_musl=musl-gcc \ RUSTFLAGS='-Clink-args=-lgcc' \ CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc \ diff --git a/ci/docker/arm-linux-androideabi/Dockerfile b/ci/docker/arm-linux-androideabi/Dockerfile index a3fc64bfd52f3..faca8ebf64569 100644 --- a/ci/docker/arm-linux-androideabi/Dockerfile +++ b/ci/docker/arm-linux-androideabi/Dockerfile @@ -27,8 +27,7 @@ RUN mv /root/.android /tmp RUN chmod 777 -R /tmp/.android RUN chmod 755 /android/sdk/tools/* /android/sdk/emulator/qemu/linux-x86_64/* -ENV PATH=$PATH:/rust/bin \ - CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi-gcc \ +ENV CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=arm-linux-androideabi-gcc \ CARGO_TARGET_ARM_LINUX_ANDROIDEABI_RUNNER=/tmp/runtest \ HOME=/tmp diff --git a/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile b/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile index 9fe71dcf87cb0..365c9b8dd96b1 100644 --- a/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile +++ b/ci/docker/arm-unknown-linux-gnueabihf/Dockerfile @@ -3,5 +3,4 @@ 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 ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \ - CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER="qemu-arm -L /usr/arm-linux-gnueabihf" \ - PATH=$PATH:/rust/bin + CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER="qemu-arm -L /usr/arm-linux-gnueabihf" diff --git a/ci/docker/arm-unknown-linux-musleabihf/Dockerfile b/ci/docker/arm-unknown-linux-musleabihf/Dockerfile index 0d493ca39b0d4..d464892a9ceae 100644 --- a/ci/docker/arm-unknown-linux-musleabihf/Dockerfile +++ b/ci/docker/arm-unknown-linux-musleabihf/Dockerfile @@ -19,7 +19,7 @@ RUN curl --retry 5 -L https://github.com/sabotage-linux/kernel-headers/archive/v cd .. && \ rm -rf kernel-headers-3.12.6-6 -ENV PATH=$PATH:/musl-arm/bin:/rust/bin \ +ENV PATH=$PATH:/musl-arm/bin \ CC_arm_unknown_linux_musleabihf=musl-gcc \ CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_LINKER=musl-gcc \ CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_RUNNER="qemu-arm -L /musl-arm" diff --git a/ci/docker/asmjs-unknown-emscripten/Dockerfile b/ci/docker/asmjs-unknown-emscripten/Dockerfile index 3088fc53c442f..d0aa717510349 100644 --- a/ci/docker/asmjs-unknown-emscripten/Dockerfile +++ b/ci/docker/asmjs-unknown-emscripten/Dockerfile @@ -13,8 +13,7 @@ RUN apt-get update && \ COPY emscripten.sh / RUN bash /emscripten.sh -ENV PATH=$PATH:/rust/bin \ - CARGO_TARGET_ASMJS_UNKNOWN_EMSCRIPTEN_RUNNER=node +ENV CARGO_TARGET_ASMJS_UNKNOWN_EMSCRIPTEN_RUNNER=node COPY emscripten-entry.sh / ENTRYPOINT ["/emscripten-entry.sh"] diff --git a/ci/docker/i686-linux-android/Dockerfile b/ci/docker/i686-linux-android/Dockerfile index f0836c38538e0..ebb84f9b60829 100644 --- a/ci/docker/i686-linux-android/Dockerfile +++ b/ci/docker/i686-linux-android/Dockerfile @@ -27,8 +27,7 @@ RUN mv /root/.android /tmp RUN chmod 777 -R /tmp/.android RUN chmod 755 /android/sdk/tools/* /android/sdk/emulator/qemu/linux-x86_64/* -ENV PATH=$PATH:/rust/bin \ - CARGO_TARGET_I686_LINUX_ANDROID_LINKER=i686-linux-android-gcc \ +ENV CARGO_TARGET_I686_LINUX_ANDROID_LINKER=i686-linux-android-gcc \ CARGO_TARGET_I686_LINUX_ANDROID_RUNNER=/tmp/runtest \ HOME=/tmp diff --git a/ci/docker/i686-unknown-linux-gnu/Dockerfile b/ci/docker/i686-unknown-linux-gnu/Dockerfile index 03f3e8e690e32..f26c013f81d94 100644 --- a/ci/docker/i686-unknown-linux-gnu/Dockerfile +++ b/ci/docker/i686-unknown-linux-gnu/Dockerfile @@ -2,4 +2,3 @@ FROM ubuntu:18.04 RUN apt-get update RUN apt-get install -y --no-install-recommends \ gcc-multilib libc6-dev ca-certificates -ENV PATH=$PATH:/rust/bin diff --git a/ci/docker/i686-unknown-linux-musl/Dockerfile b/ci/docker/i686-unknown-linux-musl/Dockerfile index b726e4d41c793..0ef886a1d5886 100644 --- a/ci/docker/i686-unknown-linux-musl/Dockerfile +++ b/ci/docker/i686-unknown-linux-musl/Dockerfile @@ -27,5 +27,5 @@ RUN curl --retry 5 -L https://github.com/sabotage-linux/kernel-headers/archive/v cd .. && \ rm -rf kernel-headers-3.12.6-6 -ENV PATH=$PATH:/musl-i686/bin:/rust/bin \ +ENV PATH=$PATH:/musl-i686/bin \ CC_i686_unknown_linux_musl=musl-gcc diff --git a/ci/docker/mips-unknown-linux-gnu/Dockerfile b/ci/docker/mips-unknown-linux-gnu/Dockerfile index c66abd471b0f8..3f654ff78b420 100644 --- a/ci/docker/mips-unknown-linux-gnu/Dockerfile +++ b/ci/docker/mips-unknown-linux-gnu/Dockerfile @@ -6,5 +6,4 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ qemu-system-mips ENV CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_LINKER=mips-linux-gnu-gcc \ - CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_RUNNER="qemu-mips -L /usr/mips-linux-gnu" \ - PATH=$PATH:/rust/bin + CARGO_TARGET_MIPS_UNKNOWN_LINUX_GNU_RUNNER="qemu-mips -L /usr/mips-linux-gnu" diff --git a/ci/docker/mips-unknown-linux-musl/Dockerfile b/ci/docker/mips-unknown-linux-musl/Dockerfile index dde22fd17ee67..fc2e4a1bc46f0 100644 --- a/ci/docker/mips-unknown-linux-musl/Dockerfile +++ b/ci/docker/mips-unknown-linux-musl/Dockerfile @@ -11,7 +11,7 @@ RUN mkdir /toolchain RUN curl --retry 5 -L https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/OpenWrt-SDK-ar71xx-generic_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \ tar xjf - -C /toolchain --strip-components=1 -ENV PATH=$PATH:/rust/bin:/toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15/bin \ +ENV PATH=$PATH:/toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15/bin \ CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \ CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_LINKER=mips-openwrt-linux-gcc \ CARGO_TARGET_MIPS_UNKNOWN_LINUX_MUSL_RUNNER="qemu-mips -L /toolchain/staging_dir/toolchain-mips_34kc_gcc-5.3.0_musl-1.1.15" diff --git a/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile b/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile index b9921fcc50d22..84206628d20d3 100644 --- a/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile +++ b/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile @@ -7,5 +7,4 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc \ CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64 -L /usr/mips64-linux-gnuabi64" \ - CC_mips64_unknown_linux_gnuabi64=mips64-linux-gnuabi64-gcc \ - PATH=$PATH:/rust/bin + CC_mips64_unknown_linux_gnuabi64=mips64-linux-gnuabi64-gcc diff --git a/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile b/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile index 434c90819eb57..6b61bdfc1fb18 100644 --- a/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile +++ b/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile @@ -7,5 +7,4 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER=mips64el-linux-gnuabi64-gcc \ CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64el -L /usr/mips64el-linux-gnuabi64" \ - CC_mips64el_unknown_linux_gnuabi64=mips64el-linux-gnuabi64-gcc \ - PATH=$PATH:/rust/bin + CC_mips64el_unknown_linux_gnuabi64=mips64el-linux-gnuabi64-gcc diff --git a/ci/docker/mipsel-unknown-linux-musl/Dockerfile b/ci/docker/mipsel-unknown-linux-musl/Dockerfile index 037bf6493e5e1..a720a7d997abb 100644 --- a/ci/docker/mipsel-unknown-linux-musl/Dockerfile +++ b/ci/docker/mipsel-unknown-linux-musl/Dockerfile @@ -11,7 +11,7 @@ RUN mkdir /toolchain RUN curl --retry 5 -L https://s3-us-west-1.amazonaws.com/rust-lang-ci2/libc/OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2 | \ tar xjf - -C /toolchain --strip-components=2 -ENV PATH=$PATH:/rust/bin:/toolchain/bin \ +ENV PATH=$PATH:/toolchain/bin \ CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \ CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_LINKER=mipsel-openwrt-linux-gcc \ CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_MUSL_RUNNER="qemu-mipsel -L /toolchain" diff --git a/ci/docker/powerpc-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc-unknown-linux-gnu/Dockerfile index 106ada444a0da..34889679aa13c 100644 --- a/ci/docker/powerpc-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc-unknown-linux-gnu/Dockerfile @@ -6,5 +6,4 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ qemu-system-ppc ENV CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER=powerpc-linux-gnu-gcc \ - CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc -L /usr/powerpc-linux-gnu" \ - PATH=$PATH:/rust/bin + CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc -L /usr/powerpc-linux-gnu" diff --git a/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile index a6ab66a9a617b..928bbaee0bf34 100644 --- a/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc64-unknown-linux-gnu/Dockerfile @@ -7,5 +7,4 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-linux-gnu-gcc \ CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64 -L /usr/powerpc64-linux-gnu" \ - CC=powerpc64-linux-gnu-gcc \ - PATH=$PATH:/rust/bin + CC=powerpc64-linux-gnu-gcc diff --git a/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile b/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile index 627123e9a1bf2..cccab8e5a41c5 100644 --- a/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile +++ b/ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile @@ -7,5 +7,4 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ENV CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc \ CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64le -L /usr/powerpc64le-linux-gnu" \ - CC=powerpc64le-linux-gnu-gcc \ - PATH=$PATH:/rust/bin + CC=powerpc64le-linux-gnu-gcc diff --git a/ci/docker/s390x-unknown-linux-gnu/Dockerfile b/ci/docker/s390x-unknown-linux-gnu/Dockerfile index 861f4f9b00ee0..64f24409ffdb6 100644 --- a/ci/docker/s390x-unknown-linux-gnu/Dockerfile +++ b/ci/docker/s390x-unknown-linux-gnu/Dockerfile @@ -14,5 +14,4 @@ COPY test-runner-linux / ENV CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc \ CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER="/test-runner-linux s390x" \ - CC_s390x_unknown_linux_gnu=s390x-linux-gnu-gcc \ - PATH=$PATH:/rust/bin + CC_s390x_unknown_linux_gnu=s390x-linux-gnu-gcc diff --git a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile index d9edaab426356..83661117d5330 100644 --- a/ci/docker/sparc64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/sparc64-unknown-linux-gnu/Dockerfile @@ -17,5 +17,4 @@ COPY test-runner-linux / ENV CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_LINKER=sparc64-linux-gnu-gcc \ CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_RUNNER="/test-runner-linux sparc64" \ - CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \ - PATH=$PATH:/rust/bin + CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc diff --git a/ci/docker/wasm32-unknown-emscripten/Dockerfile b/ci/docker/wasm32-unknown-emscripten/Dockerfile index 59bf7d9a23a45..01d9681a4abb9 100644 --- a/ci/docker/wasm32-unknown-emscripten/Dockerfile +++ b/ci/docker/wasm32-unknown-emscripten/Dockerfile @@ -13,8 +13,7 @@ RUN apt-get update && \ COPY emscripten.sh / RUN bash /emscripten.sh -ENV PATH=$PATH:/rust/bin \ - CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_RUNNER=node-wrapper.sh +ENV CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_RUNNER=node-wrapper.sh COPY emscripten-entry.sh / COPY docker/wasm32-unknown-emscripten/node-wrapper.sh /usr/local/bin/node-wrapper.sh diff --git a/ci/docker/x86_64-linux-android/Dockerfile b/ci/docker/x86_64-linux-android/Dockerfile index 0cfbc4820903a..38c33f17a8e5c 100644 --- a/ci/docker/x86_64-linux-android/Dockerfile +++ b/ci/docker/x86_64-linux-android/Dockerfile @@ -19,7 +19,7 @@ RUN sh /android/android-install-ndk.sh $ANDROID_ARCH COPY android-sysimage.sh /android/ RUN bash /android/android-sysimage.sh x86_64 x86_64-24_r07.zip -ENV PATH=$PATH:/rust/bin:/android/ndk-$ANDROID_ARCH/bin \ +ENV PATH=$PATH:/android/ndk-$ANDROID_ARCH/bin \ CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android-gcc \ CC_x86_64_linux_android=x86_64-linux-android-gcc \ CXX_x86_64_linux_android=x86_64-linux-android-g++ \ diff --git a/ci/docker/x86_64-rumprun-netbsd/Dockerfile b/ci/docker/x86_64-rumprun-netbsd/Dockerfile index a486d05b2ebea..aad4f8c21d1e3 100644 --- a/ci/docker/x86_64-rumprun-netbsd/Dockerfile +++ b/ci/docker/x86_64-rumprun-netbsd/Dockerfile @@ -3,8 +3,7 @@ USER root RUN apt-get update RUN apt-get install -y --no-install-recommends \ qemu -ENV PATH=$PATH:/rust/bin \ - CARGO_TARGET_X86_64_RUMPRUN_NETBSD_RUNNER=/tmp/runtest +ENV CARGO_TARGET_X86_64_RUMPRUN_NETBSD_RUNNER=/tmp/runtest ADD docker/x86_64-rumprun-netbsd/runtest.rs /tmp/ ENTRYPOINT ["sh", "-c", "rustc /tmp/runtest.rs -o /tmp/runtest && exec \"$@\"", "--"] diff --git a/ci/docker/x86_64-unknown-linux-gnu/Dockerfile b/ci/docker/x86_64-unknown-linux-gnu/Dockerfile index 6ab9c9231955a..7010f17bbd3b4 100644 --- a/ci/docker/x86_64-unknown-linux-gnu/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-gnu/Dockerfile @@ -1,5 +1,4 @@ FROM ubuntu:18.04 RUN apt-get update RUN apt-get install -y --no-install-recommends \ - gcc libc6-dev ca-certificates -ENV PATH=$PATH:/rust/bin + gcc libc6-dev ca-certificates \ No newline at end of file diff --git a/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile b/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile index 03f3e8e690e32..158f1847165b7 100644 --- a/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-gnux32/Dockerfile @@ -1,5 +1,4 @@ FROM ubuntu:18.04 RUN apt-get update RUN apt-get install -y --no-install-recommends \ - gcc-multilib libc6-dev ca-certificates -ENV PATH=$PATH:/rust/bin + gcc-multilib libc6-dev ca-certificates \ No newline at end of file diff --git a/ci/docker/x86_64-unknown-linux-musl/Dockerfile b/ci/docker/x86_64-unknown-linux-musl/Dockerfile index 0a2770927106c..703ba90f9dfd7 100644 --- a/ci/docker/x86_64-unknown-linux-musl/Dockerfile +++ b/ci/docker/x86_64-unknown-linux-musl/Dockerfile @@ -17,4 +17,4 @@ RUN curl --retry 5 -L https://github.com/sabotage-linux/kernel-headers/archive/v make ARCH=x86_64 prefix=/musl-x86_64 install -j4 && \ cd .. && \ rm -rf kernel-headers-3.12.6-6 -ENV PATH=$PATH:/musl-x86_64/bin:/rust/bin +ENV PATH=$PATH:/musl-x86_64/bin diff --git a/ci/run-docker.sh b/ci/run-docker.sh index c656f5904d684..73270fb903ccd 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -25,10 +25,13 @@ run() { $kvm \ --env CARGO_HOME=/cargo \ --volume "$(rustc --print sysroot)":/rust:ro \ + --volume "${HOME}"/.rustup:/.rustup:ro \ + --env RUSTUP_HOME=/.rustup \ --volume "$(pwd)":/checkout:ro \ --volume "$(pwd)"/target:/checkout/target \ --env CARGO_TARGET_DIR=/checkout/target \ --workdir /checkout \ + -c 'export PATH=$PATH:/cargo/bin; bash' \ libc \ ci/run.sh "${1}" } diff --git a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs index 03f5248365b86..f1de4f4e6363f 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs @@ -138,11 +138,9 @@ s! { pub ex_mask: *mut ::sockaddr, pub ex_masklen: ::c_int, } -} -// This type uses the union mount_info: -#[cfg(libc_union)] -s! { + // This type uses the union mount_info: + #[cfg(libc_union)] pub struct statfs { pub f_flags: ::uint32_t, pub f_bsize: ::uint32_t, @@ -264,16 +262,19 @@ extern { pub fn strtonum(nptr: *const ::c_char, minval: ::c_longlong, maxval: ::c_longlong, errstr: *mut *const ::c_char) -> ::c_longlong; - - // these functions use statfs which uses the union mount_info: - #[cfg(libc_union)] - pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; - #[cfg(libc_union)] - pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; - pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int; } +cfg_if! { + if #[cfg(libc_union)] { + extern { + // these functions use statfs which uses the union mount_info: + pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int; + pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int; + } + } +} + cfg_if! { if #[cfg(target_arch = "x86")] { mod x86; From fb2ed990de1125ae38a6a06bed192b78928e63c2 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 10:14:16 +0100 Subject: [PATCH 11/72] Advertise Rust version support in README --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1caab85438577..a4b7260e6509e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,18 @@ Raw FFI bindings to platform libraries like `libc`. [![Build Status](https://api.cirrus-ci.com/github/rust-lang/libc.svg)](https://cirrus-ci.com/github/rust-lang/libc) [![Latest version](https://img.shields.io/crates/v/libc.svg)](https://crates.io/crates/libc) [![Documentation](https://docs.rs/libc/badge.svg)](https://docs.rs/libc) -![License](https://img.shields.io/crates/l/libc.svg) +![License](https://img.shields.io/crates/l/libc.svg** + +**NOTE:** The minimum supported Rust version is Rust 1.13.0 . APIs requiring +newer Rust features are only available on newer Rust versions: + +| Feature | Version | +|----------------------|---------| +| `union` | 1.19.0 | +| `const mem::size_of` | 1.24.0 | +| `core::ffi::c_void` | 1.30.0 | + +To use `libc` at its fullest, Rust 1.30.0 is required. ## Usage From 1fe0482f18297cd55341da3146f62c45b1a62c17 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 11:03:51 +0100 Subject: [PATCH 12/72] Update cfg_if macro --- src/macros.rs | 52 +++++++++++++++++++++++++++++---------- src/unix/bsd/apple/mod.rs | 8 +----- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 01455863ed058..a9c4c86528862 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -7,31 +7,57 @@ /// This allows you to conveniently provide a long list #[cfg]'d blocks of code /// without having to rewrite each clause multiple times. macro_rules! cfg_if { + // match if/else chains with a final `else` ($( if #[cfg($($meta:meta),*)] { $($it:item)* } ) else * else { $($it2:item)* }) => { - __cfg_if_items! { + cfg_if! { + @__items () ; $( ( ($($meta),*) ($($it)*) ), )* ( () ($($it2)*) ), } - } -} + }; -macro_rules! __cfg_if_items { - (($($not:meta,)*) ; ) => {}; - (($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ), $($rest:tt)*) => { - __cfg_if_apply! { cfg(all(not(any($($not),*)), $($m,)*)), $($it)* } - __cfg_if_items! { ($($not,)* $($m,)*) ; $($rest)* } - } -} + // match if/else chains lacking a final `else` + ( + if #[cfg($($i_met:meta),*)] { $($i_it:item)* } + $( + else if #[cfg($($e_met:meta),*)] { $($e_it:item)* } + )* + ) => { + cfg_if! { + @__items + () ; + ( ($($i_met),*) ($($i_it)*) ), + $( ( ($($e_met),*) ($($e_it)*) ), )* + ( () () ), + } + }; + + // Internal and recursive macro to emit all the items + // + // Collects all the negated cfgs in a list at the beginning and after the + // semicolon is all the remaining items + (@__items ($($not:meta,)*) ; ) => {}; + (@__items ($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ), $($rest:tt)*) => { + // Emit all items within one block, applying an approprate #[cfg]. The + // #[cfg] will require all `$m` matchers specified and must also negate + // all previous matchers. + cfg_if! { @__apply cfg(all($($m,)* not(any($($not),*)))), $($it)* } -macro_rules! __cfg_if_apply { - ($m:meta, $($it:item)*) => { + // Recurse to emit all other items in `$rest`, and when we do so add all + // our `$m` matchers to the list of `$not` matchers as future emissions + // will have to negate everything we just matched as well. + cfg_if! { @__items ($($not,)* $($m,)*) ; $($rest)* } + }; + + // Internal macro to Apply a cfg attribute to a list of items + (@__apply $m:meta, $($it:item)*) => { $(#[$m] $it)* - } + }; } macro_rules! s { diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index d19af10a1c69b..26900d7ad4018 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -486,12 +486,6 @@ s! { pub sem_pad3: [::int32_t; 4], } - pub union semun { - pub val: ::c_int, - pub buf: *mut semid_ds, - pub array: *mut ::c_ushort, - } - // sys/shm.h #[cfg_attr(feature = "rustc-dep-of-std", repr(packed(4)))] @@ -628,7 +622,7 @@ cfg_if! { } } } - } + } } #[cfg(feature = "extra_traits")] From 867f87f832242d0d99940271e64b816dbc5f192c Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 11:28:10 +0100 Subject: [PATCH 13/72] Automatically enable packed(N) and align when the Rust version supports them --- build.rs | 20 +++++++++++--- src/fuchsia/mod.rs | 44 +++++++++++++++--------------- src/lib.rs | 25 ++++++++++------- src/macros.rs | 4 +-- src/redox/net.rs | 4 +-- src/unix/bsd/apple/mod.rs | 6 ++-- src/unix/mod.rs | 4 +-- src/unix/newlib/mod.rs | 32 +++++++++++----------- src/unix/notbsd/emscripten.rs | 26 +++++++++--------- src/unix/notbsd/linux/mips/mod.rs | 6 ++-- src/unix/notbsd/linux/mod.rs | 44 +++++++++++++++--------------- src/unix/notbsd/linux/other/mod.rs | 6 ++-- src/unix/notbsd/linux/s390x.rs | 6 ++-- src/unix/uclibc/mips/mips32.rs | 6 ++-- src/unix/uclibc/mips/mips64.rs | 6 ++-- src/unix/uclibc/mod.rs | 32 +++++++++++----------- src/unix/uclibc/x86_64/mod.rs | 40 +++++++++++++-------------- 17 files changed, 164 insertions(+), 147 deletions(-) diff --git a/build.rs b/build.rs index 17d90ba35a42f..fa4bc90c2f7d8 100644 --- a/build.rs +++ b/build.rs @@ -5,21 +5,33 @@ use std::str; fn main() { let rustc_minor_ver = rustc_minor_version().expect("Failed to get rustc version"); + let rustc_dep_of_std = std::env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); + let align_cargo_feature = std::env::var("CARGO_FEATURE_ALIGN").is_ok(); // Rust >= 1.19 supports unions: - if rustc_minor_ver >= 19 { + if rustc_minor_ver >= 19 || rustc_dep_of_std { println!("cargo:rustc-cfg=libc_union"); } // Rust >= 1.24 supports const mem::size_of: - if rustc_minor_ver >= 24 { + if rustc_minor_ver >= 24 || rustc_dep_of_std { println!("cargo:rustc-cfg=libc_const_size_of"); } + // Rust >= 1.25 supports repr(align): + if rustc_minor_ver >= 25 || rustc_dep_of_std || align_cargo_feature { + println!("cargo:rustc-cfg=libc_align"); + } + // If `core::ffi::c_void` exists, libc can just re-export it. Otherwise, it // must define an incompatible type to retain backwards-compatibility. - if rustc_minor_ver >= 30 { - println!("cargo:rustc-cfg=core_cvoid"); + if rustc_minor_ver >= 30 || rustc_dep_of_std { + println!("cargo:rustc-cfg=libc_core_cvoid"); + } + + // Rust >= 1.33 supports repr(packed(N)) + if rustc_minor_ver >= 30 || rustc_dep_of_std { + println!("cargo:rustc-cfg=libc_packedN"); } } diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index ba20979a748a3..4845a026b1e7e 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -546,23 +546,23 @@ s! { pub ifa_data: *mut ::c_void } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, target_pointer_width = "32", any(target_arch = "arm", target_arch = "x86_64")), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, any(target_pointer_width = "64", not(any(target_arch = "arm", target_arch = "x86_64")))), repr(align(8)))] pub struct pthread_mutex_t { - #[cfg(all(not(feature = "align"), + #[cfg(all(not(libc_align), any(target_arch = "arm", all(target_arch = "x86_64", target_pointer_width = "32"))))] __align: [::c_long; 0], - #[cfg(not(any(feature = "align", + #[cfg(not(any(libc_align, target_arch = "arm", all(target_arch = "x86_64", target_pointer_width = "32"))))] @@ -570,23 +570,23 @@ s! { size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, target_pointer_width = "32", any(target_arch = "arm", target_arch = "x86_64")), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, any(target_pointer_width = "64", not(any(target_arch = "arm", target_arch = "x86_64")))), repr(align(8)))] pub struct pthread_rwlock_t { - #[cfg(all(not(feature = "align"), + #[cfg(all(not(libc_align), any(target_arch = "arm", all(target_arch = "x86_64", target_pointer_width = "32"))))] __align: [::c_long; 0], - #[cfg(not(any(feature = "align", + #[cfg(not(any(libc_align, target_arch = "arm", all(target_arch = "x86_64", target_pointer_width = "32"))))] @@ -594,12 +594,12 @@ s! { size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, any(target_pointer_width = "32", target_arch = "x86_64", all(target_arch = "aarch64", target_env = "musl"))), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, not(any(target_pointer_width = "32", target_arch = "x86_64", all(target_arch = "aarch64", target_env = "musl")))), @@ -616,48 +616,48 @@ s! { size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, any(target_env = "musl", target_pointer_width = "32")), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, not(target_env = "musl"), target_pointer_width = "64"), repr(align(8)))] pub struct pthread_rwlockattr_t { - #[cfg(all(not(feature = "align"), target_env = "musl"))] + #[cfg(all(not(libc_align), target_env = "musl"))] __align: [::c_int; 0], - #[cfg(all(not(feature = "align"), not(target_env = "musl")))] + #[cfg(all(not(libc_align), not(target_env = "musl")))] __align: [::c_long; 0], size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, target_env = "musl", target_pointer_width = "32"), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, target_env = "musl", target_pointer_width = "64"), repr(align(8)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, not(target_env = "musl"), target_arch = "x86"), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, not(target_env = "musl"), not(target_arch = "x86")), repr(align(8)))] pub struct pthread_cond_t { - #[cfg(all(not(feature = "align"), target_env = "musl"))] + #[cfg(all(not(libc_align), target_env = "musl"))] __align: [*const ::c_void; 0], - #[cfg(not(any(feature = "align", target_env = "musl")))] + #[cfg(not(any(libc_align, target_env = "musl")))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_COND_T], } - #[cfg_attr(feature = "align", repr(align(4)))] + #[cfg_attr(libc_align, repr(align(4)))] pub struct pthread_condattr_t { - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_int; 0], size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], } diff --git a/src/lib.rs b/src/lib.rs index 2300e823e9672..8f96d0fc63703 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -151,11 +151,14 @@ )] // Attributes needed when building as part of the standard library #![cfg_attr(feature = "rustc-dep-of-std", feature(cfg_target_vendor))] -#![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, repr_packed))] +#![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg))] #![cfg_attr(feature = "rustc-dep-of-std", feature(no_core))] +#![cfg_attr(libc_packedN, feature(repr_packed))] +#![cfg_attr(libc_align, feature(repr_align))] #![cfg_attr(feature = "rustc-dep-of-std", no_core)] #![cfg_attr(feature = "rustc-dep-of-std", allow(warnings))] #![cfg_attr(not(any(feature = "use_std", feature = "rustc-dep-of-std")), no_std)] +#![allow(stable_features)] // Enable lints #![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))] #![deny(missing_copy_implementations)] @@ -163,18 +166,20 @@ #[cfg(all(not(cross_platform_docs), feature = "use_std"))] extern crate std as core; -#[cfg(feature = "rustc-dep-of-std")] -extern crate rustc_std_workspace_core as core; -#[cfg(feature = "rustc-dep-of-std")] -#[allow(unused_imports)] -use core::iter; -#[cfg(feature = "rustc-dep-of-std")] -#[allow(unused_imports)] -use core::option; - #[macro_use] mod macros; +cfg_if! { + if #[cfg(feature = "rustc-dep-of-std")] { + extern crate rustc_std_workspace_core as core; + #[allow(unused_imports)] + use core::iter; + #[allow(unused_imports)] + use core::option; + } +} + + mod dox; cfg_if! { diff --git a/src/macros.rs b/src/macros.rs index a9c4c86528862..9e25d2a22ce41 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -156,12 +156,12 @@ macro_rules! __item { #[allow(unused_macros)] macro_rules! align_const { ($($(#[$attr:meta])* pub const $name:ident : $t1:ty = $t2:ident { $($field:tt)* };)*) => ($( - #[cfg(feature = "align")] + #[cfg(libc_align)] $(#[$attr])* pub const $name : $t1 = $t2 { $($field)* }; - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] $(#[$attr])* pub const $name : $t1 = $t2 { $($field)* diff --git a/src/redox/net.rs b/src/redox/net.rs index fcbb181c3297d..7a9490260d4a2 100644 --- a/src/redox/net.rs +++ b/src/redox/net.rs @@ -9,10 +9,10 @@ s! { pub s_addr: in_addr_t, } - #[cfg_attr(feature = "align", repr(align(4)))] + #[cfg_attr(libc_align, repr(align(4)))] pub struct in6_addr { pub s6_addr: [u8; 16], - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [u32; 0], } diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 26900d7ad4018..2b654256e3656 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -189,7 +189,7 @@ s! { pub sin_zero: [::c_char; 8], } - #[cfg_attr(feature = "rustc-dep-of-std", repr(packed(4)))] + #[cfg_attr(libc_packedN, repr(packed(4)))] pub struct kevent { pub ident: ::uintptr_t, pub filter: ::int16_t, @@ -473,7 +473,7 @@ s! { pub sem_flg: ::c_short, } - #[cfg_attr(feature = "rustc-dep-of-std", repr(packed(4)))] + #[cfg_attr(libc_packedN, repr(packed(4)))] pub struct semid_ds { // Note the manpage shows different types than the system header. pub sem_perm: ipc_perm, @@ -488,7 +488,7 @@ s! { // sys/shm.h - #[cfg_attr(feature = "rustc-dep-of-std", repr(packed(4)))] + #[cfg_attr(libc_packedN, repr(packed(4)))] pub struct shmid_ds { pub shm_perm: ipc_perm, pub shm_segsz: ::size_t, diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 409f2835fd04d..d4df5f32844ac 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -142,10 +142,10 @@ s! { pub s_addr: in_addr_t, } - #[cfg_attr(feature = "align", repr(align(4)))] + #[cfg_attr(libc_align, repr(align(4)))] pub struct in6_addr { pub s6_addr: [u8; 16], - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [u32; 0], } diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 0cc411d6a67b7..50c60a6be09e4 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -238,25 +238,25 @@ s! { __size: [u64; 7] } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, target_pointer_width = "32", any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, any(target_pointer_width = "64", not(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))), repr(align(8)))] pub struct pthread_mutex_t { // Unverified - #[cfg(all(not(feature = "align"), + #[cfg(all(not(libc_align), any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))] __align: [::c_long; 0], - #[cfg(not(any(feature = "align", + #[cfg(not(any(libc_align, target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))] @@ -264,25 +264,25 @@ s! { size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, target_pointer_width = "32", any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, any(target_pointer_width = "64", not(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))), repr(align(8)))] pub struct pthread_rwlock_t { // Unverified - #[cfg(all(not(feature = "align"), + #[cfg(all(not(libc_align), any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))] __align: [::c_long; 0], - #[cfg(not(any(feature = "align", + #[cfg(not(any(libc_align, target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))] @@ -290,25 +290,25 @@ s! { size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, any(target_pointer_width = "32", target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64")), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, not(any(target_pointer_width = "32", target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64"))), repr(align(8)))] pub struct pthread_mutexattr_t { // Unverified - #[cfg(all(not(feature = "align"), + #[cfg(all(not(libc_align), any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64")))] __align: [::c_int; 0], - #[cfg(all(not(feature = "align"), + #[cfg(all(not(libc_align), not(any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64"))))] @@ -321,16 +321,16 @@ s! { __pshared: ::c_int, } - #[cfg_attr(feature = "align", repr(align(8)))] + #[cfg_attr(libc_align, repr(align(8)))] pub struct pthread_cond_t { // Unverified - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_COND_T], } - #[cfg_attr(feature = "align", repr(align(4)))] + #[cfg_attr(libc_align, repr(align(4)))] pub struct pthread_condattr_t { // Unverified - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_int; 0], size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], } diff --git a/src/unix/notbsd/emscripten.rs b/src/unix/notbsd/emscripten.rs index 2685e769fc1d6..8ebf260262b83 100644 --- a/src/unix/notbsd/emscripten.rs +++ b/src/unix/notbsd/emscripten.rs @@ -77,47 +77,47 @@ s! { __unused5: *mut ::c_void, } - #[cfg_attr(feature = "align", repr(align(4)))] + #[cfg_attr(libc_align, repr(align(4)))] pub struct pthread_mutex_t { - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_long; 0], size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } - #[cfg_attr(feature = "align", repr(align(4)))] + #[cfg_attr(libc_align, repr(align(4)))] pub struct pthread_rwlock_t { - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_long; 0], size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], } - #[cfg_attr(feature = "align", repr(align(4)))] + #[cfg_attr(libc_align, repr(align(4)))] pub struct pthread_mutexattr_t { - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_int; 0], size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], } - #[cfg_attr(feature = "align", repr(align(4)))] + #[cfg_attr(libc_align, repr(align(4)))] pub struct pthread_rwlockattr_t { - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_int; 0], size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], } - #[cfg_attr(all(feature = "align", target_pointer_width = "32"), + #[cfg_attr(all(libc_align, target_pointer_width = "32"), repr(align(4)))] - #[cfg_attr(all(feature = "align", target_pointer_width = "64"), + #[cfg_attr(all(libc_align, target_pointer_width = "64"), repr(align(8)))] pub struct pthread_cond_t { - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [*const ::c_void; 0], size: [u8; __SIZEOF_PTHREAD_COND_T], } - #[cfg_attr(feature = "align", repr(align(4)))] + #[cfg_attr(libc_align, repr(align(4)))] pub struct pthread_condattr_t { - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_int; 0], size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], } diff --git a/src/unix/notbsd/linux/mips/mod.rs b/src/unix/notbsd/linux/mips/mod.rs index 8809bef81e87a..0f1cf7ad0146c 100644 --- a/src/unix/notbsd/linux/mips/mod.rs +++ b/src/unix/notbsd/linux/mips/mod.rs @@ -21,16 +21,16 @@ s! { } // FIXME this is actually a union - #[cfg_attr(all(feature = "align", target_pointer_width = "32"), + #[cfg_attr(all(libc_align, target_pointer_width = "32"), repr(align(4)))] - #[cfg_attr(all(feature = "align", target_pointer_width = "64"), + #[cfg_attr(all(libc_align, target_pointer_width = "64"), repr(align(8)))] pub struct sem_t { #[cfg(target_pointer_width = "32")] __size: [::c_char; 16], #[cfg(target_pointer_width = "64")] __size: [::c_char; 32], - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_long; 0], } diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 034db9bc85482..0d266a602d395 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -64,14 +64,14 @@ s! { __unused5: *mut ::c_void, } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, any(target_pointer_width = "32", target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64", all(target_arch = "aarch64", target_env = "musl"))), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, not(any(target_pointer_width = "32", target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", @@ -94,24 +94,24 @@ s! { size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, any(target_env = "musl", target_pointer_width = "32")), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, not(target_env = "musl"), target_pointer_width = "64"), repr(align(8)))] pub struct pthread_rwlockattr_t { - #[cfg(all(not(feature = "align"), target_env = "musl"))] + #[cfg(all(not(libc_align), target_env = "musl"))] __align: [::c_int; 0], - #[cfg(all(not(feature = "align"), not(target_env = "musl")))] + #[cfg(all(not(libc_align), not(target_env = "musl")))] __align: [::c_long; 0], size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], } - #[cfg_attr(feature = "align", repr(align(4)))] + #[cfg_attr(libc_align, repr(align(4)))] pub struct pthread_condattr_t { - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_int; 0], size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], } @@ -578,31 +578,31 @@ s_no_extra_traits!{ pub d_name: [::c_char; 256], } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, target_env = "musl", target_pointer_width = "32"), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, target_env = "musl", target_pointer_width = "64"), repr(align(8)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, not(target_env = "musl"), target_arch = "x86"), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, not(target_env = "musl"), not(target_arch = "x86")), repr(align(8)))] pub struct pthread_cond_t { - #[cfg(all(not(feature = "align"), target_env = "musl"))] + #[cfg(all(not(libc_align), target_env = "musl"))] __align: [*const ::c_void; 0], - #[cfg(not(any(feature = "align", target_env = "musl")))] + #[cfg(not(any(libc_align, target_env = "musl")))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_COND_T], } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, target_pointer_width = "32", any(target_arch = "mips", target_arch = "arm", @@ -610,7 +610,7 @@ s_no_extra_traits!{ target_arch = "x86_64", target_arch = "x86")), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, any(target_pointer_width = "64", not(any(target_arch = "mips", target_arch = "arm", @@ -619,14 +619,14 @@ s_no_extra_traits!{ target_arch = "x86")))), repr(align(8)))] pub struct pthread_mutex_t { - #[cfg(all(not(feature = "align"), + #[cfg(all(not(libc_align), any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc", all(target_arch = "x86_64", target_pointer_width = "32"))))] __align: [::c_long; 0], - #[cfg(not(any(feature = "align", + #[cfg(not(any(libc_align, target_arch = "mips", target_arch = "arm", target_arch = "powerpc", @@ -636,7 +636,7 @@ s_no_extra_traits!{ size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, target_pointer_width = "32", any(target_arch = "mips", target_arch = "arm", @@ -644,7 +644,7 @@ s_no_extra_traits!{ target_arch = "x86_64", target_arch = "x86")), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, any(target_pointer_width = "64", not(any(target_arch = "mips", target_arch = "arm", @@ -653,14 +653,14 @@ s_no_extra_traits!{ target_arch = "x86")))), repr(align(8)))] pub struct pthread_rwlock_t { - #[cfg(all(not(feature = "align"), + #[cfg(all(not(libc_align), any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc", all(target_arch = "x86_64", target_pointer_width = "32"))))] __align: [::c_long; 0], - #[cfg(not(any(feature = "align", + #[cfg(not(any(libc_align, target_arch = "mips", target_arch = "arm", target_arch = "powerpc", diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index 4036ceab1d346..4202a0e792489 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -122,16 +122,16 @@ s! { } // FIXME this is actually a union - #[cfg_attr(all(feature = "align", target_pointer_width = "32"), + #[cfg_attr(all(libc_align, target_pointer_width = "32"), repr(align(4)))] - #[cfg_attr(all(feature = "align", target_pointer_width = "64"), + #[cfg_attr(all(libc_align, target_pointer_width = "64"), repr(align(8)))] pub struct sem_t { #[cfg(target_pointer_width = "32")] __size: [::c_char; 16], #[cfg(target_pointer_width = "64")] __size: [::c_char; 32], - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_long; 0], } diff --git a/src/unix/notbsd/linux/s390x.rs b/src/unix/notbsd/linux/s390x.rs index f53e47e097cd0..0d4ba8141d353 100644 --- a/src/unix/notbsd/linux/s390x.rs +++ b/src/unix/notbsd/linux/s390x.rs @@ -247,13 +247,13 @@ s! { } // FIXME this is actually a union - #[cfg_attr(all(feature = "align", target_pointer_width = "32"), + #[cfg_attr(all(libc_align, target_pointer_width = "32"), repr(align(4)))] - #[cfg_attr(all(feature = "align", target_pointer_width = "64"), + #[cfg_attr(all(libc_align, target_pointer_width = "64"), repr(align(8)))] pub struct sem_t { __size: [::c_char; 32], - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_long; 0], } diff --git a/src/unix/uclibc/mips/mips32.rs b/src/unix/uclibc/mips/mips32.rs index dcbfcf8ff2bd2..1ae3962f4995c 100644 --- a/src/unix/uclibc/mips/mips32.rs +++ b/src/unix/uclibc/mips/mips32.rs @@ -222,16 +222,16 @@ s! { } // FIXME this is actually a union - #[cfg_attr(all(feature = "align", target_pointer_width = "32"), + #[cfg_attr(all(libc_align, target_pointer_width = "32"), repr(align(4)))] - #[cfg_attr(all(feature = "align", target_pointer_width = "64"), + #[cfg_attr(all(libc_align, target_pointer_width = "64"), repr(align(8)))] pub struct sem_t { #[cfg(target_pointer_width = "32")] __size: [::c_char; 16], #[cfg(target_pointer_width = "64")] __size: [::c_char; 32], - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_long; 0], } } diff --git a/src/unix/uclibc/mips/mips64.rs b/src/unix/uclibc/mips/mips64.rs index e35938b1fc8d9..c9e1c197ccb66 100644 --- a/src/unix/uclibc/mips/mips64.rs +++ b/src/unix/uclibc/mips/mips64.rs @@ -188,13 +188,13 @@ s! { } // FIXME this is actually a union - #[cfg_attr(all(feature = "align", target_pointer_width = "32"), + #[cfg_attr(all(libc_align, target_pointer_width = "32"), repr(align(4)))] - #[cfg_attr(all(feature = "align", target_pointer_width = "64"), + #[cfg_attr(all(libc_align, target_pointer_width = "64"), repr(align(8)))] pub struct sem_t { __size: [::c_char; 32], - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_long; 0], } } diff --git a/src/unix/uclibc/mod.rs b/src/unix/uclibc/mod.rs index bb314196af608..a5cb80e04397c 100644 --- a/src/unix/uclibc/mod.rs +++ b/src/unix/uclibc/mod.rs @@ -234,25 +234,25 @@ s! { pub ifa_data: *mut ::c_void } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, target_pointer_width = "32", any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, any(target_pointer_width = "64", not(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))), repr(align(8)))] pub struct pthread_mutex_t { - #[cfg(all(not(feature = "align"), + #[cfg(all(not(libc_align), any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))] __align: [::c_long; 0], - #[cfg(not(any(feature = "align", + #[cfg(not(any(libc_align, target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))] @@ -260,25 +260,25 @@ s! { size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, target_pointer_width = "32", any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, any(target_pointer_width = "64", not(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))), repr(align(8)))] pub struct pthread_rwlock_t { - #[cfg(all(not(feature = "align"), + #[cfg(all(not(libc_align), any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))] __align: [::c_long; 0], - #[cfg(not(any(feature = "align", + #[cfg(not(any(libc_align, target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))] @@ -286,25 +286,25 @@ s! { size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, any(target_pointer_width = "32", target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64")), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, not(any(target_pointer_width = "32", target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64"))), repr(align(8)))] pub struct pthread_mutexattr_t { - #[cfg(all(not(feature = "align"), + #[cfg(all(not(libc_align), any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64")))] __align: [::c_int; 0], - #[cfg(all(not(feature = "align"), + #[cfg(all(not(libc_align), not(any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64"))))] @@ -317,16 +317,16 @@ s! { __pshared: ::c_int, } - #[cfg_attr(feature = "align", repr(align(8)))] + #[cfg_attr(libc_align, repr(align(8)))] pub struct pthread_cond_t { - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_COND_T], } - #[cfg_attr(feature = "align", repr(align(4)))] + #[cfg_attr(libc_align, repr(align(4)))] pub struct pthread_condattr_t { - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_int; 0], size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], } diff --git a/src/unix/uclibc/x86_64/mod.rs b/src/unix/uclibc/x86_64/mod.rs index bc6571aff98c2..25de7e15d4389 100644 --- a/src/unix/uclibc/x86_64/mod.rs +++ b/src/unix/uclibc/x86_64/mod.rs @@ -133,7 +133,7 @@ s! { // // pub struct in6_addr { // pub s6_addr: [u8; 16], -// #[cfg(not(feature = "align"))] +// #[cfg(not(libc_align))] // __align: [u32; 0], // } @@ -205,38 +205,38 @@ s! { pub c_cc: [::cc_t; ::NCCS], } - #[cfg_attr(all(feature = "align", target_pointer_width = "32"), + #[cfg_attr(all(libc_align, target_pointer_width = "32"), repr(align(4)))] - #[cfg_attr(all(feature = "align", target_pointer_width = "64"), + #[cfg_attr(all(libc_align, target_pointer_width = "64"), repr(align(8)))] pub struct sem_t { // ToDo #[cfg(target_pointer_width = "32")] __size: [::c_char; 16], #[cfg(target_pointer_width = "64")] __size: [::c_char; 32], - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_long; 0], } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, target_pointer_width = "32", any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, any(target_pointer_width = "64", not(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))), repr(align(8)))] pub struct pthread_mutex_t { // ToDo - #[cfg(all(not(feature = "align"), + #[cfg(all(not(libc_align), any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))] __align: [::c_long; 0], - #[cfg(not(any(feature = "align", + #[cfg(not(any(libc_align, target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))] @@ -244,25 +244,25 @@ s! { size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, any(target_pointer_width = "32", target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64")), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, not(any(target_pointer_width = "32", target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64"))), repr(align(8)))] pub struct pthread_mutexattr_t { // ToDo - #[cfg(all(not(feature = "align"), + #[cfg(all(not(libc_align), any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64")))] __align: [::c_int; 0], - #[cfg(all(not(feature = "align"), + #[cfg(all(not(libc_align), not(any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64"))))] @@ -270,39 +270,39 @@ s! { size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], } - #[cfg_attr(feature = "align", repr(align(8)))] + #[cfg_attr(libc_align, repr(align(8)))] pub struct pthread_cond_t { // ToDo - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_longlong; 0], size: [u8; __SIZEOF_PTHREAD_COND_T], } - #[cfg_attr(feature = "align", repr(align(4)))] + #[cfg_attr(libc_align, repr(align(4)))] pub struct pthread_condattr_t { // ToDo - #[cfg(not(feature = "align"))] + #[cfg(not(libc_align))] __align: [::c_int; 0], size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], } - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, target_pointer_width = "32", any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")), repr(align(4)))] - #[cfg_attr(all(feature = "align", + #[cfg_attr(all(libc_align, any(target_pointer_width = "64", not(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))), repr(align(8)))] pub struct pthread_rwlock_t { // ToDo - #[cfg(all(not(feature = "align"), + #[cfg(all(not(libc_align), any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))] __align: [::c_long; 0], - #[cfg(not(any(feature = "align", + #[cfg(not(any(libc_align, target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))] From 93263338454a9c0a5126a1e8f51026a516c9ad39 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 12:00:31 +0100 Subject: [PATCH 14/72] Put cfg(feature = extra_traits) behind cfg_ifs --- ci/style.rs | 5 + src/cloudabi/mod.rs | 3 +- src/fuchsia/mod.rs | 7 +- src/macros.rs | 18 +- src/redox/mod.rs | 3 +- src/sgx.rs | 3 +- src/switch.rs | 3 +- src/unix/bsd/apple/b32.rs | 52 +- src/unix/bsd/apple/b64.rs | 52 +- src/unix/bsd/apple/mod.rs | 744 +++++++++++----------- src/unix/bsd/mod.rs | 169 ++--- src/unix/mod.rs | 3 +- src/unix/notbsd/android/b64/mod.rs | 198 +++--- src/unix/notbsd/android/mod.rs | 419 ++++++------ src/unix/notbsd/linux/mod.rs | 287 ++++----- src/unix/notbsd/linux/musl/b32/x86.rs | 82 +-- src/unix/notbsd/linux/musl/b64/x86_64.rs | 81 +-- src/unix/notbsd/linux/musl/mod.rs | 121 ++-- src/unix/notbsd/linux/other/b32/x86.rs | 189 +++--- src/unix/notbsd/linux/other/b64/x86_64.rs | 181 +++--- src/unix/notbsd/linux/other/mod.rs | 111 ++-- src/unix/notbsd/linux/s390x.rs | 43 +- src/unix/notbsd/mod.rs | 235 +++---- src/windows/mod.rs | 3 +- 24 files changed, 1522 insertions(+), 1490 deletions(-) diff --git a/ci/style.rs b/ci/style.rs index 9353e07012f0d..e976c45432106 100644 --- a/ci/style.rs +++ b/ci/style.rs @@ -139,6 +139,11 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) { } } + if line.contains("#[cfg(") && !line.contains(" if ") && + line.contains("extra_traits") { + err.error(path, i, "use cfg_if! instead of #[cfg]"); + } + let line = line.trim_start(); let is_pub = line.starts_with("pub "); let line = if is_pub {&line[4..]} else {line}; diff --git a/src/cloudabi/mod.rs b/src/cloudabi/mod.rs index 51859cb40b127..a24ffc4b566f9 100644 --- a/src/cloudabi/mod.rs +++ b/src/cloudabi/mod.rs @@ -316,7 +316,7 @@ cfg_if! { } cfg_if! { - if #[cfg(core_cvoid)] { + if #[cfg(libc_core_cvoid)] { pub use core::ffi::c_void; } else { // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help @@ -324,6 +324,7 @@ cfg_if! { // like malloc/free. #[repr(u8)] #[allow(missing_copy_implementations)] + #[allow(missing_debug_implementations)] pub enum c_void { // Two dummy variants so the #[repr] attribute can be used. #[doc(hidden)] diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 4845a026b1e7e..138bf2a91631f 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -605,11 +605,11 @@ s! { all(target_arch = "aarch64", target_env = "musl")))), repr(align(8)))] pub struct pthread_mutexattr_t { - #[cfg(all(not(features = "align"), + #[cfg(all(not(libc_align), any(target_arch = "x86_64", all(target_arch = "aarch64", target_env = "musl"))))] __align: [::c_int; 0], - #[cfg(all(not(features = "align"), + #[cfg(all(not(libc_align), not(any(target_arch = "x86_64", all(target_arch = "aarch64", target_env = "musl")))))] __align: [::c_long; 0], @@ -4120,7 +4120,7 @@ cfg_if! { } cfg_if! { - if #[cfg(core_cvoid)] { + if #[cfg(libc_core_cvoid)] { pub use core::ffi::c_void; } else { // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help @@ -4128,6 +4128,7 @@ cfg_if! { // like malloc/free. #[repr(u8)] #[allow(missing_copy_implementations)] + #[allow(missing_debug_implementations)] pub enum c_void { // Two dummy variants so the #[repr] attribute can be used. #[doc(hidden)] diff --git a/src/macros.rs b/src/macros.rs index 9e25d2a22ce41..e8c3c4fc7beaf 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -65,21 +65,7 @@ macro_rules! s { s!(it: $(#[$attr])* pub $t $i { $($field)* }); )*); (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => ( - cfg_if! { - if #[cfg(libc_union)] { - __item! { - #[repr(C)] - #[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] - $(#[$attr])* - pub union $i { $($field)* } - } - - impl ::dox::Copy for $i {} - impl ::dox::Clone for $i { - fn clone(&self) -> $i { *self } - } - } - } + compile_error!("unions cannot derive extra traits, use s_no_extra_traits instead"); ); (it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => ( __item! { @@ -97,7 +83,7 @@ macro_rules! s { macro_rules! s_no_extra_traits { ($($(#[$attr:meta])* pub $t:ident $i:ident { $($field:tt)* })*) => ($( - s!(it: $(#[$attr])* pub $t $i { $($field)* }); + s_no_extra_traits!(it: $(#[$attr])* pub $t $i { $($field)* }); )*); (it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => ( cfg_if! { diff --git a/src/redox/mod.rs b/src/redox/mod.rs index 82782bc16404e..ac60324969f35 100644 --- a/src/redox/mod.rs +++ b/src/redox/mod.rs @@ -386,7 +386,7 @@ pub use self::net::*; mod net; cfg_if! { - if #[cfg(core_cvoid)] { + if #[cfg(libc_core_cvoid)] { pub use core::ffi::c_void; } else { // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help @@ -394,6 +394,7 @@ cfg_if! { // like malloc/free. #[repr(u8)] #[allow(missing_copy_implementations)] + #[allow(missing_debug_implementations)] pub enum c_void { // Two dummy variants so the #[repr] attribute can be used. #[doc(hidden)] diff --git a/src/sgx.rs b/src/sgx.rs index 1d5ca21292e9f..b9d8b5c5e2470 100644 --- a/src/sgx.rs +++ b/src/sgx.rs @@ -36,7 +36,7 @@ pub const INT_MIN: c_int = -2147483648; pub const INT_MAX: c_int = 2147483647; cfg_if! { - if #[cfg(core_cvoid)] { + if #[cfg(libc_core_cvoid)] { pub use core::ffi::c_void; } else { // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help @@ -44,6 +44,7 @@ cfg_if! { // like malloc/free. #[repr(u8)] #[allow(missing_copy_implementations)] + #[allow(missing_debug_implementations)] pub enum c_void { // Two dummy variants so the #[repr] attribute can be used. #[doc(hidden)] diff --git a/src/switch.rs b/src/switch.rs index 89e259ea27ca2..47d689d3adb71 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -38,7 +38,7 @@ pub const INT_MIN: c_int = -2147483648; pub const INT_MAX: c_int = 2147483647; cfg_if! { - if #[cfg(core_cvoid)] { + if #[cfg(libc_core_cvoid)] { pub use core::ffi::c_void; } else { // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help @@ -46,6 +46,7 @@ cfg_if! { // like malloc/free. #[repr(u8)] #[allow(missing_copy_implementations)] + #[allow(missing_debug_implementations)] pub enum c_void { // Two dummy variants so the #[repr] attribute can be used. #[doc(hidden)] diff --git a/src/unix/bsd/apple/b32.rs b/src/unix/bsd/apple/b32.rs index 284eae399ddec..a0c84c4705b1e 100644 --- a/src/unix/bsd/apple/b32.rs +++ b/src/unix/bsd/apple/b32.rs @@ -52,32 +52,32 @@ s_no_extra_traits!{ } } -#[cfg(feature = "extra_traits")] -impl PartialEq for pthread_attr_t { - fn eq(&self, other: &pthread_attr_t) -> bool { - self.__sig == other.__sig - && self.__opaque - .iter() - .zip(other.__opaque.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for pthread_attr_t {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for pthread_attr_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("pthread_attr_t") - .field("__sig", &self.__sig) - // FIXME: .field("__opaque", &self.__opaque) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for pthread_attr_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - self.__opaque.hash(state); +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for pthread_attr_t { + fn eq(&self, other: &pthread_attr_t) -> bool { + self.__sig == other.__sig + && self.__opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for pthread_attr_t {} + impl std::fmt::Debug for pthread_attr_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_attr_t") + .field("__sig", &self.__sig) + // FIXME: .field("__opaque", &self.__opaque) + .finish() + } + } + impl std::hash::Hash for pthread_attr_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } + } } } diff --git a/src/unix/bsd/apple/b64.rs b/src/unix/bsd/apple/b64.rs index 2161fc47590f9..7fecf31c8429a 100644 --- a/src/unix/bsd/apple/b64.rs +++ b/src/unix/bsd/apple/b64.rs @@ -57,32 +57,32 @@ s_no_extra_traits!{ } } -#[cfg(feature = "extra_traits")] -impl PartialEq for pthread_attr_t { - fn eq(&self, other: &pthread_attr_t) -> bool { - self.__sig == other.__sig - && self.__opaque - .iter() - .zip(other.__opaque.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for pthread_attr_t {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for pthread_attr_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("pthread_attr_t") - .field("__sig", &self.__sig) - // FIXME: .field("__opaque", &self.__opaque) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for pthread_attr_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - self.__opaque.hash(state); +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for pthread_attr_t { + fn eq(&self, other: &pthread_attr_t) -> bool { + self.__sig == other.__sig + && self.__opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for pthread_attr_t {} + impl std::fmt::Debug for pthread_attr_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_attr_t") + .field("__sig", &self.__sig) + // FIXME: .field("__opaque", &self.__opaque) + .finish() + } + } + impl std::hash::Hash for pthread_attr_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } + } } } diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 2b654256e3656..f809089ce5283 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -189,16 +189,6 @@ s! { pub sin_zero: [::c_char; 8], } - #[cfg_attr(libc_packedN, repr(packed(4)))] - pub struct kevent { - pub ident: ::uintptr_t, - pub filter: ::int16_t, - pub flags: ::uint16_t, - pub fflags: ::uint32_t, - pub data: ::intptr_t, - pub udata: *mut ::c_void, - } - pub struct kevent64_s { pub ident: ::uint64_t, pub filter: ::int16_t, @@ -473,6 +463,33 @@ s! { pub sem_flg: ::c_short, } + // sys/shm.h + + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } +} + +s_no_extra_traits!{ + + // FIXME: https://github.com/rust-lang/libc/issues/1243 + #[allow(missing_debug_implementations)] + #[cfg_attr(libc_packedN, repr(packed(4)))] + pub struct kevent { + pub ident: ::uintptr_t, + pub filter: ::int16_t, + pub flags: ::uint16_t, + pub fflags: ::uint32_t, + pub data: ::intptr_t, + pub udata: *mut ::c_void, + } + + // FIXME: https://github.com/rust-lang/libc/issues/1243 + #[allow(missing_debug_implementations)] #[cfg_attr(libc_packedN, repr(packed(4)))] pub struct semid_ds { // Note the manpage shows different types than the system header. @@ -486,8 +503,8 @@ s! { pub sem_pad3: [::int32_t; 4], } - // sys/shm.h - + // FIXME: https://github.com/rust-lang/libc/issues/1243 + #[allow(missing_debug_implementations)] #[cfg_attr(libc_packedN, repr(packed(4)))] pub struct shmid_ds { pub shm_perm: ipc_perm, @@ -500,19 +517,8 @@ s! { pub shm_ctime: ::time_t, // FIXME: 64-bit wrong align => wrong offset // FIXME: 64-bit wrong align => wrong offset: pub shm_internal: *mut ::c_void, - } - pub struct arphdr { - pub ar_hrd: u16, - pub ar_pro: u16, - pub ar_hln: u8, - pub ar_pln: u8, - pub ar_op: u16, - } -} - -s_no_extra_traits!{ pub struct proc_threadinfo { pub pth_user_time: u64, pub pth_system_time: u64, @@ -622,358 +628,350 @@ cfg_if! { } } } - } -} - -#[cfg(feature = "extra_traits")] -impl PartialEq for proc_threadinfo { - fn eq(&self, other: &proc_threadinfo) -> bool { - self.pth_user_time == other.pth_user_time - && self.pth_system_time == other.pth_system_time - && self.pth_cpu_usage == other.pth_cpu_usage - && self.pth_policy == other.pth_policy - && self.pth_run_state == other.pth_run_state - && self.pth_flags == other.pth_flags - && self.pth_sleep_time == other.pth_sleep_time - && self.pth_curpri == other.pth_curpri - && self.pth_priority == other.pth_priority - && self.pth_maxpriority == other.pth_maxpriority - && self - .pth_name - .iter() - .zip(other.pth_name.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for proc_threadinfo {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for proc_threadinfo { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("proc_threadinfo") - .field("pth_user_time", &self.pth_user_time) - .field("pth_system_time", &self.pth_system_time) - .field("pth_cpu_usage", &self.pth_cpu_usage) - .field("pth_policy", &self.pth_policy) - .field("pth_run_state", &self.pth_run_state) - .field("pth_flags", &self.pth_flags) - .field("pth_sleep_time", &self.pth_sleep_time) - .field("pth_curpri", &self.pth_curpri) - .field("pth_priority", &self.pth_priority) - .field("pth_maxpriority", &self.pth_maxpriority) - // FIXME: .field("pth_name", &self.pth_name) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for proc_threadinfo { - fn hash(&self, state: &mut H) { - self.pth_user_time.hash(state); - self.pth_system_time.hash(state); - self.pth_cpu_usage.hash(state); - self.pth_policy.hash(state); - self.pth_run_state.hash(state); - self.pth_flags.hash(state); - self.pth_sleep_time.hash(state); - self.pth_curpri.hash(state); - self.pth_priority.hash(state); - self.pth_maxpriority.hash(state); - self.pth_name.hash(state); - } -} -#[cfg(feature = "extra_traits")] -impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_fsid == other.f_fsid - && self.f_owner == other.f_owner - && self.f_flags == other.f_flags - && self.f_fssubtype == other.f_fssubtype - && self.f_fstypename == other.f_fstypename - && self.f_type == other.f_type - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a,b)| a == b) - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a,b)| a == b) - && self.f_reserved == other.f_reserved - } -} -#[cfg(feature = "extra_traits")] -impl Eq for statfs {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for statfs { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("statfs") - .field("f_bsize", &self.f_bsize) - .field("f_iosize", &self.f_iosize) - .field("f_blocks", &self.f_blocks) - .field("f_bfree", &self.f_bfree) - .field("f_bavail", &self.f_bavail) - .field("f_files", &self.f_files) - .field("f_ffree", &self.f_ffree) - .field("f_fsid", &self.f_fsid) - .field("f_owner", &self.f_owner) - .field("f_flags", &self.f_flags) - .field("f_fssubtype", &self.f_fssubtype) - .field("f_fstypename", &self.f_fstypename) - .field("f_type", &self.f_type) - // FIXME: .field("f_mntonname", &self.f_mntonname) - // FIXME: .field("f_mntfromname", &self.f_mntfromname) - .field("f_reserved", &self.f_reserved) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_fsid.hash(state); - self.f_owner.hash(state); - self.f_flags.hash(state); - self.f_fssubtype.hash(state); - self.f_fstypename.hash(state); - self.f_type.hash(state); - self.f_mntonname.hash(state); - self.f_mntfromname.hash(state); - self.f_reserved.hash(state); - } -} -#[cfg(feature = "extra_traits")] -impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_seekoff == other.d_seekoff - && self.d_reclen == other.d_reclen - && self.d_namlen == other.d_namlen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for dirent {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for dirent { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("dirent") - .field("d_ino", &self.d_ino) - .field("d_seekoff", &self.d_seekoff) - .field("d_reclen", &self.d_reclen) - .field("d_namlen", &self.d_namlen) - .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_seekoff.hash(state); - self.d_reclen.hash(state); - self.d_namlen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } -} -#[cfg(feature = "extra_traits")] -impl PartialEq for pthread_rwlock_t { - fn eq(&self, other: &pthread_rwlock_t) -> bool { - self.__sig == other.__sig - && self. - __opaque - .iter() - .zip(other.__opaque.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for pthread_rwlock_t {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for pthread_rwlock_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("pthread_rwlock_t") - .field("__sig", &self.__sig) - // FIXME: .field("__opaque", &self.__opaque) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - self.__opaque.hash(state); - } -} -#[cfg(feature = "extra_traits")] -impl PartialEq for pthread_mutex_t { - fn eq(&self, other: &pthread_mutex_t) -> bool { - self.__sig == other.__sig - && self. - __opaque - .iter() - .zip(other.__opaque.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for pthread_mutex_t {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for pthread_mutex_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("pthread_mutex_t") - .field("__sig", &self.__sig) - // FIXME: .field("__opaque", &self.__opaque) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - self.__opaque.hash(state); } } -#[cfg(feature = "extra_traits")] -impl PartialEq for pthread_cond_t { - fn eq(&self, other: &pthread_cond_t) -> bool { - self.__sig == other.__sig - && self. - __opaque - .iter() - .zip(other.__opaque.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for pthread_cond_t {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for pthread_cond_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("pthread_cond_t") - .field("__sig", &self.__sig) - // FIXME: .field("__opaque", &self.__opaque) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - self.__opaque.hash(state); - } -} -#[cfg(feature = "extra_traits")] -impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_len == other.ss_len - && self.ss_family == other.ss_family - && self - .__ss_pad1 - .iter() - .zip(other.__ss_pad1.iter()) - .all(|(a, b)| a == b) - && self.__ss_align == other.__ss_align - && self - .__ss_pad2 - .iter() - .zip(other.__ss_pad2.iter()) - .all(|(a, b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for sockaddr_storage {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("sockaddr_storage") - .field("ss_len", &self.ss_len) - .field("ss_family", &self.ss_family) - .field("__ss_pad1", &self.__ss_pad1) - .field("__ss_align", &self.__ss_align) - // FIXME: .field("__ss_pad2", &self.__ss_pad2) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_len.hash(state); - self.ss_family.hash(state); - self.__ss_pad1.hash(state); - self.__ss_align.hash(state); - self.__ss_pad2.hash(state); - } -} -#[cfg(feature = "extra_traits")] -impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_user - .iter() - .zip(other.ut_user.iter()) - .all(|(a,b)| a == b) - && self.ut_id == other.ut_id - && self.ut_line == other.ut_line - && self.ut_pid == other.ut_pid - && self.ut_type == other.ut_type - && self.ut_tv == other.ut_tv - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a,b)| a == b) - && self.ut_pad == other.ut_pad - } -} -#[cfg(feature = "extra_traits")] -impl Eq for utmpx {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for utmpx { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("utmpx") - // FIXME: .field("ut_user", &self.ut_user) - .field("ut_id", &self.ut_id) - .field("ut_line", &self.ut_line) - .field("ut_pid", &self.ut_pid) - .field("ut_type", &self.ut_type) - .field("ut_tv", &self.ut_tv) - // FIXME: .field("ut_host", &self.ut_host) - .field("ut_pad", &self.ut_pad) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_user.hash(state); - self.ut_id.hash(state); - self.ut_line.hash(state); - self.ut_pid.hash(state); - self.ut_type.hash(state); - self.ut_tv.hash(state); - self.ut_host.hash(state); - self.ut_pad.hash(state); + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for proc_threadinfo { + fn eq(&self, other: &proc_threadinfo) -> bool { + self.pth_user_time == other.pth_user_time + && self.pth_system_time == other.pth_system_time + && self.pth_cpu_usage == other.pth_cpu_usage + && self.pth_policy == other.pth_policy + && self.pth_run_state == other.pth_run_state + && self.pth_flags == other.pth_flags + && self.pth_sleep_time == other.pth_sleep_time + && self.pth_curpri == other.pth_curpri + && self.pth_priority == other.pth_priority + && self.pth_maxpriority == other.pth_maxpriority + && self.pth_name + .iter() + .zip(other.pth_name.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for proc_threadinfo {} + impl std::fmt::Debug for proc_threadinfo { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("proc_threadinfo") + .field("pth_user_time", &self.pth_user_time) + .field("pth_system_time", &self.pth_system_time) + .field("pth_cpu_usage", &self.pth_cpu_usage) + .field("pth_policy", &self.pth_policy) + .field("pth_run_state", &self.pth_run_state) + .field("pth_flags", &self.pth_flags) + .field("pth_sleep_time", &self.pth_sleep_time) + .field("pth_curpri", &self.pth_curpri) + .field("pth_priority", &self.pth_priority) + .field("pth_maxpriority", &self.pth_maxpriority) + // FIXME: .field("pth_name", &self.pth_name) + .finish() + } + } + + impl std::hash::Hash for proc_threadinfo { + fn hash(&self, state: &mut H) { + self.pth_user_time.hash(state); + self.pth_system_time.hash(state); + self.pth_cpu_usage.hash(state); + self.pth_policy.hash(state); + self.pth_run_state.hash(state); + self.pth_flags.hash(state); + self.pth_sleep_time.hash(state); + self.pth_curpri.hash(state); + self.pth_priority.hash(state); + self.pth_maxpriority.hash(state); + self.pth_name.hash(state); + } + } + + impl PartialEq for statfs { + fn eq(&self, other: &statfs) -> bool { + self.f_bsize == other.f_bsize + && self.f_iosize == other.f_iosize + && self.f_blocks == other.f_blocks + && self.f_bfree == other.f_bfree + && self.f_bavail == other.f_bavail + && self.f_files == other.f_files + && self.f_ffree == other.f_ffree + && self.f_fsid == other.f_fsid + && self.f_owner == other.f_owner + && self.f_flags == other.f_flags + && self.f_fssubtype == other.f_fssubtype + && self.f_fstypename == other.f_fstypename + && self.f_type == other.f_type + && self + .f_mntonname + .iter() + .zip(other.f_mntonname.iter()) + .all(|(a,b)| a == b) + && self + .f_mntfromname + .iter() + .zip(other.f_mntfromname.iter()) + .all(|(a,b)| a == b) + && self.f_reserved == other.f_reserved + } + } + + impl Eq for statfs {} + impl std::fmt::Debug for statfs { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("statfs") + .field("f_bsize", &self.f_bsize) + .field("f_iosize", &self.f_iosize) + .field("f_blocks", &self.f_blocks) + .field("f_bfree", &self.f_bfree) + .field("f_bavail", &self.f_bavail) + .field("f_files", &self.f_files) + .field("f_ffree", &self.f_ffree) + .field("f_fsid", &self.f_fsid) + .field("f_owner", &self.f_owner) + .field("f_flags", &self.f_flags) + .field("f_fssubtype", &self.f_fssubtype) + .field("f_fstypename", &self.f_fstypename) + .field("f_type", &self.f_type) + // FIXME: .field("f_mntonname", &self.f_mntonname) + // FIXME: .field("f_mntfromname", &self.f_mntfromname) + .field("f_reserved", &self.f_reserved) + .finish() + } + } + + impl std::hash::Hash for statfs { + fn hash(&self, state: &mut H) { + self.f_bsize.hash(state); + self.f_iosize.hash(state); + self.f_blocks.hash(state); + self.f_bfree.hash(state); + self.f_bavail.hash(state); + self.f_files.hash(state); + self.f_ffree.hash(state); + self.f_fsid.hash(state); + self.f_owner.hash(state); + self.f_flags.hash(state); + self.f_fssubtype.hash(state); + self.f_fstypename.hash(state); + self.f_type.hash(state); + self.f_mntonname.hash(state); + self.f_mntfromname.hash(state); + self.f_reserved.hash(state); + } + } + + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_ino == other.d_ino + && self.d_seekoff == other.d_seekoff + && self.d_reclen == other.d_reclen + && self.d_namlen == other.d_namlen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for dirent {} + impl std::fmt::Debug for dirent { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("dirent") + .field("d_ino", &self.d_ino) + .field("d_seekoff", &self.d_seekoff) + .field("d_reclen", &self.d_reclen) + .field("d_namlen", &self.d_namlen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + impl std::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_seekoff.hash(state); + self.d_reclen.hash(state); + self.d_namlen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } + } + impl PartialEq for pthread_rwlock_t { + fn eq(&self, other: &pthread_rwlock_t) -> bool { + self.__sig == other.__sig + && self. + __opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for pthread_rwlock_t {} + impl std::fmt::Debug for pthread_rwlock_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_rwlock_t") + .field("__sig", &self.__sig) + // FIXME: .field("__opaque", &self.__opaque) + .finish() + } + } + impl std::hash::Hash for pthread_rwlock_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } + } + + impl PartialEq for pthread_mutex_t { + fn eq(&self, other: &pthread_mutex_t) -> bool { + self.__sig == other.__sig + && self. + __opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for pthread_mutex_t {} + + impl std::fmt::Debug for pthread_mutex_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_mutex_t") + .field("__sig", &self.__sig) + // FIXME: .field("__opaque", &self.__opaque) + .finish() + } + } + + impl std::hash::Hash for pthread_mutex_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } + } + + impl PartialEq for pthread_cond_t { + fn eq(&self, other: &pthread_cond_t) -> bool { + self.__sig == other.__sig + && self. + __opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for pthread_cond_t {} + + impl std::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_cond_t") + .field("__sig", &self.__sig) + // FIXME: .field("__opaque", &self.__opaque) + .finish() + } + } + + impl std::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } + } + + impl PartialEq for sockaddr_storage { + fn eq(&self, other: &sockaddr_storage) -> bool { + self.ss_len == other.ss_len + && self.ss_family == other.ss_family + && self + .__ss_pad1 + .iter() + .zip(other.__ss_pad1.iter()) + .all(|(a, b)| a == b) + && self.__ss_align == other.__ss_align + && self + .__ss_pad2 + .iter() + .zip(other.__ss_pad2.iter()) + .all(|(a, b)| a == b) + } + } + + impl Eq for sockaddr_storage {} + + impl std::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("sockaddr_storage") + .field("ss_len", &self.ss_len) + .field("ss_family", &self.ss_family) + .field("__ss_pad1", &self.__ss_pad1) + .field("__ss_align", &self.__ss_align) + // FIXME: .field("__ss_pad2", &self.__ss_pad2) + .finish() + } + } + + impl std::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { + self.ss_len.hash(state); + self.ss_family.hash(state); + self.__ss_pad1.hash(state); + self.__ss_align.hash(state); + self.__ss_pad2.hash(state); + } + } + + impl PartialEq for utmpx { + fn eq(&self, other: &utmpx) -> bool { + self.ut_user + .iter() + .zip(other.ut_user.iter()) + .all(|(a,b)| a == b) + && self.ut_id == other.ut_id + && self.ut_line == other.ut_line + && self.ut_pid == other.ut_pid + && self.ut_type == other.ut_type + && self.ut_tv == other.ut_tv + && self + .ut_host + .iter() + .zip(other.ut_host.iter()) + .all(|(a,b)| a == b) + && self.ut_pad == other.ut_pad + } + } + + impl Eq for utmpx {} + + impl std::fmt::Debug for utmpx { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("utmpx") + // FIXME: .field("ut_user", &self.ut_user) + .field("ut_id", &self.ut_id) + .field("ut_line", &self.ut_line) + .field("ut_pid", &self.ut_pid) + .field("ut_type", &self.ut_type) + .field("ut_tv", &self.ut_tv) + // FIXME: .field("ut_host", &self.ut_host) + .field("ut_pad", &self.ut_pad) + .finish() + } + } + + impl std::hash::Hash for utmpx { + fn hash(&self, state: &mut H) { + self.ut_user.hash(state); + self.ut_id.hash(state); + self.ut_line.hash(state); + self.ut_pid.hash(state); + self.ut_type.hash(state); + self.ut_tv.hash(state); + self.ut_host.hash(state); + self.ut_pad.hash(state); + } + } } } diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 0541c5a005805..e3b3c7af83847 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -137,89 +137,92 @@ s_no_extra_traits!{ } -#[cfg(feature = "extra_traits")] -impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_len == other.sun_len - && self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for sockaddr_un {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for sockaddr_un { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("sockaddr_un") - .field("sun_len", &self.sun_len) - .field("sun_family", &self.sun_family) - // FIXME: .field("sun_path", &self.sun_path) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_len.hash(state); - self.sun_family.hash(state); - self.sun_path.hash(state); - } -} -#[cfg(feature = "extra_traits")] -impl PartialEq for utsname { - fn eq(&self, other: &utsname) -> bool { - self.sysname - .iter() - .zip(other.sysname.iter()) - .all(|(a,b)| a == b) - && self - .nodename - .iter() - .zip(other.nodename.iter()) - .all(|(a,b)| a == b) - && self - .release - .iter() - .zip(other.release.iter()) - .all(|(a,b)| a == b) - && self - .version - .iter() - .zip(other.version.iter()) - .all(|(a,b)| a == b) - && self - .machine - .iter() - .zip(other.machine.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for utsname {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for utsname { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("utsname") - // FIXME: .field("sysname", &self.sysname) - // FIXME: .field("nodename", &self.nodename) - // FIXME: .field("release", &self.release) - // FIXME: .field("version", &self.version) - // FIXME: .field("machine", &self.machine) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for utsname { - fn hash(&self, state: &mut H) { - self.sysname.hash(state); - self.nodename.hash(state); - self.release.hash(state); - self.version.hash(state); - self.machine.hash(state); +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for sockaddr_un { + fn eq(&self, other: &sockaddr_un) -> bool { + self.sun_len == other.sun_len + && self.sun_family == other.sun_family + && self + .sun_path + .iter() + .zip(other.sun_path.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for sockaddr_un {} + + impl std::fmt::Debug for sockaddr_un { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("sockaddr_un") + .field("sun_len", &self.sun_len) + .field("sun_family", &self.sun_family) + // FIXME: .field("sun_path", &self.sun_path) + .finish() + } + } + + impl std::hash::Hash for sockaddr_un { + fn hash(&self, state: &mut H) { + self.sun_len.hash(state); + self.sun_family.hash(state); + self.sun_path.hash(state); + } + } + + impl PartialEq for utsname { + fn eq(&self, other: &utsname) -> bool { + self.sysname + .iter() + .zip(other.sysname.iter()) + .all(|(a,b)| a == b) + && self + .nodename + .iter() + .zip(other.nodename.iter()) + .all(|(a,b)| a == b) + && self + .release + .iter() + .zip(other.release.iter()) + .all(|(a,b)| a == b) + && self + .version + .iter() + .zip(other.version.iter()) + .all(|(a,b)| a == b) + && self + .machine + .iter() + .zip(other.machine.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for utsname {} + + impl std::fmt::Debug for utsname { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("utsname") + // FIXME: .field("sysname", &self.sysname) + // FIXME: .field("nodename", &self.nodename) + // FIXME: .field("release", &self.release) + // FIXME: .field("version", &self.version) + // FIXME: .field("machine", &self.machine) + .finish() + } + } + + impl std::hash::Hash for utsname { + fn hash(&self, state: &mut H) { + self.sysname.hash(state); + self.nodename.hash(state); + self.release.hash(state); + self.version.hash(state); + self.machine.hash(state); + } + } } } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index d4df5f32844ac..e048f719777d4 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -1169,7 +1169,7 @@ cfg_if! { } cfg_if! { - if #[cfg(core_cvoid)] { + if #[cfg(libc_core_cvoid)] { pub use core::ffi::c_void; } else { // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help @@ -1177,6 +1177,7 @@ cfg_if! { // like malloc/free. #[repr(u8)] #[allow(missing_copy_implementations)] + #[allow(missing_debug_implementations)] pub enum c_void { // Two dummy variants so the #[repr] attribute can be used. #[doc(hidden)] diff --git a/src/unix/notbsd/android/b64/mod.rs b/src/unix/notbsd/android/b64/mod.rs index 1da667bccc0c2..824bd580d4fcc 100644 --- a/src/unix/notbsd/android/b64/mod.rs +++ b/src/unix/notbsd/android/b64/mod.rs @@ -127,103 +127,107 @@ s_no_extra_traits!{ __reserved: [::c_char; 36], } } -#[cfg(feature = "extra_traits")] -impl PartialEq for pthread_mutex_t { - fn eq(&self, other: &pthread_mutex_t) -> bool { - self.value == other.value - && self - .__reserved - .iter() - .zip(other.__reserved.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for pthread_mutex_t {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for pthread_mutex_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("pthread_mutex_t") - .field("value", &self.value) - // FIXME: .field("__reserved", &self.__reserved) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { - self.value.hash(state); - self.__reserved.hash(state); - } -} -#[cfg(feature = "extra_traits")] -impl PartialEq for pthread_cond_t { - fn eq(&self, other: &pthread_cond_t) -> bool { - self.value == other.value - && self - .__reserved - .iter() - .zip(other.__reserved.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for pthread_cond_t {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for pthread_cond_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("pthread_cond_t") - .field("value", &self.value) - // FIXME: .field("__reserved", &self.__reserved) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { - self.value.hash(state); - self.__reserved.hash(state); - } -} -#[cfg(feature = "extra_traits")] -impl PartialEq for pthread_rwlock_t { - fn eq(&self, other: &pthread_rwlock_t) -> bool { - self.numLocks == other.numLocks - && self.writerThreadId == other.writerThreadId - && self.pendingReaders == other.pendingReaders - && self.pendingWriters == other.pendingWriters - && self.attr == other.attr - && self - .__reserved - .iter() - .zip(other.__reserved.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for pthread_rwlock_t {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for pthread_rwlock_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("pthread_rwlock_t") - .field("numLocks", &self.numLocks) - .field("writerThreadId", &self.writerThreadId) - .field("pendingReaders", &self.pendingReaders) - .field("pendingWriters", &self.pendingWriters) - .field("attr", &self.attr) - // FIXME: .field("__reserved", &self.__reserved) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { - self.numLocks.hash(state); - self.writerThreadId.hash(state); - self.pendingReaders.hash(state); - self.pendingWriters.hash(state); - self.attr.hash(state); - self.__reserved.hash(state); + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for pthread_mutex_t { + fn eq(&self, other: &pthread_mutex_t) -> bool { + self.value == other.value + && self + .__reserved + .iter() + .zip(other.__reserved.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for pthread_mutex_t {} + + impl std::fmt::Debug for pthread_mutex_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_mutex_t") + .field("value", &self.value) + // FIXME: .field("__reserved", &self.__reserved) + .finish() + } + } + + impl std::hash::Hash for pthread_mutex_t { + fn hash(&self, state: &mut H) { + self.value.hash(state); + self.__reserved.hash(state); + } + } + + impl PartialEq for pthread_cond_t { + fn eq(&self, other: &pthread_cond_t) -> bool { + self.value == other.value + && self + .__reserved + .iter() + .zip(other.__reserved.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for pthread_cond_t {} + + impl std::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_cond_t") + .field("value", &self.value) + // FIXME: .field("__reserved", &self.__reserved) + .finish() + } + } + + impl std::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { + self.value.hash(state); + self.__reserved.hash(state); + } + } + + impl PartialEq for pthread_rwlock_t { + fn eq(&self, other: &pthread_rwlock_t) -> bool { + self.numLocks == other.numLocks + && self.writerThreadId == other.writerThreadId + && self.pendingReaders == other.pendingReaders + && self.pendingWriters == other.pendingWriters + && self.attr == other.attr + && self + .__reserved + .iter() + .zip(other.__reserved.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for pthread_rwlock_t {} + + impl std::fmt::Debug for pthread_rwlock_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_rwlock_t") + .field("numLocks", &self.numLocks) + .field("writerThreadId", &self.writerThreadId) + .field("pendingReaders", &self.pendingReaders) + .field("pendingWriters", &self.pendingWriters) + .field("attr", &self.attr) + // FIXME: .field("__reserved", &self.__reserved) + .finish() + } + } + + impl std::hash::Hash for pthread_rwlock_t { + fn hash(&self, state: &mut H) { + self.numLocks.hash(state); + self.writerThreadId.hash(state); + self.pendingReaders.hash(state); + self.pendingWriters.hash(state); + self.attr.hash(state); + self.__reserved.hash(state); + } + } } } diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index f768ce1283e0e..a872e8b111e6b 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -240,214 +240,217 @@ s_no_extra_traits!{ } } -#[cfg(feature = "extra_traits")] -impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for dirent {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for dirent { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("dirent") - .field("d_ino", &self.d_ino) - .field("d_off", &self.d_off) - .field("d_reclen", &self.d_reclen) - .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } -} -#[cfg(feature = "extra_traits")] -impl PartialEq for dirent64 { - fn eq(&self, other: &dirent64) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for dirent64 {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for dirent64 { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("dirent64") - .field("d_ino", &self.d_ino) - .field("d_off", &self.d_off) - .field("d_reclen", &self.d_reclen) - .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for dirent64 { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } -} -#[cfg(feature = "extra_traits")] -impl PartialEq for siginfo_t { - fn eq(&self, other: &siginfo_t) -> bool { - self.si_signo == other.si_signo - && self.si_errno == other.si_errno - && self.si_code == other.si_code - // Ignore _pad - // Ignore _align - } -} -#[cfg(feature = "extra_traits")] -impl Eq for siginfo_t {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for siginfo_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("siginfo_t") - .field("si_signo", &self.si_signo) - .field("si_errno", &self.si_errno) - .field("si_code", &self.si_code) - // Ignore _pad - // Ignore _align - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for siginfo_t { - fn hash(&self, state: &mut H) { - self.si_signo.hash(state); - self.si_errno.hash(state); - self.si_code.hash(state); - // Ignore _pad - // Ignore _align - } -} -#[cfg(feature = "extra_traits")] -impl PartialEq for lastlog { - fn eq(&self, other: &lastlog) -> bool { - self.ll_time == other.ll_time - && self - .ll_line - .iter() - .zip(other.ll_line.iter()) - .all(|(a,b)| a == b) - && self - .ll_host - .iter() - .zip(other.ll_host.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for lastlog {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for lastlog { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("lastlog") - .field("ll_time", &self.ll_time) - .field("ll_line", &self.ll_line) - // FIXME: .field("ll_host", &self.ll_host) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for lastlog { - fn hash(&self, state: &mut H) { - self.ll_time.hash(state); - self.ll_line.hash(state); - self.ll_host.hash(state); - } -} -#[cfg(feature = "extra_traits")] -impl PartialEq for utmp { - fn eq(&self, other: &utmp) -> bool { - self.ut_type == other.ut_type - && self.ut_pid == other.ut_pid - && self - .ut_line - .iter() - .zip(other.ut_line.iter()) - .all(|(a,b)| a == b) - && self.ut_id == other.ut_id - && self - .ut_user - .iter() - .zip(other.ut_user.iter()) - .all(|(a,b)| a == b) - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a,b)| a == b) - && self.ut_exit == other.ut_exit - && self.ut_session == other.ut_session - && self.ut_tv == other.ut_tv - && self.ut_addr_v6 == other.ut_addr_v6 - && self.unused == other.unused - } -} -#[cfg(feature = "extra_traits")] -impl Eq for utmp {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for utmp { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("utmp") - .field("ut_type", &self.ut_type) - .field("ut_pid", &self.ut_pid) - .field("ut_line", &self.ut_line) - .field("ut_id", &self.ut_id) - .field("ut_user", &self.ut_user) - // FIXME: .field("ut_host", &self.ut_host) - .field("ut_exit", &self.ut_exit) - .field("ut_session", &self.ut_session) - .field("ut_tv", &self.ut_tv) - .field("ut_addr_v6", &self.ut_addr_v6) - .field("unused", &self.unused) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for utmp { - fn hash(&self, state: &mut H) { - self.ut_type.hash(state); - self.ut_pid.hash(state); - self.ut_line.hash(state); - self.ut_id.hash(state); - self.ut_user.hash(state); - self.ut_host.hash(state); - self.ut_exit.hash(state); - self.ut_session.hash(state); - self.ut_tv.hash(state); - self.ut_addr_v6.hash(state); - self.unused.hash(state); +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_ino == other.d_ino + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for dirent {} + + impl std::fmt::Debug for dirent { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("dirent") + .field("d_ino", &self.d_ino) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + + impl std::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } + } + + impl PartialEq for dirent64 { + fn eq(&self, other: &dirent64) -> bool { + self.d_ino == other.d_ino + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for dirent64 {} + + impl std::fmt::Debug for dirent64 { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("dirent64") + .field("d_ino", &self.d_ino) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + + impl std::hash::Hash for dirent64 { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } + } + + impl PartialEq for siginfo_t { + fn eq(&self, other: &siginfo_t) -> bool { + self.si_signo == other.si_signo + && self.si_errno == other.si_errno + && self.si_code == other.si_code + // Ignore _pad + // Ignore _align + } + } + + impl Eq for siginfo_t {} + + impl std::fmt::Debug for siginfo_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("siginfo_t") + .field("si_signo", &self.si_signo) + .field("si_errno", &self.si_errno) + .field("si_code", &self.si_code) + // Ignore _pad + // Ignore _align + .finish() + } + } + + impl std::hash::Hash for siginfo_t { + fn hash(&self, state: &mut H) { + self.si_signo.hash(state); + self.si_errno.hash(state); + self.si_code.hash(state); + // Ignore _pad + // Ignore _align + } + } + + impl PartialEq for lastlog { + fn eq(&self, other: &lastlog) -> bool { + self.ll_time == other.ll_time + && self + .ll_line + .iter() + .zip(other.ll_line.iter()) + .all(|(a,b)| a == b) + && self + .ll_host + .iter() + .zip(other.ll_host.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for lastlog {} + + impl std::fmt::Debug for lastlog { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("lastlog") + .field("ll_time", &self.ll_time) + .field("ll_line", &self.ll_line) + // FIXME: .field("ll_host", &self.ll_host) + .finish() + } + } + + impl std::hash::Hash for lastlog { + fn hash(&self, state: &mut H) { + self.ll_time.hash(state); + self.ll_line.hash(state); + self.ll_host.hash(state); + } + } + + impl PartialEq for utmp { + fn eq(&self, other: &utmp) -> bool { + self.ut_type == other.ut_type + && self.ut_pid == other.ut_pid + && self + .ut_line + .iter() + .zip(other.ut_line.iter()) + .all(|(a,b)| a == b) + && self.ut_id == other.ut_id + && self + .ut_user + .iter() + .zip(other.ut_user.iter()) + .all(|(a,b)| a == b) + && self + .ut_host + .iter() + .zip(other.ut_host.iter()) + .all(|(a,b)| a == b) + && self.ut_exit == other.ut_exit + && self.ut_session == other.ut_session + && self.ut_tv == other.ut_tv + && self.ut_addr_v6 == other.ut_addr_v6 + && self.unused == other.unused + } + } + + impl Eq for utmp {} + + impl std::fmt::Debug for utmp { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("utmp") + .field("ut_type", &self.ut_type) + .field("ut_pid", &self.ut_pid) + .field("ut_line", &self.ut_line) + .field("ut_id", &self.ut_id) + .field("ut_user", &self.ut_user) + // FIXME: .field("ut_host", &self.ut_host) + .field("ut_exit", &self.ut_exit) + .field("ut_session", &self.ut_session) + .field("ut_tv", &self.ut_tv) + .field("ut_addr_v6", &self.ut_addr_v6) + .field("unused", &self.unused) + .finish() + } + } + + impl std::hash::Hash for utmp { + fn hash(&self, state: &mut H) { + self.ut_type.hash(state); + self.ut_pid.hash(state); + self.ut_line.hash(state); + self.ut_id.hash(state); + self.ut_user.hash(state); + self.ut_host.hash(state); + self.ut_exit.hash(state); + self.ut_session.hash(state); + self.ut_tv.hash(state); + self.ut_addr_v6.hash(state); + self.unused.hash(state); + } + } } } diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 0d266a602d395..af92aea9d73b0 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -79,13 +79,13 @@ s! { all(target_arch = "aarch64", target_env = "musl")))), repr(align(8)))] pub struct pthread_mutexattr_t { - #[cfg(all(not(features = "align"), + #[cfg(all(not(libc_align), any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64", all(target_arch = "aarch64", target_env = "musl"))))] __align: [::c_int; 0], - #[cfg(all(not(features = "align"), + #[cfg(all(not(libc_align), not(any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64", @@ -671,150 +671,153 @@ s_no_extra_traits!{ } } -#[cfg(feature = "extra_traits")] -impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for dirent {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for dirent { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("dirent") - .field("d_ino", &self.d_ino) - .field("d_off", &self.d_off) - .field("d_reclen", &self.d_reclen) - .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } -} +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_ino == other.d_ino + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } -#[cfg(feature = "extra_traits")] -impl PartialEq for dirent64 { - fn eq(&self, other: &dirent64) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for dirent64 {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for dirent64 { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("dirent64") - .field("d_ino", &self.d_ino) - .field("d_off", &self.d_off) - .field("d_reclen", &self.d_reclen) - .field("d_type", &self.d_type) - // FIXME: .field("d_name", &self.d_name) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for dirent64 { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } -} + impl Eq for dirent {} + + impl std::fmt::Debug for dirent { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("dirent") + .field("d_ino", &self.d_ino) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } -#[cfg(feature = "extra_traits")] -impl PartialEq for pthread_cond_t { - fn eq(&self, other: &pthread_cond_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for pthread_cond_t {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for pthread_cond_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("pthread_cond_t") - // FIXME: .field("size", &self.size) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } -} + impl std::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } + } -#[cfg(feature = "extra_traits")] -impl PartialEq for pthread_mutex_t { - fn eq(&self, other: &pthread_mutex_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for pthread_mutex_t {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for pthread_mutex_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("pthread_mutex_t") - // FIXME: .field("size", &self.size) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } -} -#[cfg(feature = "extra_traits")] -impl PartialEq for pthread_rwlock_t { - fn eq(&self, other: &pthread_rwlock_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for pthread_rwlock_t {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for pthread_rwlock_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("pthread_rwlock_t") - // FIXME: .field("size", &self.size) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); + impl PartialEq for dirent64 { + fn eq(&self, other: &dirent64) -> bool { + self.d_ino == other.d_ino + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self + .d_name + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for dirent64 {} + + impl std::fmt::Debug for dirent64 { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("dirent64") + .field("d_ino", &self.d_ino) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + // FIXME: .field("d_name", &self.d_name) + .finish() + } + } + + impl std::hash::Hash for dirent64 { + fn hash(&self, state: &mut H) { + self.d_ino.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_name.hash(state); + } + } + + + impl PartialEq for pthread_cond_t { + fn eq(&self, other: &pthread_cond_t) -> bool { + self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b) + } + } + + impl Eq for pthread_cond_t {} + + impl std::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_cond_t") + // FIXME: .field("size", &self.size) + .finish() + } + } + + impl std::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { + self.size.hash(state); + } + } + + + impl PartialEq for pthread_mutex_t { + fn eq(&self, other: &pthread_mutex_t) -> bool { + self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b) + } + } + + impl Eq for pthread_mutex_t {} + + impl std::fmt::Debug for pthread_mutex_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_mutex_t") + // FIXME: .field("size", &self.size) + .finish() + } + } + + impl std::hash::Hash for pthread_mutex_t { + fn hash(&self, state: &mut H) { + self.size.hash(state); + } + } + + + impl PartialEq for pthread_rwlock_t { + fn eq(&self, other: &pthread_rwlock_t) -> bool { + self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b) + } + } + + impl Eq for pthread_rwlock_t {} + + impl std::fmt::Debug for pthread_rwlock_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("pthread_rwlock_t") + // FIXME: .field("size", &self.size) + .finish() + } + } + + impl std::hash::Hash for pthread_rwlock_t { + fn hash(&self, state: &mut H) { + self.size.hash(state); + } + } } } diff --git a/src/unix/notbsd/linux/musl/b32/x86.rs b/src/unix/notbsd/linux/musl/b32/x86.rs index 42ff2a2847e27..81cea985433cf 100644 --- a/src/unix/notbsd/linux/musl/b32/x86.rs +++ b/src/unix/notbsd/linux/musl/b32/x86.rs @@ -177,45 +177,49 @@ s_no_extra_traits!{ __private: [u8; 112], } } -#[cfg(feature = "extra_traits")] -impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask == other.uc_sigmask - && self - .__private - .iter() - .zip(other.__private.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for ucontext_t {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ucontext_t") - .field("uc_flags", &self.uc_flags) - .field("uc_link", &self.uc_link) - .field("uc_stack", &self.uc_stack) - .field("uc_mcontext", &self.uc_mcontext) - .field("uc_sigmask", &self.uc_sigmask) - // Ignore __private field - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask.hash(state); - self.__private.hash(state); + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for ucontext_t { + fn eq(&self, other: &ucontext_t) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask == other.uc_sigmask + && self + .__private + .iter() + .zip(other.__private.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for ucontext_t {} + + impl std::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_flags) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_sigmask", &self.uc_sigmask) + // Ignore __private field + .finish() + } + } + + impl std::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask.hash(state); + self.__private.hash(state); + } + } } } diff --git a/src/unix/notbsd/linux/musl/b64/x86_64.rs b/src/unix/notbsd/linux/musl/b64/x86_64.rs index 8462a4f635876..49b03eb228ed2 100644 --- a/src/unix/notbsd/linux/musl/b64/x86_64.rs +++ b/src/unix/notbsd/linux/musl/b64/x86_64.rs @@ -75,45 +75,48 @@ s_no_extra_traits!{ } } -#[cfg(feature = "extra_traits")] -impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask == other.uc_sigmask - && self - .__private - .iter() - .zip(other.__private.iter()) - .all(|(a,b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for ucontext_t {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ucontext_t") - .field("uc_flags", &self.uc_flags) - .field("uc_link", &self.uc_link) - .field("uc_stack", &self.uc_stack) - .field("uc_mcontext", &self.uc_mcontext) - .field("uc_sigmask", &self.uc_sigmask) - // Ignore __private field - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask.hash(state); - self.__private.hash(state); +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for ucontext_t { + fn eq(&self, other: &ucontext_t) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask == other.uc_sigmask + && self + .__private + .iter() + .zip(other.__private.iter()) + .all(|(a,b)| a == b) + } + } + + impl Eq for ucontext_t {} + + impl std::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_flags) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_sigmask", &self.uc_sigmask) + // Ignore __private field + .finish() + } + } + + impl std::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask.hash(state); + self.__private.hash(state); + } + } } } diff --git a/src/unix/notbsd/linux/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs index b3ab650277187..7bf7410dbe182 100644 --- a/src/unix/notbsd/linux/musl/mod.rs +++ b/src/unix/notbsd/linux/musl/mod.rs @@ -99,65 +99,68 @@ s_no_extra_traits!{ } } -#[cfg(feature = "extra_traits")] -impl PartialEq for sysinfo { - fn eq(&self, other: &sysinfo) -> bool { - self.uptime == other.uptime - && self.loads == other.loads - && self.totalram == other.totalram - && self.freeram == other.freeram - && self.sharedram == other.sharedram - && self.bufferram == other.bufferram - && self.totalswap == other.totalswap - && self.freeswap == other.freeswap - && self.procs == other.procs - && self.pad == other.pad - && self.totalhigh == other.totalhigh - && self.freehigh == other.freehigh - && self.mem_unit == other.mem_unit - // Ignore __reserved field - } -} -#[cfg(feature = "extra_traits")] -impl Eq for sysinfo {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for sysinfo { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("sysinfo") - .field("uptime", &self.uptime) - .field("loads", &self.loads) - .field("totalram", &self.totalram) - .field("freeram", &self.freeram) - .field("sharedram", &self.sharedram) - .field("bufferram", &self.bufferram) - .field("totalswap", &self.totalswap) - .field("freeswap", &self.freeswap) - .field("procs", &self.procs) - .field("pad", &self.pad) - .field("totalhigh", &self.totalhigh) - .field("freehigh", &self.freehigh) - .field("mem_unit", &self.mem_unit) - // FIXME: .field("__reserved", &self.__reserved) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for sysinfo { - fn hash(&self, state: &mut H) { - self.uptime.hash(state); - self.loads.hash(state); - self.totalram.hash(state); - self.freeram.hash(state); - self.sharedram.hash(state); - self.bufferram.hash(state); - self.totalswap.hash(state); - self.freeswap.hash(state); - self.procs.hash(state); - self.pad.hash(state); - self.totalhigh.hash(state); - self.freehigh.hash(state); - self.mem_unit.hash(state); - self.__reserved.hash(state); +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for sysinfo { + fn eq(&self, other: &sysinfo) -> bool { + self.uptime == other.uptime + && self.loads == other.loads + && self.totalram == other.totalram + && self.freeram == other.freeram + && self.sharedram == other.sharedram + && self.bufferram == other.bufferram + && self.totalswap == other.totalswap + && self.freeswap == other.freeswap + && self.procs == other.procs + && self.pad == other.pad + && self.totalhigh == other.totalhigh + && self.freehigh == other.freehigh + && self.mem_unit == other.mem_unit + // Ignore __reserved field + } + } + + impl Eq for sysinfo {} + + impl std::fmt::Debug for sysinfo { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("sysinfo") + .field("uptime", &self.uptime) + .field("loads", &self.loads) + .field("totalram", &self.totalram) + .field("freeram", &self.freeram) + .field("sharedram", &self.sharedram) + .field("bufferram", &self.bufferram) + .field("totalswap", &self.totalswap) + .field("freeswap", &self.freeswap) + .field("procs", &self.procs) + .field("pad", &self.pad) + .field("totalhigh", &self.totalhigh) + .field("freehigh", &self.freehigh) + .field("mem_unit", &self.mem_unit) + // FIXME: .field("__reserved", &self.__reserved) + .finish() + } + } + + impl std::hash::Hash for sysinfo { + fn hash(&self, state: &mut H) { + self.uptime.hash(state); + self.loads.hash(state); + self.totalram.hash(state); + self.freeram.hash(state); + self.sharedram.hash(state); + self.bufferram.hash(state); + self.totalswap.hash(state); + self.freeswap.hash(state); + self.procs.hash(state); + self.pad.hash(state); + self.totalhigh.hash(state); + self.freehigh.hash(state); + self.mem_unit.hash(state); + self.__reserved.hash(state); + } + } } } diff --git a/src/unix/notbsd/linux/other/b32/x86.rs b/src/unix/notbsd/linux/other/b32/x86.rs index fb48982162a34..6218a6ac675fb 100644 --- a/src/unix/notbsd/linux/other/b32/x86.rs +++ b/src/unix/notbsd/linux/other/b32/x86.rs @@ -215,99 +215,102 @@ s_no_extra_traits!{ } } -#[cfg(feature = "extra_traits")] -impl PartialEq for user_fpxregs_struct { - fn eq(&self, other: &user_fpxregs_struct) -> bool { - self.cwd == other.cwd - && self.swd == other.swd - && self.twd == other.twd - && self.fop == other.fop - && self.fip == other.fip - && self.fcs == other.fcs - && self.foo == other.foo - && self.fos == other.fos - && self.mxcsr == other.mxcsr - // Ignore __reserved field - && self.st_space == other.st_space - && self.xmm_space == other.xmm_space - // Ignore padding field - } -} -#[cfg(feature = "extra_traits")] -impl Eq for user_fpxregs_struct {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for user_fpxregs_struct { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("user_fpxregs_struct") - .field("cwd", &self.cwd) - .field("swd", &self.swd) - .field("twd", &self.twd) - .field("fop", &self.fop) - .field("fip", &self.fip) - .field("fcs", &self.fcs) - .field("foo", &self.foo) - .field("fos", &self.fos) - .field("mxcsr", &self.mxcsr) - // Ignore __reserved field - .field("st_space", &self.st_space) - .field("xmm_space", &self.xmm_space) - // Ignore padding field - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for user_fpxregs_struct { - fn hash(&self, state: &mut H) { - self.cwd.hash(state); - self.swd.hash(state); - self.twd.hash(state); - self.fop.hash(state); - self.fip.hash(state); - self.fcs.hash(state); - self.foo.hash(state); - self.fos.hash(state); - self.mxcsr.hash(state); - // Ignore __reserved field - self.st_space.hash(state); - self.xmm_space.hash(state); - // Ignore padding field - } -} -#[cfg(feature = "extra_traits")] -impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask == other.uc_sigmask - // Ignore __private field - } -} -#[cfg(feature = "extra_traits")] -impl Eq for ucontext_t {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ucontext_t") - .field("uc_flags", &self.uc_flags) - .field("uc_link", &self.uc_link) - .field("uc_stack", &self.uc_stack) - .field("uc_mcontext", &self.uc_mcontext) - .field("uc_sigmask", &self.uc_sigmask) - // Ignore __private field - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask.hash(state); - // Ignore __private field +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for user_fpxregs_struct { + fn eq(&self, other: &user_fpxregs_struct) -> bool { + self.cwd == other.cwd + && self.swd == other.swd + && self.twd == other.twd + && self.fop == other.fop + && self.fip == other.fip + && self.fcs == other.fcs + && self.foo == other.foo + && self.fos == other.fos + && self.mxcsr == other.mxcsr + // Ignore __reserved field + && self.st_space == other.st_space + && self.xmm_space == other.xmm_space + // Ignore padding field + } + } + + impl Eq for user_fpxregs_struct {} + + impl std::fmt::Debug for user_fpxregs_struct { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("user_fpxregs_struct") + .field("cwd", &self.cwd) + .field("swd", &self.swd) + .field("twd", &self.twd) + .field("fop", &self.fop) + .field("fip", &self.fip) + .field("fcs", &self.fcs) + .field("foo", &self.foo) + .field("fos", &self.fos) + .field("mxcsr", &self.mxcsr) + // Ignore __reserved field + .field("st_space", &self.st_space) + .field("xmm_space", &self.xmm_space) + // Ignore padding field + .finish() + } + } + + impl std::hash::Hash for user_fpxregs_struct { + fn hash(&self, state: &mut H) { + self.cwd.hash(state); + self.swd.hash(state); + self.twd.hash(state); + self.fop.hash(state); + self.fip.hash(state); + self.fcs.hash(state); + self.foo.hash(state); + self.fos.hash(state); + self.mxcsr.hash(state); + // Ignore __reserved field + self.st_space.hash(state); + self.xmm_space.hash(state); + // Ignore padding field + } + } + + impl PartialEq for ucontext_t { + fn eq(&self, other: &ucontext_t) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask == other.uc_sigmask + // Ignore __private field + } + } + + impl Eq for ucontext_t {} + + impl std::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_flags) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_sigmask", &self.uc_sigmask) + // Ignore __private field + .finish() + } + } + + impl std::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask.hash(state); + // Ignore __private field + } + } } } diff --git a/src/unix/notbsd/linux/other/b64/x86_64.rs b/src/unix/notbsd/linux/other/b64/x86_64.rs index b2a67ee9aab79..2e42e591034bb 100644 --- a/src/unix/notbsd/linux/other/b64/x86_64.rs +++ b/src/unix/notbsd/linux/other/b64/x86_64.rs @@ -234,96 +234,99 @@ s_no_extra_traits! { } } -#[cfg(feature = "extra_traits")] -impl PartialEq for user_fpregs_struct { - fn eq(&self, other: &user_fpregs_struct) -> bool { - self.cwd == other.cwd - && self.swd == other.swd - && self.ftw == other.ftw - && self.fop == other.fop - && self.rip == other.rip - && self.rdp == other.rdp - && self.mxcsr == other.mxcsr - && self.mxcr_mask == other.mxcr_mask - && self.st_space == other.st_space - && self - .xmm_space - .iter() - .zip(other.xmm_space.iter()) - .all(|(a,b)| a == b) +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for user_fpregs_struct { + fn eq(&self, other: &user_fpregs_struct) -> bool { + self.cwd == other.cwd + && self.swd == other.swd + && self.ftw == other.ftw + && self.fop == other.fop + && self.rip == other.rip + && self.rdp == other.rdp + && self.mxcsr == other.mxcsr + && self.mxcr_mask == other.mxcr_mask + && self.st_space == other.st_space + && self + .xmm_space + .iter() + .zip(other.xmm_space.iter()) + .all(|(a,b)| a == b) // Ignore padding field - } -} -#[cfg(feature = "extra_traits")] -impl Eq for user_fpregs_struct {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for user_fpregs_struct { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("user_fpregs_struct") - .field("cwd", &self.cwd) - .field("ftw", &self.ftw) - .field("fop", &self.fop) - .field("rip", &self.rip) - .field("rdp", &self.rdp) - .field("mxcsr", &self.mxcsr) - .field("mxcr_mask", &self.mxcr_mask) - .field("st_space", &self.st_space) - // FIXME: .field("xmm_space", &self.xmm_space) - // Ignore padding field - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for user_fpregs_struct { - fn hash(&self, state: &mut H) { - self.cwd.hash(state); - self.ftw.hash(state); - self.fop.hash(state); - self.rip.hash(state); - self.rdp.hash(state); - self.mxcsr.hash(state); - self.mxcr_mask.hash(state); - self.st_space.hash(state); - self.xmm_space.hash(state); - // Ignore padding field - } -} - -#[cfg(feature = "extra_traits")] -impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask == other.uc_sigmask - // Ignore __private field - } -} -#[cfg(feature = "extra_traits")] -impl Eq for ucontext_t {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("ucontext_t") - .field("uc_flags", &self.uc_flags) - .field("uc_link", &self.uc_link) - .field("uc_stack", &self.uc_stack) - .field("uc_mcontext", &self.uc_mcontext) - .field("uc_sigmask", &self.uc_sigmask) - // Ignore __private field - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask.hash(state); - // Ignore __private field + } + } + + impl Eq for user_fpregs_struct {} + + impl std::fmt::Debug for user_fpregs_struct { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("user_fpregs_struct") + .field("cwd", &self.cwd) + .field("ftw", &self.ftw) + .field("fop", &self.fop) + .field("rip", &self.rip) + .field("rdp", &self.rdp) + .field("mxcsr", &self.mxcsr) + .field("mxcr_mask", &self.mxcr_mask) + .field("st_space", &self.st_space) + // FIXME: .field("xmm_space", &self.xmm_space) + // Ignore padding field + .finish() + } + } + + impl std::hash::Hash for user_fpregs_struct { + fn hash(&self, state: &mut H) { + self.cwd.hash(state); + self.ftw.hash(state); + self.fop.hash(state); + self.rip.hash(state); + self.rdp.hash(state); + self.mxcsr.hash(state); + self.mxcr_mask.hash(state); + self.st_space.hash(state); + self.xmm_space.hash(state); + // Ignore padding field + } + } + + + impl PartialEq for ucontext_t { + fn eq(&self, other: &ucontext_t) -> bool { + self.uc_flags == other.uc_flags + && self.uc_link == other.uc_link + && self.uc_stack == other.uc_stack + && self.uc_mcontext == other.uc_mcontext + && self.uc_sigmask == other.uc_sigmask + // Ignore __private field + } + } + + impl Eq for ucontext_t {} + + impl std::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_flags", &self.uc_flags) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_sigmask", &self.uc_sigmask) + // Ignore __private field + .finish() + } + } + + impl std::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { + self.uc_flags.hash(state); + self.uc_link.hash(state); + self.uc_stack.hash(state); + self.uc_mcontext.hash(state); + self.uc_sigmask.hash(state); + // Ignore __private field + } + } } } diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index 4202a0e792489..d30ffff3baf1a 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -246,60 +246,63 @@ s_no_extra_traits! { } } -#[cfg(feature = "extra_traits")] -impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_type == other.ut_type - && self.ut_pid == other.ut_pid - && self.ut_line == other.ut_line - && self.ut_id == other.ut_id - && self.ut_user == other.ut_user - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a,b)| a == b) - && self.ut_exit == other.ut_exit - && self.ut_session == other.ut_session - && self.ut_tv == other.ut_tv - && self.ut_addr_v6 == other.ut_addr_v6 - && self.__glibc_reserved == other.__glibc_reserved - } -} -#[cfg(feature = "extra_traits")] -impl Eq for utmpx {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for utmpx { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("utmpx") - .field("ut_type", &self.ut_type) - .field("ut_pid", &self.ut_pid) - .field("ut_line", &self.ut_line) - .field("ut_id", &self.ut_id) - .field("ut_user", &self.ut_user) - // FIXME: .field("ut_host", &self.ut_host) - .field("ut_exit", &self.ut_exit) - .field("ut_session", &self.ut_session) - .field("ut_tv", &self.ut_tv) - .field("ut_addr_v6", &self.ut_addr_v6) - .field("__glibc_reserved", &self.__glibc_reserved) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_type.hash(state); - self.ut_pid.hash(state); - self.ut_line.hash(state); - self.ut_id.hash(state); - self.ut_user.hash(state); - self.ut_host.hash(state); - self.ut_exit.hash(state); - self.ut_session.hash(state); - self.ut_tv.hash(state); - self.ut_addr_v6.hash(state); - self.__glibc_reserved.hash(state); +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for utmpx { + fn eq(&self, other: &utmpx) -> bool { + self.ut_type == other.ut_type + && self.ut_pid == other.ut_pid + && self.ut_line == other.ut_line + && self.ut_id == other.ut_id + && self.ut_user == other.ut_user + && self + .ut_host + .iter() + .zip(other.ut_host.iter()) + .all(|(a,b)| a == b) + && self.ut_exit == other.ut_exit + && self.ut_session == other.ut_session + && self.ut_tv == other.ut_tv + && self.ut_addr_v6 == other.ut_addr_v6 + && self.__glibc_reserved == other.__glibc_reserved + } + } + + impl Eq for utmpx {} + + impl std::fmt::Debug for utmpx { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("utmpx") + .field("ut_type", &self.ut_type) + .field("ut_pid", &self.ut_pid) + .field("ut_line", &self.ut_line) + .field("ut_id", &self.ut_id) + .field("ut_user", &self.ut_user) + // FIXME: .field("ut_host", &self.ut_host) + .field("ut_exit", &self.ut_exit) + .field("ut_session", &self.ut_session) + .field("ut_tv", &self.ut_tv) + .field("ut_addr_v6", &self.ut_addr_v6) + .field("__glibc_reserved", &self.__glibc_reserved) + .finish() + } + } + + impl std::hash::Hash for utmpx { + fn hash(&self, state: &mut H) { + self.ut_type.hash(state); + self.ut_pid.hash(state); + self.ut_line.hash(state); + self.ut_id.hash(state); + self.ut_user.hash(state); + self.ut_host.hash(state); + self.ut_exit.hash(state); + self.ut_session.hash(state); + self.ut_tv.hash(state); + self.ut_addr_v6.hash(state); + self.__glibc_reserved.hash(state); + } + } } } diff --git a/src/unix/notbsd/linux/s390x.rs b/src/unix/notbsd/linux/s390x.rs index 0d4ba8141d353..e0a79d32665d7 100644 --- a/src/unix/notbsd/linux/s390x.rs +++ b/src/unix/notbsd/linux/s390x.rs @@ -336,26 +336,29 @@ s_no_extra_traits!{ } } -#[cfg(feature = "extra_traits")] -impl PartialEq for fpreg_t { - fn eq(&self, other: &fpreg_t) -> bool { - self.d == other.d - } -} -#[cfg(feature = "extra_traits")] -impl Eq for fpreg_t {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for fpreg_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("fpreg_t") - .field("d", &self.d) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for fpreg_t { - fn hash(&self, state: &mut H) { - self.d.to_bits().hash(state); +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for fpreg_t { + fn eq(&self, other: &fpreg_t) -> bool { + self.d == other.d + } + } + + impl Eq for fpreg_t {} + + impl std::fmt::Debug for fpreg_t { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("fpreg_t") + .field("d", &self.d) + .finish() + } + } + + impl std::hash::Hash for fpreg_t { + fn hash(&self, state: &mut H) { + self.d.to_bits().hash(state); + } + } } } diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 3698590ad4525..d2f0cce945285 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -237,125 +237,126 @@ s_no_extra_traits!{ } } -#[cfg(feature = "extra_traits")] -impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a, b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for sockaddr_un {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for sockaddr_un { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("sockaddr_un") - .field("sun_family", &self.sun_family) - // FIXME: .field("sun_path", &self.sun_path) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_family.hash(state); - self.sun_path.hash(state); - } -} +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for sockaddr_un { + fn eq(&self, other: &sockaddr_un) -> bool { + self.sun_family == other.sun_family + && self + .sun_path + .iter() + .zip(other.sun_path.iter()) + .all(|(a, b)| a == b) + } + } -#[cfg(feature = "extra_traits")] -impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_family == other.ss_family - && self - .__ss_pad2 - .iter() - .zip(other.__ss_pad2.iter()) - .all(|(a, b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for sockaddr_storage {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("sockaddr_storage") - .field("ss_family", &self.ss_family) - .field("__ss_align", &self.__ss_align) - // FIXME: .field("__ss_pad2", &self.__ss_pad2) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_family.hash(state); - self.__ss_pad2.hash(state); - } -} + impl Eq for sockaddr_un {} -#[cfg(feature = "extra_traits")] -impl PartialEq for utsname { - fn eq(&self, other: &utsname) -> bool { - self.sysname - .iter() - .zip(other.sysname.iter()) - .all(|(a, b)| a == b) - && self - .nodename - .iter() - .zip(other.nodename.iter()) - .all(|(a, b)| a == b) - && self - .release - .iter() - .zip(other.release.iter()) - .all(|(a, b)| a == b) - && self - .version - .iter() - .zip(other.version.iter()) - .all(|(a, b)| a == b) - && self - .machine - .iter() - .zip(other.machine.iter()) - .all(|(a, b)| a == b) - && self - .domainname - .iter() - .zip(other.domainname.iter()) - .all(|(a, b)| a == b) - } -} -#[cfg(feature = "extra_traits")] -impl Eq for utsname {} -#[cfg(feature = "extra_traits")] -impl std::fmt::Debug for utsname { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - f.debug_struct("utsname") - // FIXME: .field("sysname", &self.sysname) - // FIXME: .field("nodename", &self.nodename) - // FIXME: .field("release", &self.release) - // FIXME: .field("version", &self.version) - // FIXME: .field("machine", &self.machine) - // FIXME: .field("domainname", &self.domainname) - .finish() - } -} -#[cfg(feature = "extra_traits")] -impl std::hash::Hash for utsname { - fn hash(&self, state: &mut H) { - self.sysname.hash(state); - self.nodename.hash(state); - self.release.hash(state); - self.version.hash(state); - self.machine.hash(state); - self.domainname.hash(state); + impl std::fmt::Debug for sockaddr_un { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("sockaddr_un") + .field("sun_family", &self.sun_family) + // FIXME: .field("sun_path", &self.sun_path) + .finish() + } + } + + impl std::hash::Hash for sockaddr_un { + fn hash(&self, state: &mut H) { + self.sun_family.hash(state); + self.sun_path.hash(state); + } + } + + impl PartialEq for sockaddr_storage { + fn eq(&self, other: &sockaddr_storage) -> bool { + self.ss_family == other.ss_family + && self + .__ss_pad2 + .iter() + .zip(other.__ss_pad2.iter()) + .all(|(a, b)| a == b) + } + } + + impl Eq for sockaddr_storage {} + + impl std::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("sockaddr_storage") + .field("ss_family", &self.ss_family) + .field("__ss_align", &self.__ss_align) + // FIXME: .field("__ss_pad2", &self.__ss_pad2) + .finish() + } + } + + impl std::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { + self.ss_family.hash(state); + self.__ss_pad2.hash(state); + } + } + + impl PartialEq for utsname { + fn eq(&self, other: &utsname) -> bool { + self.sysname + .iter() + .zip(other.sysname.iter()) + .all(|(a, b)| a == b) + && self + .nodename + .iter() + .zip(other.nodename.iter()) + .all(|(a, b)| a == b) + && self + .release + .iter() + .zip(other.release.iter()) + .all(|(a, b)| a == b) + && self + .version + .iter() + .zip(other.version.iter()) + .all(|(a, b)| a == b) + && self + .machine + .iter() + .zip(other.machine.iter()) + .all(|(a, b)| a == b) + && self + .domainname + .iter() + .zip(other.domainname.iter()) + .all(|(a, b)| a == b) + } + } + + impl Eq for utsname {} + + impl std::fmt::Debug for utsname { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("utsname") + // FIXME: .field("sysname", &self.sysname) + // FIXME: .field("nodename", &self.nodename) + // FIXME: .field("release", &self.release) + // FIXME: .field("version", &self.version) + // FIXME: .field("machine", &self.machine) + // FIXME: .field("domainname", &self.domainname) + .finish() + } + } + + impl std::hash::Hash for utsname { + fn hash(&self, state: &mut H) { + self.sysname.hash(state); + self.nodename.hash(state); + self.release.hash(state); + self.version.hash(state); + self.machine.hash(state); + self.domainname.hash(state); + } + } } } diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 25a381ae72d27..30270cdf88ead 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -434,7 +434,7 @@ extern "system" { } cfg_if! { - if #[cfg(core_cvoid)] { + if #[cfg(libc_core_cvoid)] { pub use core::ffi::c_void; } else { // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help @@ -442,6 +442,7 @@ cfg_if! { // like malloc/free. #[repr(u8)] #[allow(missing_copy_implementations)] + #[allow(missing_debug_implementations)] pub enum c_void { // Two dummy variants so the #[repr] attribute can be used. #[doc(hidden)] From 7ab9a808b9128671200eb1abe612723150d39a4d Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 12:09:32 +0100 Subject: [PATCH 15/72] Introduce Travis-CI stages, check style in a single build job, and fix style --- .travis.yml | 58 ++++++++++++++++++++--- build.rs | 9 ++-- src/unix/bsd/apple/mod.rs | 3 +- src/unix/notbsd/linux/mod.rs | 6 +-- src/unix/notbsd/linux/other/b64/x86_64.rs | 1 - 5 files changed, 60 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4a6a57a56477a..1fe46b2af3c10 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,57 +4,101 @@ sudo: required dist: xenial services: docker +stages: + - min-checks-and-tier1 + - other-targets + matrix: include: - name: "Documentation" env: TARGET=x86_64-unknown-linux-gnu script: sh ci/dox.sh install: true + stage: min-checks-and-tier1 - name: "Shellcheck" install: true script: - shellcheck --version - shellcheck ci/*.sh - + stage: min-checks-and-tier1 + - name: "Style" + install: true + script: rustc ci/style.rs && ./style src + stage: min-checks-and-tier1 - env: TARGET=x86_64-unknown-linux-gnu + stage: min-checks-and-tier1 - env: TARGET=i686-unknown-linux-gnu - - env: TARGET=x86_64-unknown-linux-gnux32 OPT="--release" - - os: osx - env: TARGET=x86_64-apple-darwin + stage: min-checks-and-tier1 + - env: TARGET=x86_64-apple-darwin + os: osx osx_image: xcode10 - - os: osx - env: TARGET=i686-apple-darwin + stage: min-checks-and-tier1 + - env: TARGET=i686-apple-darwin + os: osx osx_image: xcode10 + stage: min-checks-and-tier1 + + - env: TARGET=x86_64-unknown-linux-gnux32 OPT="--release" + stage: other-targets - env: TARGET=arm-linux-androideabi + stage: other-targets - env: TARGET=aarch64-linux-android + stage: other-targets # FIXME(#826) should reenable #- env: TARGET=i686-linux-android + # stage: other-targets - env: TARGET=x86_64-linux-android + stage: other-targets - env: TARGET=x86_64-unknown-linux-musl + stage: other-targets - env: TARGET=i686-unknown-linux-musl + stage: other-targets - env: TARGET=arm-unknown-linux-gnueabihf + stage: other-targets - env: TARGET=arm-unknown-linux-musleabihf + stage: other-targets - env: TARGET=aarch64-unknown-linux-gnu + stage: other-targets - env: TARGET=aarch64-unknown-linux-musl + stage: other-targets - env: TARGET=powerpc-unknown-linux-gnu + stage: other-targets - env: TARGET=powerpc64-unknown-linux-gnu + stage: other-targets - env: TARGET=powerpc64le-unknown-linux-gnu + stage: other-targets - env: TARGET=mips-unknown-linux-musl + stage: other-targets - env: TARGET=mipsel-unknown-linux-musl + stage: other-targets - env: TARGET=mips64-unknown-linux-gnuabi64 + stage: other-targets - env: TARGET=mips64el-unknown-linux-gnuabi64 + stage: other-targets - env: TARGET=mips-unknown-linux-gnu + stage: other-targets - env: TARGET=s390x-unknown-linux-gnu + stage: other-targets - env: TARGET=sparc64-unknown-linux-gnu + stage: other-targets - env: TARGET=asmjs-unknown-emscripten + stage: other-targets - env: TARGET=wasm32-unknown-emscripten + stage: other-targets - env: TARGET=wasm32-unknown-unknown BUILD_ONLY=1 + stage: other-targets - env: TARGET=x86_64-unknown-freebsd BUILD_ONLY=1 + stage: other-targets - env: TARGET=x86_64-unknown-openbsd BUILD_ONLY=1 + stage: other-targets - env: TARGET=x86_64-unknown-bitrig BUILD_ONLY=1 + stage: other-targets - env: TARGET=x86_64-unknown-netbsd BUILD_ONLY=1 + stage: other-targets - env: TARGET=x86_64-unknown-dragonfly BUILD_ONLY=1 + stage: other-targets - env: TARGET=x86_64-unknown-solaris BUILD_ONLY=1 + stage: other-targets allow_failures: # FIXME: https://github.com/rust-lang/libc/issues/1226 @@ -88,7 +132,7 @@ script: 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=" diff --git a/build.rs b/build.rs index fa4bc90c2f7d8..4f4bd6193ca45 100644 --- a/build.rs +++ b/build.rs @@ -4,9 +4,12 @@ use std::str; fn main() { - let rustc_minor_ver = rustc_minor_version().expect("Failed to get rustc version"); - let rustc_dep_of_std = std::env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); - let align_cargo_feature = std::env::var("CARGO_FEATURE_ALIGN").is_ok(); + let rustc_minor_ver + = rustc_minor_version().expect("Failed to get rustc version"); + let rustc_dep_of_std + = std::env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); + let align_cargo_feature + = std::env::var("CARGO_FEATURE_ALIGN").is_ok(); // Rust >= 1.19 supports unions: if rustc_minor_ver >= 19 || rustc_dep_of_std { diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index f809089ce5283..ac908fc3451c2 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -615,7 +615,8 @@ cfg_if! { } impl Eq for semun {} impl std::fmt::Debug for semun { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + fn fmt(&self, f: &mut std::fmt::Formatter) + -> std::fmt::Result { f.debug_struct("semun") .field("val", unsafe { &self.val }) .finish() diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index af92aea9d73b0..8d270934762d4 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -711,7 +711,6 @@ cfg_if! { } } - impl PartialEq for dirent64 { fn eq(&self, other: &dirent64) -> bool { self.d_ino == other.d_ino @@ -750,7 +749,6 @@ cfg_if! { } } - impl PartialEq for pthread_cond_t { fn eq(&self, other: &pthread_cond_t) -> bool { self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b) @@ -773,7 +771,6 @@ cfg_if! { } } - impl PartialEq for pthread_mutex_t { fn eq(&self, other: &pthread_mutex_t) -> bool { self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b) @@ -796,7 +793,6 @@ cfg_if! { } } - impl PartialEq for pthread_rwlock_t { fn eq(&self, other: &pthread_rwlock_t) -> bool { self.size.iter().zip(other.size.iter()).all(|(a,b)| a == b) @@ -812,7 +808,7 @@ cfg_if! { .finish() } } - + impl std::hash::Hash for pthread_rwlock_t { fn hash(&self, state: &mut H) { self.size.hash(state); diff --git a/src/unix/notbsd/linux/other/b64/x86_64.rs b/src/unix/notbsd/linux/other/b64/x86_64.rs index 2e42e591034bb..90a8f53ff2e56 100644 --- a/src/unix/notbsd/linux/other/b64/x86_64.rs +++ b/src/unix/notbsd/linux/other/b64/x86_64.rs @@ -290,7 +290,6 @@ cfg_if! { } } - impl PartialEq for ucontext_t { fn eq(&self, other: &ucontext_t) -> bool { self.uc_flags == other.uc_flags From 3990b0981f02cac660df1bcc1fd3b2b3fb0beef0 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 12:10:39 +0100 Subject: [PATCH 16/72] repr(align) enabled/disabled is now automatically tested depending on Rust version --- ci/run.sh | 8 -------- 1 file changed, 8 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index 7a38f8fde750a..91a113907e493 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -111,14 +111,6 @@ do --target "${TARGET}" fi - # Test the #[repr(align(x))] feature; requires Rust >= 1.25.0 - if [ "$build_type" != "+1.13.0" ]; then - cargo "$build_type" test $opt \ - --features align \ - --manifest-path libc-test/Cargo.toml \ - --target "${TARGET}" - fi - # Test the `extra_traits` feature; requires Rust >= 1.25.0 if [ "$build_type" != "+1.13.0" ]; then cargo "$build_type" test $opt \ From ca10983d885203924c7bbd46ecc76d2a60ee1b4e Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 12:16:35 +0100 Subject: [PATCH 17/72] Do not derive extra traits for OpenBSD union mount_info --- .../bsd/netbsdlike/openbsdlike/openbsd/mod.rs | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs index f1de4f4e6363f..6a71908a4c7cc 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs @@ -26,17 +26,6 @@ s! { pub int_n_sign_posn: ::c_char, } - pub union mount_info { - pub ufs_args: ufs_args, - pub mfs_args: mfs_args, - pub nfs_args: nfs_args, - pub iso_args: iso_args, - pub msdosfs_args: msdosfs_args, - pub ntfs_args: ntfs_args, - pub tmpfs_args: tmpfs_args, - align: [::c_char; 160], - } - pub struct ufs_args { pub fspec: *mut ::c_char, pub export_info: export_args, @@ -167,6 +156,19 @@ s! { } } +s_no_extra_traits! { + pub union mount_info { + pub ufs_args: ufs_args, + pub mfs_args: mfs_args, + pub nfs_args: nfs_args, + pub iso_args: iso_args, + pub msdosfs_args: msdosfs_args, + pub ntfs_args: ntfs_args, + pub tmpfs_args: tmpfs_args, + align: [::c_char; 160], + } +} + //https://github.com/openbsd/src/blob/master/sys/sys/mount.h pub const ISOFSMNT_NORRIP: ::c_int = 0x1; // disable Rock Ridge Ext pub const ISOFSMNT_GENS: ::c_int = 0x2; // enable generation numbers From b4123220ba3f4ee253540e895c9e928b48fbeb55 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 12:24:40 +0100 Subject: [PATCH 18/72] Add Rust 1.25 toolchain; only check that extra_traits builds, fix OpenBSD mount_info extra traits --- .travis.yml | 2 + ci/run.sh | 20 ++++--- .../bsd/netbsdlike/openbsdlike/openbsd/mod.rs | 59 ++++++++++--------- 3 files changed, 45 insertions(+), 36 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1fe46b2af3c10..20677fbcf607d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -111,6 +111,7 @@ install: - rustup install 1.13.0 - rustup install 1.19.0 - rustup install 1.24.0 + - rustup install 1.25.0 - rustup install 1.30.0 - rustup target add $TARGET || true - rustup target add $TARGET --toolchain beta || true @@ -118,6 +119,7 @@ install: - rustup target add $TARGET --toolchain 1.13.0 || true - rustup target add $TARGET --toolchain 1.19.0 || true - rustup target add $TARGET --toolchain 1.24.0 || true + - rustup target add $TARGET --toolchain 1.25.0 || true - rustup target add $TARGET --toolchain 1.30.0 || true script: diff --git a/ci/run.sh b/ci/run.sh index 91a113907e493..20863e79f298f 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -82,7 +82,7 @@ fi command -v cargo -build_types="+nightly +beta +stable +1.13.0 +1.19.0 +1.24.0 +1.30.0" +build_types="+nightly +beta +stable +1.13.0 +1.19.0 +1.24.0 +1.25.0 +1.30.0" for build_type in $build_types; do opt= @@ -111,16 +111,18 @@ do --target "${TARGET}" fi - # Test the `extra_traits` feature; requires Rust >= 1.25.0 - if [ "$build_type" != "+1.13.0" ]; then - cargo "$build_type" test $opt \ - --features extra_traits \ - --manifest-path libc-test/Cargo.toml \ - --target "${TARGET}" - fi - cargo "$build_type" test $opt \ --manifest-path libc-test/Cargo.toml \ --target "${TARGET}" fi + + # Test the `extra_traits` feature; requires Rust >= 1.25.0 + # No need to run libc-test, only check that libc builds. + if [ "$build_type" != "+1.13.0" ] && \ + [ "$build_type" != "+1.19.0" ] && \ + [ "$build_type" != "+1.24.0" ]; then + cargo "$build_type" build $opt \ + --features extra_traits \ + --target "${TARGET}" + fi done diff --git a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs index 6a71908a4c7cc..53d7bb58ab23d 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs @@ -127,33 +127,6 @@ s! { pub ex_mask: *mut ::sockaddr, pub ex_masklen: ::c_int, } - - // This type uses the union mount_info: - #[cfg(libc_union)] - pub struct statfs { - pub f_flags: ::uint32_t, - pub f_bsize: ::uint32_t, - pub f_iosize: ::uint32_t, - pub f_blocks: ::uint64_t, - pub f_bfree: ::uint64_t, - pub f_bavail: ::int64_t, - pub f_files: ::uint64_t, - pub f_ffree: ::uint64_t, - pub f_favail: ::int64_t, - pub f_syncwrites: ::uint64_t, - pub f_syncreads: ::uint64_t, - pub f_asyncwrites: ::uint64_t, - pub f_asyncreads: ::uint64_t, - pub f_fsid: ::fsid_t, - pub f_namemax: ::uint32_t, - pub f_owner: ::uid_t, - pub f_ctime: ::uint64_t, - pub f_fstypename: [::c_char; 16], - pub f_mntonname: [::c_char; 90], - pub f_mntfromname: [::c_char; 90], - pub f_mntfromspec: [::c_char; 90], - pub mount_info: mount_info, - } } s_no_extra_traits! { @@ -169,6 +142,38 @@ s_no_extra_traits! { } } +cfg_f! { + if #[cfg(libc_union)] { + s_no_extra_traits! { + // This type uses the union mount_info: + pub struct statfs { + pub f_flags: ::uint32_t, + pub f_bsize: ::uint32_t, + pub f_iosize: ::uint32_t, + pub f_blocks: ::uint64_t, + pub f_bfree: ::uint64_t, + pub f_bavail: ::int64_t, + pub f_files: ::uint64_t, + pub f_ffree: ::uint64_t, + pub f_favail: ::int64_t, + pub f_syncwrites: ::uint64_t, + pub f_syncreads: ::uint64_t, + pub f_asyncwrites: ::uint64_t, + pub f_asyncreads: ::uint64_t, + pub f_fsid: ::fsid_t, + pub f_namemax: ::uint32_t, + pub f_owner: ::uid_t, + pub f_ctime: ::uint64_t, + pub f_fstypename: [::c_char; 16], + pub f_mntonname: [::c_char; 90], + pub f_mntfromname: [::c_char; 90], + pub f_mntfromspec: [::c_char; 90], + pub mount_info: mount_info, + } + } + } +} + //https://github.com/openbsd/src/blob/master/sys/sys/mount.h pub const ISOFSMNT_NORRIP: ::c_int = 0x1; // disable Rock Ridge Ext pub const ISOFSMNT_GENS: ::c_int = 0x2; // enable generation numbers From 14d0069a5a1906794420ce6f4e58a941369fa38c Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 12:26:23 +0100 Subject: [PATCH 19/72] Fix packed(N) detection in build.rs --- build.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build.rs b/build.rs index 4f4bd6193ca45..21f35fe111c7b 100644 --- a/build.rs +++ b/build.rs @@ -26,14 +26,15 @@ fn main() { println!("cargo:rustc-cfg=libc_align"); } - // If `core::ffi::c_void` exists, libc can just re-export it. Otherwise, it - // must define an incompatible type to retain backwards-compatibility. + // Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it. + // Otherwise, it defines an incompatible type to retaining + // backwards-compatibility. if rustc_minor_ver >= 30 || rustc_dep_of_std { println!("cargo:rustc-cfg=libc_core_cvoid"); } // Rust >= 1.33 supports repr(packed(N)) - if rustc_minor_ver >= 30 || rustc_dep_of_std { + if rustc_minor_ver >= 33 || rustc_dep_of_std { println!("cargo:rustc-cfg=libc_packedN"); } } From 6cde5179deb124a55ceee34a364c517d9f71acf4 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 12:57:08 +0100 Subject: [PATCH 20/72] Test most Rust targets --- .travis.yml | 227 ++++++++++++------ ci/run-docker.sh | 2 + ci/run.sh | 23 +- .../bsd/netbsdlike/openbsdlike/openbsd/mod.rs | 2 +- 4 files changed, 180 insertions(+), 74 deletions(-) diff --git a/.travis.yml b/.travis.yml index 20677fbcf607d..ad34beebe9fa9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,16 @@ services: docker stages: - min-checks-and-tier1 - - other-targets + - tier2-1 + - tier2-2 + - tier2-3 + - tier2-4 + - tier25 + - tier3 matrix: include: + # Min Checks and Tier 1 targets - name: "Documentation" env: TARGET=x86_64-unknown-linux-gnu script: sh ci/dox.sh @@ -25,7 +31,10 @@ matrix: install: true script: rustc ci/style.rs && ./style src stage: min-checks-and-tier1 - - env: TARGET=x86_64-unknown-linux-gnu + + - env: TARGET=i686-apple-darwin + os: osx + osx_image: xcode10 stage: min-checks-and-tier1 - env: TARGET=i686-unknown-linux-gnu stage: min-checks-and-tier1 @@ -33,72 +42,149 @@ matrix: os: osx osx_image: xcode10 stage: min-checks-and-tier1 - - env: TARGET=i686-apple-darwin - os: osx - osx_image: xcode10 + - env: TARGET=x86_64-unknown-linux-gnu stage: min-checks-and-tier1 - - env: TARGET=x86_64-unknown-linux-gnux32 OPT="--release" - stage: other-targets - - env: TARGET=arm-linux-androideabi - stage: other-targets + # Tier 2 targets + - env: TARGET=aarch64-apple-ios BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier2-1 + os: osx + osx_image: xcode10 + - env: TARGET=aarch64-fuchsia BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier2-1 - env: TARGET=aarch64-linux-android - stage: other-targets - # FIXME(#826) should reenable - #- env: TARGET=i686-linux-android - # stage: other-targets - - env: TARGET=x86_64-linux-android - stage: other-targets - - env: TARGET=x86_64-unknown-linux-musl - stage: other-targets - - env: TARGET=i686-unknown-linux-musl - stage: other-targets - - env: TARGET=arm-unknown-linux-gnueabihf - stage: other-targets - - env: TARGET=arm-unknown-linux-musleabihf - stage: other-targets + stage: tier2-1 - env: TARGET=aarch64-unknown-linux-gnu - stage: other-targets + stage: tier2-1 - env: TARGET=aarch64-unknown-linux-musl - stage: other-targets - - env: TARGET=powerpc-unknown-linux-gnu - stage: other-targets - - env: TARGET=powerpc64-unknown-linux-gnu - stage: other-targets - - env: TARGET=powerpc64le-unknown-linux-gnu - stage: other-targets + stage: tier2-1 + - env: TARGET=arm-linux-androideabi + stage: tier2-1 + - env: TARGET=arm-unknown-linux-gnueabihf + stage: tier2-1 + - env: TARGET=arm-unknown-linux-musleabihf + stage: tier2-1 + - env: TARGET=armv7-apple-ios BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier2-1 + os: osx + osx_image: xcode10 + - env: TARGET=armv7-linux-androideabi BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier2-1 + - env: TARGET=armv7-unknown-linux-gnueabihf BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier2-2 + - env: TARGET=armv7-unknown-linux-musleabihf BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier2-2 + - env: TARGET=armv7s-apple-ios BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier2-2 + os: osx + osx_image: xcode10 + - env: TARGET=asmjs-unknown-emscripten + stage: tier2-2 + - env: TARGET=i586-unknown-linux-gnu BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier2-2 + - env: TARGET=i586-unknown-linux-musl BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier2-2 + # FIXME(#826) should reenable tests + - env: TARGET=i686-linux-android BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier2-2 + - env: TARGET=i686-unknown-freebsd BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier2-2 + - env: TARGET=i686-unknown-linux-musl + stage: tier2-2 + - env: TARGET=mips-unknown-linux-gnu + stage: tier2-2 - env: TARGET=mips-unknown-linux-musl - stage: other-targets - - env: TARGET=mipsel-unknown-linux-musl - stage: other-targets + stage: tier2-3 - env: TARGET=mips64-unknown-linux-gnuabi64 - stage: other-targets + stage: tier2-3 - env: TARGET=mips64el-unknown-linux-gnuabi64 - stage: other-targets - - env: TARGET=mips-unknown-linux-gnu - stage: other-targets + stage: tier2-3 + - env: TARGET=mipsel-unknown-linux-gnu BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier2-3 + - env: TARGET=mipsel-unknown-linux-musl + stage: tier2-3 + - env: TARGET=powerpc-unknown-linux-gnu + stage: tier2-3 + - env: TARGET=powerpc64-unknown-linux-gnu + stage: tier2-3 + - env: TARGET=powerpc64le-unknown-linux-gnu + stage: tier2-3 - env: TARGET=s390x-unknown-linux-gnu - stage: other-targets + stage: tier2-3 - env: TARGET=sparc64-unknown-linux-gnu - stage: other-targets - - env: TARGET=asmjs-unknown-emscripten - stage: other-targets - - env: TARGET=wasm32-unknown-emscripten - stage: other-targets + stage: tier2-3 + - env: TARGET=sparcv9-sun-solaris + stage: tier2-4 - env: TARGET=wasm32-unknown-unknown BUILD_ONLY=1 - stage: other-targets + stage: tier2-4 + - env: TARGET=wasm32-unknown-emscripten + stage: tier2-4 + - env: TARGET=x86_64-apple-ios BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier2-4 + os: osx + osx_image: xcode10 + - env: TARGET=x86_64-fuchsia BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier2-4 + - env: TARGET=x86_64-linux-android + stage: tier2-4 + - env: TARGET=x86_64-rumprun-netbsd BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier2-4 + - env: TARGET=x86_64-sun-solaris BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier2-4 + - env: TARGET=x86_64-unknown-cloudabi BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier2-4 - env: TARGET=x86_64-unknown-freebsd BUILD_ONLY=1 - stage: other-targets - - env: TARGET=x86_64-unknown-openbsd BUILD_ONLY=1 - stage: other-targets - - env: TARGET=x86_64-unknown-bitrig BUILD_ONLY=1 - stage: other-targets + stage: tier2-4 + - env: TARGET=x86_64-unknown-linux-gnux32 OPT="--release" + stage: tier2-4 + - env: TARGET=x86_64-unknown-linux-musl + stage: tier2-4 - env: TARGET=x86_64-unknown-netbsd BUILD_ONLY=1 - stage: other-targets - - env: TARGET=x86_64-unknown-dragonfly BUILD_ONLY=1 - stage: other-targets - - env: TARGET=x86_64-unknown-solaris BUILD_ONLY=1 - stage: other-targets + stage: tier2-4 + - env: TARGET=x86_64-unknown-redox BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier2-4 + + # Tier 2.5 targets: + - env: TARGET=aarch64-unknown-cloudabi BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier25 + - env: TARGET=armv7-unknown-cloudabi-eabihf BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier25 + - env: TARGET=i686-unknown-cloudabi BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier25 + - env: TARGET=powerpc-unknown-linux-gnuspe BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier25 + - env: TARGET=sparc-unknown-linux-gnu BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier25 + + # Tier 3 targets: + - env: TARGET=i686-unknown-haiku BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier3 + - env: TARGET=i686-unknown-netbsd BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier3 + - env: TARGET=mips-unknown-unknown-linux-uclib BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier3 + - env: TARGET=mipsel-unknown-unknown-linux-uclib BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier3 + - env: TARGET=sparc64-unknown-netbsd BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier3 + - env: TARGET=thumbv6m-none-eabi BUILD_ONLY=1 NIGHTLY_ONLY=1 NO_STD=1 + stage: tier3 + - env: TARGET=thumbv7em-none-eabi BUILD_ONLY=1 NIGHTLY_ONLY=1 NO_STD=1 + stage: tier3 + - env: TARGET=thumbv7em-none-eabihf BUILD_ONLY=1 NIGHTLY_ONLY=1 NO_STD=1 + stage: tier3 + - env: TARGET=thumbv7m-none-eabi BUILD_ONLY=1 NIGHTLY_ONLY=1 NO_STD=1 + stage: tier3 + - env: TARGET=x86_64-fortanix-unknown-sgx BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier3 + - env: TARGET=x86_64-unknown-bitrig BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier3 + - env: TARGET=x86_64-unknown-dragonfly BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier3 + - env: TARGET=x86_64-unknown-haiku BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier3 + - env: TARGET=x86_64-unknown-openbsd BUILD_ONLY=1 NIGHTLY_ONLY=1 + stage: tier3 allow_failures: # FIXME: https://github.com/rust-lang/libc/issues/1226 @@ -106,21 +192,24 @@ matrix: - env: TARGET=wasm32-unknown-emscripten install: - - rustup install beta - - rustup install stable - - rustup install 1.13.0 - - rustup install 1.19.0 - - rustup install 1.24.0 - - rustup install 1.25.0 - - rustup install 1.30.0 - rustup target add $TARGET || true - - rustup target add $TARGET --toolchain beta || true - - rustup target add $TARGET --toolchain stable || true - - rustup target add $TARGET --toolchain 1.13.0 || true - - rustup target add $TARGET --toolchain 1.19.0 || true - - rustup target add $TARGET --toolchain 1.24.0 || true - - rustup target add $TARGET --toolchain 1.25.0 || true - - rustup target add $TARGET --toolchain 1.30.0 || true + - | + if [ "${NIGHTLY_ONLY}" != "1" ]; then + rustup install beta + rustup install stable + rustup install 1.13.0 + rustup install 1.19.0 + rustup install 1.24.0 + rustup install 1.25.0 + rustup install 1.30.0 + rustup target add $TARGET --toolchain beta || true + rustup target add $TARGET --toolchain stable || true + rustup target add $TARGET --toolchain 1.13.0 || true + rustup target add $TARGET --toolchain 1.19.0 || true + rustup target add $TARGET --toolchain 1.24.0 || true + rustup target add $TARGET --toolchain 1.25.0 || true + rustup target add $TARGET --toolchain 1.30.0 || true + fi script: - cargo generate-lockfile --manifest-path libc-test/Cargo.toml diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 73270fb903ccd..8f5653d716dcd 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -24,6 +24,8 @@ run() { --volume "${HOME}/.cargo":/cargo \ $kvm \ --env CARGO_HOME=/cargo \ + --env BUILD_ONLY="${BUILD_ONLY}" \ + --env NIGHTLY_ONLY="${NIGHTLY_ONLY}" \ --volume "$(rustc --print sysroot)":/rust:ro \ --volume "${HOME}"/.rustup:/.rustup:ro \ --env RUSTUP_HOME=/.rustup \ diff --git a/ci/run.sh b/ci/run.sh index 20863e79f298f..b503ef3a2f979 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -83,6 +83,9 @@ fi command -v cargo build_types="+nightly +beta +stable +1.13.0 +1.19.0 +1.24.0 +1.25.0 +1.30.0" +if [ "$NIGHTLY_ONLY" = "1" ]; then + build_types="+nightly" +fi for build_type in $build_types; do opt= @@ -100,7 +103,10 @@ do fi if [ "$BUILD_ONLY" = "1" ]; then - cargo "$build_type" build $opt --target "${TARGET}" + cargo "$build_type" build $opt --no-default-features --target "${TARGET}" + if [ "$NO_STD" != "1" ]; then + cargo "$build_type" build $opt --target "${TARGET}" + fi else # Building with --no-default-features is currently broken on rumprun # because we need cfg(target_vendor), which is currently unstable. @@ -111,9 +117,11 @@ do --target "${TARGET}" fi - cargo "$build_type" test $opt \ - --manifest-path libc-test/Cargo.toml \ - --target "${TARGET}" + if [ "$NO_STD" != "1" ]; then + cargo "$build_type" test $opt \ + --manifest-path libc-test/Cargo.toml \ + --target "${TARGET}" + fi fi # Test the `extra_traits` feature; requires Rust >= 1.25.0 @@ -122,7 +130,14 @@ do [ "$build_type" != "+1.19.0" ] && \ [ "$build_type" != "+1.24.0" ]; then cargo "$build_type" build $opt \ + --no-default-features \ --features extra_traits \ --target "${TARGET}" + + if [ "$NO_STD" != "1" ]; then + cargo "$build_type" build $opt \ + --features extra_traits \ + --target "${TARGET}" + fi fi done diff --git a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs index 53d7bb58ab23d..9bf2db83e6972 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs @@ -142,7 +142,7 @@ s_no_extra_traits! { } } -cfg_f! { +cfg_if! { if #[cfg(libc_union)] { s_no_extra_traits! { // This type uses the union mount_info: From 74fdc2d4e3a60367e914c8b0c86318a12f7a0659 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 13:04:35 +0100 Subject: [PATCH 21/72] Detect running in docker, add cargo/bin to PATH, allow modifying the Cargo.lock --- .travis.yml | 1 - ci/run-docker.sh | 4 ++-- ci/run.sh | 32 ++++++++++++++++++-------------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index ad34beebe9fa9..22177e37995b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -212,7 +212,6 @@ install: fi script: - - cargo generate-lockfile --manifest-path libc-test/Cargo.toml - if [[ $TRAVIS_OS_NAME = "linux" ]]; then if [[ $BUILD_ONLY = "1" ]]; then sh ci/run.sh $TARGET; diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 8f5653d716dcd..4816ca9c4e814 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -24,16 +24,16 @@ run() { --volume "${HOME}/.cargo":/cargo \ $kvm \ --env CARGO_HOME=/cargo \ + --env RUNNING_IN_DOCKER=1 \ --env BUILD_ONLY="${BUILD_ONLY}" \ --env NIGHTLY_ONLY="${NIGHTLY_ONLY}" \ --volume "$(rustc --print sysroot)":/rust:ro \ --volume "${HOME}"/.rustup:/.rustup:ro \ --env RUSTUP_HOME=/.rustup \ - --volume "$(pwd)":/checkout:ro \ + --volume "$(pwd)":/checkout \ --volume "$(pwd)"/target:/checkout/target \ --env CARGO_TARGET_DIR=/checkout/target \ --workdir /checkout \ - -c 'export PATH=$PATH:/cargo/bin; bash' \ libc \ ci/run.sh "${1}" } diff --git a/ci/run.sh b/ci/run.sh index b503ef3a2f979..7131e5ca6bce4 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -80,16 +80,20 @@ if [ "$QEMU" != "" ]; then exec egrep "^(PASSED)|(test result: ok)" "${CARGO_TARGET_DIR}/out.log" fi +if [ "${RUNNING_IN_DOCKER}" = "1" ]; then + export PATH=$PATH:$CARGO_HOME/bin +fi + command -v cargo build_types="+nightly +beta +stable +1.13.0 +1.19.0 +1.24.0 +1.25.0 +1.30.0" -if [ "$NIGHTLY_ONLY" = "1" ]; then +if [ "${NIGHTLY_ONLY}" = "1" ]; then build_types="+nightly" fi for build_type in $build_types; do opt= - if [ "$TARGET" = "x86_64-unknown-linux-gnux32" ]; then + if [ "${TARGET}" = "x86_64-unknown-linux-gnux32" ]; then # FIXME: x86_64-unknown-linux-gnux32 fail to compile without # --release # @@ -97,28 +101,28 @@ do opt="--release" # x86_64-unknown-linux-gnux32 is only available on nightly: - if [ "$build_type" != "nightly" ]; then + if [ "${build_type}" != "nightly" ]; then continue fi fi - if [ "$BUILD_ONLY" = "1" ]; then - cargo "$build_type" build $opt --no-default-features --target "${TARGET}" + if [ "${BUILD_ONLY}" = "1" ]; then + cargo "${build_type}" build $opt --no-default-features --target "${TARGET}" if [ "$NO_STD" != "1" ]; then - cargo "$build_type" build $opt --target "${TARGET}" + cargo "${build_type}" build $opt --target "${TARGET}" fi else # 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 "$build_type" test $opt \ + if [ "${TARGET}" != "x86_64-rumprun-netbsd" ]; then + cargo "${build_type}" test $opt \ --no-default-features \ --manifest-path libc-test/Cargo.toml \ --target "${TARGET}" fi if [ "$NO_STD" != "1" ]; then - cargo "$build_type" test $opt \ + cargo "${build_type}" test $opt \ --manifest-path libc-test/Cargo.toml \ --target "${TARGET}" fi @@ -126,16 +130,16 @@ do # Test the `extra_traits` feature; requires Rust >= 1.25.0 # No need to run libc-test, only check that libc builds. - if [ "$build_type" != "+1.13.0" ] && \ - [ "$build_type" != "+1.19.0" ] && \ - [ "$build_type" != "+1.24.0" ]; then - cargo "$build_type" build $opt \ + if [ "${build_type}" != "+1.13.0" ] && \ + [ "${build_type}" != "+1.19.0" ] && \ + [ "${build_type}" != "+1.24.0" ]; then + cargo "${build_type}" build $opt \ --no-default-features \ --features extra_traits \ --target "${TARGET}" if [ "$NO_STD" != "1" ]; then - cargo "$build_type" build $opt \ + cargo "${build_type}" build $opt \ --features extra_traits \ --target "${TARGET}" fi From 1d1b1677fbbe2841449c90a3127d69429689bb3a Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 13:36:53 +0100 Subject: [PATCH 22/72] Allow deprecated items in libc-test tests --- libc-test/test/cmsg.rs | 2 ++ libc-test/test/linux_fcntl.rs | 2 +- libc-test/test/main.rs | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libc-test/test/cmsg.rs b/libc-test/test/cmsg.rs index c9eecb628d975..afeb2e14d1bfc 100644 --- a/libc-test/test/cmsg.rs +++ b/libc-test/test/cmsg.rs @@ -1,6 +1,8 @@ //! Compare libc's CMSG(3) family of functions against the actual C macros, for //! various inputs. +#![allow(deprecated)] + extern crate libc; #[cfg(unix)] diff --git a/libc-test/test/linux_fcntl.rs b/libc-test/test/linux_fcntl.rs index 4c8ad52a91e86..9afe355f8dc52 100644 --- a/libc-test/test/linux_fcntl.rs +++ b/libc-test/test/linux_fcntl.rs @@ -1,4 +1,4 @@ -#![allow(bad_style, improper_ctypes, unused)] +#![allow(bad_style, improper_ctypes, unused, deprecated)] extern crate libc; diff --git a/libc-test/test/main.rs b/libc-test/test/main.rs index 3d336102bba45..62a587cf5868f 100644 --- a/libc-test/test/main.rs +++ b/libc-test/test/main.rs @@ -1,4 +1,4 @@ -#![allow(bad_style, improper_ctypes)] +#![allow(bad_style, improper_ctypes, deprecated)] extern crate libc; use libc::*; From 55a026d14da187b8f3a504524688a212b627b0bf Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 13:40:33 +0100 Subject: [PATCH 23/72] Do not assume libstd is available --- src/lib.rs | 3 - src/unix/bsd/apple/b32.rs | 8 +-- src/unix/bsd/apple/b64.rs | 8 +-- src/unix/bsd/apple/mod.rs | 74 +++++++++++------------ src/unix/bsd/mod.rs | 16 ++--- src/unix/notbsd/android/b64/mod.rs | 24 ++++---- src/unix/notbsd/android/mod.rs | 40 ++++++------ src/unix/notbsd/linux/mod.rs | 40 ++++++------ src/unix/notbsd/linux/musl/b32/x86.rs | 8 +-- src/unix/notbsd/linux/musl/b64/x86_64.rs | 8 +-- src/unix/notbsd/linux/musl/mod.rs | 8 +-- src/unix/notbsd/linux/other/b32/x86.rs | 16 ++--- src/unix/notbsd/linux/other/b64/x86_64.rs | 16 ++--- src/unix/notbsd/linux/other/mod.rs | 8 +-- src/unix/notbsd/linux/s390x.rs | 8 +-- src/unix/notbsd/mod.rs | 24 ++++---- 16 files changed, 153 insertions(+), 156 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8f96d0fc63703..4aff70efbe76e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -153,12 +153,9 @@ #![cfg_attr(feature = "rustc-dep-of-std", feature(cfg_target_vendor))] #![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg))] #![cfg_attr(feature = "rustc-dep-of-std", feature(no_core))] -#![cfg_attr(libc_packedN, feature(repr_packed))] -#![cfg_attr(libc_align, feature(repr_align))] #![cfg_attr(feature = "rustc-dep-of-std", no_core)] #![cfg_attr(feature = "rustc-dep-of-std", allow(warnings))] #![cfg_attr(not(any(feature = "use_std", feature = "rustc-dep-of-std")), no_std)] -#![allow(stable_features)] // Enable lints #![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))] #![deny(missing_copy_implementations)] diff --git a/src/unix/bsd/apple/b32.rs b/src/unix/bsd/apple/b32.rs index a0c84c4705b1e..2e0202b82b1aa 100644 --- a/src/unix/bsd/apple/b32.rs +++ b/src/unix/bsd/apple/b32.rs @@ -64,16 +64,16 @@ cfg_if! { } } impl Eq for pthread_attr_t {} - impl std::fmt::Debug for pthread_attr_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for pthread_attr_t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("pthread_attr_t") .field("__sig", &self.__sig) // FIXME: .field("__opaque", &self.__opaque) .finish() } } - impl std::hash::Hash for pthread_attr_t { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for pthread_attr_t { + fn hash(&self, state: &mut H) { self.__sig.hash(state); self.__opaque.hash(state); } diff --git a/src/unix/bsd/apple/b64.rs b/src/unix/bsd/apple/b64.rs index 7fecf31c8429a..f374b3084281f 100644 --- a/src/unix/bsd/apple/b64.rs +++ b/src/unix/bsd/apple/b64.rs @@ -69,16 +69,16 @@ cfg_if! { } } impl Eq for pthread_attr_t {} - impl std::fmt::Debug for pthread_attr_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for pthread_attr_t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("pthread_attr_t") .field("__sig", &self.__sig) // FIXME: .field("__opaque", &self.__opaque) .finish() } } - impl std::hash::Hash for pthread_attr_t { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for pthread_attr_t { + fn hash(&self, state: &mut H) { self.__sig.hash(state); self.__opaque.hash(state); } diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index ac908fc3451c2..1754303eef901 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -614,16 +614,16 @@ cfg_if! { } } impl Eq for semun {} - impl std::fmt::Debug for semun { - fn fmt(&self, f: &mut std::fmt::Formatter) - -> std::fmt::Result { + impl core::fmt::Debug for semun { + fn fmt(&self, f: &mut core::fmt::Formatter) + -> core::fmt::Result { f.debug_struct("semun") .field("val", unsafe { &self.val }) .finish() } } - impl std::hash::Hash for semun { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for semun { + fn hash(&self, state: &mut H) { unsafe { self.val.hash(state) }; } } @@ -653,8 +653,8 @@ cfg_if! { } } impl Eq for proc_threadinfo {} - impl std::fmt::Debug for proc_threadinfo { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for proc_threadinfo { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("proc_threadinfo") .field("pth_user_time", &self.pth_user_time) .field("pth_system_time", &self.pth_system_time) @@ -671,8 +671,8 @@ cfg_if! { } } - impl std::hash::Hash for proc_threadinfo { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for proc_threadinfo { + fn hash(&self, state: &mut H) { self.pth_user_time.hash(state); self.pth_system_time.hash(state); self.pth_cpu_usage.hash(state); @@ -717,8 +717,8 @@ cfg_if! { } impl Eq for statfs {} - impl std::fmt::Debug for statfs { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for statfs { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("statfs") .field("f_bsize", &self.f_bsize) .field("f_iosize", &self.f_iosize) @@ -740,8 +740,8 @@ cfg_if! { } } - impl std::hash::Hash for statfs { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for statfs { + fn hash(&self, state: &mut H) { self.f_bsize.hash(state); self.f_iosize.hash(state); self.f_blocks.hash(state); @@ -776,8 +776,8 @@ cfg_if! { } } impl Eq for dirent {} - impl std::fmt::Debug for dirent { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for dirent { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("dirent") .field("d_ino", &self.d_ino) .field("d_seekoff", &self.d_seekoff) @@ -788,8 +788,8 @@ cfg_if! { .finish() } } - impl std::hash::Hash for dirent { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for dirent { + fn hash(&self, state: &mut H) { self.d_ino.hash(state); self.d_seekoff.hash(state); self.d_reclen.hash(state); @@ -809,16 +809,16 @@ cfg_if! { } } impl Eq for pthread_rwlock_t {} - impl std::fmt::Debug for pthread_rwlock_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for pthread_rwlock_t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("pthread_rwlock_t") .field("__sig", &self.__sig) // FIXME: .field("__opaque", &self.__opaque) .finish() } } - impl std::hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for pthread_rwlock_t { + fn hash(&self, state: &mut H) { self.__sig.hash(state); self.__opaque.hash(state); } @@ -837,8 +837,8 @@ cfg_if! { impl Eq for pthread_mutex_t {} - impl std::fmt::Debug for pthread_mutex_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for pthread_mutex_t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("pthread_mutex_t") .field("__sig", &self.__sig) // FIXME: .field("__opaque", &self.__opaque) @@ -846,8 +846,8 @@ cfg_if! { } } - impl std::hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for pthread_mutex_t { + fn hash(&self, state: &mut H) { self.__sig.hash(state); self.__opaque.hash(state); } @@ -866,8 +866,8 @@ cfg_if! { impl Eq for pthread_cond_t {} - impl std::fmt::Debug for pthread_cond_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("pthread_cond_t") .field("__sig", &self.__sig) // FIXME: .field("__opaque", &self.__opaque) @@ -875,8 +875,8 @@ cfg_if! { } } - impl std::hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { self.__sig.hash(state); self.__opaque.hash(state); } @@ -902,8 +902,8 @@ cfg_if! { impl Eq for sockaddr_storage {} - impl std::fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("sockaddr_storage") .field("ss_len", &self.ss_len) .field("ss_family", &self.ss_family) @@ -914,8 +914,8 @@ cfg_if! { } } - impl std::hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { self.ss_len.hash(state); self.ss_family.hash(state); self.__ss_pad1.hash(state); @@ -946,8 +946,8 @@ cfg_if! { impl Eq for utmpx {} - impl std::fmt::Debug for utmpx { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for utmpx { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("utmpx") // FIXME: .field("ut_user", &self.ut_user) .field("ut_id", &self.ut_id) @@ -961,8 +961,8 @@ cfg_if! { } } - impl std::hash::Hash for utmpx { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for utmpx { + fn hash(&self, state: &mut H) { self.ut_user.hash(state); self.ut_id.hash(state); self.ut_line.hash(state); diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index e3b3c7af83847..b058fad8128c8 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -153,8 +153,8 @@ cfg_if! { impl Eq for sockaddr_un {} - impl std::fmt::Debug for sockaddr_un { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for sockaddr_un { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("sockaddr_un") .field("sun_len", &self.sun_len) .field("sun_family", &self.sun_family) @@ -163,8 +163,8 @@ cfg_if! { } } - impl std::hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for sockaddr_un { + fn hash(&self, state: &mut H) { self.sun_len.hash(state); self.sun_family.hash(state); self.sun_path.hash(state); @@ -202,8 +202,8 @@ cfg_if! { impl Eq for utsname {} - impl std::fmt::Debug for utsname { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for utsname { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("utsname") // FIXME: .field("sysname", &self.sysname) // FIXME: .field("nodename", &self.nodename) @@ -214,8 +214,8 @@ cfg_if! { } } - impl std::hash::Hash for utsname { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for utsname { + fn hash(&self, state: &mut H) { self.sysname.hash(state); self.nodename.hash(state); self.release.hash(state); diff --git a/src/unix/notbsd/android/b64/mod.rs b/src/unix/notbsd/android/b64/mod.rs index 824bd580d4fcc..3b810c771882c 100644 --- a/src/unix/notbsd/android/b64/mod.rs +++ b/src/unix/notbsd/android/b64/mod.rs @@ -143,8 +143,8 @@ cfg_if! { impl Eq for pthread_mutex_t {} - impl std::fmt::Debug for pthread_mutex_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for pthread_mutex_t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("pthread_mutex_t") .field("value", &self.value) // FIXME: .field("__reserved", &self.__reserved) @@ -152,8 +152,8 @@ cfg_if! { } } - impl std::hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for pthread_mutex_t { + fn hash(&self, state: &mut H) { self.value.hash(state); self.__reserved.hash(state); } @@ -172,8 +172,8 @@ cfg_if! { impl Eq for pthread_cond_t {} - impl std::fmt::Debug for pthread_cond_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("pthread_cond_t") .field("value", &self.value) // FIXME: .field("__reserved", &self.__reserved) @@ -181,8 +181,8 @@ cfg_if! { } } - impl std::hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { self.value.hash(state); self.__reserved.hash(state); } @@ -205,8 +205,8 @@ cfg_if! { impl Eq for pthread_rwlock_t {} - impl std::fmt::Debug for pthread_rwlock_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for pthread_rwlock_t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("pthread_rwlock_t") .field("numLocks", &self.numLocks) .field("writerThreadId", &self.writerThreadId) @@ -218,8 +218,8 @@ cfg_if! { } } - impl std::hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for pthread_rwlock_t { + fn hash(&self, state: &mut H) { self.numLocks.hash(state); self.writerThreadId.hash(state); self.pendingReaders.hash(state); diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index a872e8b111e6b..e0303f93ec7e2 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -258,8 +258,8 @@ cfg_if! { impl Eq for dirent {} - impl std::fmt::Debug for dirent { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for dirent { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("dirent") .field("d_ino", &self.d_ino) .field("d_off", &self.d_off) @@ -270,8 +270,8 @@ cfg_if! { } } - impl std::hash::Hash for dirent { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for dirent { + fn hash(&self, state: &mut H) { self.d_ino.hash(state); self.d_off.hash(state); self.d_reclen.hash(state); @@ -296,8 +296,8 @@ cfg_if! { impl Eq for dirent64 {} - impl std::fmt::Debug for dirent64 { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for dirent64 { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("dirent64") .field("d_ino", &self.d_ino) .field("d_off", &self.d_off) @@ -308,8 +308,8 @@ cfg_if! { } } - impl std::hash::Hash for dirent64 { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for dirent64 { + fn hash(&self, state: &mut H) { self.d_ino.hash(state); self.d_off.hash(state); self.d_reclen.hash(state); @@ -330,8 +330,8 @@ cfg_if! { impl Eq for siginfo_t {} - impl std::fmt::Debug for siginfo_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for siginfo_t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("siginfo_t") .field("si_signo", &self.si_signo) .field("si_errno", &self.si_errno) @@ -342,8 +342,8 @@ cfg_if! { } } - impl std::hash::Hash for siginfo_t { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for siginfo_t { + fn hash(&self, state: &mut H) { self.si_signo.hash(state); self.si_errno.hash(state); self.si_code.hash(state); @@ -370,8 +370,8 @@ cfg_if! { impl Eq for lastlog {} - impl std::fmt::Debug for lastlog { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for lastlog { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("lastlog") .field("ll_time", &self.ll_time) .field("ll_line", &self.ll_line) @@ -380,8 +380,8 @@ cfg_if! { } } - impl std::hash::Hash for lastlog { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for lastlog { + fn hash(&self, state: &mut H) { self.ll_time.hash(state); self.ll_line.hash(state); self.ll_host.hash(state); @@ -418,8 +418,8 @@ cfg_if! { impl Eq for utmp {} - impl std::fmt::Debug for utmp { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for utmp { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("utmp") .field("ut_type", &self.ut_type) .field("ut_pid", &self.ut_pid) @@ -436,8 +436,8 @@ cfg_if! { } } - impl std::hash::Hash for utmp { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for utmp { + fn hash(&self, state: &mut H) { self.ut_type.hash(state); self.ut_pid.hash(state); self.ut_line.hash(state); diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 8d270934762d4..6d0593d00c6da 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -689,8 +689,8 @@ cfg_if! { impl Eq for dirent {} - impl std::fmt::Debug for dirent { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for dirent { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("dirent") .field("d_ino", &self.d_ino) .field("d_off", &self.d_off) @@ -701,8 +701,8 @@ cfg_if! { } } - impl std::hash::Hash for dirent { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for dirent { + fn hash(&self, state: &mut H) { self.d_ino.hash(state); self.d_off.hash(state); self.d_reclen.hash(state); @@ -727,8 +727,8 @@ cfg_if! { impl Eq for dirent64 {} - impl std::fmt::Debug for dirent64 { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for dirent64 { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("dirent64") .field("d_ino", &self.d_ino) .field("d_off", &self.d_off) @@ -739,8 +739,8 @@ cfg_if! { } } - impl std::hash::Hash for dirent64 { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for dirent64 { + fn hash(&self, state: &mut H) { self.d_ino.hash(state); self.d_off.hash(state); self.d_reclen.hash(state); @@ -757,16 +757,16 @@ cfg_if! { impl Eq for pthread_cond_t {} - impl std::fmt::Debug for pthread_cond_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("pthread_cond_t") // FIXME: .field("size", &self.size) .finish() } } - impl std::hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { self.size.hash(state); } } @@ -779,16 +779,16 @@ cfg_if! { impl Eq for pthread_mutex_t {} - impl std::fmt::Debug for pthread_mutex_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for pthread_mutex_t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("pthread_mutex_t") // FIXME: .field("size", &self.size) .finish() } } - impl std::hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for pthread_mutex_t { + fn hash(&self, state: &mut H) { self.size.hash(state); } } @@ -801,16 +801,16 @@ cfg_if! { impl Eq for pthread_rwlock_t {} - impl std::fmt::Debug for pthread_rwlock_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for pthread_rwlock_t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("pthread_rwlock_t") // FIXME: .field("size", &self.size) .finish() } } - impl std::hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for pthread_rwlock_t { + fn hash(&self, state: &mut H) { self.size.hash(state); } } diff --git a/src/unix/notbsd/linux/musl/b32/x86.rs b/src/unix/notbsd/linux/musl/b32/x86.rs index 81cea985433cf..d06d9a9daa084 100644 --- a/src/unix/notbsd/linux/musl/b32/x86.rs +++ b/src/unix/notbsd/linux/musl/b32/x86.rs @@ -197,8 +197,8 @@ cfg_if! { impl Eq for ucontext_t {} - impl std::fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("ucontext_t") .field("uc_flags", &self.uc_flags) .field("uc_link", &self.uc_link) @@ -210,8 +210,8 @@ cfg_if! { } } - impl std::hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { self.uc_flags.hash(state); self.uc_link.hash(state); self.uc_stack.hash(state); diff --git a/src/unix/notbsd/linux/musl/b64/x86_64.rs b/src/unix/notbsd/linux/musl/b64/x86_64.rs index 49b03eb228ed2..7c58eaacbc914 100644 --- a/src/unix/notbsd/linux/musl/b64/x86_64.rs +++ b/src/unix/notbsd/linux/musl/b64/x86_64.rs @@ -94,8 +94,8 @@ cfg_if! { impl Eq for ucontext_t {} - impl std::fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("ucontext_t") .field("uc_flags", &self.uc_flags) .field("uc_link", &self.uc_link) @@ -107,8 +107,8 @@ cfg_if! { } } - impl std::hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { self.uc_flags.hash(state); self.uc_link.hash(state); self.uc_stack.hash(state); diff --git a/src/unix/notbsd/linux/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs index 7bf7410dbe182..b36039293ecad 100644 --- a/src/unix/notbsd/linux/musl/mod.rs +++ b/src/unix/notbsd/linux/musl/mod.rs @@ -122,8 +122,8 @@ cfg_if! { impl Eq for sysinfo {} - impl std::fmt::Debug for sysinfo { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for sysinfo { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("sysinfo") .field("uptime", &self.uptime) .field("loads", &self.loads) @@ -143,8 +143,8 @@ cfg_if! { } } - impl std::hash::Hash for sysinfo { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for sysinfo { + fn hash(&self, state: &mut H) { self.uptime.hash(state); self.loads.hash(state); self.totalram.hash(state); diff --git a/src/unix/notbsd/linux/other/b32/x86.rs b/src/unix/notbsd/linux/other/b32/x86.rs index 6218a6ac675fb..82d72c9250ada 100644 --- a/src/unix/notbsd/linux/other/b32/x86.rs +++ b/src/unix/notbsd/linux/other/b32/x86.rs @@ -237,8 +237,8 @@ cfg_if! { impl Eq for user_fpxregs_struct {} - impl std::fmt::Debug for user_fpxregs_struct { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for user_fpxregs_struct { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("user_fpxregs_struct") .field("cwd", &self.cwd) .field("swd", &self.swd) @@ -257,8 +257,8 @@ cfg_if! { } } - impl std::hash::Hash for user_fpxregs_struct { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for user_fpxregs_struct { + fn hash(&self, state: &mut H) { self.cwd.hash(state); self.swd.hash(state); self.twd.hash(state); @@ -288,8 +288,8 @@ cfg_if! { impl Eq for ucontext_t {} - impl std::fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("ucontext_t") .field("uc_flags", &self.uc_flags) .field("uc_link", &self.uc_link) @@ -301,8 +301,8 @@ cfg_if! { } } - impl std::hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { self.uc_flags.hash(state); self.uc_link.hash(state); self.uc_stack.hash(state); diff --git a/src/unix/notbsd/linux/other/b64/x86_64.rs b/src/unix/notbsd/linux/other/b64/x86_64.rs index 90a8f53ff2e56..22341c73deeae 100644 --- a/src/unix/notbsd/linux/other/b64/x86_64.rs +++ b/src/unix/notbsd/linux/other/b64/x86_64.rs @@ -258,8 +258,8 @@ cfg_if! { impl Eq for user_fpregs_struct {} - impl std::fmt::Debug for user_fpregs_struct { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for user_fpregs_struct { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("user_fpregs_struct") .field("cwd", &self.cwd) .field("ftw", &self.ftw) @@ -275,8 +275,8 @@ cfg_if! { } } - impl std::hash::Hash for user_fpregs_struct { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for user_fpregs_struct { + fn hash(&self, state: &mut H) { self.cwd.hash(state); self.ftw.hash(state); self.fop.hash(state); @@ -303,8 +303,8 @@ cfg_if! { impl Eq for ucontext_t {} - impl std::fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("ucontext_t") .field("uc_flags", &self.uc_flags) .field("uc_link", &self.uc_link) @@ -316,8 +316,8 @@ cfg_if! { } } - impl std::hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { self.uc_flags.hash(state); self.uc_link.hash(state); self.uc_stack.hash(state); diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index d30ffff3baf1a..fb1450712858e 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -270,8 +270,8 @@ cfg_if! { impl Eq for utmpx {} - impl std::fmt::Debug for utmpx { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for utmpx { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("utmpx") .field("ut_type", &self.ut_type) .field("ut_pid", &self.ut_pid) @@ -288,8 +288,8 @@ cfg_if! { } } - impl std::hash::Hash for utmpx { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for utmpx { + fn hash(&self, state: &mut H) { self.ut_type.hash(state); self.ut_pid.hash(state); self.ut_line.hash(state); diff --git a/src/unix/notbsd/linux/s390x.rs b/src/unix/notbsd/linux/s390x.rs index e0a79d32665d7..1d40e7527f346 100644 --- a/src/unix/notbsd/linux/s390x.rs +++ b/src/unix/notbsd/linux/s390x.rs @@ -346,16 +346,16 @@ cfg_if! { impl Eq for fpreg_t {} - impl std::fmt::Debug for fpreg_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for fpreg_t { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("fpreg_t") .field("d", &self.d) .finish() } } - impl std::hash::Hash for fpreg_t { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for fpreg_t { + fn hash(&self, state: &mut H) { self.d.to_bits().hash(state); } } diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index d2f0cce945285..ebc1127eed6f5 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -252,8 +252,8 @@ cfg_if! { impl Eq for sockaddr_un {} - impl std::fmt::Debug for sockaddr_un { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for sockaddr_un { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("sockaddr_un") .field("sun_family", &self.sun_family) // FIXME: .field("sun_path", &self.sun_path) @@ -261,8 +261,8 @@ cfg_if! { } } - impl std::hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for sockaddr_un { + fn hash(&self, state: &mut H) { self.sun_family.hash(state); self.sun_path.hash(state); } @@ -281,8 +281,8 @@ cfg_if! { impl Eq for sockaddr_storage {} - impl std::fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("sockaddr_storage") .field("ss_family", &self.ss_family) .field("__ss_align", &self.__ss_align) @@ -291,8 +291,8 @@ cfg_if! { } } - impl std::hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { self.ss_family.hash(state); self.__ss_pad2.hash(state); } @@ -334,8 +334,8 @@ cfg_if! { impl Eq for utsname {} - impl std::fmt::Debug for utsname { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl core::fmt::Debug for utsname { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { f.debug_struct("utsname") // FIXME: .field("sysname", &self.sysname) // FIXME: .field("nodename", &self.nodename) @@ -347,8 +347,8 @@ cfg_if! { } } - impl std::hash::Hash for utsname { - fn hash(&self, state: &mut H) { + impl core::hash::Hash for utsname { + fn hash(&self, state: &mut H) { self.sysname.hash(state); self.nodename.hash(state); self.release.hash(state); From df7cc95fde9d99882bbf596d05ed4fd1ab2be1dc Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 14:13:42 +0100 Subject: [PATCH 24/72] Do not derive traits for packed structs --- src/lib.rs | 3 +-- src/unix/bsd/apple/mod.rs | 1 - src/unix/bsd/netbsdlike/netbsd/mod.rs | 2 ++ src/unix/mod.rs | 22 +++++++++++++++++----- src/unix/notbsd/mod.rs | 23 +++++++++++++---------- src/unix/solaris/mod.rs | 2 ++ src/unix/uclibc/mod.rs | 19 +++++++++++-------- 7 files changed, 46 insertions(+), 26 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 4aff70efbe76e..fa3199bb80e18 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -158,8 +158,7 @@ #![cfg_attr(not(any(feature = "use_std", feature = "rustc-dep-of-std")), no_std)] // Enable lints #![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))] -#![deny(missing_copy_implementations)] - +#![deny(missing_copy_implementations, safe_packed_borrows)] #[cfg(all(not(cross_platform_docs), feature = "use_std"))] extern crate std as core; diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 1754303eef901..c8955ad89bdac 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -475,7 +475,6 @@ s! { } s_no_extra_traits!{ - // FIXME: https://github.com/rust-lang/libc/issues/1243 #[allow(missing_debug_implementations)] #[cfg_attr(libc_packedN, repr(packed(4)))] diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index d3acfb9394ae8..ca7faaec4ef43 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -323,7 +323,9 @@ s! { pub ipi_addr: ::in_addr, pub ipi_ifindex: ::c_uint, } +} +s_no_extra_traits! { #[repr(packed)] pub struct arphdr { pub ar_hrd: u16, diff --git a/src/unix/mod.rs b/src/unix/mod.rs index e048f719777d4..bdc39c917916c 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -137,11 +137,6 @@ s! { __reserved: [c_long; 16], } - #[cfg_attr(target_os = "netbsd", repr(packed))] - pub struct in_addr { - pub s_addr: in_addr_t, - } - #[cfg_attr(libc_align, repr(align(4)))] pub struct in6_addr { pub s6_addr: [u8; 16], @@ -226,6 +221,23 @@ s! { } } +cfg_if! { + if #[cfg(target_os = "netbsd")] { + s_no_extra_traits! { + #[repr(packed)] + pub struct in_addr { + pub s_addr: in_addr_t, + } + } + } else { + s! { + pub struct in_addr { + pub s_addr: in_addr_t, + } + } + } +} + pub const INT_MIN: c_int = -2147483648; pub const INT_MAX: c_int = 2147483647; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index ebc1127eed6f5..fc8cb41393aff 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -109,16 +109,6 @@ s! { pub dli_saddr: *mut ::c_void, } - #[cfg_attr(any(all(target_arch = "x86", - not(target_env = "musl"), - not(target_os = "android")), - target_arch = "x86_64"), - repr(packed))] - pub struct epoll_event { - pub events: ::uint32_t, - pub u64: ::uint64_t, - } - pub struct lconv { pub decimal_point: *mut ::c_char, pub thousands_sep: *mut ::c_char, @@ -213,6 +203,19 @@ s! { } s_no_extra_traits!{ + #[cfg_attr( + any( + all( + target_arch = "x86", + not(target_env = "musl"), + not(target_os = "android")), + target_arch = "x86_64"), + repr(packed))] + pub struct epoll_event { + pub events: ::uint32_t, + pub u64: ::uint64_t, + } + pub struct sockaddr_un { pub sun_family: sa_family_t, pub sun_path: [::c_char; 108] diff --git a/src/unix/solaris/mod.rs b/src/unix/solaris/mod.rs index c9a53e1f57737..98f6c2ee4b789 100644 --- a/src/unix/solaris/mod.rs +++ b/src/unix/solaris/mod.rs @@ -358,7 +358,9 @@ s! { pub portev_object: ::uintptr_t, pub portev_user: *mut ::c_void, } +} +s_no_extra_traits! { #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed))] pub struct epoll_event { pub events: ::uint32_t, diff --git a/src/unix/uclibc/mod.rs b/src/unix/uclibc/mod.rs index a5cb80e04397c..2cb4d9750d6b2 100644 --- a/src/unix/uclibc/mod.rs +++ b/src/unix/uclibc/mod.rs @@ -133,14 +133,6 @@ s! { pub dli_saddr: *mut ::c_void, } - #[cfg_attr(any(all(target_arch = "x86", - target_arch = "x86_64")), - repr(packed))] - pub struct epoll_event { - pub events: ::uint32_t, - pub u64: ::uint64_t, - } - pub struct utsname { pub sysname: [::c_char; 65], pub nodename: [::c_char; 65], @@ -446,6 +438,17 @@ s! { } } +s_no_extra_traits! { + #[cfg_attr( + any(target_arch = "x86", target_arch = "x86_64"), + repr(packed) + )] + pub struct epoll_event { + pub events: ::uint32_t, + pub u64: ::uint64_t, + } +} + // intentionally not public, only used for fd_set cfg_if! { if #[cfg(target_pointer_width = "32")] { From 155de4442159b79ac0e121cb62736574dcc0afd3 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 14:18:55 +0100 Subject: [PATCH 25/72] Fix documentation and style builds; import core modules in crate root --- ci/dox.sh | 7 ++- src/cloudabi/mod.rs | 2 +- src/fuchsia/mod.rs | 2 +- src/lib.rs | 10 +++ src/redox/mod.rs | 2 +- src/sgx.rs | 2 +- src/switch.rs | 2 +- src/unix/bsd/apple/b32.rs | 8 +-- src/unix/bsd/apple/b64.rs | 8 +-- src/unix/bsd/apple/mod.rs | 74 +++++++++++------------ src/unix/bsd/mod.rs | 16 ++--- src/unix/mod.rs | 26 ++++---- src/unix/notbsd/android/b64/mod.rs | 24 ++++---- src/unix/notbsd/android/mod.rs | 40 ++++++------ src/unix/notbsd/linux/mod.rs | 40 ++++++------ src/unix/notbsd/linux/musl/b32/x86.rs | 8 +-- src/unix/notbsd/linux/musl/b64/x86_64.rs | 8 +-- src/unix/notbsd/linux/musl/mod.rs | 8 +-- src/unix/notbsd/linux/other/b32/x86.rs | 16 ++--- src/unix/notbsd/linux/other/b64/x86_64.rs | 16 ++--- src/unix/notbsd/linux/other/mod.rs | 8 +-- src/unix/notbsd/linux/s390x.rs | 8 +-- src/unix/notbsd/mod.rs | 24 ++++---- src/windows/mod.rs | 2 +- 24 files changed, 185 insertions(+), 176 deletions(-) diff --git a/ci/dox.sh b/ci/dox.sh index 521743e39946b..1efb10d785b4e 100644 --- a/ci/dox.sh +++ b/ci/dox.sh @@ -16,8 +16,11 @@ cp ci/landing-page-head.html target/doc/index.html for target in $TARGETS; do echo "documenting ${target}" - rustdoc -o "target/doc/${target}" --target "${target}" src/lib.rs --cfg cross_platform_docs \ - --crate-name libc + rustdoc -o "target/doc/${target}" \ + --target "${target}" \ + src/lib.rs \ + --cfg cross_platform_docs \ + --crate-name libc echo "
  • ${target}
  • " \ >> target/doc/index.html diff --git a/src/cloudabi/mod.rs b/src/cloudabi/mod.rs index a24ffc4b566f9..e5027b935b1c9 100644 --- a/src/cloudabi/mod.rs +++ b/src/cloudabi/mod.rs @@ -317,7 +317,7 @@ cfg_if! { cfg_if! { if #[cfg(libc_core_cvoid)] { - pub use core::ffi::c_void; + pub use ::ffi::c_void; } else { // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help // enable more optimization opportunities around it recognizing things diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 138bf2a91631f..cf33dadf2d9b4 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -4121,7 +4121,7 @@ cfg_if! { cfg_if! { if #[cfg(libc_core_cvoid)] { - pub use core::ffi::c_void; + pub use ::ffi::c_void; } else { // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help // enable more optimization opportunities around it recognizing things diff --git a/src/lib.rs b/src/lib.rs index fa3199bb80e18..1734450f5e1d6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -175,6 +175,16 @@ cfg_if! { } } +cfg_if! { + if #[cfg(not(cross_platform_docs))] { + #[cfg(libc_core_cvoid)] + use core::ffi; + #[allow(unused_imports)] + use core::fmt; + #[allow(unused_imports)] + use core::hash; + } +} mod dox; diff --git a/src/redox/mod.rs b/src/redox/mod.rs index ac60324969f35..e770b4625a557 100644 --- a/src/redox/mod.rs +++ b/src/redox/mod.rs @@ -387,7 +387,7 @@ mod net; cfg_if! { if #[cfg(libc_core_cvoid)] { - pub use core::ffi::c_void; + pub use ::ffi::c_void; } else { // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help // enable more optimization opportunities around it recognizing things diff --git a/src/sgx.rs b/src/sgx.rs index b9d8b5c5e2470..8a69ad36e48b6 100644 --- a/src/sgx.rs +++ b/src/sgx.rs @@ -37,7 +37,7 @@ pub const INT_MAX: c_int = 2147483647; cfg_if! { if #[cfg(libc_core_cvoid)] { - pub use core::ffi::c_void; + pub use ::ffi::c_void; } else { // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help // enable more optimization opportunities around it recognizing things diff --git a/src/switch.rs b/src/switch.rs index 47d689d3adb71..06fa2030cdf56 100644 --- a/src/switch.rs +++ b/src/switch.rs @@ -39,7 +39,7 @@ pub const INT_MAX: c_int = 2147483647; cfg_if! { if #[cfg(libc_core_cvoid)] { - pub use core::ffi::c_void; + pub use ::ffi::c_void; } else { // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help // enable more optimization opportunities around it recognizing things diff --git a/src/unix/bsd/apple/b32.rs b/src/unix/bsd/apple/b32.rs index 2e0202b82b1aa..13b1a0b7c3dc6 100644 --- a/src/unix/bsd/apple/b32.rs +++ b/src/unix/bsd/apple/b32.rs @@ -64,16 +64,16 @@ cfg_if! { } } impl Eq for pthread_attr_t {} - impl core::fmt::Debug for pthread_attr_t { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for pthread_attr_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("pthread_attr_t") .field("__sig", &self.__sig) // FIXME: .field("__opaque", &self.__opaque) .finish() } } - impl core::hash::Hash for pthread_attr_t { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for pthread_attr_t { + fn hash(&self, state: &mut H) { self.__sig.hash(state); self.__opaque.hash(state); } diff --git a/src/unix/bsd/apple/b64.rs b/src/unix/bsd/apple/b64.rs index f374b3084281f..50b48fa5ecd7f 100644 --- a/src/unix/bsd/apple/b64.rs +++ b/src/unix/bsd/apple/b64.rs @@ -69,16 +69,16 @@ cfg_if! { } } impl Eq for pthread_attr_t {} - impl core::fmt::Debug for pthread_attr_t { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for pthread_attr_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("pthread_attr_t") .field("__sig", &self.__sig) // FIXME: .field("__opaque", &self.__opaque) .finish() } } - impl core::hash::Hash for pthread_attr_t { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for pthread_attr_t { + fn hash(&self, state: &mut H) { self.__sig.hash(state); self.__opaque.hash(state); } diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index c8955ad89bdac..5bc0aa209552d 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -613,16 +613,16 @@ cfg_if! { } } impl Eq for semun {} - impl core::fmt::Debug for semun { - fn fmt(&self, f: &mut core::fmt::Formatter) - -> core::fmt::Result { + impl ::fmt::Debug for semun { + fn fmt(&self, f: &mut ::fmt::Formatter) + -> ::fmt::Result { f.debug_struct("semun") .field("val", unsafe { &self.val }) .finish() } } - impl core::hash::Hash for semun { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for semun { + fn hash(&self, state: &mut H) { unsafe { self.val.hash(state) }; } } @@ -652,8 +652,8 @@ cfg_if! { } } impl Eq for proc_threadinfo {} - impl core::fmt::Debug for proc_threadinfo { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for proc_threadinfo { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("proc_threadinfo") .field("pth_user_time", &self.pth_user_time) .field("pth_system_time", &self.pth_system_time) @@ -670,8 +670,8 @@ cfg_if! { } } - impl core::hash::Hash for proc_threadinfo { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for proc_threadinfo { + fn hash(&self, state: &mut H) { self.pth_user_time.hash(state); self.pth_system_time.hash(state); self.pth_cpu_usage.hash(state); @@ -716,8 +716,8 @@ cfg_if! { } impl Eq for statfs {} - impl core::fmt::Debug for statfs { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for statfs { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("statfs") .field("f_bsize", &self.f_bsize) .field("f_iosize", &self.f_iosize) @@ -739,8 +739,8 @@ cfg_if! { } } - impl core::hash::Hash for statfs { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for statfs { + fn hash(&self, state: &mut H) { self.f_bsize.hash(state); self.f_iosize.hash(state); self.f_blocks.hash(state); @@ -775,8 +775,8 @@ cfg_if! { } } impl Eq for dirent {} - impl core::fmt::Debug for dirent { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("dirent") .field("d_ino", &self.d_ino) .field("d_seekoff", &self.d_seekoff) @@ -787,8 +787,8 @@ cfg_if! { .finish() } } - impl core::hash::Hash for dirent { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { self.d_ino.hash(state); self.d_seekoff.hash(state); self.d_reclen.hash(state); @@ -808,16 +808,16 @@ cfg_if! { } } impl Eq for pthread_rwlock_t {} - impl core::fmt::Debug for pthread_rwlock_t { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for pthread_rwlock_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("pthread_rwlock_t") .field("__sig", &self.__sig) // FIXME: .field("__opaque", &self.__opaque) .finish() } } - impl core::hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for pthread_rwlock_t { + fn hash(&self, state: &mut H) { self.__sig.hash(state); self.__opaque.hash(state); } @@ -836,8 +836,8 @@ cfg_if! { impl Eq for pthread_mutex_t {} - impl core::fmt::Debug for pthread_mutex_t { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for pthread_mutex_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("pthread_mutex_t") .field("__sig", &self.__sig) // FIXME: .field("__opaque", &self.__opaque) @@ -845,8 +845,8 @@ cfg_if! { } } - impl core::hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for pthread_mutex_t { + fn hash(&self, state: &mut H) { self.__sig.hash(state); self.__opaque.hash(state); } @@ -865,8 +865,8 @@ cfg_if! { impl Eq for pthread_cond_t {} - impl core::fmt::Debug for pthread_cond_t { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("pthread_cond_t") .field("__sig", &self.__sig) // FIXME: .field("__opaque", &self.__opaque) @@ -874,8 +874,8 @@ cfg_if! { } } - impl core::hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { self.__sig.hash(state); self.__opaque.hash(state); } @@ -901,8 +901,8 @@ cfg_if! { impl Eq for sockaddr_storage {} - impl core::fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("sockaddr_storage") .field("ss_len", &self.ss_len) .field("ss_family", &self.ss_family) @@ -913,8 +913,8 @@ cfg_if! { } } - impl core::hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { self.ss_len.hash(state); self.ss_family.hash(state); self.__ss_pad1.hash(state); @@ -945,8 +945,8 @@ cfg_if! { impl Eq for utmpx {} - impl core::fmt::Debug for utmpx { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for utmpx { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("utmpx") // FIXME: .field("ut_user", &self.ut_user) .field("ut_id", &self.ut_id) @@ -960,8 +960,8 @@ cfg_if! { } } - impl core::hash::Hash for utmpx { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for utmpx { + fn hash(&self, state: &mut H) { self.ut_user.hash(state); self.ut_id.hash(state); self.ut_line.hash(state); diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index b058fad8128c8..8b5ec8c54d766 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -153,8 +153,8 @@ cfg_if! { impl Eq for sockaddr_un {} - impl core::fmt::Debug for sockaddr_un { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for sockaddr_un { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("sockaddr_un") .field("sun_len", &self.sun_len) .field("sun_family", &self.sun_family) @@ -163,8 +163,8 @@ cfg_if! { } } - impl core::hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for sockaddr_un { + fn hash(&self, state: &mut H) { self.sun_len.hash(state); self.sun_family.hash(state); self.sun_path.hash(state); @@ -202,8 +202,8 @@ cfg_if! { impl Eq for utsname {} - impl core::fmt::Debug for utsname { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for utsname { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("utsname") // FIXME: .field("sysname", &self.sysname) // FIXME: .field("nodename", &self.nodename) @@ -214,8 +214,8 @@ cfg_if! { } } - impl core::hash::Hash for utsname { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for utsname { + fn hash(&self, state: &mut H) { self.sysname.hash(state); self.nodename.hash(state); self.release.hash(state); diff --git a/src/unix/mod.rs b/src/unix/mod.rs index bdc39c917916c..27d00d7346d90 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -219,22 +219,18 @@ s! { pub p_aliases: *mut *mut ::c_char, pub p_proto: ::c_int, } + + #[cfg(not(target_os = "netbsd"))] + pub struct in_addr { + pub s_addr: in_addr_t, + } } -cfg_if! { - if #[cfg(target_os = "netbsd")] { - s_no_extra_traits! { - #[repr(packed)] - pub struct in_addr { - pub s_addr: in_addr_t, - } - } - } else { - s! { - pub struct in_addr { - pub s_addr: in_addr_t, - } - } +s_no_extra_traits! { + #[cfg(target_os = "netbsd")] + #[repr(packed)] + pub struct in_addr { + pub s_addr: in_addr_t, } } @@ -1182,7 +1178,7 @@ cfg_if! { cfg_if! { if #[cfg(libc_core_cvoid)] { - pub use core::ffi::c_void; + pub use ::ffi::c_void; } else { // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help // enable more optimization opportunities around it recognizing things diff --git a/src/unix/notbsd/android/b64/mod.rs b/src/unix/notbsd/android/b64/mod.rs index 3b810c771882c..fce9965b0017a 100644 --- a/src/unix/notbsd/android/b64/mod.rs +++ b/src/unix/notbsd/android/b64/mod.rs @@ -143,8 +143,8 @@ cfg_if! { impl Eq for pthread_mutex_t {} - impl core::fmt::Debug for pthread_mutex_t { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for pthread_mutex_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("pthread_mutex_t") .field("value", &self.value) // FIXME: .field("__reserved", &self.__reserved) @@ -152,8 +152,8 @@ cfg_if! { } } - impl core::hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for pthread_mutex_t { + fn hash(&self, state: &mut H) { self.value.hash(state); self.__reserved.hash(state); } @@ -172,8 +172,8 @@ cfg_if! { impl Eq for pthread_cond_t {} - impl core::fmt::Debug for pthread_cond_t { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("pthread_cond_t") .field("value", &self.value) // FIXME: .field("__reserved", &self.__reserved) @@ -181,8 +181,8 @@ cfg_if! { } } - impl core::hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { self.value.hash(state); self.__reserved.hash(state); } @@ -205,8 +205,8 @@ cfg_if! { impl Eq for pthread_rwlock_t {} - impl core::fmt::Debug for pthread_rwlock_t { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for pthread_rwlock_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("pthread_rwlock_t") .field("numLocks", &self.numLocks) .field("writerThreadId", &self.writerThreadId) @@ -218,8 +218,8 @@ cfg_if! { } } - impl core::hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for pthread_rwlock_t { + fn hash(&self, state: &mut H) { self.numLocks.hash(state); self.writerThreadId.hash(state); self.pendingReaders.hash(state); diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs index e0303f93ec7e2..2213b75b663ed 100644 --- a/src/unix/notbsd/android/mod.rs +++ b/src/unix/notbsd/android/mod.rs @@ -258,8 +258,8 @@ cfg_if! { impl Eq for dirent {} - impl core::fmt::Debug for dirent { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("dirent") .field("d_ino", &self.d_ino) .field("d_off", &self.d_off) @@ -270,8 +270,8 @@ cfg_if! { } } - impl core::hash::Hash for dirent { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { self.d_ino.hash(state); self.d_off.hash(state); self.d_reclen.hash(state); @@ -296,8 +296,8 @@ cfg_if! { impl Eq for dirent64 {} - impl core::fmt::Debug for dirent64 { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for dirent64 { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("dirent64") .field("d_ino", &self.d_ino) .field("d_off", &self.d_off) @@ -308,8 +308,8 @@ cfg_if! { } } - impl core::hash::Hash for dirent64 { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for dirent64 { + fn hash(&self, state: &mut H) { self.d_ino.hash(state); self.d_off.hash(state); self.d_reclen.hash(state); @@ -330,8 +330,8 @@ cfg_if! { impl Eq for siginfo_t {} - impl core::fmt::Debug for siginfo_t { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for siginfo_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("siginfo_t") .field("si_signo", &self.si_signo) .field("si_errno", &self.si_errno) @@ -342,8 +342,8 @@ cfg_if! { } } - impl core::hash::Hash for siginfo_t { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for siginfo_t { + fn hash(&self, state: &mut H) { self.si_signo.hash(state); self.si_errno.hash(state); self.si_code.hash(state); @@ -370,8 +370,8 @@ cfg_if! { impl Eq for lastlog {} - impl core::fmt::Debug for lastlog { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for lastlog { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("lastlog") .field("ll_time", &self.ll_time) .field("ll_line", &self.ll_line) @@ -380,8 +380,8 @@ cfg_if! { } } - impl core::hash::Hash for lastlog { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for lastlog { + fn hash(&self, state: &mut H) { self.ll_time.hash(state); self.ll_line.hash(state); self.ll_host.hash(state); @@ -418,8 +418,8 @@ cfg_if! { impl Eq for utmp {} - impl core::fmt::Debug for utmp { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for utmp { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("utmp") .field("ut_type", &self.ut_type) .field("ut_pid", &self.ut_pid) @@ -436,8 +436,8 @@ cfg_if! { } } - impl core::hash::Hash for utmp { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for utmp { + fn hash(&self, state: &mut H) { self.ut_type.hash(state); self.ut_pid.hash(state); self.ut_line.hash(state); diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 6d0593d00c6da..b99bea24a14f3 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -689,8 +689,8 @@ cfg_if! { impl Eq for dirent {} - impl core::fmt::Debug for dirent { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("dirent") .field("d_ino", &self.d_ino) .field("d_off", &self.d_off) @@ -701,8 +701,8 @@ cfg_if! { } } - impl core::hash::Hash for dirent { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { self.d_ino.hash(state); self.d_off.hash(state); self.d_reclen.hash(state); @@ -727,8 +727,8 @@ cfg_if! { impl Eq for dirent64 {} - impl core::fmt::Debug for dirent64 { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for dirent64 { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("dirent64") .field("d_ino", &self.d_ino) .field("d_off", &self.d_off) @@ -739,8 +739,8 @@ cfg_if! { } } - impl core::hash::Hash for dirent64 { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for dirent64 { + fn hash(&self, state: &mut H) { self.d_ino.hash(state); self.d_off.hash(state); self.d_reclen.hash(state); @@ -757,16 +757,16 @@ cfg_if! { impl Eq for pthread_cond_t {} - impl core::fmt::Debug for pthread_cond_t { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for pthread_cond_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("pthread_cond_t") // FIXME: .field("size", &self.size) .finish() } } - impl core::hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for pthread_cond_t { + fn hash(&self, state: &mut H) { self.size.hash(state); } } @@ -779,16 +779,16 @@ cfg_if! { impl Eq for pthread_mutex_t {} - impl core::fmt::Debug for pthread_mutex_t { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for pthread_mutex_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("pthread_mutex_t") // FIXME: .field("size", &self.size) .finish() } } - impl core::hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for pthread_mutex_t { + fn hash(&self, state: &mut H) { self.size.hash(state); } } @@ -801,16 +801,16 @@ cfg_if! { impl Eq for pthread_rwlock_t {} - impl core::fmt::Debug for pthread_rwlock_t { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for pthread_rwlock_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("pthread_rwlock_t") // FIXME: .field("size", &self.size) .finish() } } - impl core::hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for pthread_rwlock_t { + fn hash(&self, state: &mut H) { self.size.hash(state); } } diff --git a/src/unix/notbsd/linux/musl/b32/x86.rs b/src/unix/notbsd/linux/musl/b32/x86.rs index d06d9a9daa084..8bfb60ba3852a 100644 --- a/src/unix/notbsd/linux/musl/b32/x86.rs +++ b/src/unix/notbsd/linux/musl/b32/x86.rs @@ -197,8 +197,8 @@ cfg_if! { impl Eq for ucontext_t {} - impl core::fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("ucontext_t") .field("uc_flags", &self.uc_flags) .field("uc_link", &self.uc_link) @@ -210,8 +210,8 @@ cfg_if! { } } - impl core::hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { self.uc_flags.hash(state); self.uc_link.hash(state); self.uc_stack.hash(state); diff --git a/src/unix/notbsd/linux/musl/b64/x86_64.rs b/src/unix/notbsd/linux/musl/b64/x86_64.rs index 7c58eaacbc914..94c5d88dab306 100644 --- a/src/unix/notbsd/linux/musl/b64/x86_64.rs +++ b/src/unix/notbsd/linux/musl/b64/x86_64.rs @@ -94,8 +94,8 @@ cfg_if! { impl Eq for ucontext_t {} - impl core::fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("ucontext_t") .field("uc_flags", &self.uc_flags) .field("uc_link", &self.uc_link) @@ -107,8 +107,8 @@ cfg_if! { } } - impl core::hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { self.uc_flags.hash(state); self.uc_link.hash(state); self.uc_stack.hash(state); diff --git a/src/unix/notbsd/linux/musl/mod.rs b/src/unix/notbsd/linux/musl/mod.rs index b36039293ecad..d5351d624bea6 100644 --- a/src/unix/notbsd/linux/musl/mod.rs +++ b/src/unix/notbsd/linux/musl/mod.rs @@ -122,8 +122,8 @@ cfg_if! { impl Eq for sysinfo {} - impl core::fmt::Debug for sysinfo { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for sysinfo { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("sysinfo") .field("uptime", &self.uptime) .field("loads", &self.loads) @@ -143,8 +143,8 @@ cfg_if! { } } - impl core::hash::Hash for sysinfo { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for sysinfo { + fn hash(&self, state: &mut H) { self.uptime.hash(state); self.loads.hash(state); self.totalram.hash(state); diff --git a/src/unix/notbsd/linux/other/b32/x86.rs b/src/unix/notbsd/linux/other/b32/x86.rs index 82d72c9250ada..563ac98ac3335 100644 --- a/src/unix/notbsd/linux/other/b32/x86.rs +++ b/src/unix/notbsd/linux/other/b32/x86.rs @@ -237,8 +237,8 @@ cfg_if! { impl Eq for user_fpxregs_struct {} - impl core::fmt::Debug for user_fpxregs_struct { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for user_fpxregs_struct { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("user_fpxregs_struct") .field("cwd", &self.cwd) .field("swd", &self.swd) @@ -257,8 +257,8 @@ cfg_if! { } } - impl core::hash::Hash for user_fpxregs_struct { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for user_fpxregs_struct { + fn hash(&self, state: &mut H) { self.cwd.hash(state); self.swd.hash(state); self.twd.hash(state); @@ -288,8 +288,8 @@ cfg_if! { impl Eq for ucontext_t {} - impl core::fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("ucontext_t") .field("uc_flags", &self.uc_flags) .field("uc_link", &self.uc_link) @@ -301,8 +301,8 @@ cfg_if! { } } - impl core::hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { self.uc_flags.hash(state); self.uc_link.hash(state); self.uc_stack.hash(state); diff --git a/src/unix/notbsd/linux/other/b64/x86_64.rs b/src/unix/notbsd/linux/other/b64/x86_64.rs index 22341c73deeae..d4f4ffc4da399 100644 --- a/src/unix/notbsd/linux/other/b64/x86_64.rs +++ b/src/unix/notbsd/linux/other/b64/x86_64.rs @@ -258,8 +258,8 @@ cfg_if! { impl Eq for user_fpregs_struct {} - impl core::fmt::Debug for user_fpregs_struct { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for user_fpregs_struct { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("user_fpregs_struct") .field("cwd", &self.cwd) .field("ftw", &self.ftw) @@ -275,8 +275,8 @@ cfg_if! { } } - impl core::hash::Hash for user_fpregs_struct { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for user_fpregs_struct { + fn hash(&self, state: &mut H) { self.cwd.hash(state); self.ftw.hash(state); self.fop.hash(state); @@ -303,8 +303,8 @@ cfg_if! { impl Eq for ucontext_t {} - impl core::fmt::Debug for ucontext_t { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("ucontext_t") .field("uc_flags", &self.uc_flags) .field("uc_link", &self.uc_link) @@ -316,8 +316,8 @@ cfg_if! { } } - impl core::hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for ucontext_t { + fn hash(&self, state: &mut H) { self.uc_flags.hash(state); self.uc_link.hash(state); self.uc_stack.hash(state); diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index fb1450712858e..08d0b58d07959 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -270,8 +270,8 @@ cfg_if! { impl Eq for utmpx {} - impl core::fmt::Debug for utmpx { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for utmpx { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("utmpx") .field("ut_type", &self.ut_type) .field("ut_pid", &self.ut_pid) @@ -288,8 +288,8 @@ cfg_if! { } } - impl core::hash::Hash for utmpx { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for utmpx { + fn hash(&self, state: &mut H) { self.ut_type.hash(state); self.ut_pid.hash(state); self.ut_line.hash(state); diff --git a/src/unix/notbsd/linux/s390x.rs b/src/unix/notbsd/linux/s390x.rs index 1d40e7527f346..dbd5ea5454149 100644 --- a/src/unix/notbsd/linux/s390x.rs +++ b/src/unix/notbsd/linux/s390x.rs @@ -346,16 +346,16 @@ cfg_if! { impl Eq for fpreg_t {} - impl core::fmt::Debug for fpreg_t { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for fpreg_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("fpreg_t") .field("d", &self.d) .finish() } } - impl core::hash::Hash for fpreg_t { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for fpreg_t { + fn hash(&self, state: &mut H) { self.d.to_bits().hash(state); } } diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index fc8cb41393aff..8aa318840d912 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -255,8 +255,8 @@ cfg_if! { impl Eq for sockaddr_un {} - impl core::fmt::Debug for sockaddr_un { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for sockaddr_un { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("sockaddr_un") .field("sun_family", &self.sun_family) // FIXME: .field("sun_path", &self.sun_path) @@ -264,8 +264,8 @@ cfg_if! { } } - impl core::hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for sockaddr_un { + fn hash(&self, state: &mut H) { self.sun_family.hash(state); self.sun_path.hash(state); } @@ -284,8 +284,8 @@ cfg_if! { impl Eq for sockaddr_storage {} - impl core::fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("sockaddr_storage") .field("ss_family", &self.ss_family) .field("__ss_align", &self.__ss_align) @@ -294,8 +294,8 @@ cfg_if! { } } - impl core::hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { self.ss_family.hash(state); self.__ss_pad2.hash(state); } @@ -337,8 +337,8 @@ cfg_if! { impl Eq for utsname {} - impl core::fmt::Debug for utsname { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + impl ::fmt::Debug for utsname { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("utsname") // FIXME: .field("sysname", &self.sysname) // FIXME: .field("nodename", &self.nodename) @@ -350,8 +350,8 @@ cfg_if! { } } - impl core::hash::Hash for utsname { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for utsname { + fn hash(&self, state: &mut H) { self.sysname.hash(state); self.nodename.hash(state); self.release.hash(state); diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 30270cdf88ead..acde2e9ee2261 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -435,7 +435,7 @@ extern "system" { cfg_if! { if #[cfg(libc_core_cvoid)] { - pub use core::ffi::c_void; + pub use ::ffi::c_void; } else { // Use repr(u8) as LLVM expects `void*` to be the same as `i8*` to help // enable more optimization opportunities around it recognizing things From 28bd5780e2623142d70adc6f46c79b4e2eae8692 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 14:35:08 +0100 Subject: [PATCH 26/72] Refactor in_addr --- src/unix/bsd/apple/mod.rs | 4 ++++ src/unix/bsd/freebsdlike/mod.rs | 4 ++++ src/unix/bsd/netbsdlike/netbsd/mod.rs | 7 +++++++ src/unix/bsd/netbsdlike/openbsdlike/mod.rs | 4 ++++ src/unix/haiku/mod.rs | 4 ++++ src/unix/hermit/mod.rs | 4 ++++ src/unix/mod.rs | 13 ------------- src/unix/newlib/mod.rs | 4 ++++ src/unix/notbsd/mod.rs | 7 ++++++- src/unix/solaris/mod.rs | 4 ++++ src/unix/uclibc/mod.rs | 4 ++++ 11 files changed, 45 insertions(+), 14 deletions(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 5bc0aa209552d..d94027bdb8013 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -472,6 +472,10 @@ s! { pub ar_pln: u8, pub ar_op: u16, } + + pub struct in_addr { + pub s_addr: ::in_addr_t, + } } s_no_extra_traits!{ diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 73f8852052e58..95d9400987456 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -23,6 +23,10 @@ impl ::dox::Clone for timezone { } s! { + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + pub struct glob_t { pub gl_pathc: ::size_t, pub gl_matchc: ::size_t, diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index ca7faaec4ef43..6ff545cdb855b 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -327,6 +327,7 @@ s! { s_no_extra_traits! { #[repr(packed)] + #[allow(missing_debug_implementations)] pub struct arphdr { pub ar_hrd: u16, pub ar_pro: u16, @@ -334,6 +335,12 @@ s_no_extra_traits! { pub ar_pln: u8, pub ar_op: u16, } + + #[repr(packed)] + #[allow(missing_debug_implementations)] + pub struct in_addr { + pub s_addr: ::in_addr_t, + } } pub const AT_FDCWD: ::c_int = -100; diff --git a/src/unix/bsd/netbsdlike/openbsdlike/mod.rs b/src/unix/bsd/netbsdlike/openbsdlike/mod.rs index 1c2e47dc3f98f..c7ed0198c0bed 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/mod.rs @@ -17,6 +17,10 @@ pub type pthread_rwlockattr_t = *mut ::c_void; pub type caddr_t = *mut ::c_char; s! { + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + pub struct dirent { pub d_fileno: ::ino_t, pub d_off: ::off_t, diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 94d8039006d2a..6eaadc845cd15 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -39,6 +39,10 @@ impl ::dox::Clone for timezone { } s! { + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + pub struct sockaddr { pub sa_len: u8, pub sa_family: sa_family_t, diff --git a/src/unix/hermit/mod.rs b/src/unix/hermit/mod.rs index ba7a90f7be368..7d652291319e1 100644 --- a/src/unix/hermit/mod.rs +++ b/src/unix/hermit/mod.rs @@ -50,6 +50,10 @@ pub type pthread_rwlock_t = usize; pub type pthread_rwlockattr_t = usize; s! { + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + pub struct addrinfo { pub ai_flags: ::c_int, pub ai_family: ::c_int, diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 27d00d7346d90..72324c16f5a5d 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -219,19 +219,6 @@ s! { pub p_aliases: *mut *mut ::c_char, pub p_proto: ::c_int, } - - #[cfg(not(target_os = "netbsd"))] - pub struct in_addr { - pub s_addr: in_addr_t, - } -} - -s_no_extra_traits! { - #[cfg(target_os = "netbsd")] - #[repr(packed)] - pub struct in_addr { - pub s_addr: in_addr_t, - } } pub const INT_MIN: c_int = -2147483648; diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 50c60a6be09e4..c8594fa5d08a0 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -27,6 +27,10 @@ pub type time_t = i32; pub type useconds_t = u32; s! { + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + pub struct sockaddr { pub sa_family: sa_family_t, pub sa_data: [::c_char; 14], diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 8aa318840d912..19e01be654118 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -16,6 +16,10 @@ impl ::dox::Clone for timezone { } s! { + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + pub struct sockaddr { pub sa_family: sa_family_t, pub sa_data: [::c_char; 14], @@ -210,7 +214,8 @@ s_no_extra_traits!{ not(target_env = "musl"), not(target_os = "android")), target_arch = "x86_64"), - repr(packed))] + repr(packed))] + #[allow(missing_debug_implementations)] pub struct epoll_event { pub events: ::uint32_t, pub u64: ::uint64_t, diff --git a/src/unix/solaris/mod.rs b/src/unix/solaris/mod.rs index 98f6c2ee4b789..889408a1a1def 100644 --- a/src/unix/solaris/mod.rs +++ b/src/unix/solaris/mod.rs @@ -44,6 +44,10 @@ impl ::dox::Clone for timezone { } s! { + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + pub struct sockaddr { pub sa_family: sa_family_t, pub sa_data: [::c_char; 14], diff --git a/src/unix/uclibc/mod.rs b/src/unix/uclibc/mod.rs index 2cb4d9750d6b2..c964932932516 100644 --- a/src/unix/uclibc/mod.rs +++ b/src/unix/uclibc/mod.rs @@ -39,6 +39,10 @@ impl ::dox::Clone for timezone { } s! { + pub struct in_addr { + pub s_addr: ::in_addr_t, + } + pub struct sockaddr { pub sa_family: sa_family_t, pub sa_data: [::c_char; 14], From 38d41486aa0de61811bdad13a9eb06df129ee90a Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 14:51:45 +0100 Subject: [PATCH 27/72] Add rustfmt support --- .travis.yml | 6 +- build.rs | 12 ++-- libc-test/build.rs | 15 ++--- libc-test/test/cmsg.rs | 134 +++++++++++++++++++++-------------------- rustfmt.toml | 3 + src/lib.rs | 5 +- src/macros.rs | 6 +- 7 files changed, 96 insertions(+), 85 deletions(-) create mode 100644 rustfmt.toml diff --git a/.travis.yml b/.travis.yml index 22177e37995b1..fd6edff53da35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,8 +28,10 @@ matrix: - shellcheck ci/*.sh stage: min-checks-and-tier1 - name: "Style" - install: true - script: rustc ci/style.rs && ./style src + install: rustup component add rustfmt-preview + script: + - rustc ci/style.rs && ./style src + - cargo fmt --all -- --check stage: min-checks-and-tier1 - env: TARGET=i686-apple-darwin diff --git a/build.rs b/build.rs index 21f35fe111c7b..e4114eade1f08 100644 --- a/build.rs +++ b/build.rs @@ -3,13 +3,11 @@ use std::process::Command; use std::str; fn main() { - - let rustc_minor_ver - = rustc_minor_version().expect("Failed to get rustc version"); - let rustc_dep_of_std - = std::env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); - let align_cargo_feature - = std::env::var("CARGO_FEATURE_ALIGN").is_ok(); + let rustc_minor_ver = + rustc_minor_version().expect("Failed to get rustc version"); + let rustc_dep_of_std = + std::env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); + let align_cargo_feature = std::env::var("CARGO_FEATURE_ALIGN").is_ok(); // Rust >= 1.19 supports unions: if rustc_minor_ver >= 19 || rustc_dep_of_std { diff --git a/libc-test/build.rs b/libc-test/build.rs index eab5b762f0db2..e0bd795bb0e52 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -7,13 +7,10 @@ use std::env; #[cfg(unix)] fn do_cc() { - cc::Build::new() - .file("src/cmsg.c") - .compile("cmsg"); + cc::Build::new().file("src/cmsg.c").compile("cmsg"); } #[cfg(not(unix))] -fn do_cc() { -} +fn do_cc() {} fn do_ctest() { let target = env::var("TARGET").unwrap(); @@ -385,7 +382,7 @@ fn do_ctest() { // Fixup a few types on windows that don't actually exist. "time64_t" if windows => "__time64_t".to_string(), "ssize_t" if windows => "SSIZE_T".to_string(), - // windows + // windows "sighandler_t" if windows && !mingw => "_crt_signal_t".to_string(), "sighandler_t" if windows && mingw => "__p_sig_fn_t".to_string(), // OSX calls this something else @@ -671,7 +668,11 @@ fn do_ctest() { // MFD_HUGETLB is not available in some older libc versions on the CI builders. On the // x86_64 and i686 builders it seems to be available for all targets, so at least test // it there. - "MFD_HUGETLB" if !(x86_64 || i686) || musl || (x86_64 && android)=> true, + "MFD_HUGETLB" + if !(x86_64 || i686) || musl || (x86_64 && android) => + { + true + } "DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK" | "DT_SOCK" diff --git a/libc-test/test/cmsg.rs b/libc-test/test/cmsg.rs index afeb2e14d1bfc..af16f29f0be5f 100644 --- a/libc-test/test/cmsg.rs +++ b/libc-test/test/cmsg.rs @@ -8,94 +8,96 @@ extern crate libc; #[cfg(unix)] mod t { -use libc::{self, c_uchar, c_uint, c_void, cmsghdr, msghdr}; -use std::mem; + use libc::{self, c_uchar, c_uint, c_void, cmsghdr, msghdr}; + use std::mem; -extern { - pub fn cmsg_firsthdr(msgh: *const msghdr) -> *mut cmsghdr; - pub fn cmsg_nxthdr(mhdr: *const msghdr, - cmsg: *const cmsghdr) -> *mut cmsghdr; - pub fn cmsg_space(length: c_uint) -> usize; - pub fn cmsg_len(length: c_uint) -> usize; - pub fn cmsg_data(cmsg: *const cmsghdr) -> *mut c_uchar; -} + extern "C" { + pub fn cmsg_firsthdr(msgh: *const msghdr) -> *mut cmsghdr; + pub fn cmsg_nxthdr( + mhdr: *const msghdr, + cmsg: *const cmsghdr, + ) -> *mut cmsghdr; + pub fn cmsg_space(length: c_uint) -> usize; + pub fn cmsg_len(length: c_uint) -> usize; + pub fn cmsg_data(cmsg: *const cmsghdr) -> *mut c_uchar; + } -#[test] -fn test_cmsg_data() { - for l in 0..128 { - let pcmsghdr = l as *const cmsghdr; - unsafe { - assert_eq!(libc::CMSG_DATA(pcmsghdr), cmsg_data(pcmsghdr)); + #[test] + fn test_cmsg_data() { + for l in 0..128 { + let pcmsghdr = l as *const cmsghdr; + unsafe { + assert_eq!(libc::CMSG_DATA(pcmsghdr), cmsg_data(pcmsghdr)); + } } } -} -#[test] -fn test_cmsg_firsthdr() { - let mut mhdr: msghdr = unsafe{mem::zeroed()}; - mhdr.msg_control = 0xdeadbeef as *mut c_void; - let pmhdr = &mhdr as *const msghdr; - for l in 0..128 { - mhdr.msg_controllen = l; - unsafe { - assert_eq!(libc::CMSG_FIRSTHDR(pmhdr), cmsg_firsthdr(pmhdr)); + #[test] + fn test_cmsg_firsthdr() { + let mut mhdr: msghdr = unsafe { mem::zeroed() }; + mhdr.msg_control = 0xdeadbeef as *mut c_void; + let pmhdr = &mhdr as *const msghdr; + for l in 0..128 { + mhdr.msg_controllen = l; + unsafe { + assert_eq!(libc::CMSG_FIRSTHDR(pmhdr), cmsg_firsthdr(pmhdr)); + } } } -} -#[test] -fn test_cmsg_len() { - for l in 0..128 { - unsafe { - assert_eq!(libc::CMSG_LEN(l) as usize, cmsg_len(l)); + #[test] + fn test_cmsg_len() { + for l in 0..128 { + unsafe { + assert_eq!(libc::CMSG_LEN(l) as usize, cmsg_len(l)); + } } } -} - -// Skip on sparc64 -// https://github.com/rust-lang/libc/issues/1239 -#[cfg(not(target_arch = "sparc64"))] -#[test] -fn test_cmsg_nxthdr() { - use std::ptr; - let mut buffer = [0u8; 256]; - let mut mhdr: msghdr = unsafe{mem::zeroed()}; - let pmhdr = &mhdr as *const msghdr; - for start_ofs in 0..64 { - let pcmsghdr = &mut buffer[start_ofs] as *mut u8 as *mut cmsghdr; - mhdr.msg_control = pcmsghdr as *mut c_void; - mhdr.msg_controllen = (160 - start_ofs) as _; - for cmsg_len in 0..64 { - for next_cmsg_len in 0..32 { - for i in buffer[start_ofs..].iter_mut() { - *i = 0; - } - unsafe { - (*pcmsghdr).cmsg_len = cmsg_len; - let libc_next = libc::CMSG_NXTHDR(pmhdr, pcmsghdr); - let next = cmsg_nxthdr(pmhdr, pcmsghdr); - assert_eq!(libc_next, next); + // Skip on sparc64 + // https://github.com/rust-lang/libc/issues/1239 + #[cfg(not(target_arch = "sparc64"))] + #[test] + fn test_cmsg_nxthdr() { + use std::ptr; - if libc_next != ptr::null_mut() { - (*libc_next).cmsg_len = next_cmsg_len; + let mut buffer = [0u8; 256]; + let mut mhdr: msghdr = unsafe { mem::zeroed() }; + let pmhdr = &mhdr as *const msghdr; + for start_ofs in 0..64 { + let pcmsghdr = &mut buffer[start_ofs] as *mut u8 as *mut cmsghdr; + mhdr.msg_control = pcmsghdr as *mut c_void; + mhdr.msg_controllen = (160 - start_ofs) as _; + for cmsg_len in 0..64 { + for next_cmsg_len in 0..32 { + for i in buffer[start_ofs..].iter_mut() { + *i = 0; + } + unsafe { + (*pcmsghdr).cmsg_len = cmsg_len; let libc_next = libc::CMSG_NXTHDR(pmhdr, pcmsghdr); let next = cmsg_nxthdr(pmhdr, pcmsghdr); assert_eq!(libc_next, next); + + if libc_next != ptr::null_mut() { + (*libc_next).cmsg_len = next_cmsg_len; + let libc_next = libc::CMSG_NXTHDR(pmhdr, pcmsghdr); + let next = cmsg_nxthdr(pmhdr, pcmsghdr); + assert_eq!(libc_next, next); + } } } } } } -} -#[test] -fn test_cmsg_space() { - unsafe { - for l in 0..128 { - assert_eq!(libc::CMSG_SPACE(l) as usize, cmsg_space(l)); + #[test] + fn test_cmsg_space() { + unsafe { + for l in 0..128 { + assert_eq!(libc::CMSG_SPACE(l) as usize, cmsg_space(l)); + } } } -} } diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000000000..7ecc610f330a4 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,3 @@ +max_width = 79 +comment_width = 79 +error_on_line_overflow = true \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 1734450f5e1d6..581e770333227 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -155,7 +155,10 @@ #![cfg_attr(feature = "rustc-dep-of-std", feature(no_core))] #![cfg_attr(feature = "rustc-dep-of-std", no_core)] #![cfg_attr(feature = "rustc-dep-of-std", allow(warnings))] -#![cfg_attr(not(any(feature = "use_std", feature = "rustc-dep-of-std")), no_std)] +#![cfg_attr( + not(any(feature = "use_std", feature = "rustc-dep-of-std")), + no_std +)] // Enable lints #![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))] #![deny(missing_copy_implementations, safe_packed_borrows)] diff --git a/src/macros.rs b/src/macros.rs index e8c3c4fc7beaf..b35cdc6315703 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -42,7 +42,8 @@ macro_rules! cfg_if { // Collects all the negated cfgs in a list at the beginning and after the // semicolon is all the remaining items (@__items ($($not:meta,)*) ; ) => {}; - (@__items ($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ), $($rest:tt)*) => { + (@__items ($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ), + $($rest:tt)*) => { // Emit all items within one block, applying an approprate #[cfg]. The // #[cfg] will require all `$m` matchers specified and must also negate // all previous matchers. @@ -141,7 +142,8 @@ macro_rules! __item { #[allow(unused_macros)] macro_rules! align_const { - ($($(#[$attr:meta])* pub const $name:ident : $t1:ty = $t2:ident { $($field:tt)* };)*) => ($( + ($($(#[$attr:meta])* pub const $name:ident : + $t1:ty = $t2:ident { $($field:tt)* };)*) => ($( #[cfg(libc_align)] $(#[$attr])* pub const $name : $t1 = $t2 { From 7dc61769a0dbd8bf9a45bf5e0cb89f6d0e6a51d8 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 15:03:04 +0100 Subject: [PATCH 28/72] Only run libc-test on nightly --- ci/run.sh | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index 7131e5ca6bce4..642807db1428a 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -106,30 +106,17 @@ do fi fi - if [ "${BUILD_ONLY}" = "1" ]; then - cargo "${build_type}" build $opt --no-default-features --target "${TARGET}" - if [ "$NO_STD" != "1" ]; then - cargo "${build_type}" build $opt --target "${TARGET}" - fi - else - # 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 "${build_type}" test $opt \ - --no-default-features \ - --manifest-path libc-test/Cargo.toml \ - --target "${TARGET}" - fi + # Always test that libc builds without any default features (no libstd) + cargo "${build_type}" build $opt --no-default-features --target "${TARGET}" - if [ "$NO_STD" != "1" ]; then - cargo "${build_type}" test $opt \ - --manifest-path libc-test/Cargo.toml \ - --target "${TARGET}" - fi + # Always test that libc builds with default features (e.g. libstd) + # if the target supports libstd + if [ "$NO_STD" != "1" ]; then + cargo "${build_type}" build $opt --target "${TARGET}" fi - # Test the `extra_traits` feature; requires Rust >= 1.25.0 - # No need to run libc-test, only check that libc builds. + # Always test that libc builds with the `extra_traits` feature if Rust >= + # 1.25.0 if [ "${build_type}" != "+1.13.0" ] && \ [ "${build_type}" != "+1.19.0" ] && \ [ "${build_type}" != "+1.24.0" ]; then @@ -138,10 +125,25 @@ do --features extra_traits \ --target "${TARGET}" + # Also test that it builds with `extra_traits` and default features: if [ "$NO_STD" != "1" ]; then cargo "${build_type}" build $opt \ --features extra_traits \ --target "${TARGET}" fi fi + + # If libc-test should be run, do so only with Rust nightly w/o libstd: + if [ "${BUILD_ONLY}" != "1" ] && [ "${build_type}" = "+nightly" ]; then + cargo "${build_type}" test $opt \ + --no-default-features \ + --manifest-path libc-test/Cargo.toml \ + --target "${TARGET}" + + if [ "$NO_STD" != "1" ]; then + cargo "${build_type}" test $opt \ + --manifest-path libc-test/Cargo.toml \ + --target "${TARGET}" + fi + fi done From 221cf7e98cc019ec85c49c22a69d9e9d0c5ddabd Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 16:46:00 +0100 Subject: [PATCH 29/72] Pass NO_STD to docker, simplify travis script --- .travis.yml | 9 ++------- ci/run-docker.sh | 1 + 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index fd6edff53da35..f1b046d756ff8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -214,14 +214,9 @@ install: fi script: - - if [[ $TRAVIS_OS_NAME = "linux" ]]; then - if [[ $BUILD_ONLY = "1" ]]; then - sh ci/run.sh $TARGET; - else - sh ci/run-docker.sh $TARGET; - fi + - if [[ $TRAVIS_OS_NAME = "linux" ]] && [[ $BUILD_ONLY != "1" ]]; then + sh ci/run-docker.sh $TARGET; else - export CARGO_TARGET_DIR=`pwd`/target; sh ci/run.sh $TARGET; fi diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 4816ca9c4e814..10a675eb781ae 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -27,6 +27,7 @@ run() { --env RUNNING_IN_DOCKER=1 \ --env BUILD_ONLY="${BUILD_ONLY}" \ --env NIGHTLY_ONLY="${NIGHTLY_ONLY}" \ + --env NO_STD="${NO_STD}" \ --volume "$(rustc --print sysroot)":/rust:ro \ --volume "${HOME}"/.rustup:/.rustup:ro \ --env RUSTUP_HOME=/.rustup \ From 3f140ce689c54278114fd0c254e205f5d2aa6456 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 17:00:25 +0100 Subject: [PATCH 30/72] Fix aarch64-fuchsia build --- src/fuchsia/mod.rs | 267 +++++++++++++++++++++++---------------------- 1 file changed, 134 insertions(+), 133 deletions(-) diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index cf33dadf2d9b4..d82303723d44c 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -202,9 +202,6 @@ s! { pub ru_nivcsw: c_long, #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] __pad14: u32, - - #[cfg(any(target_env = "musl", target_os = "emscripten"))] - __reserved: [c_long; 16], } pub struct in_addr { @@ -334,23 +331,6 @@ s! { pub l_pid: ::pid_t, } - pub struct sysinfo { - pub uptime: ::c_ulong, - pub loads: [::c_ulong; 3], - pub totalram: ::c_ulong, - pub freeram: ::c_ulong, - pub sharedram: ::c_ulong, - pub bufferram: ::c_ulong, - pub totalswap: ::c_ulong, - pub freeswap: ::c_ulong, - pub procs: ::c_ushort, - pub pad: ::c_ushort, - pub totalhigh: ::c_ulong, - pub freehigh: ::c_ulong, - pub mem_unit: ::c_uint, - pub __reserved: [::c_char; 256], - } - pub struct ucred { pub pid: ::pid_t, pub uid: ::uid_t, @@ -377,17 +357,6 @@ s! { pub sin6_scope_id: u32, } - pub struct sockaddr_un { - pub sun_family: sa_family_t, - pub sun_path: [::c_char; 108] - } - - pub struct sockaddr_storage { - pub ss_family: sa_family_t, - __ss_align: ::size_t, - __ss_pad2: [u8; 128 - 2 * 8], - } - pub struct addrinfo { pub ai_flags: ::c_int, pub ai_family: ::c_int, @@ -457,15 +426,6 @@ s! { pub u64: ::uint64_t, } - pub struct utsname { - pub sysname: [::c_char; 65], - pub nodename: [::c_char; 65], - pub release: [::c_char; 65], - pub version: [::c_char; 65], - pub machine: [::c_char; 65], - pub domainname: [::c_char; 65] - } - pub struct lconv { pub decimal_point: *mut ::c_char, pub thousands_sep: *mut ::c_char, @@ -502,22 +462,6 @@ s! { pub __pad: [::c_char; 56 - 3 * 8 /* 8 == sizeof(long) */], } - pub struct dirent { - pub d_ino: ::ino_t, - pub d_off: ::off_t, - pub d_reclen: ::c_ushort, - pub d_type: ::c_uchar, - pub d_name: [::c_char; 256], - } - - pub struct dirent64 { - pub d_ino: ::ino64_t, - pub d_off: ::off64_t, - pub d_reclen: ::c_ushort, - pub d_type: ::c_uchar, - pub d_name: [::c_char; 256], - } - pub struct rlimit64 { pub rlim_cur: rlim64_t, pub rlim_max: rlim64_t, @@ -546,54 +490,6 @@ s! { pub ifa_data: *mut ::c_void } - #[cfg_attr(all(libc_align, - target_pointer_width = "32", - any(target_arch = "arm", - target_arch = "x86_64")), - repr(align(4)))] - #[cfg_attr(all(libc_align, - any(target_pointer_width = "64", - not(any(target_arch = "arm", - target_arch = "x86_64")))), - repr(align(8)))] - pub struct pthread_mutex_t { - #[cfg(all(not(libc_align), - any(target_arch = "arm", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_long; 0], - #[cfg(not(any(libc_align, - target_arch = "arm", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], - } - - #[cfg_attr(all(libc_align, - target_pointer_width = "32", - any(target_arch = "arm", - target_arch = "x86_64")), - repr(align(4)))] - #[cfg_attr(all(libc_align, - any(target_pointer_width = "64", - not(any(target_arch = "arm", - target_arch = "x86_64")))), - repr(align(8)))] - pub struct pthread_rwlock_t { - #[cfg(all(not(libc_align), - any(target_arch = "arm", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_long; 0], - #[cfg(not(any(libc_align, - target_arch = "arm", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], - } - #[cfg_attr(all(libc_align, any(target_pointer_width = "32", target_arch = "x86_64", @@ -617,44 +513,17 @@ s! { } #[cfg_attr(all(libc_align, - any(target_env = "musl", target_pointer_width = "32")), + target_pointer_width = "32"), repr(align(4)))] #[cfg_attr(all(libc_align, - not(target_env = "musl"), target_pointer_width = "64"), repr(align(8)))] pub struct pthread_rwlockattr_t { - #[cfg(all(not(libc_align), target_env = "musl"))] - __align: [::c_int; 0], - #[cfg(all(not(libc_align), not(target_env = "musl")))] + #[cfg(not(libc_align))] __align: [::c_long; 0], size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], } - #[cfg_attr(all(libc_align, - target_env = "musl", - target_pointer_width = "32"), - repr(align(4)))] - #[cfg_attr(all(libc_align, - target_env = "musl", - target_pointer_width = "64"), - repr(align(8)))] - #[cfg_attr(all(libc_align, - not(target_env = "musl"), - target_arch = "x86"), - repr(align(4)))] - #[cfg_attr(all(libc_align, - not(target_env = "musl"), - not(target_arch = "x86")), - repr(align(8)))] - pub struct pthread_cond_t { - #[cfg(all(not(libc_align), target_env = "musl"))] - __align: [*const ::c_void; 0], - #[cfg(not(any(libc_align, target_env = "musl")))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_COND_T], - } - #[cfg_attr(libc_align, repr(align(4)))] pub struct pthread_condattr_t { #[cfg(not(libc_align))] @@ -1095,6 +964,138 @@ s! { } } +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct sysinfo { + pub uptime: ::c_ulong, + pub loads: [::c_ulong; 3], + pub totalram: ::c_ulong, + pub freeram: ::c_ulong, + pub sharedram: ::c_ulong, + pub bufferram: ::c_ulong, + pub totalswap: ::c_ulong, + pub freeswap: ::c_ulong, + pub procs: ::c_ushort, + pub pad: ::c_ushort, + pub totalhigh: ::c_ulong, + pub freehigh: ::c_ulong, + pub mem_unit: ::c_uint, + pub __reserved: [::c_char; 256], + } + + #[allow(missing_debug_implementations)] + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [::c_char; 108] + } + + #[allow(missing_debug_implementations)] + pub struct sockaddr_storage { + pub ss_family: sa_family_t, + __ss_align: ::size_t, + __ss_pad2: [u8; 128 - 2 * 8], + } + + #[allow(missing_debug_implementations)] + pub struct utsname { + pub sysname: [::c_char; 65], + pub nodename: [::c_char; 65], + pub release: [::c_char; 65], + pub version: [::c_char; 65], + pub machine: [::c_char; 65], + pub domainname: [::c_char; 65] + } + + #[allow(missing_debug_implementations)] + pub struct dirent { + pub d_ino: ::ino_t, + pub d_off: ::off_t, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + #[allow(missing_debug_implementations)] + pub struct dirent64 { + pub d_ino: ::ino64_t, + pub d_off: ::off64_t, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + #[allow(missing_debug_implementations)] + #[cfg_attr(all(libc_align, + target_pointer_width = "32", + any(target_arch = "arm", + target_arch = "x86_64")), + repr(align(4)))] + #[cfg_attr(all(libc_align, + any(target_pointer_width = "64", + not(any(target_arch = "arm", + target_arch = "x86_64")))), + repr(align(8)))] + pub struct pthread_mutex_t { + #[cfg(all(not(libc_align), + any(target_arch = "arm", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] + __align: [::c_long; 0], + #[cfg(not(any(libc_align, + target_arch = "arm", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } + + #[allow(missing_debug_implementations)] + #[cfg_attr(all(libc_align, + target_pointer_width = "32", + any(target_arch = "arm", + target_arch = "x86_64")), + repr(align(4)))] + #[cfg_attr(all(libc_align, + any(target_pointer_width = "64", + not(any(target_arch = "arm", + target_arch = "x86_64")))), + repr(align(8)))] + pub struct pthread_rwlock_t { + #[cfg(all(not(libc_align), + any(target_arch = "arm", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] + __align: [::c_long; 0], + #[cfg(not(any(libc_align, + target_arch = "arm", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + } + + #[allow(missing_debug_implementations)] + #[cfg_attr(all(libc_align, + target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(libc_align, + target_pointer_width = "64"), + repr(align(8)))] + #[cfg_attr(all(libc_align, + target_arch = "x86"), + repr(align(4)))] + #[cfg_attr(all(libc_align, + not(target_arch = "x86")), + repr(align(8)))] + pub struct pthread_cond_t { + #[cfg(all(not(libc_align), target_env = "musl"))] + __align: [*const ::c_void; 0], + #[cfg(not(any(libc_align, target_env = "musl")))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_COND_T], + } +} + // PUB_CONST pub const INT_MIN: c_int = -2147483648; From c28e45cdfe480a7ef5ac765e4f059ba660269231 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 17:04:08 +0100 Subject: [PATCH 31/72] Use the proper rustc path when building android runtest --- ci/docker/aarch64-linux-android/Dockerfile | 2 +- ci/docker/arm-linux-androideabi/Dockerfile | 2 +- ci/docker/i686-linux-android/Dockerfile | 2 +- ci/docker/x86_64-rumprun-netbsd/Dockerfile | 2 +- ci/run-docker.sh | 1 - 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ci/docker/aarch64-linux-android/Dockerfile b/ci/docker/aarch64-linux-android/Dockerfile index 42a11b79cdece..6e4bb99f55640 100644 --- a/ci/docker/aarch64-linux-android/Dockerfile +++ b/ci/docker/aarch64-linux-android/Dockerfile @@ -38,7 +38,7 @@ ENTRYPOINT [ \ # set SHELL so android can detect a 64bits system, see # http://stackoverflow.com/a/41789144 "SHELL=/bin/dash /android/sdk/emulator/emulator @aarch64 -no-window & \ - rustc /tmp/runtest.rs -o /tmp/runtest && \ + cargo/bin/rustc /tmp/runtest.rs -o /tmp/runtest && \ exec \"$@\"", \ "--" \ ] diff --git a/ci/docker/arm-linux-androideabi/Dockerfile b/ci/docker/arm-linux-androideabi/Dockerfile index faca8ebf64569..0c21801a16286 100644 --- a/ci/docker/arm-linux-androideabi/Dockerfile +++ b/ci/docker/arm-linux-androideabi/Dockerfile @@ -38,7 +38,7 @@ ENTRYPOINT [ \ # set SHELL so android can detect a 64bits system, see # http://stackoverflow.com/a/41789144 "SHELL=/bin/dash /android/sdk/emulator/emulator @arm -no-window & \ - rustc /tmp/runtest.rs -o /tmp/runtest && \ + cargo/bin/rustc /tmp/runtest.rs -o /tmp/runtest && \ exec \"$@\"", \ "--" \ ] diff --git a/ci/docker/i686-linux-android/Dockerfile b/ci/docker/i686-linux-android/Dockerfile index ebb84f9b60829..8a471de05f292 100644 --- a/ci/docker/i686-linux-android/Dockerfile +++ b/ci/docker/i686-linux-android/Dockerfile @@ -38,7 +38,7 @@ ENTRYPOINT [ \ # set SHELL so android can detect a 64bits system, see # http://stackoverflow.com/a/41789144 "SHELL=/bin/dash /android/sdk/emulator/emulator @i686 -no-window -no-accel & \ - rustc /tmp/runtest.rs -o /tmp/runtest && \ + cargo/bin/rustc /tmp/runtest.rs -o /tmp/runtest && \ exec \"$@\"", \ "--" \ ] diff --git a/ci/docker/x86_64-rumprun-netbsd/Dockerfile b/ci/docker/x86_64-rumprun-netbsd/Dockerfile index aad4f8c21d1e3..e057fd0e824f1 100644 --- a/ci/docker/x86_64-rumprun-netbsd/Dockerfile +++ b/ci/docker/x86_64-rumprun-netbsd/Dockerfile @@ -6,4 +6,4 @@ RUN apt-get install -y --no-install-recommends \ ENV CARGO_TARGET_X86_64_RUMPRUN_NETBSD_RUNNER=/tmp/runtest ADD docker/x86_64-rumprun-netbsd/runtest.rs /tmp/ -ENTRYPOINT ["sh", "-c", "rustc /tmp/runtest.rs -o /tmp/runtest && exec \"$@\"", "--"] +ENTRYPOINT ["sh", "-c", "cargo/bin/rustc /tmp/runtest.rs -o /tmp/runtest && exec \"$@\"", "--"] diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 10a675eb781ae..29d0465e0226f 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -28,7 +28,6 @@ run() { --env BUILD_ONLY="${BUILD_ONLY}" \ --env NIGHTLY_ONLY="${NIGHTLY_ONLY}" \ --env NO_STD="${NO_STD}" \ - --volume "$(rustc --print sysroot)":/rust:ro \ --volume "${HOME}"/.rustup:/.rustup:ro \ --env RUSTUP_HOME=/.rustup \ --volume "$(pwd)":/checkout \ From b52f3c2a33fd1d996a81205d3d98ecb9926f0b88 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 17:06:04 +0100 Subject: [PATCH 32/72] Very verbose builds --- ci/run.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ci/run.sh b/ci/run.sh index 642807db1428a..05fa723db043f 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -107,12 +107,12 @@ do fi # Always test that libc builds without any default features (no libstd) - cargo "${build_type}" build $opt --no-default-features --target "${TARGET}" + cargo "${build_type}" build $opt --no-default-features --target "${TARGET}" -vv # Always test that libc builds with default features (e.g. libstd) # if the target supports libstd if [ "$NO_STD" != "1" ]; then - cargo "${build_type}" build $opt --target "${TARGET}" + cargo "${build_type}" build $opt --target "${TARGET}" -vv fi # Always test that libc builds with the `extra_traits` feature if Rust >= @@ -123,13 +123,13 @@ do cargo "${build_type}" build $opt \ --no-default-features \ --features extra_traits \ - --target "${TARGET}" + --target "${TARGET}" -vv # Also test that it builds with `extra_traits` and default features: if [ "$NO_STD" != "1" ]; then cargo "${build_type}" build $opt \ --features extra_traits \ - --target "${TARGET}" + --target "${TARGET}" -vv fi fi @@ -138,12 +138,12 @@ do cargo "${build_type}" test $opt \ --no-default-features \ --manifest-path libc-test/Cargo.toml \ - --target "${TARGET}" + --target "${TARGET}" -vv if [ "$NO_STD" != "1" ]; then cargo "${build_type}" test $opt \ --manifest-path libc-test/Cargo.toml \ - --target "${TARGET}" + --target "${TARGET}" -vv fi fi done From af851104668e48303951a147c6f219bb11f68dd3 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 18:00:41 +0100 Subject: [PATCH 33/72] Add script to test all builds and build jobs specific to that --- .travis.yml | 264 ++++++++++++++++++++++++---------------------------- ci/build.sh | 85 +++++++++++++++++ ci/run.sh | 74 ++++----------- 3 files changed, 221 insertions(+), 202 deletions(-) create mode 100644 ci/build.sh diff --git a/.travis.yml b/.travis.yml index f1b046d756ff8..411ee6cc4b410 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,55 +5,136 @@ dist: xenial services: docker stages: - - min-checks-and-tier1 + - tools + - build-new + - build-old + - tier1 - tier2-1 - tier2-2 - - tier2-3 - - tier2-4 - - tier25 - - tier3 matrix: include: - # Min Checks and Tier 1 targets + # TOOLS - name: "Documentation" env: TARGET=x86_64-unknown-linux-gnu script: sh ci/dox.sh install: true - stage: min-checks-and-tier1 + stage: tools - name: "Shellcheck" install: true script: - shellcheck --version - shellcheck ci/*.sh - stage: min-checks-and-tier1 + stage: tools - name: "Style" install: rustup component add rustfmt-preview script: - rustc ci/style.rs && ./style src - cargo fmt --all -- --check - stage: min-checks-and-tier1 + stage: tools + # BUILD stable, beta, nightly + - name: "Build Stable Rust" + script: sh ci/build.sh + stage: build-new + rust: stable + - name: "Build Beta Rust" + script: sh ci/build.sh + stage: build-new + rust: beta + - name: "Build Nightly Rust" + script: sh ci/build.sh + stage: build-new + rust: nightly + - name: "Build Stable Rust" + script: sh ci/build.sh + stage: build-new + rust: stable + os: osx + osx_image: xcode10 + - name: "Build Beta Rust" + script: sh ci/build.sh + stage: build-new + rust: beta + os: osx + osx_image: xcode10 + - name: "Build Nightly Rust" + script: sh ci/build.sh + stage: build-new + rust: nightly + os: osx + osx_image: xcode10 + + # BUILD older Rust versions + - name: "Build Stable Rust 1.13.0" + script: sh ci/build.sh + stage: build-old + rust: 1.13.0 + - name: "Build Stable Rust 1.19.0" + script: sh ci/build.sh + stage: build-old + rust: 1.19.0 + - name: "Build Stable Rust 1.24.0" + script: sh ci/build.sh + stage: build-old + rust: 1.24.0 + - name: "Build Stable Rust 1.25.0" + env: RUST=1.25.0 + script: sh ci/build.sh + stage: build-old + rust: 1.25.0 + - name: "Build Stable Rust 1.30.0" + script: sh ci/build.sh + stage: build-old + rust: 1.30.0 + - name: "Build Stable Rust 1.13.0" + script: sh ci/build.sh + stage: build + rust: 1.13.0 + os: osx + osx_image: xcode10 + - name: "Build Stable Rust 1.19.0" + script: sh ci/build.sh + stage: build + rust: 1.19.0 + os: osx + osx_image: xcode10 + - name: "Build Stable Rust 1.24.0" + script: sh ci/build.sh + stage: build + rust: 1.24.0 + os: osx + osx_image: xcode10 + - name: "Build Stable Rust 1.25.0" + env: RUST=1.25.0 + script: sh ci/build.sh + stage: build + rust: 1.25.0 + os: osx + osx_image: xcode10 + - name: "Build Stable Rust 1.30.0" + script: sh ci/build.sh + stage: build + rust: 1.30.0 + os: osx + osx_image: xcode10 + + + # TIER 1 - env: TARGET=i686-apple-darwin os: osx osx_image: xcode10 - stage: min-checks-and-tier1 + stage: tier1 - env: TARGET=i686-unknown-linux-gnu - stage: min-checks-and-tier1 + stage: tier1 - env: TARGET=x86_64-apple-darwin os: osx osx_image: xcode10 - stage: min-checks-and-tier1 + stage: tier1 - env: TARGET=x86_64-unknown-linux-gnu - stage: min-checks-and-tier1 + stage: tier1 # Tier 2 targets - - env: TARGET=aarch64-apple-ios BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier2-1 - os: osx - osx_image: xcode10 - - env: TARGET=aarch64-fuchsia BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier2-1 - env: TARGET=aarch64-linux-android stage: tier2-1 - env: TARGET=aarch64-unknown-linux-gnu @@ -66,152 +147,47 @@ matrix: stage: tier2-1 - env: TARGET=arm-unknown-linux-musleabihf stage: tier2-1 - - env: TARGET=armv7-apple-ios BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier2-1 - os: osx - osx_image: xcode10 - - env: TARGET=armv7-linux-androideabi BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier2-1 - - env: TARGET=armv7-unknown-linux-gnueabihf BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier2-2 - - env: TARGET=armv7-unknown-linux-musleabihf BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier2-2 - - env: TARGET=armv7s-apple-ios BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier2-2 - os: osx - osx_image: xcode10 - env: TARGET=asmjs-unknown-emscripten - stage: tier2-2 - - env: TARGET=i586-unknown-linux-gnu BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier2-2 - - env: TARGET=i586-unknown-linux-musl BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier2-2 - # FIXME(#826) should reenable tests - - env: TARGET=i686-linux-android BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier2-2 - - env: TARGET=i686-unknown-freebsd BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier2-2 + stage: tier2-1 - env: TARGET=i686-unknown-linux-musl - stage: tier2-2 + stage: tier2-1 - env: TARGET=mips-unknown-linux-gnu - stage: tier2-2 + stage: tier2-1 - env: TARGET=mips-unknown-linux-musl - stage: tier2-3 + stage: tier2-1 - env: TARGET=mips64-unknown-linux-gnuabi64 - stage: tier2-3 + stage: tier2-1 - env: TARGET=mips64el-unknown-linux-gnuabi64 - stage: tier2-3 - - env: TARGET=mipsel-unknown-linux-gnu BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier2-3 + stage: tier2-1 - env: TARGET=mipsel-unknown-linux-musl - stage: tier2-3 + stage: tier2-2 - env: TARGET=powerpc-unknown-linux-gnu - stage: tier2-3 + stage: tier2-2 - env: TARGET=powerpc64-unknown-linux-gnu - stage: tier2-3 + stage: tier2-2 - env: TARGET=powerpc64le-unknown-linux-gnu - stage: tier2-3 + stage: tier2-2 - env: TARGET=s390x-unknown-linux-gnu - stage: tier2-3 + stage: tier2-2 - env: TARGET=sparc64-unknown-linux-gnu - stage: tier2-3 - - env: TARGET=sparcv9-sun-solaris - stage: tier2-4 - - env: TARGET=wasm32-unknown-unknown BUILD_ONLY=1 - stage: tier2-4 + stage: tier2-2 + - env: TARGaarch64-unknown-cloudabiET=sparcv9-sun-solaris + stage: tier2-2 - env: TARGET=wasm32-unknown-emscripten - stage: tier2-4 - - env: TARGET=x86_64-apple-ios BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier2-4 - os: osx - osx_image: xcode10 - - env: TARGET=x86_64-fuchsia BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier2-4 + stage: tier2-2 - env: TARGET=x86_64-linux-android - stage: tier2-4 - - env: TARGET=x86_64-rumprun-netbsd BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier2-4 - - env: TARGET=x86_64-sun-solaris BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier2-4 - - env: TARGET=x86_64-unknown-cloudabi BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier2-4 - - env: TARGET=x86_64-unknown-freebsd BUILD_ONLY=1 - stage: tier2-4 + stage: tier2-2 - env: TARGET=x86_64-unknown-linux-gnux32 OPT="--release" - stage: tier2-4 - - env: TARGET=x86_64-unknown-linux-musl - stage: tier2-4 - - env: TARGET=x86_64-unknown-netbsd BUILD_ONLY=1 - stage: tier2-4 - - env: TARGET=x86_64-unknown-redox BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier2-4 - - # Tier 2.5 targets: - - env: TARGET=aarch64-unknown-cloudabi BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier25 - - env: TARGET=armv7-unknown-cloudabi-eabihf BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier25 - - env: TARGET=i686-unknown-cloudabi BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier25 - - env: TARGET=powerpc-unknown-linux-gnuspe BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier25 - - env: TARGET=sparc-unknown-linux-gnu BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier25 - - # Tier 3 targets: - - env: TARGET=i686-unknown-haiku BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier3 - - env: TARGET=i686-unknown-netbsd BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier3 - - env: TARGET=mips-unknown-unknown-linux-uclib BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier3 - - env: TARGET=mipsel-unknown-unknown-linux-uclib BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier3 - - env: TARGET=sparc64-unknown-netbsd BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier3 - - env: TARGET=thumbv6m-none-eabi BUILD_ONLY=1 NIGHTLY_ONLY=1 NO_STD=1 - stage: tier3 - - env: TARGET=thumbv7em-none-eabi BUILD_ONLY=1 NIGHTLY_ONLY=1 NO_STD=1 - stage: tier3 - - env: TARGET=thumbv7em-none-eabihf BUILD_ONLY=1 NIGHTLY_ONLY=1 NO_STD=1 - stage: tier3 - - env: TARGET=thumbv7m-none-eabi BUILD_ONLY=1 NIGHTLY_ONLY=1 NO_STD=1 - stage: tier3 - - env: TARGET=x86_64-fortanix-unknown-sgx BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier3 - - env: TARGET=x86_64-unknown-bitrig BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier3 - - env: TARGET=x86_64-unknown-dragonfly BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier3 - - env: TARGET=x86_64-unknown-haiku BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier3 - - env: TARGET=x86_64-unknown-openbsd BUILD_ONLY=1 NIGHTLY_ONLY=1 - stage: tier3 + stage: tier2-2 + - env: TARGET=x86_64-unknown-linux-mussl + stage: tier2-2 allow_failures: # FIXME: https://github.com/rust-lang/libc/issues/1226 - env: TARGET=asmjs-unknown-emscripten - env: TARGET=wasm32-unknown-emscripten -install: - - rustup target add $TARGET || true - - | - if [ "${NIGHTLY_ONLY}" != "1" ]; then - rustup install beta - rustup install stable - rustup install 1.13.0 - rustup install 1.19.0 - rustup install 1.24.0 - rustup install 1.25.0 - rustup install 1.30.0 - rustup target add $TARGET --toolchain beta || true - rustup target add $TARGET --toolchain stable || true - rustup target add $TARGET --toolchain 1.13.0 || true - rustup target add $TARGET --toolchain 1.19.0 || true - rustup target add $TARGET --toolchain 1.24.0 || true - rustup target add $TARGET --toolchain 1.25.0 || true - rustup target add $TARGET --toolchain 1.30.0 || true - fi +install: rustup target add $TARGET || true script: - if [[ $TRAVIS_OS_NAME = "linux" ]] && [[ $BUILD_ONLY != "1" ]]; then diff --git a/ci/build.sh b/ci/build.sh new file mode 100644 index 0000000000000..15174c298afe6 --- /dev/null +++ b/ci/build.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env sh + +# Checks that libc builds properly for all supported targets on a particular +# Rust version: + +set -ex + +RUST=${TRAVIS_RUST_VERSION} +OS=${TRAVIS_OS_NAME} + +echo "Testing Rust ${RUST} on ${OS}" + +test_target() { + TARGET = "${1}" + + opt= + if [ "${TARGET}" = "x86_64-unknown-linux-gnux32" ]; then + # FIXME: x86_64-unknown-linux-gnux32 fail to compile without + # --release + # + # See https://github.com/rust-lang/rust/issues/45417 + opt="--release" + fi + + NO_STD= + case ${TARGET} in + thumbv*) + NO_STD=1 + ;; + *) + ;; + esac + + rustup target add "${TARGET}" --tolchain "${RUST}" || true + + # Test that libc builds without any default features (no libstd) + cargo "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}" + + # Test that libc builds with default features (e.g. libstd) + # if the target supports libstd + if [ "$NO_STD" != "1" ]; then + cargo "+${RUST}" build -vv $opt --target "${TARGET}" + fi + + # Test that libc builds with the `extra_traits` feature if Rust >= 1.25.0 + if [ "${RUST}" != "+1.13.0" ] && \ + [ "${RUST}" != "+1.19.0" ] && \ + [ "${RUST}" != "+1.24.0" ]; then + cargo "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}" \ + --features extra_traits + + # Also test that it builds with `extra_traits` and default features: + if [ "$NO_STD" != "1" ]; then + cargo "+${RUST}" build -vv $opt --target "${TARGET}" \ + --features extra_traits + fi + fi +} + +TARGETS="wasm32-unknown-unknown" +case "${OS}" in + linux*) + TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd " + + if [ "${RUST}" = "nightly" ]; then + TARGETS="${TARGETS} aarch64-fuchsia armv7-linux-androideabi armv7-unknown-linux-gnueabihf armv7-unknown-linux-musleabihf i586-unknown-linux-gnu i586-unknown-linux-musl i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu x86_64-fuchsia x86_64-rumprun-netbsd x86_64-sun-solaris x86_64-unknown-cloudabi x86_64-unknown-redox aarch64-unknown-cloudabi armv7-unknown-cloudabi-eabihf i686-unknown-cloudabi powerpc-unknown-linux-gnuspe sparc-unknown-linux-gnu mips-unknown-unknown-linux-uclib i686-unknown-haiku i686-unknown-netbsd mipsel-unknown-unknown-linux-uclib sparc64-unknown-netbsd thumbv6m-none-eabi thumbv7em-none-eabi thumbv7em-none-eabihf thumbv7m-none-eabi x86_64-fortanix-unknown-sgx x86_64-unknown-bitrig x86_64-unknown-haiku x86_64-unknown-openbsd" + fi + + ;; + osx*) + TARGETS="i686-apple-darwin x86_64-apple-darwin" + + if [ "${RUST}" = "nightly" ]; then + TARGETS="${TARGETS} aarch64-apple-ios armv7-apple-ios armv7s-apple-ios x86_64-apple-ios" + fi + + ;; + *) + ;; +esac + + +for TARGET in $TARGETS; do + test_target "$TARGET" +done diff --git a/ci/run.sh b/ci/run.sh index 05fa723db043f..c3acbf6d5697d 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -86,64 +86,22 @@ fi command -v cargo -build_types="+nightly +beta +stable +1.13.0 +1.19.0 +1.24.0 +1.25.0 +1.30.0" -if [ "${NIGHTLY_ONLY}" = "1" ]; then - build_types="+nightly" +opt= +if [ "${TARGET}" = "x86_64-unknown-linux-gnux32" ]; then + # FIXME: x86_64-unknown-linux-gnux32 fail to compile without + # --release + # + # See https://github.com/rust-lang/rust/issues/45417 + opt="--release" fi -for build_type in $build_types; -do - opt= - if [ "${TARGET}" = "x86_64-unknown-linux-gnux32" ]; then - # FIXME: x86_64-unknown-linux-gnux32 fail to compile without - # --release - # - # See https://github.com/rust-lang/rust/issues/45417 - opt="--release" - # x86_64-unknown-linux-gnux32 is only available on nightly: - if [ "${build_type}" != "nightly" ]; then - continue - fi - fi - - # Always test that libc builds without any default features (no libstd) - cargo "${build_type}" build $opt --no-default-features --target "${TARGET}" -vv - - # Always test that libc builds with default features (e.g. libstd) - # if the target supports libstd - if [ "$NO_STD" != "1" ]; then - cargo "${build_type}" build $opt --target "${TARGET}" -vv - fi - - # Always test that libc builds with the `extra_traits` feature if Rust >= - # 1.25.0 - if [ "${build_type}" != "+1.13.0" ] && \ - [ "${build_type}" != "+1.19.0" ] && \ - [ "${build_type}" != "+1.24.0" ]; then - cargo "${build_type}" build $opt \ - --no-default-features \ - --features extra_traits \ - --target "${TARGET}" -vv +cargo test $opt \ + --no-default-features \ + --manifest-path libc-test/Cargo.toml \ + --target "${TARGET}" -vv - # Also test that it builds with `extra_traits` and default features: - if [ "$NO_STD" != "1" ]; then - cargo "${build_type}" build $opt \ - --features extra_traits \ - --target "${TARGET}" -vv - fi - fi - - # If libc-test should be run, do so only with Rust nightly w/o libstd: - if [ "${BUILD_ONLY}" != "1" ] && [ "${build_type}" = "+nightly" ]; then - cargo "${build_type}" test $opt \ - --no-default-features \ - --manifest-path libc-test/Cargo.toml \ - --target "${TARGET}" -vv - - if [ "$NO_STD" != "1" ]; then - cargo "${build_type}" test $opt \ - --manifest-path libc-test/Cargo.toml \ - --target "${TARGET}" -vv - fi - fi -done +if [ "$NO_STD" != "1" ]; then + cargo test $opt \ + --manifest-path libc-test/Cargo.toml \ + --target "${TARGET}" -vv +fi From e695917dcbe53c6e914d22dee8ed8e4d450ab3fc Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 18:02:19 +0100 Subject: [PATCH 34/72] fixup --- ci/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build.sh b/ci/build.sh index 15174c298afe6..3ce68584d2fc6 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -11,7 +11,7 @@ OS=${TRAVIS_OS_NAME} echo "Testing Rust ${RUST} on ${OS}" test_target() { - TARGET = "${1}" + TARGET="${1}" opt= if [ "${TARGET}" = "x86_64-unknown-linux-gnux32" ]; then From db270ec09bca05928912179911fa1638da085f67 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 18:05:25 +0100 Subject: [PATCH 35/72] Reorganize Travis-CI stages --- .travis.yml | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/.travis.yml b/.travis.yml index 411ee6cc4b410..3de45403aa9c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,8 @@ dist: xenial services: docker stages: - - tools - - build-new - - build-old - - tier1 + - tools-and-build-new + - build-old-and-tier1 - tier2-1 - tier2-2 @@ -19,48 +17,48 @@ matrix: env: TARGET=x86_64-unknown-linux-gnu script: sh ci/dox.sh install: true - stage: tools + stage: tools-and-build-new - name: "Shellcheck" install: true script: - shellcheck --version - shellcheck ci/*.sh - stage: tools + stage: tools-and-build-new - name: "Style" install: rustup component add rustfmt-preview script: - rustc ci/style.rs && ./style src - cargo fmt --all -- --check - stage: tools + stage: tools-and-build-new # BUILD stable, beta, nightly - name: "Build Stable Rust" script: sh ci/build.sh - stage: build-new + stage: tools-and-build-new rust: stable - name: "Build Beta Rust" script: sh ci/build.sh - stage: build-new + stage: tools-and-build-new rust: beta - name: "Build Nightly Rust" script: sh ci/build.sh - stage: build-new + stage: tools-and-build-new rust: nightly - name: "Build Stable Rust" script: sh ci/build.sh - stage: build-new + stage: tools-and-build-new rust: stable os: osx osx_image: xcode10 - name: "Build Beta Rust" script: sh ci/build.sh - stage: build-new + stage: tools-and-build-new rust: beta os: osx osx_image: xcode10 - name: "Build Nightly Rust" script: sh ci/build.sh - stage: build-new + stage: tools-and-build-new rust: nightly os: osx osx_image: xcode10 @@ -68,24 +66,24 @@ matrix: # BUILD older Rust versions - name: "Build Stable Rust 1.13.0" script: sh ci/build.sh - stage: build-old + stage: build-old-and-tier1 rust: 1.13.0 - name: "Build Stable Rust 1.19.0" script: sh ci/build.sh - stage: build-old + stage: build-old-and-tier1 rust: 1.19.0 - name: "Build Stable Rust 1.24.0" script: sh ci/build.sh - stage: build-old + stage: build-old-and-tier1 rust: 1.24.0 - name: "Build Stable Rust 1.25.0" env: RUST=1.25.0 script: sh ci/build.sh - stage: build-old + stage: build-old-and-tier1 rust: 1.25.0 - name: "Build Stable Rust 1.30.0" script: sh ci/build.sh - stage: build-old + stage: build-old-and-tier1 rust: 1.30.0 - name: "Build Stable Rust 1.13.0" script: sh ci/build.sh @@ -124,15 +122,15 @@ matrix: - env: TARGET=i686-apple-darwin os: osx osx_image: xcode10 - stage: tier1 + stage: build-old-and-tier1 - env: TARGET=i686-unknown-linux-gnu - stage: tier1 + stage: build-old-and-tier1 - env: TARGET=x86_64-apple-darwin os: osx osx_image: xcode10 - stage: tier1 + stage: build-old-and-tier1 - env: TARGET=x86_64-unknown-linux-gnu - stage: tier1 + stage: build-old-and-tier1 # Tier 2 targets - env: TARGET=aarch64-linux-android From b889d3d52ac8196fbadd91a08e65bf36e604e261 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 18:06:57 +0100 Subject: [PATCH 36/72] Rename Travis-CI stages --- .travis.yml | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3de45403aa9c8..f387362d4659e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,8 @@ dist: xenial services: docker stages: - - tools-and-build-new - - build-old-and-tier1 + - tools-and-build-latest + - tier1-and-backwards-compat - tier2-1 - tier2-2 @@ -17,48 +17,48 @@ matrix: env: TARGET=x86_64-unknown-linux-gnu script: sh ci/dox.sh install: true - stage: tools-and-build-new + stage: tools-and-build-latest - name: "Shellcheck" install: true script: - shellcheck --version - shellcheck ci/*.sh - stage: tools-and-build-new + stage: tools-and-build-latest - name: "Style" install: rustup component add rustfmt-preview script: - rustc ci/style.rs && ./style src - cargo fmt --all -- --check - stage: tools-and-build-new + stage: tools-and-build-latest # BUILD stable, beta, nightly - name: "Build Stable Rust" script: sh ci/build.sh - stage: tools-and-build-new + stage: tools-and-build-latest rust: stable - name: "Build Beta Rust" script: sh ci/build.sh - stage: tools-and-build-new + stage: tools-and-build-latest rust: beta - name: "Build Nightly Rust" script: sh ci/build.sh - stage: tools-and-build-new + stage: tools-and-build-latest rust: nightly - name: "Build Stable Rust" script: sh ci/build.sh - stage: tools-and-build-new + stage: tools-and-build-latest rust: stable os: osx osx_image: xcode10 - name: "Build Beta Rust" script: sh ci/build.sh - stage: tools-and-build-new + stage: tools-and-build-latest rust: beta os: osx osx_image: xcode10 - name: "Build Nightly Rust" script: sh ci/build.sh - stage: tools-and-build-new + stage: tools-and-build-latest rust: nightly os: osx osx_image: xcode10 @@ -66,24 +66,24 @@ matrix: # BUILD older Rust versions - name: "Build Stable Rust 1.13.0" script: sh ci/build.sh - stage: build-old-and-tier1 + stage: tier1-and-backwards-compat rust: 1.13.0 - name: "Build Stable Rust 1.19.0" script: sh ci/build.sh - stage: build-old-and-tier1 + stage: tier1-and-backwards-compat rust: 1.19.0 - name: "Build Stable Rust 1.24.0" script: sh ci/build.sh - stage: build-old-and-tier1 + stage: tier1-and-backwards-compat rust: 1.24.0 - name: "Build Stable Rust 1.25.0" env: RUST=1.25.0 script: sh ci/build.sh - stage: build-old-and-tier1 + stage: tier1-and-backwards-compat rust: 1.25.0 - name: "Build Stable Rust 1.30.0" script: sh ci/build.sh - stage: build-old-and-tier1 + stage: tier1-and-backwards-compat rust: 1.30.0 - name: "Build Stable Rust 1.13.0" script: sh ci/build.sh @@ -122,15 +122,15 @@ matrix: - env: TARGET=i686-apple-darwin os: osx osx_image: xcode10 - stage: build-old-and-tier1 + stage: tier1-and-backwards-compat - env: TARGET=i686-unknown-linux-gnu - stage: build-old-and-tier1 + stage: tier1-and-backwards-compat - env: TARGET=x86_64-apple-darwin os: osx osx_image: xcode10 - stage: build-old-and-tier1 + stage: tier1-and-backwards-compat - env: TARGET=x86_64-unknown-linux-gnu - stage: build-old-and-tier1 + stage: tier1-and-backwards-compat # Tier 2 targets - env: TARGET=aarch64-linux-android From 91856cfeb734548d359e5da41ddb10b24e6f3a2b Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 18:08:28 +0100 Subject: [PATCH 37/72] Fix typo in build script --- ci/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build.sh b/ci/build.sh index 3ce68584d2fc6..b277f7f9d5a9a 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -31,7 +31,7 @@ test_target() { ;; esac - rustup target add "${TARGET}" --tolchain "${RUST}" || true + rustup target add "${TARGET}" --toolchain "${RUST}" || true # Test that libc builds without any default features (no libstd) cargo "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}" From 95f329696ba8bfa3e72fe34cd9644c4e38d8563f Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 18:10:10 +0100 Subject: [PATCH 38/72] Reorganize stages --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index f387362d4659e..ec70bd9757e94 100644 --- a/.travis.yml +++ b/.travis.yml @@ -87,32 +87,32 @@ matrix: rust: 1.30.0 - name: "Build Stable Rust 1.13.0" script: sh ci/build.sh - stage: build + stage: tier1-and-backwards-compat rust: 1.13.0 os: osx osx_image: xcode10 - name: "Build Stable Rust 1.19.0" script: sh ci/build.sh - stage: build + stage: tier1-and-backwards-compat rust: 1.19.0 os: osx osx_image: xcode10 - name: "Build Stable Rust 1.24.0" script: sh ci/build.sh - stage: build + stage: tier1-and-backwards-compat rust: 1.24.0 os: osx osx_image: xcode10 - name: "Build Stable Rust 1.25.0" env: RUST=1.25.0 script: sh ci/build.sh - stage: build + stage: tier1-and-backwards-compat rust: 1.25.0 os: osx osx_image: xcode10 - name: "Build Stable Rust 1.30.0" script: sh ci/build.sh - stage: build + stage: tier1-and-backwards-compat rust: 1.30.0 os: osx osx_image: xcode10 From f28f9e61f574c28764c09b95d42b4a472ed8136d Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 18:11:47 +0100 Subject: [PATCH 39/72] Reorganize stages --- .travis.yml | 49 +++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index ec70bd9757e94..7f2e67affb684 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,7 @@ services: docker stages: - tools-and-build-latest - tier1-and-backwards-compat - - tier2-1 - - tier2-2 + - tier2 matrix: include: @@ -134,51 +133,49 @@ matrix: # Tier 2 targets - env: TARGET=aarch64-linux-android - stage: tier2-1 + stage: tier2 - env: TARGET=aarch64-unknown-linux-gnu - stage: tier2-1 + stage: tier2 - env: TARGET=aarch64-unknown-linux-musl - stage: tier2-1 + stage: tier2 - env: TARGET=arm-linux-androideabi - stage: tier2-1 + stage: tier2 - env: TARGET=arm-unknown-linux-gnueabihf - stage: tier2-1 + stage: tier2 - env: TARGET=arm-unknown-linux-musleabihf - stage: tier2-1 + stage: tier2 - env: TARGET=asmjs-unknown-emscripten - stage: tier2-1 + stage: tier2 - env: TARGET=i686-unknown-linux-musl - stage: tier2-1 + stage: tier2 - env: TARGET=mips-unknown-linux-gnu - stage: tier2-1 + stage: tier2 - env: TARGET=mips-unknown-linux-musl - stage: tier2-1 + stage: tier2 - env: TARGET=mips64-unknown-linux-gnuabi64 - stage: tier2-1 + stage: tier2 - env: TARGET=mips64el-unknown-linux-gnuabi64 - stage: tier2-1 + stage: tier2 - env: TARGET=mipsel-unknown-linux-musl - stage: tier2-2 + stage: tier2 - env: TARGET=powerpc-unknown-linux-gnu - stage: tier2-2 + stage: tier2 - env: TARGET=powerpc64-unknown-linux-gnu - stage: tier2-2 + stage: tier2 - env: TARGET=powerpc64le-unknown-linux-gnu - stage: tier2-2 + stage: tier2 - env: TARGET=s390x-unknown-linux-gnu - stage: tier2-2 + stage: tier2 - env: TARGET=sparc64-unknown-linux-gnu - stage: tier2-2 - - env: TARGaarch64-unknown-cloudabiET=sparcv9-sun-solaris - stage: tier2-2 + stage: tier2 - env: TARGET=wasm32-unknown-emscripten - stage: tier2-2 + stage: tier2 - env: TARGET=x86_64-linux-android - stage: tier2-2 + stage: tier2 - env: TARGET=x86_64-unknown-linux-gnux32 OPT="--release" - stage: tier2-2 + stage: tier2 - env: TARGET=x86_64-unknown-linux-mussl - stage: tier2-2 + stage: tier2 allow_failures: # FIXME: https://github.com/rust-lang/libc/issues/1226 From 1948d324ab0b86d8789c0dc405492a8905758cfe Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 18:59:31 +0100 Subject: [PATCH 40/72] Fix more build issues --- ci/build.sh | 6 +- src/fuchsia/x86_64.rs | 21 ++-- src/lib.rs | 2 + src/unix/bsd/apple/mod.rs | 5 + src/unix/bsd/freebsdlike/freebsd/mod.rs | 106 ++++++++--------- src/unix/bsd/freebsdlike/mod.rs | 24 ++-- src/unix/bsd/netbsdlike/mod.rs | 8 -- src/unix/bsd/netbsdlike/netbsd/mod.rs | 125 ++++++++++++--------- src/unix/bsd/netbsdlike/openbsdlike/mod.rs | 13 +++ src/unix/haiku/mod.rs | 5 + src/unix/hermit/mod.rs | 5 + src/unix/mod.rs | 5 - src/unix/newlib/mod.rs | 5 + src/unix/notbsd/mod.rs | 5 + src/unix/solaris/mod.rs | 85 ++++++++------ src/unix/uclibc/mod.rs | 5 + 16 files changed, 251 insertions(+), 174 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index b277f7f9d5a9a..8458dc05afc10 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -27,8 +27,6 @@ test_target() { thumbv*) NO_STD=1 ;; - *) - ;; esac rustup target add "${TARGET}" --toolchain "${RUST}" || true @@ -63,7 +61,8 @@ case "${OS}" in TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd " if [ "${RUST}" = "nightly" ]; then - TARGETS="${TARGETS} aarch64-fuchsia armv7-linux-androideabi armv7-unknown-linux-gnueabihf armv7-unknown-linux-musleabihf i586-unknown-linux-gnu i586-unknown-linux-musl i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu x86_64-fuchsia x86_64-rumprun-netbsd x86_64-sun-solaris x86_64-unknown-cloudabi x86_64-unknown-redox aarch64-unknown-cloudabi armv7-unknown-cloudabi-eabihf i686-unknown-cloudabi powerpc-unknown-linux-gnuspe sparc-unknown-linux-gnu mips-unknown-unknown-linux-uclib i686-unknown-haiku i686-unknown-netbsd mipsel-unknown-unknown-linux-uclib sparc64-unknown-netbsd thumbv6m-none-eabi thumbv7em-none-eabi thumbv7em-none-eabihf thumbv7m-none-eabi x86_64-fortanix-unknown-sgx x86_64-unknown-bitrig x86_64-unknown-haiku x86_64-unknown-openbsd" + # aarch64-unknown-cloudabi armv7-unknown-cloudabi-eabihf i686-unknown-cloudabi powerpc-unknown-linux-gnuspe sparc-unknown-linux-gnu mips-unknown-unknown-linux-uclib i686-unknown-haiku i686-unknown-netbsd mipsel-unknown-unknown-linux-uclib sparc64-unknown-netbsd x86_64-unknown-bitrig x86_64-unknown-haiku x86_64-unknown-openbsd + TARGETS="${TARGETS} aarch64-fuchsia armv7-linux-androideabi armv7-unknown-linux-gnueabihf armv7-unknown-linux-musleabihf i586-unknown-linux-gnu i586-unknown-linux-musl i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu x86_64-fuchsia x86_64-rumprun-netbsd x86_64-sun-solaris x86_64-unknown-cloudabi x86_64-unknown-redox thumbv6m-none-eabi thumbv7em-none-eabi thumbv7em-none-eabihf thumbv7m-none-eabi x86_64-fortanix-unknown-sgx" fi ;; @@ -79,7 +78,6 @@ case "${OS}" in ;; esac - for TARGET in $TARGETS; do test_target "$TARGET" done diff --git a/src/fuchsia/x86_64.rs b/src/fuchsia/x86_64.rs index 2e4ecccbf7909..8c0dc55ac2b8f 100644 --- a/src/fuchsia/x86_64.rs +++ b/src/fuchsia/x86_64.rs @@ -51,15 +51,6 @@ s! { __private: [u64; 32], } - pub struct ucontext_t { - pub uc_flags: ::c_ulong, - pub uc_link: *mut ucontext_t, - pub uc_stack: ::stack_t, - pub uc_mcontext: mcontext_t, - pub uc_sigmask: ::sigset_t, - __private: [u8; 512], - } - pub struct ipc_perm { pub __ipc_perm_key: ::key_t, pub uid: ::uid_t, @@ -73,6 +64,18 @@ s! { } } +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct ucontext_t { + pub uc_flags: ::c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: ::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: ::sigset_t, + __private: [u8; 512], + } +} + // Syscall table pub const SYS_read: ::c_long = 0; diff --git a/src/lib.rs b/src/lib.rs index 581e770333227..63c64c7f0f2bb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -162,6 +162,7 @@ // Enable lints #![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))] #![deny(missing_copy_implementations, safe_packed_borrows)] +#![allow(unused_macros)] #[cfg(all(not(cross_platform_docs), feature = "use_std"))] extern crate std as core; @@ -181,6 +182,7 @@ cfg_if! { cfg_if! { if #[cfg(not(cross_platform_docs))] { #[cfg(libc_core_cvoid)] + #[allow(unused_imports)] use core::ffi; #[allow(unused_imports)] use core::fmt; diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index d94027bdb8013..670ef568b6435 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -42,6 +42,11 @@ impl ::dox::Clone for timezone { } s! { + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + pub struct aiocb { pub aio_fildes: ::c_int, pub aio_offset: ::off_t, diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 99f3675d8c621..0d0eb3f3b0ff5 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -21,17 +21,6 @@ pub type posix_spawnattr_t = *mut ::c_void; pub type posix_spawn_file_actions_t = *mut ::c_void; s! { - pub struct utmpx { - pub ut_type: ::c_short, - pub ut_tv: ::timeval, - pub ut_id: [::c_char; 8], - pub ut_pid: ::pid_t, - pub ut_user: [::c_char; 32], - pub ut_line: [::c_char; 16], - pub ut_host: [::c_char; 128], - pub __ut_spare: [::c_char; 64], - } - pub struct aiocb { pub aio_fildes: ::c_int, pub aio_offset: ::off_t, @@ -48,14 +37,6 @@ s! { pub aio_sigevent: sigevent } - pub struct dirent { - pub d_fileno: u32, - pub d_reclen: u16, - pub d_type: u8, - pub d_namlen: u8, - pub d_name: [::c_char; 256], - } - pub struct jail { pub version: u32, pub path: *mut ::c_char, @@ -101,31 +82,6 @@ s! { pub f_namemax: ::c_ulong, } - pub struct statfs { - pub f_version: ::uint32_t, - pub f_type: ::uint32_t, - pub f_flags: ::uint64_t, - pub f_bsize: ::uint64_t, - pub f_iosize: ::uint64_t, - pub f_blocks: ::uint64_t, - pub f_bfree: ::uint64_t, - pub f_bavail: ::int64_t, - pub f_files: ::uint64_t, - pub f_ffree: ::int64_t, - pub f_syncwrites: ::uint64_t, - pub f_asyncwrites: ::uint64_t, - pub f_syncreads: ::uint64_t, - pub f_asyncreads: ::uint64_t, - f_spare: [::uint64_t; 10], - pub f_namemax: ::uint32_t, - pub f_owner: ::uid_t, - pub f_fsid: ::fsid_t, - f_charspare: [::c_char; 80], - pub f_fstypename: [::c_char; 16], - pub f_mntfromname: [::c_char; 88], - pub f_mntonname: [::c_char; 88], - } - // internal structure has changed over time pub struct _sem { data: [u32; 4], @@ -174,6 +130,62 @@ s! { __cr_unused1: *mut ::c_void, } + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } +} + +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct utmpx { + pub ut_type: ::c_short, + pub ut_tv: ::timeval, + pub ut_id: [::c_char; 8], + pub ut_pid: ::pid_t, + pub ut_user: [::c_char; 32], + pub ut_line: [::c_char; 16], + pub ut_host: [::c_char; 128], + pub __ut_spare: [::c_char; 64], + } + + #[allow(missing_debug_implementations)] + pub struct dirent { + pub d_fileno: u32, + pub d_reclen: u16, + pub d_type: u8, + pub d_namlen: u8, + pub d_name: [::c_char; 256], + } + + #[allow(missing_debug_implementations)] + pub struct statfs { + pub f_version: ::uint32_t, + pub f_type: ::uint32_t, + pub f_flags: ::uint64_t, + pub f_bsize: ::uint64_t, + pub f_iosize: ::uint64_t, + pub f_blocks: ::uint64_t, + pub f_bfree: ::uint64_t, + pub f_bavail: ::int64_t, + pub f_files: ::uint64_t, + pub f_ffree: ::int64_t, + pub f_syncwrites: ::uint64_t, + pub f_asyncwrites: ::uint64_t, + pub f_syncreads: ::uint64_t, + pub f_asyncreads: ::uint64_t, + f_spare: [::uint64_t; 10], + pub f_namemax: ::uint32_t, + pub f_owner: ::uid_t, + pub f_fsid: ::fsid_t, + f_charspare: [::c_char; 80], + pub f_fstypename: [::c_char; 16], + pub f_mntfromname: [::c_char; 88], + pub f_mntonname: [::c_char; 88], + } + + #[allow(missing_debug_implementations)] pub struct sockaddr_dl { pub sdl_len: ::c_uchar, pub sdl_family: ::c_uchar, @@ -184,12 +196,6 @@ s! { pub sdl_slen: ::c_uchar, pub sdl_data: [::c_char; 46], } - - pub struct stack_t { - pub ss_sp: *mut ::c_void, - pub ss_size: ::size_t, - pub ss_flags: ::c_int, - } } pub const SIGEV_THREAD_ID: ::c_int = 4; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 95d9400987456..ca9ed982be5fa 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -27,6 +27,11 @@ s! { pub s_addr: ::in_addr_t, } + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + pub struct glob_t { pub gl_pathc: ::size_t, pub gl_matchc: ::size_t, @@ -50,14 +55,6 @@ s! { pub udata: *mut ::c_void, } - pub struct sockaddr_storage { - pub ss_len: u8, - pub ss_family: ::sa_family_t, - __ss_pad1: [u8; 6], - __ss_align: i64, - __ss_pad2: [u8; 112], - } - pub struct addrinfo { pub ai_flags: ::c_int, pub ai_family: ::c_int, @@ -191,6 +188,17 @@ s! { } } +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: ::sa_family_t, + __ss_pad1: [u8; 6], + __ss_align: i64, + __ss_pad2: [u8; 112], + } +} + pub const AIO_LISTIO_MAX: ::c_int = 16; pub const AIO_CANCELED: ::c_int = 1; pub const AIO_NOTCANCELED: ::c_int = 2; diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 764174d18ab7b..d03529662faa4 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -39,14 +39,6 @@ s! { pub ss_flags: ::c_int, } - pub struct sockaddr_in { - pub sin_len: u8, - pub sin_family: ::sa_family_t, - pub sin_port: ::in_port_t, - pub sin_addr: ::in_addr, - pub sin_zero: [::int8_t; 8], - } - pub struct in6_pktinfo { pub ipi6_addr: ::in6_addr, pub ipi6_ifindex: ::c_uint, diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 6ff545cdb855b..9c611d8d8d5b2 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -24,14 +24,6 @@ s! { _retval: ::ssize_t } - pub struct dirent { - pub d_fileno: ::ino_t, - pub d_reclen: u16, - pub d_namlen: u16, - pub d_type: u8, - pub d_name: [::c_char; 512], - } - pub struct glob_t { pub gl_pathc: ::size_t, pub gl_matchc: ::size_t, @@ -91,41 +83,7 @@ s! { pub st_spare: [::uint32_t; 2], } - pub struct statvfs { - pub f_flag: ::c_ulong, - pub f_bsize: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_iosize: ::c_ulong, - - pub f_blocks: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_bavail: ::fsblkcnt_t, - pub f_bresvd: ::fsblkcnt_t, - - pub f_files: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_favail: ::fsfilcnt_t, - pub f_fresvd: ::fsfilcnt_t, - - pub f_syncreads: ::uint64_t, - pub f_syncwrites: ::uint64_t, - - pub f_asyncreads: ::uint64_t, - pub f_asyncwrites: ::uint64_t, - - pub f_fsidx: ::fsid_t, - pub f_fsid: ::c_ulong, - pub f_namemax: ::c_ulong, - pub f_owner: ::uid_t, - - pub f_spare: [::uint32_t; 4], - - pub f_fstypename: [::c_char; 32], - pub f_mntonname: [::c_char; 1024], - pub f_mntfromname: [::c_char; 1024], - } - - pub struct addrinfo { + pub struct addrinfo { pub ai_flags: ::c_int, pub ai_family: ::c_int, pub ai_socktype: ::c_int, @@ -136,14 +94,6 @@ s! { pub ai_next: *mut ::addrinfo, } - pub struct sockaddr_storage { - pub ss_len: u8, - pub ss_family: ::sa_family_t, - __ss_pad1: [u8; 6], - __ss_pad2: i64, - __ss_pad3: [u8; 112], - } - pub struct siginfo_t { pub si_signo: ::c_int, pub si_code: ::c_int, @@ -318,14 +268,15 @@ s! { pub sdl_slen: ::uint8_t, pub sdl_data: [::c_char; 12], } +} +s_no_extra_traits! { + #[allow(missing_debug_implementations)] pub struct in_pktinfo { pub ipi_addr: ::in_addr, pub ipi_ifindex: ::c_uint, } -} -s_no_extra_traits! { #[repr(packed)] #[allow(missing_debug_implementations)] pub struct arphdr { @@ -341,6 +292,74 @@ s_no_extra_traits! { pub struct in_addr { pub s_addr: ::in_addr_t, } + + #[allow(missing_debug_implementations)] + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + #[allow(missing_debug_implementations)] + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: ::sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [::int8_t; 8], + } + + #[allow(missing_debug_implementations)] + pub struct dirent { + pub d_fileno: ::ino_t, + pub d_reclen: u16, + pub d_namlen: u16, + pub d_type: u8, + pub d_name: [::c_char; 512], + } + + #[allow(missing_debug_implementations)] + pub struct statvfs { + pub f_flag: ::c_ulong, + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_iosize: ::c_ulong, + + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_bresvd: ::fsblkcnt_t, + + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fresvd: ::fsfilcnt_t, + + pub f_syncreads: ::uint64_t, + pub f_syncwrites: ::uint64_t, + + pub f_asyncreads: ::uint64_t, + pub f_asyncwrites: ::uint64_t, + + pub f_fsidx: ::fsid_t, + pub f_fsid: ::c_ulong, + pub f_namemax: ::c_ulong, + pub f_owner: ::uid_t, + + pub f_spare: [::uint32_t; 4], + + pub f_fstypename: [::c_char; 32], + pub f_mntonname: [::c_char; 1024], + pub f_mntfromname: [::c_char; 1024], + } + + #[allow(missing_debug_implementations)] + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: ::sa_family_t, + __ss_pad1: [u8; 6], + __ss_pad2: i64, + __ss_pad3: [u8; 112], + } } pub const AT_FDCWD: ::c_int = -100; diff --git a/src/unix/bsd/netbsdlike/openbsdlike/mod.rs b/src/unix/bsd/netbsdlike/openbsdlike/mod.rs index c7ed0198c0bed..0d71fde26e37f 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/mod.rs @@ -17,10 +17,23 @@ pub type pthread_rwlockattr_t = *mut ::c_void; pub type caddr_t = *mut ::c_char; s! { + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + pub struct in_addr { pub s_addr: ::in_addr_t, } + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: ::sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [::int8_t; 8], + } + pub struct dirent { pub d_fileno: ::ino_t, pub d_off: ::off_t, diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 6eaadc845cd15..e0365d913ce8c 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -43,6 +43,11 @@ s! { pub s_addr: ::in_addr_t, } + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + pub struct sockaddr { pub sa_len: u8, pub sa_family: sa_family_t, diff --git a/src/unix/hermit/mod.rs b/src/unix/hermit/mod.rs index 7d652291319e1..ca389f06c1e12 100644 --- a/src/unix/hermit/mod.rs +++ b/src/unix/hermit/mod.rs @@ -54,6 +54,11 @@ s! { pub s_addr: ::in_addr_t, } + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + pub struct addrinfo { pub ai_flags: ::c_int, pub ai_family: ::c_int, diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 72324c16f5a5d..c086b8ac3f000 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -144,11 +144,6 @@ s! { __align: [u32; 0], } - pub struct ip_mreq { - pub imr_multiaddr: in_addr, - pub imr_interface: in_addr, - } - pub struct ipv6_mreq { pub ipv6mr_multiaddr: in6_addr, #[cfg(target_os = "android")] diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index c8594fa5d08a0..9a85c25e2d93f 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -31,6 +31,11 @@ s! { pub s_addr: ::in_addr_t, } + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + pub struct sockaddr { pub sa_family: sa_family_t, pub sa_data: [::c_char; 14], diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 19e01be654118..baabd6e84dadd 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -20,6 +20,11 @@ s! { pub s_addr: ::in_addr_t, } + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + pub struct sockaddr { pub sa_family: sa_family_t, pub sa_data: [::c_char; 14], diff --git a/src/unix/solaris/mod.rs b/src/unix/solaris/mod.rs index 889408a1a1def..fce314f67074d 100644 --- a/src/unix/solaris/mod.rs +++ b/src/unix/solaris/mod.rs @@ -48,6 +48,11 @@ s! { pub s_addr: ::in_addr_t, } + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + pub struct sockaddr { pub sa_family: sa_family_t, pub sa_data: [::c_char; 14], @@ -69,11 +74,6 @@ s! { pub __sin6_src_id: u32 } - pub struct sockaddr_un { - pub sun_family: sa_family_t, - pub sun_path: [c_char; 108] - } - pub struct passwd { pub pw_name: *mut ::c_char, pub pw_passwd: *mut ::c_char, @@ -108,15 +108,7 @@ s! { pub tm_isdst: ::c_int } - pub struct utsname { - pub sysname: [::c_char; 257], - pub nodename: [::c_char; 257], - pub release: [::c_char; 257], - pub version: [::c_char; 257], - pub machine: [::c_char; 257], - } - - pub struct msghdr { + pub struct msghdr { pub msg_name: *mut ::c_void, pub msg_namelen: ::socklen_t, pub msg_iov: *mut ::iovec, @@ -132,13 +124,6 @@ s! { pub cmsg_type: ::c_int, } - pub struct fd_set { - #[cfg(target_pointer_width = "64")] - fds_bits: [i64; FD_SETSIZE / 64], - #[cfg(target_pointer_width = "32")] - fds_bits: [i32; FD_SETSIZE / 32], - } - pub struct pthread_attr_t { __pthread_attrp: *mut ::c_void } @@ -204,13 +189,6 @@ s! { __unused10: *mut ::c_void, } - pub struct sockaddr_storage { - pub ss_family: ::sa_family_t, - __ss_pad1: [u8; 6], - __ss_align: i64, - __ss_pad2: [u8; 240], - } - pub struct addrinfo { pub ai_flags: ::c_int, pub ai_family: ::c_int, @@ -228,15 +206,6 @@ s! { bits: [u32; 4], } - pub struct siginfo_t { - pub si_signo: ::c_int, - pub si_code: ::c_int, - pub si_errno: ::c_int, - pub si_pad: ::c_int, - pub si_addr: *mut ::c_void, - __pad: [u8; 232], - } - pub struct sigaction { pub sa_flags: ::c_int, pub sa_sigaction: ::sighandler_t, @@ -366,10 +335,52 @@ s! { s_no_extra_traits! { #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed))] + #[allow(missing_debug_implementations)] pub struct epoll_event { pub events: ::uint32_t, pub u64: ::uint64_t, } + + #[allow(missing_debug_implementations)] + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [c_char; 108] + } + + #[allow(missing_debug_implementations)] + pub struct utsname { + pub sysname: [::c_char; 257], + pub nodename: [::c_char; 257], + pub release: [::c_char; 257], + pub version: [::c_char; 257], + pub machine: [::c_char; 257], + } + + #[allow(missing_debug_implementations)] + pub struct fd_set { + #[cfg(target_pointer_width = "64")] + fds_bits: [i64; FD_SETSIZE / 64], + #[cfg(target_pointer_width = "32")] + fds_bits: [i32; FD_SETSIZE / 32], + } + + #[allow(missing_debug_implementations)] + pub struct sockaddr_storage { + pub ss_family: ::sa_family_t, + __ss_pad1: [u8; 6], + __ss_align: i64, + __ss_pad2: [u8; 240], + } + + #[allow(missing_debug_implementations)] + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_code: ::c_int, + pub si_errno: ::c_int, + pub si_pad: ::c_int, + pub si_addr: *mut ::c_void, + __pad: [u8; 232], + } } pub const LC_CTYPE: ::c_int = 0; diff --git a/src/unix/uclibc/mod.rs b/src/unix/uclibc/mod.rs index c964932932516..ad5d794a751e0 100644 --- a/src/unix/uclibc/mod.rs +++ b/src/unix/uclibc/mod.rs @@ -43,6 +43,11 @@ s! { pub s_addr: ::in_addr_t, } + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + pub struct sockaddr { pub sa_family: sa_family_t, pub sa_data: [::c_char; 14], From 49ba25ad06fb72ca8e3d9bc325b5342f2a7d942f Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 19:04:55 +0100 Subject: [PATCH 41/72] Do not allow unused_macros for the whole crate --- src/lib.rs | 1 - src/macros.rs | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 63c64c7f0f2bb..bb1005c7ae71a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -162,7 +162,6 @@ // Enable lints #![cfg_attr(feature = "extra_traits", deny(missing_debug_implementations))] #![deny(missing_copy_implementations, safe_packed_borrows)] -#![allow(unused_macros)] #[cfg(all(not(cross_platform_docs), feature = "use_std"))] extern crate std as core; diff --git a/src/macros.rs b/src/macros.rs index b35cdc6315703..8aec1ab8028c3 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -6,6 +6,7 @@ /// /// This allows you to conveniently provide a long list #[cfg]'d blocks of code /// without having to rewrite each clause multiple times. +#[allow(unused_macros)] macro_rules! cfg_if { // match if/else chains with a final `else` ($( @@ -61,6 +62,7 @@ macro_rules! cfg_if { }; } +#[allow(unused_macros)] macro_rules! s { ($($(#[$attr:meta])* pub $t:ident $i:ident { $($field:tt)* })*) => ($( s!(it: $(#[$attr])* pub $t $i { $($field)* }); @@ -82,6 +84,7 @@ macro_rules! s { ); } +#[allow(unused_macros)] macro_rules! s_no_extra_traits { ($($(#[$attr:meta])* pub $t:ident $i:ident { $($field:tt)* })*) => ($( s_no_extra_traits!(it: $(#[$attr])* pub $t $i { $($field)* }); @@ -134,6 +137,7 @@ macro_rules! f { )*) } +#[allow(unused_macros)] macro_rules! __item { ($i:item) => { $i From c4e185555a2d0f04a59a941ab9698d97982c1a18 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 19:07:08 +0100 Subject: [PATCH 42/72] enable more build targets on all build jobs --- ci/build.sh | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 8458dc05afc10..743c53536a30e 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -58,21 +58,16 @@ test_target() { TARGETS="wasm32-unknown-unknown" case "${OS}" in linux*) - TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd " + TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i586-unknown-linux-musl i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu armv7-linux-androideabi armv7-unknown-linux-gnueabihf armv7-unknown-linux-musleabihf x86_64-sun-solaris " if [ "${RUST}" = "nightly" ]; then # aarch64-unknown-cloudabi armv7-unknown-cloudabi-eabihf i686-unknown-cloudabi powerpc-unknown-linux-gnuspe sparc-unknown-linux-gnu mips-unknown-unknown-linux-uclib i686-unknown-haiku i686-unknown-netbsd mipsel-unknown-unknown-linux-uclib sparc64-unknown-netbsd x86_64-unknown-bitrig x86_64-unknown-haiku x86_64-unknown-openbsd - TARGETS="${TARGETS} aarch64-fuchsia armv7-linux-androideabi armv7-unknown-linux-gnueabihf armv7-unknown-linux-musleabihf i586-unknown-linux-gnu i586-unknown-linux-musl i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu x86_64-fuchsia x86_64-rumprun-netbsd x86_64-sun-solaris x86_64-unknown-cloudabi x86_64-unknown-redox thumbv6m-none-eabi thumbv7em-none-eabi thumbv7em-none-eabihf thumbv7m-none-eabi x86_64-fortanix-unknown-sgx" + TARGETS="${TARGETS} aarch64-fuchsia x86_64-fuchsia x86_64-rumprun-netbsd x86_64-unknown-cloudabi x86_64-unknown-redox thumbv6m-none-eabi thumbv7em-none-eabi thumbv7em-none-eabihf thumbv7m-none-eabi x86_64-fortanix-unknown-sgx" fi ;; osx*) - TARGETS="i686-apple-darwin x86_64-apple-darwin" - - if [ "${RUST}" = "nightly" ]; then - TARGETS="${TARGETS} aarch64-apple-ios armv7-apple-ios armv7s-apple-ios x86_64-apple-ios" - fi - + TARGETS="i686-apple-darwin x86_64-apple-darwin aarch64-apple-ios armv7-apple-ios armv7s-apple-ios x86_64-apple-ios" ;; *) ;; From 170d67d5d648de698b25fe555ea6ce34cd9a4e5f Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 19:08:01 +0100 Subject: [PATCH 43/72] Enable netbsd build jobs on nightly linux --- ci/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 743c53536a30e..9a53408f1cbe7 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -61,8 +61,8 @@ case "${OS}" in TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i586-unknown-linux-musl i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu armv7-linux-androideabi armv7-unknown-linux-gnueabihf armv7-unknown-linux-musleabihf x86_64-sun-solaris " if [ "${RUST}" = "nightly" ]; then - # aarch64-unknown-cloudabi armv7-unknown-cloudabi-eabihf i686-unknown-cloudabi powerpc-unknown-linux-gnuspe sparc-unknown-linux-gnu mips-unknown-unknown-linux-uclib i686-unknown-haiku i686-unknown-netbsd mipsel-unknown-unknown-linux-uclib sparc64-unknown-netbsd x86_64-unknown-bitrig x86_64-unknown-haiku x86_64-unknown-openbsd - TARGETS="${TARGETS} aarch64-fuchsia x86_64-fuchsia x86_64-rumprun-netbsd x86_64-unknown-cloudabi x86_64-unknown-redox thumbv6m-none-eabi thumbv7em-none-eabi thumbv7em-none-eabihf thumbv7m-none-eabi x86_64-fortanix-unknown-sgx" + # aarch64-unknown-cloudabi armv7-unknown-cloudabi-eabihf i686-unknown-cloudabi powerpc-unknown-linux-gnuspe sparc-unknown-linux-gnu mips-unknown-unknown-linux-uclib i686-unknown-haiku mipsel-unknown-unknown-linux-uclib sparc64-unknown-netbsd x86_64-unknown-bitrig x86_64-unknown-haiku + TARGETS="${TARGETS} aarch64-fuchsia x86_64-fuchsia x86_64-rumprun-netbsd x86_64-unknown-cloudabi x86_64-unknown-redox thumbv6m-none-eabi thumbv7em-none-eabi thumbv7em-none-eabihf thumbv7m-none-eabi x86_64-fortanix-unknown-sgx x86_64-unknown-openbsd i686-unknown-netbsd" fi ;; From e79c5c3a3b2efc4cabfe0660f22987a229f4e5a0 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 19:34:18 +0100 Subject: [PATCH 44/72] Do not test i686/x86_64 openbsd --- ci/build.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 9a53408f1cbe7..00439e31730b4 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -61,8 +61,13 @@ case "${OS}" in TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i586-unknown-linux-musl i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu armv7-linux-androideabi armv7-unknown-linux-gnueabihf armv7-unknown-linux-musleabihf x86_64-sun-solaris " if [ "${RUST}" = "nightly" ]; then - # aarch64-unknown-cloudabi armv7-unknown-cloudabi-eabihf i686-unknown-cloudabi powerpc-unknown-linux-gnuspe sparc-unknown-linux-gnu mips-unknown-unknown-linux-uclib i686-unknown-haiku mipsel-unknown-unknown-linux-uclib sparc64-unknown-netbsd x86_64-unknown-bitrig x86_64-unknown-haiku - TARGETS="${TARGETS} aarch64-fuchsia x86_64-fuchsia x86_64-rumprun-netbsd x86_64-unknown-cloudabi x86_64-unknown-redox thumbv6m-none-eabi thumbv7em-none-eabi thumbv7em-none-eabihf thumbv7m-none-eabi x86_64-fortanix-unknown-sgx x86_64-unknown-openbsd i686-unknown-netbsd" + # aarch64-unknown-cloudabi armv7-unknown-cloudabi-eabihf + # i686-unknown-cloudabi powerpc-unknown-linux-gnuspe + # sparc-unknown-linux-gnu mips-unknown-unknown-linux-uclib + # i686-unknown-haiku mipsel-unknown-unknown-linux-uclib + # sparc64-unknown-netbsd x86_64-unknown-bitrig x86_64-unknown-haiku + # x86_64-unknown-openbsd i686-unknown-netbsd + TARGETS="${TARGETS} aarch64-fuchsia x86_64-fuchsia x86_64-rumprun-netbsd x86_64-unknown-cloudabi x86_64-unknown-redox thumbv6m-none-eabi thumbv7em-none-eabi thumbv7em-none-eabihf thumbv7m-none-eabi x86_64-fortanix-unknown-sgx" fi ;; From 9f4ade53c0f912d85884472724dc1a1dae382e54 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 20:23:12 +0100 Subject: [PATCH 45/72] Bump minimum required Rust version to Rust 1.25.0 --- .travis.yml | 72 ++++++++++++++--------------------------------------- README.md | 9 ++++--- 2 files changed, 23 insertions(+), 58 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7f2e67affb684..82b8d312dfe5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,7 @@ dist: xenial services: docker stages: - - tools-and-build-latest - - tier1-and-backwards-compat + - tools-and-build-and-tier1 - tier2 matrix: @@ -16,120 +15,85 @@ matrix: env: TARGET=x86_64-unknown-linux-gnu script: sh ci/dox.sh install: true - stage: tools-and-build-latest + stage: tools-and-build-and-tier1 - name: "Shellcheck" install: true script: - shellcheck --version - shellcheck ci/*.sh - stage: tools-and-build-latest + stage: tools-and-build-and-tier1 - name: "Style" install: rustup component add rustfmt-preview script: - rustc ci/style.rs && ./style src - cargo fmt --all -- --check - stage: tools-and-build-latest + stage: tools-and-build-and-tier1 # BUILD stable, beta, nightly - name: "Build Stable Rust" script: sh ci/build.sh - stage: tools-and-build-latest + stage: tools-and-build-and-tier1 rust: stable - name: "Build Beta Rust" script: sh ci/build.sh - stage: tools-and-build-latest + stage: tools-and-build-and-tier1 rust: beta - name: "Build Nightly Rust" script: sh ci/build.sh - stage: tools-and-build-latest + stage: tools-and-build-and-tier1 rust: nightly - name: "Build Stable Rust" script: sh ci/build.sh - stage: tools-and-build-latest + stage: tools-and-build-and-tier1 rust: stable os: osx osx_image: xcode10 - name: "Build Beta Rust" script: sh ci/build.sh - stage: tools-and-build-latest + stage: tools-and-build-and-tier1 rust: beta os: osx osx_image: xcode10 - name: "Build Nightly Rust" script: sh ci/build.sh - stage: tools-and-build-latest + stage: tools-and-build-and-tier1 rust: nightly os: osx osx_image: xcode10 - - # BUILD older Rust versions - - name: "Build Stable Rust 1.13.0" - script: sh ci/build.sh - stage: tier1-and-backwards-compat - rust: 1.13.0 - - name: "Build Stable Rust 1.19.0" - script: sh ci/build.sh - stage: tier1-and-backwards-compat - rust: 1.19.0 - - name: "Build Stable Rust 1.24.0" - script: sh ci/build.sh - stage: tier1-and-backwards-compat - rust: 1.24.0 - name: "Build Stable Rust 1.25.0" env: RUST=1.25.0 script: sh ci/build.sh - stage: tier1-and-backwards-compat + stage: tools-and-build-and-tier1 rust: 1.25.0 - name: "Build Stable Rust 1.30.0" script: sh ci/build.sh - stage: tier1-and-backwards-compat + stage: tools-and-build-and-tier1 rust: 1.30.0 - - name: "Build Stable Rust 1.13.0" - script: sh ci/build.sh - stage: tier1-and-backwards-compat - rust: 1.13.0 - os: osx - osx_image: xcode10 - - name: "Build Stable Rust 1.19.0" - script: sh ci/build.sh - stage: tier1-and-backwards-compat - rust: 1.19.0 - os: osx - osx_image: xcode10 - - name: "Build Stable Rust 1.24.0" - script: sh ci/build.sh - stage: tier1-and-backwards-compat - rust: 1.24.0 - os: osx - osx_image: xcode10 - name: "Build Stable Rust 1.25.0" env: RUST=1.25.0 script: sh ci/build.sh - stage: tier1-and-backwards-compat + stage: tools-and-build-and-tier1 rust: 1.25.0 os: osx osx_image: xcode10 - name: "Build Stable Rust 1.30.0" script: sh ci/build.sh - stage: tier1-and-backwards-compat + stage: tools-and-build-and-tier1 rust: 1.30.0 os: osx osx_image: xcode10 - - - # TIER 1 - env: TARGET=i686-apple-darwin os: osx osx_image: xcode10 - stage: tier1-and-backwards-compat + stage: tools-and-build-and-tier1 - env: TARGET=i686-unknown-linux-gnu - stage: tier1-and-backwards-compat + stage: tools-and-build-and-tier1 - env: TARGET=x86_64-apple-darwin os: osx osx_image: xcode10 - stage: tier1-and-backwards-compat + stage: tools-and-build-and-tier1 - env: TARGET=x86_64-unknown-linux-gnu - stage: tier1-and-backwards-compat + stage: tools-and-build-and-tier1 # Tier 2 targets - env: TARGET=aarch64-linux-android diff --git a/README.md b/README.md index a4b7260e6509e..6608e2a650be5 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,14 @@ Raw FFI bindings to platform libraries like `libc`. [![Documentation](https://docs.rs/libc/badge.svg)](https://docs.rs/libc) ![License](https://img.shields.io/crates/l/libc.svg** -**NOTE:** The minimum supported Rust version is Rust 1.13.0 . APIs requiring +**NOTE:** The minimum supported Rust version is **Rust 1.25.0** . APIs requiring newer Rust features are only available on newer Rust versions: -| Feature | Version | -|----------------------|---------| -| `union` | 1.19.0 | +| Feature | Version | +|-------------------------|---------| +| `union` | 1.19.0 | | `const mem::size_of` | 1.24.0 | +| `repr(align)` | 1.25.0 | | `core::ffi::c_void` | 1.30.0 | To use `libc` at its fullest, Rust 1.30.0 is required. From 5b804c6670da8f6e60d53d4e594c749e4d53d260 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 6 Feb 2019 22:17:42 +0100 Subject: [PATCH 46/72] Re-add support for Rust 1.13.0 --- .travis.yml | 34 +++- ci/build.sh | 2 +- src/fuchsia/align.rs | 71 ++++++++ src/fuchsia/mod.rs | 122 ++------------ src/fuchsia/no_align.rs | 49 ++++++ src/redox/align.rs | 6 + src/redox/mod.rs | 10 ++ src/redox/net.rs | 7 - src/redox/no_align.rs | 6 + src/unix/align.rs | 6 + src/unix/mod.rs | 18 +- src/unix/newlib/align.rs | 53 ++++++ src/unix/newlib/mod.rs | 103 ++---------- src/unix/newlib/no_align.rs | 47 ++++++ src/unix/no_align.rs | 6 + src/unix/notbsd/emscripten/align.rs | 34 ++++ .../{emscripten.rs => emscripten/mod.rs} | 56 ++----- src/unix/notbsd/emscripten/no_align.rs | 31 ++++ src/unix/notbsd/linux/align.rs | 85 ++++++++++ src/unix/notbsd/linux/mips/align.rs | 15 ++ src/unix/notbsd/linux/mips/mod.rs | 25 ++- src/unix/notbsd/linux/mips/no_align.rs | 10 ++ src/unix/notbsd/linux/mod.rs | 155 ++---------------- src/unix/notbsd/linux/no_align.rs | 70 ++++++++ src/unix/notbsd/linux/other/align.rs | 13 ++ src/unix/notbsd/linux/other/mod.rs | 24 ++- src/unix/notbsd/linux/other/no_align.rs | 10 ++ src/unix/notbsd/linux/s390x/align.rs | 10 ++ .../notbsd/linux/{s390x.rs => s390x/mod.rs} | 21 ++- src/unix/notbsd/linux/s390x/no_align.rs | 7 + src/unix/uclibc/align.rs | 53 ++++++ src/unix/uclibc/mips/mips32/align.rs | 13 ++ .../uclibc/mips/{mips32.rs => mips32/mod.rs} | 24 ++- src/unix/uclibc/mips/mips32/no_align.rs | 10 ++ src/unix/uclibc/mips/mips64/align.rs | 10 ++ .../uclibc/mips/{mips64.rs => mips64/mod.rs} | 21 ++- src/unix/uclibc/mips/mips64/no_align.rs | 8 + src/unix/uclibc/mod.rs | 101 +----------- src/unix/uclibc/no_align.rs | 49 ++++++ src/unix/uclibc/x86_64/align.rs | 64 ++++++++ src/unix/uclibc/x86_64/mod.rs | 114 +------------ src/unix/uclibc/x86_64/no_align.rs | 55 +++++++ 42 files changed, 955 insertions(+), 673 deletions(-) create mode 100644 src/fuchsia/align.rs create mode 100644 src/fuchsia/no_align.rs create mode 100644 src/redox/align.rs create mode 100644 src/redox/no_align.rs create mode 100644 src/unix/align.rs create mode 100644 src/unix/newlib/align.rs create mode 100644 src/unix/newlib/no_align.rs create mode 100644 src/unix/no_align.rs create mode 100644 src/unix/notbsd/emscripten/align.rs rename src/unix/notbsd/{emscripten.rs => emscripten/mod.rs} (97%) create mode 100644 src/unix/notbsd/emscripten/no_align.rs create mode 100644 src/unix/notbsd/linux/align.rs create mode 100644 src/unix/notbsd/linux/mips/align.rs create mode 100644 src/unix/notbsd/linux/mips/no_align.rs create mode 100644 src/unix/notbsd/linux/no_align.rs create mode 100644 src/unix/notbsd/linux/other/align.rs create mode 100644 src/unix/notbsd/linux/other/no_align.rs create mode 100644 src/unix/notbsd/linux/s390x/align.rs rename src/unix/notbsd/linux/{s390x.rs => s390x/mod.rs} (99%) create mode 100644 src/unix/notbsd/linux/s390x/no_align.rs create mode 100644 src/unix/uclibc/align.rs create mode 100644 src/unix/uclibc/mips/mips32/align.rs rename src/unix/uclibc/mips/{mips32.rs => mips32/mod.rs} (98%) create mode 100644 src/unix/uclibc/mips/mips32/no_align.rs create mode 100644 src/unix/uclibc/mips/mips64/align.rs rename src/unix/uclibc/mips/{mips64.rs => mips64/mod.rs} (94%) create mode 100644 src/unix/uclibc/mips/mips64/no_align.rs create mode 100644 src/unix/uclibc/no_align.rs create mode 100644 src/unix/uclibc/x86_64/align.rs create mode 100644 src/unix/uclibc/x86_64/no_align.rs diff --git a/.travis.yml b/.travis.yml index 82b8d312dfe5e..c3f1960b6081f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,8 +60,19 @@ matrix: rust: nightly os: osx osx_image: xcode10 + - name: "Build Stable Rust 1.13.0" + script: sh ci/build.sh + stage: tools-and-build-and-tier1 + rust: 1.13.0 + - name: "Build Stable Rust 1.19.0" + script: sh ci/build.sh + stage: tools-and-build-and-tier1 + rust: 1.19.0 + - name: "Build Stable Rust 1.24.0" + script: sh ci/build.sh + stage: tools-and-build-and-tier1 + rust: 1.24.0 - name: "Build Stable Rust 1.25.0" - env: RUST=1.25.0 script: sh ci/build.sh stage: tools-and-build-and-tier1 rust: 1.25.0 @@ -69,8 +80,25 @@ matrix: script: sh ci/build.sh stage: tools-and-build-and-tier1 rust: 1.30.0 + - name: "Build Stable Rust 1.13.0" + script: sh ci/build.sh + stage: tools-and-build-and-tier1 + rust: 1.13.0 + os: osx + osx_image: xcode10 + - name: "Build Stable Rust 1.19.0" + script: sh ci/build.sh + stage: tools-and-build-and-tier1 + rust: 1.19.0 + os: osx + osx_image: xcode10 + - name: "Build Stable Rust 1.24.0" + script: sh ci/build.sh + stage: tools-and-build-and-tier1 + rust: 1.24.0 + os: osx + osx_image: xcode10 - name: "Build Stable Rust 1.25.0" - env: RUST=1.25.0 script: sh ci/build.sh stage: tools-and-build-and-tier1 rust: 1.25.0 @@ -138,7 +166,7 @@ matrix: stage: tier2 - env: TARGET=x86_64-unknown-linux-gnux32 OPT="--release" stage: tier2 - - env: TARGET=x86_64-unknown-linux-mussl + - env: TARGET=x86_64-unknown-linux-musl stage: tier2 allow_failures: diff --git a/ci/build.sh b/ci/build.sh index 00439e31730b4..1782cfe70c800 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -58,7 +58,7 @@ test_target() { TARGETS="wasm32-unknown-unknown" case "${OS}" in linux*) - TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i586-unknown-linux-musl i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu armv7-linux-androideabi armv7-unknown-linux-gnueabihf armv7-unknown-linux-musleabihf x86_64-sun-solaris " + TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i586-unknown-linux-musl i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf armv7-unknown-linux-musleabihf x86_64-sun-solaris aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu sparc64-unknown-linux-gnu sparcv9-sun-solaris x86_64-unknown-linux-musl x86_64-linux-android wasm32-unknown-emscripten" if [ "${RUST}" = "nightly" ]; then # aarch64-unknown-cloudabi armv7-unknown-cloudabi-eabihf diff --git a/src/fuchsia/align.rs b/src/fuchsia/align.rs new file mode 100644 index 0000000000000..ca45086b5c308 --- /dev/null +++ b/src/fuchsia/align.rs @@ -0,0 +1,71 @@ +s! { + #[cfg_attr( + any( + target_pointer_width = "32", + target_arch = "x86_64" + ), + repr(align(4)))] + #[cfg_attr( + not(any( + target_pointer_width = "32", + target_arch = "x86_64" + )), + repr(align(8)))] + pub struct pthread_mutexattr_t { + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct pthread_rwlockattr_t { + size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { + size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + } +} + +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "arm", + target_arch = "x86_64")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "arm", + target_arch = "x86_64"))), + repr(align(8)))] + pub struct pthread_mutex_t { + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } + + #[allow(missing_debug_implementations)] + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "arm", + target_arch = "x86_64")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "arm", + target_arch = "x86_64"))), + repr(align(8)))] + pub struct pthread_rwlock_t { + size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + } + + #[allow(missing_debug_implementations)] + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + #[cfg_attr(target_arch = "x86", + repr(align(4)))] + #[cfg_attr(not(target_arch = "x86"), + repr(align(8)))] + pub struct pthread_cond_t { + size: [u8; __SIZEOF_PTHREAD_COND_T], + } +} diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index d82303723d44c..f19bf513923eb 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -490,47 +490,6 @@ s! { pub ifa_data: *mut ::c_void } - #[cfg_attr(all(libc_align, - any(target_pointer_width = "32", - target_arch = "x86_64", - all(target_arch = "aarch64", target_env = "musl"))), - repr(align(4)))] - #[cfg_attr(all(libc_align, - not(any(target_pointer_width = "32", - target_arch = "x86_64", - all(target_arch = "aarch64", target_env = "musl")))), - repr(align(8)))] - pub struct pthread_mutexattr_t { - #[cfg(all(not(libc_align), - any(target_arch = "x86_64", - all(target_arch = "aarch64", target_env = "musl"))))] - __align: [::c_int; 0], - #[cfg(all(not(libc_align), - not(any(target_arch = "x86_64", - all(target_arch = "aarch64", target_env = "musl")))))] - __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], - } - - #[cfg_attr(all(libc_align, - target_pointer_width = "32"), - repr(align(4)))] - #[cfg_attr(all(libc_align, - target_pointer_width = "64"), - repr(align(8)))] - pub struct pthread_rwlockattr_t { - #[cfg(not(libc_align))] - __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], - } - - #[cfg_attr(libc_align, repr(align(4)))] - pub struct pthread_condattr_t { - #[cfg(not(libc_align))] - __align: [::c_int; 0], - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], - } - pub struct passwd { pub pw_name: *mut ::c_char, pub pw_passwd: *mut ::c_char, @@ -1023,77 +982,6 @@ s_no_extra_traits! { pub d_type: ::c_uchar, pub d_name: [::c_char; 256], } - - #[allow(missing_debug_implementations)] - #[cfg_attr(all(libc_align, - target_pointer_width = "32", - any(target_arch = "arm", - target_arch = "x86_64")), - repr(align(4)))] - #[cfg_attr(all(libc_align, - any(target_pointer_width = "64", - not(any(target_arch = "arm", - target_arch = "x86_64")))), - repr(align(8)))] - pub struct pthread_mutex_t { - #[cfg(all(not(libc_align), - any(target_arch = "arm", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_long; 0], - #[cfg(not(any(libc_align, - target_arch = "arm", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], - } - - #[allow(missing_debug_implementations)] - #[cfg_attr(all(libc_align, - target_pointer_width = "32", - any(target_arch = "arm", - target_arch = "x86_64")), - repr(align(4)))] - #[cfg_attr(all(libc_align, - any(target_pointer_width = "64", - not(any(target_arch = "arm", - target_arch = "x86_64")))), - repr(align(8)))] - pub struct pthread_rwlock_t { - #[cfg(all(not(libc_align), - any(target_arch = "arm", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_long; 0], - #[cfg(not(any(libc_align, - target_arch = "arm", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], - } - - #[allow(missing_debug_implementations)] - #[cfg_attr(all(libc_align, - target_pointer_width = "32"), - repr(align(4)))] - #[cfg_attr(all(libc_align, - target_pointer_width = "64"), - repr(align(8)))] - #[cfg_attr(all(libc_align, - target_arch = "x86"), - repr(align(4)))] - #[cfg_attr(all(libc_align, - not(target_arch = "x86")), - repr(align(8)))] - pub struct pthread_cond_t { - #[cfg(all(not(libc_align), target_env = "musl"))] - __align: [*const ::c_void; 0], - #[cfg(not(any(libc_align, target_env = "musl")))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_COND_T], - } } // PUB_CONST @@ -4120,6 +4008,16 @@ cfg_if! { } } +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } else { + mod no_align; + pub use self::no_align::*; + } +} + cfg_if! { if #[cfg(libc_core_cvoid)] { pub use ::ffi::c_void; diff --git a/src/fuchsia/no_align.rs b/src/fuchsia/no_align.rs new file mode 100644 index 0000000000000..9dd5c9bedee28 --- /dev/null +++ b/src/fuchsia/no_align.rs @@ -0,0 +1,49 @@ +s! { + pub struct pthread_mutexattr_t { + #[cfg(target_arch = "x86_64")] + __align: [::c_int; 0], + #[cfg(not(target_arch = "x86_64"))] + __align: [::c_long; 0], + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + } + + pub struct pthread_rwlockattr_t { + __align: [::c_long; 0], + size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + pub struct pthread_condattr_t { + __align: [::c_int; 0], + size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + } +} + +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct pthread_mutex_t { + #[cfg(any(target_arch = "arm", + all(target_arch = "x86_64", + target_pointer_width = "32")))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "arm", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } + + #[allow(missing_debug_implementations)] + pub struct pthread_rwlock_t { + __align: [::c_long; 0], + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + } + + #[allow(missing_debug_implementations)] + pub struct pthread_cond_t { + __align: [*const ::c_void; 0], + #[cfg(not(target_env = "musl"))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_COND_T], + } +} diff --git a/src/redox/align.rs b/src/redox/align.rs new file mode 100644 index 0000000000000..4fdba9a6aba69 --- /dev/null +++ b/src/redox/align.rs @@ -0,0 +1,6 @@ +s! { + #[repr(align(4))] + pub struct in6_addr { + pub s6_addr: [u8; 16], + } +} diff --git a/src/redox/mod.rs b/src/redox/mod.rs index e770b4625a557..cde619e98726e 100644 --- a/src/redox/mod.rs +++ b/src/redox/mod.rs @@ -404,3 +404,13 @@ cfg_if! { } } } + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } else { + mod no_align; + pub use self::no_align::*; + } +} diff --git a/src/redox/net.rs b/src/redox/net.rs index 7a9490260d4a2..f769c83f2d98c 100644 --- a/src/redox/net.rs +++ b/src/redox/net.rs @@ -9,13 +9,6 @@ s! { pub s_addr: in_addr_t, } - #[cfg_attr(libc_align, repr(align(4)))] - pub struct in6_addr { - pub s6_addr: [u8; 16], - #[cfg(not(libc_align))] - __align: [u32; 0], - } - pub struct ip_mreq { pub imr_multiaddr: in_addr, pub imr_interface: in_addr, diff --git a/src/redox/no_align.rs b/src/redox/no_align.rs new file mode 100644 index 0000000000000..f6b9f4c12d4ba --- /dev/null +++ b/src/redox/no_align.rs @@ -0,0 +1,6 @@ +s! { + pub struct in6_addr { + pub s6_addr: [u8; 16], + __align: [u32; 0], + } +} diff --git a/src/unix/align.rs b/src/unix/align.rs new file mode 100644 index 0000000000000..4fdba9a6aba69 --- /dev/null +++ b/src/unix/align.rs @@ -0,0 +1,6 @@ +s! { + #[repr(align(4))] + pub struct in6_addr { + pub s6_addr: [u8; 16], + } +} diff --git a/src/unix/mod.rs b/src/unix/mod.rs index c086b8ac3f000..7292ba68740d9 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -137,13 +137,6 @@ s! { __reserved: [c_long; 16], } - #[cfg_attr(libc_align, repr(align(4)))] - pub struct in6_addr { - pub s6_addr: [u8; 16], - #[cfg(not(libc_align))] - __align: [u32; 0], - } - pub struct ipv6_mreq { pub ipv6mr_multiaddr: in6_addr, #[cfg(target_os = "android")] @@ -1177,3 +1170,14 @@ cfg_if! { } } } + + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } else { + mod no_align; + pub use self::no_align::*; + } +} diff --git a/src/unix/newlib/align.rs b/src/unix/newlib/align.rs new file mode 100644 index 0000000000000..d3e25495bb34a --- /dev/null +++ b/src/unix/newlib/align.rs @@ -0,0 +1,53 @@ +s! { + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))), + repr(align(8)))] + pub struct pthread_mutex_t { // Unverified + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))), + repr(align(8)))] + pub struct pthread_rwlock_t { // Unverified + size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + } + + #[cfg_attr(any(target_pointer_width = "32", + target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64"), + repr(align(4)))] + #[cfg_attr(not(any(target_pointer_width = "32", + target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64")), + repr(align(8)))] + pub struct pthread_mutexattr_t { // Unverified + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[repr(align(8))] + pub struct pthread_cond_t { // Unverified + size: [u8; __SIZEOF_PTHREAD_COND_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { // Unverified + size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + } +} diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 9a85c25e2d93f..fc5158775a835 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -247,103 +247,10 @@ s! { __size: [u64; 7] } - #[cfg_attr(all(libc_align, - target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")), - repr(align(4)))] - #[cfg_attr(all(libc_align, - any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))), - repr(align(8)))] - pub struct pthread_mutex_t { // Unverified - #[cfg(all(not(libc_align), - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - __align: [::c_long; 0], - #[cfg(not(any(libc_align, - target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], - } - - #[cfg_attr(all(libc_align, - target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")), - repr(align(4)))] - #[cfg_attr(all(libc_align, - any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))), - repr(align(8)))] - pub struct pthread_rwlock_t { // Unverified - #[cfg(all(not(libc_align), - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - __align: [::c_long; 0], - #[cfg(not(any(libc_align, - target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], - } - - #[cfg_attr(all(libc_align, - any(target_pointer_width = "32", - target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64")), - repr(align(4)))] - #[cfg_attr(all(libc_align, - not(any(target_pointer_width = "32", - target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"))), - repr(align(8)))] - pub struct pthread_mutexattr_t { // Unverified - #[cfg(all(not(libc_align), - any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64")))] - __align: [::c_int; 0], - #[cfg(all(not(libc_align), - not(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"))))] - __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], - } - pub struct pthread_rwlockattr_t { // Unverified __lockkind: ::c_int, __pshared: ::c_int, } - - #[cfg_attr(libc_align, repr(align(8)))] - pub struct pthread_cond_t { // Unverified - #[cfg(not(libc_align))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_COND_T], - } - - #[cfg_attr(libc_align, repr(align(4)))] - pub struct pthread_condattr_t { // Unverified - #[cfg(not(libc_align))] - __align: [::c_int; 0], - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], - } - } // unverified constants @@ -753,3 +660,13 @@ cfg_if! { pub use target_arch_not_implemented; } } + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } else { + mod no_align; + pub use self::no_align::*; + } +} diff --git a/src/unix/newlib/no_align.rs b/src/unix/newlib/no_align.rs new file mode 100644 index 0000000000000..3ae096854e98d --- /dev/null +++ b/src/unix/newlib/no_align.rs @@ -0,0 +1,47 @@ +s! { + pub struct pthread_mutex_t { // Unverified + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } + + pub struct pthread_rwlock_t { // Unverified + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + } + + pub struct pthread_mutexattr_t { // Unverified + #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64"))] + __align: [::c_int; 0], + #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64")))] + __align: [::c_long; 0], + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + } + + pub struct pthread_cond_t { // Unverified + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_COND_T], + } + + pub struct pthread_condattr_t { // Unverified + __align: [::c_int; 0], + size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + } +} diff --git a/src/unix/no_align.rs b/src/unix/no_align.rs new file mode 100644 index 0000000000000..f6b9f4c12d4ba --- /dev/null +++ b/src/unix/no_align.rs @@ -0,0 +1,6 @@ +s! { + pub struct in6_addr { + pub s6_addr: [u8; 16], + __align: [u32; 0], + } +} diff --git a/src/unix/notbsd/emscripten/align.rs b/src/unix/notbsd/emscripten/align.rs new file mode 100644 index 0000000000000..a2414dbd85f41 --- /dev/null +++ b/src/unix/notbsd/emscripten/align.rs @@ -0,0 +1,34 @@ +s! { + #[repr(align(4))] + pub struct pthread_mutex_t { + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } + + #[repr(align(4))] + pub struct pthread_rwlock_t { + size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + } + + #[repr(align(4))] + pub struct pthread_mutexattr_t { + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[repr(align(4))] + pub struct pthread_rwlockattr_t { + size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct pthread_cond_t { + size: [u8; __SIZEOF_PTHREAD_COND_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { + size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + } +} diff --git a/src/unix/notbsd/emscripten.rs b/src/unix/notbsd/emscripten/mod.rs similarity index 97% rename from src/unix/notbsd/emscripten.rs rename to src/unix/notbsd/emscripten/mod.rs index 8ebf260262b83..24c9d47716334 100644 --- a/src/unix/notbsd/emscripten.rs +++ b/src/unix/notbsd/emscripten/mod.rs @@ -77,51 +77,6 @@ s! { __unused5: *mut ::c_void, } - #[cfg_attr(libc_align, repr(align(4)))] - pub struct pthread_mutex_t { - #[cfg(not(libc_align))] - __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], - } - - #[cfg_attr(libc_align, repr(align(4)))] - pub struct pthread_rwlock_t { - #[cfg(not(libc_align))] - __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], - } - - #[cfg_attr(libc_align, repr(align(4)))] - pub struct pthread_mutexattr_t { - #[cfg(not(libc_align))] - __align: [::c_int; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], - } - - #[cfg_attr(libc_align, repr(align(4)))] - pub struct pthread_rwlockattr_t { - #[cfg(not(libc_align))] - __align: [::c_int; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], - } - - #[cfg_attr(all(libc_align, target_pointer_width = "32"), - repr(align(4)))] - #[cfg_attr(all(libc_align, target_pointer_width = "64"), - repr(align(8)))] - pub struct pthread_cond_t { - #[cfg(not(libc_align))] - __align: [*const ::c_void; 0], - size: [u8; __SIZEOF_PTHREAD_COND_T], - } - - #[cfg_attr(libc_align, repr(align(4)))] - pub struct pthread_condattr_t { - #[cfg(not(libc_align))] - __align: [::c_int; 0], - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], - } - pub struct passwd { pub pw_name: *mut ::c_char, pub pw_passwd: *mut ::c_char, @@ -1701,3 +1656,14 @@ extern { f: extern fn(*mut ::c_void) -> *mut ::c_void, value: *mut ::c_void) -> ::c_int; } + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } else { + mod no_align; + pub use self::no_align::*; + } +} + diff --git a/src/unix/notbsd/emscripten/no_align.rs b/src/unix/notbsd/emscripten/no_align.rs new file mode 100644 index 0000000000000..1ef0d2c4c4f04 --- /dev/null +++ b/src/unix/notbsd/emscripten/no_align.rs @@ -0,0 +1,31 @@ +s! { + pub struct pthread_mutex_t { + __align: [::c_long; 0], + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } + + pub struct pthread_rwlock_t { + __align: [::c_long; 0], + size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + } + + pub struct pthread_mutexattr_t { + __align: [::c_int; 0], + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + } + + pub struct pthread_rwlockattr_t { + __align: [::c_int; 0], + size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + pub struct pthread_cond_t { + __align: [*const ::c_void; 0], + size: [u8; __SIZEOF_PTHREAD_COND_T], + } + + pub struct pthread_condattr_t { + __align: [::c_int; 0], + size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + } +} diff --git a/src/unix/notbsd/linux/align.rs b/src/unix/notbsd/linux/align.rs new file mode 100644 index 0000000000000..b3d3926114438 --- /dev/null +++ b/src/unix/notbsd/linux/align.rs @@ -0,0 +1,85 @@ +s! { + #[cfg_attr(any(target_pointer_width = "32", + target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64", + all(target_arch = "aarch64", target_env = "musl")), + repr(align(4)))] + #[cfg_attr(not(any(target_pointer_width = "32", + target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64", + all(target_arch = "aarch64", target_env = "musl"))), + repr(align(8)))] + pub struct pthread_mutexattr_t { + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[cfg_attr(any(target_env = "musl", target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(not(target_env = "musl"), + target_pointer_width = "64"), + repr(align(8)))] + pub struct pthread_rwlockattr_t { + size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { + size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + } +} + +s_no_extra_traits! { + #[cfg_attr(all(target_env = "musl", + target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(target_env = "musl", + target_pointer_width = "64"), + repr(align(8)))] + #[cfg_attr(all(not(target_env = "musl"), + target_arch = "x86"), + repr(align(4)))] + #[cfg_attr(all(not(target_env = "musl"), + not(target_arch = "x86")), + repr(align(8)))] + pub struct pthread_cond_t { + size: [u8; __SIZEOF_PTHREAD_COND_T], + } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "x86_64", + target_arch = "x86")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "x86_64", + target_arch = "x86"))), + repr(align(8)))] + pub struct pthread_mutex_t { + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "x86_64", + target_arch = "x86")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "x86_64", + target_arch = "x86"))), + repr(align(8)))] + pub struct pthread_rwlock_t { + size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + } +} diff --git a/src/unix/notbsd/linux/mips/align.rs b/src/unix/notbsd/linux/mips/align.rs new file mode 100644 index 0000000000000..8e5c1ddebd15a --- /dev/null +++ b/src/unix/notbsd/linux/mips/align.rs @@ -0,0 +1,15 @@ +s! { + // FIXME this is actually a union + #[cfg_attr(all(libc_align, target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(libc_align, target_pointer_width = "64"), + repr(align(8)))] + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + #[cfg(not(libc_align))] + __align: [::c_long; 0], + } +} diff --git a/src/unix/notbsd/linux/mips/mod.rs b/src/unix/notbsd/linux/mips/mod.rs index 0f1cf7ad0146c..0c76fbb716704 100644 --- a/src/unix/notbsd/linux/mips/mod.rs +++ b/src/unix/notbsd/linux/mips/mod.rs @@ -20,20 +20,6 @@ s! { __unused5: *mut ::c_void, } - // FIXME this is actually a union - #[cfg_attr(all(libc_align, target_pointer_width = "32"), - repr(align(4)))] - #[cfg_attr(all(libc_align, target_pointer_width = "64"), - repr(align(8)))] - pub struct sem_t { - #[cfg(target_pointer_width = "32")] - __size: [::c_char; 16], - #[cfg(target_pointer_width = "64")] - __size: [::c_char; 32], - #[cfg(not(libc_align))] - __align: [::c_long; 0], - } - pub struct termios2 { pub c_iflag: ::tcflag_t, pub c_oflag: ::tcflag_t, @@ -962,3 +948,14 @@ cfg_if! { // Unknown target_arch } } + + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } else { + mod no_align; + pub use self::no_align::*; + } +} diff --git a/src/unix/notbsd/linux/mips/no_align.rs b/src/unix/notbsd/linux/mips/no_align.rs new file mode 100644 index 0000000000000..e32bf673d140e --- /dev/null +++ b/src/unix/notbsd/linux/mips/no_align.rs @@ -0,0 +1,10 @@ +s! { + // FIXME this is actually a union + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + __align: [::c_long; 0], + } +} diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index b99bea24a14f3..c0a192aace216 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -64,58 +64,6 @@ s! { __unused5: *mut ::c_void, } - #[cfg_attr(all(libc_align, - any(target_pointer_width = "32", - target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64", - all(target_arch = "aarch64", target_env = "musl"))), - repr(align(4)))] - #[cfg_attr(all(libc_align, - not(any(target_pointer_width = "32", - target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64", - all(target_arch = "aarch64", target_env = "musl")))), - repr(align(8)))] - pub struct pthread_mutexattr_t { - #[cfg(all(not(libc_align), - any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64", - all(target_arch = "aarch64", target_env = "musl"))))] - __align: [::c_int; 0], - #[cfg(all(not(libc_align), - not(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64", - all(target_arch = "aarch64", target_env = "musl")))))] - __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], - } - - #[cfg_attr(all(libc_align, - any(target_env = "musl", target_pointer_width = "32")), - repr(align(4)))] - #[cfg_attr(all(libc_align, - not(target_env = "musl"), - target_pointer_width = "64"), - repr(align(8)))] - pub struct pthread_rwlockattr_t { - #[cfg(all(not(libc_align), target_env = "musl"))] - __align: [::c_int; 0], - #[cfg(all(not(libc_align), not(target_env = "musl")))] - __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], - } - - #[cfg_attr(libc_align, repr(align(4)))] - pub struct pthread_condattr_t { - #[cfg(not(libc_align))] - __align: [::c_int; 0], - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], - } - pub struct passwd { pub pw_name: *mut ::c_char, pub pw_passwd: *mut ::c_char, @@ -577,98 +525,6 @@ s_no_extra_traits!{ pub d_type: ::c_uchar, pub d_name: [::c_char; 256], } - - #[cfg_attr(all(libc_align, - target_env = "musl", - target_pointer_width = "32"), - repr(align(4)))] - #[cfg_attr(all(libc_align, - target_env = "musl", - target_pointer_width = "64"), - repr(align(8)))] - #[cfg_attr(all(libc_align, - not(target_env = "musl"), - target_arch = "x86"), - repr(align(4)))] - #[cfg_attr(all(libc_align, - not(target_env = "musl"), - not(target_arch = "x86")), - repr(align(8)))] - pub struct pthread_cond_t { - #[cfg(all(not(libc_align), target_env = "musl"))] - __align: [*const ::c_void; 0], - #[cfg(not(any(libc_align, target_env = "musl")))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_COND_T], - } - - #[cfg_attr(all(libc_align, - target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - target_arch = "x86_64", - target_arch = "x86")), - repr(align(4)))] - #[cfg_attr(all(libc_align, - any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - target_arch = "x86_64", - target_arch = "x86")))), - repr(align(8)))] - pub struct pthread_mutex_t { - #[cfg(all(not(libc_align), - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_long; 0], - #[cfg(not(any(libc_align, - target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], - } - - #[cfg_attr(all(libc_align, - target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - target_arch = "x86_64", - target_arch = "x86")), - repr(align(4)))] - #[cfg_attr(all(libc_align, - any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - target_arch = "x86_64", - target_arch = "x86")))), - repr(align(8)))] - pub struct pthread_rwlock_t { - #[cfg(all(not(libc_align), - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_long; 0], - #[cfg(not(any(libc_align, - target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], - } } cfg_if! { @@ -2501,3 +2357,14 @@ cfg_if! { pub use self::other::*; } } + + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } else { + mod no_align; + pub use self::no_align::*; + } +} diff --git a/src/unix/notbsd/linux/no_align.rs b/src/unix/notbsd/linux/no_align.rs new file mode 100644 index 0000000000000..8e85396c94774 --- /dev/null +++ b/src/unix/notbsd/linux/no_align.rs @@ -0,0 +1,70 @@ +s! { + pub struct pthread_mutexattr_t { + #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64", + all(target_arch = "aarch64", target_env = "musl")))] + __align: [::c_int; 0], + #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64", + all(target_arch = "aarch64", target_env = "musl"))))] + __align: [::c_long; 0], + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + } + + pub struct pthread_rwlockattr_t { + #[cfg(target_env = "musl")] + __align: [::c_int; 0], + #[not(target_env = "musl")] + __align: [::c_long; 0], + size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + pub struct pthread_condattr_t { + __align: [::c_int; 0], + size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + } +} + +s_no_extra_traits! { + pub struct pthread_cond_t { + #[cfg(target_env = "musl")] + __align: [*const ::c_void; 0], + #[cfg(not(target_env = "musl"))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_COND_T], + } + + pub struct pthread_mutex_t { + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + all(target_arch = "x86_64", + target_pointer_width = "32")))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } + + pub struct pthread_rwlock_t { + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + all(target_arch = "x86_64", + target_pointer_width = "32")))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + } +} diff --git a/src/unix/notbsd/linux/other/align.rs b/src/unix/notbsd/linux/other/align.rs new file mode 100644 index 0000000000000..4a0e07460ebb1 --- /dev/null +++ b/src/unix/notbsd/linux/other/align.rs @@ -0,0 +1,13 @@ +s! { + // FIXME this is actually a union + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + } +} diff --git a/src/unix/notbsd/linux/other/mod.rs b/src/unix/notbsd/linux/other/mod.rs index 08d0b58d07959..497ea6d70a93d 100644 --- a/src/unix/notbsd/linux/other/mod.rs +++ b/src/unix/notbsd/linux/other/mod.rs @@ -121,20 +121,6 @@ s! { pub l_pid: ::pid_t, } - // FIXME this is actually a union - #[cfg_attr(all(libc_align, target_pointer_width = "32"), - repr(align(4)))] - #[cfg_attr(all(libc_align, target_pointer_width = "64"), - repr(align(8)))] - pub struct sem_t { - #[cfg(target_pointer_width = "32")] - __size: [::c_char; 16], - #[cfg(target_pointer_width = "64")] - __size: [::c_char; 32], - #[cfg(not(libc_align))] - __align: [::c_long; 0], - } - pub struct mallinfo { pub arena: ::c_int, pub ordblks: ::c_int, @@ -1001,3 +987,13 @@ cfg_if! { // Unknown target_arch } } + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } else { + mod no_align; + pub use self::no_align::*; + } +} diff --git a/src/unix/notbsd/linux/other/no_align.rs b/src/unix/notbsd/linux/other/no_align.rs new file mode 100644 index 0000000000000..e32bf673d140e --- /dev/null +++ b/src/unix/notbsd/linux/other/no_align.rs @@ -0,0 +1,10 @@ +s! { + // FIXME this is actually a union + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + __align: [::c_long; 0], + } +} diff --git a/src/unix/notbsd/linux/s390x/align.rs b/src/unix/notbsd/linux/s390x/align.rs new file mode 100644 index 0000000000000..21e21907d4a70 --- /dev/null +++ b/src/unix/notbsd/linux/s390x/align.rs @@ -0,0 +1,10 @@ +s! { + // FIXME this is actually a union + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct sem_t { + __size: [::c_char; 32], + } +} diff --git a/src/unix/notbsd/linux/s390x.rs b/src/unix/notbsd/linux/s390x/mod.rs similarity index 99% rename from src/unix/notbsd/linux/s390x.rs rename to src/unix/notbsd/linux/s390x/mod.rs index dbd5ea5454149..3368cffc2f49a 100644 --- a/src/unix/notbsd/linux/s390x.rs +++ b/src/unix/notbsd/linux/s390x/mod.rs @@ -246,17 +246,6 @@ s! { pub l_pid: ::pid_t, } - // FIXME this is actually a union - #[cfg_attr(all(libc_align, target_pointer_width = "32"), - repr(align(4)))] - #[cfg_attr(all(libc_align, target_pointer_width = "64"), - repr(align(8)))] - pub struct sem_t { - __size: [::c_char; 32], - #[cfg(not(libc_align))] - __align: [::c_long; 0], - } - pub struct __psw_t { pub mask: u64, pub addr: u64, @@ -1362,3 +1351,13 @@ extern { pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> ::c_int; } + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } else { + mod no_align; + pub use self::no_align::*; + } +} diff --git a/src/unix/notbsd/linux/s390x/no_align.rs b/src/unix/notbsd/linux/s390x/no_align.rs new file mode 100644 index 0000000000000..8909114cdfa42 --- /dev/null +++ b/src/unix/notbsd/linux/s390x/no_align.rs @@ -0,0 +1,7 @@ +s! { + // FIXME this is actually a union + pub struct sem_t { + __size: [::c_char; 32], + __align: [::c_long; 0], + } +} diff --git a/src/unix/uclibc/align.rs b/src/unix/uclibc/align.rs new file mode 100644 index 0000000000000..889069f072cde --- /dev/null +++ b/src/unix/uclibc/align.rs @@ -0,0 +1,53 @@ +s! { + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))), + repr(align(8)))] + pub struct pthread_mutex_t { + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))), + repr(align(8)))] + pub struct pthread_rwlock_t { + size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + } + + #[cfg_attr(any(target_pointer_width = "32", + target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64"), + repr(align(4)))] + #[cfg_attr(not(any(target_pointer_width = "32", + target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64")), + repr(align(8)))] + pub struct pthread_mutexattr_t { + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[repr(align(8))] + pub struct pthread_cond_t { + size: [u8; __SIZEOF_PTHREAD_COND_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { + size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + } +} diff --git a/src/unix/uclibc/mips/mips32/align.rs b/src/unix/uclibc/mips/mips32/align.rs new file mode 100644 index 0000000000000..965c9c3cc4498 --- /dev/null +++ b/src/unix/uclibc/mips/mips32/align.rs @@ -0,0 +1,13 @@ +s! { + // FIXME this is actually a union + #[cfg_attr(arget_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + } +} diff --git a/src/unix/uclibc/mips/mips32.rs b/src/unix/uclibc/mips/mips32/mod.rs similarity index 98% rename from src/unix/uclibc/mips/mips32.rs rename to src/unix/uclibc/mips/mips32/mod.rs index 1ae3962f4995c..8dc9429e60c1c 100644 --- a/src/unix/uclibc/mips/mips32.rs +++ b/src/unix/uclibc/mips/mips32/mod.rs @@ -220,20 +220,6 @@ s! { pub mem_unit: ::c_uint, pub _f: [::c_char; 8], } - - // FIXME this is actually a union - #[cfg_attr(all(libc_align, target_pointer_width = "32"), - repr(align(4)))] - #[cfg_attr(all(libc_align, target_pointer_width = "64"), - repr(align(8)))] - pub struct sem_t { - #[cfg(target_pointer_width = "32")] - __size: [::c_char; 16], - #[cfg(target_pointer_width = "64")] - __size: [::c_char; 32], - #[cfg(not(libc_align))] - __align: [::c_long; 0], - } } pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; @@ -637,3 +623,13 @@ extern { cpusetsize: ::size_t, cpuset: *const ::cpu_set_t) -> ::c_int; } + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } else { + mod no_align; + pub use self::no_align::*; + } +} diff --git a/src/unix/uclibc/mips/mips32/no_align.rs b/src/unix/uclibc/mips/mips32/no_align.rs new file mode 100644 index 0000000000000..e32bf673d140e --- /dev/null +++ b/src/unix/uclibc/mips/mips32/no_align.rs @@ -0,0 +1,10 @@ +s! { + // FIXME this is actually a union + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + __align: [::c_long; 0], + } +} diff --git a/src/unix/uclibc/mips/mips64/align.rs b/src/unix/uclibc/mips/mips64/align.rs new file mode 100644 index 0000000000000..21e21907d4a70 --- /dev/null +++ b/src/unix/uclibc/mips/mips64/align.rs @@ -0,0 +1,10 @@ +s! { + // FIXME this is actually a union + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct sem_t { + __size: [::c_char; 32], + } +} diff --git a/src/unix/uclibc/mips/mips64.rs b/src/unix/uclibc/mips/mips64/mod.rs similarity index 94% rename from src/unix/uclibc/mips/mips64.rs rename to src/unix/uclibc/mips/mips64/mod.rs index c9e1c197ccb66..d80762e6c0acb 100644 --- a/src/unix/uclibc/mips/mips64.rs +++ b/src/unix/uclibc/mips/mips64/mod.rs @@ -186,17 +186,6 @@ s! { pub mem_unit: ::c_uint, pub _f: [::c_char; 0], } - - // FIXME this is actually a union - #[cfg_attr(all(libc_align, target_pointer_width = "32"), - repr(align(4)))] - #[cfg_attr(all(libc_align, target_pointer_width = "64"), - repr(align(8)))] - pub struct sem_t { - __size: [::c_char; 32], - #[cfg(not(libc_align))] - __align: [::c_long; 0], - } } pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; @@ -212,3 +201,13 @@ pub const SYS_gettid: ::c_long = 5178; // Valid for n64 extern { pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; } + +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } else { + mod no_align; + pub use self::no_align::*; + } +} diff --git a/src/unix/uclibc/mips/mips64/no_align.rs b/src/unix/uclibc/mips/mips64/no_align.rs new file mode 100644 index 0000000000000..ee57ea88643db --- /dev/null +++ b/src/unix/uclibc/mips/mips64/no_align.rs @@ -0,0 +1,8 @@ +s! { + // FIXME this is actually a union + pub struct sem_t { + __size: [::c_char; 32], + __align: [::c_long; 0], + } +} + diff --git a/src/unix/uclibc/mod.rs b/src/unix/uclibc/mod.rs index ad5d794a751e0..7545212e10d21 100644 --- a/src/unix/uclibc/mod.rs +++ b/src/unix/uclibc/mod.rs @@ -235,103 +235,11 @@ s! { pub ifa_data: *mut ::c_void } - #[cfg_attr(all(libc_align, - target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")), - repr(align(4)))] - #[cfg_attr(all(libc_align, - any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))), - repr(align(8)))] - pub struct pthread_mutex_t { - #[cfg(all(not(libc_align), - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - __align: [::c_long; 0], - #[cfg(not(any(libc_align, - target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], - } - - #[cfg_attr(all(libc_align, - target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")), - repr(align(4)))] - #[cfg_attr(all(libc_align, - any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))), - repr(align(8)))] - pub struct pthread_rwlock_t { - #[cfg(all(not(libc_align), - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - __align: [::c_long; 0], - #[cfg(not(any(libc_align, - target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], - } - - #[cfg_attr(all(libc_align, - any(target_pointer_width = "32", - target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64")), - repr(align(4)))] - #[cfg_attr(all(libc_align, - not(any(target_pointer_width = "32", - target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"))), - repr(align(8)))] - pub struct pthread_mutexattr_t { - #[cfg(all(not(libc_align), - any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64")))] - __align: [::c_int; 0], - #[cfg(all(not(libc_align), - not(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"))))] - __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], - } - pub struct pthread_rwlockattr_t { __lockkind: ::c_int, __pshared: ::c_int, } - #[cfg_attr(libc_align, repr(align(8)))] - pub struct pthread_cond_t { - #[cfg(not(libc_align))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_COND_T], - } - - #[cfg_attr(libc_align, repr(align(4)))] - pub struct pthread_condattr_t { - #[cfg(not(libc_align))] - __align: [::c_int; 0], - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], - } - pub struct passwd { pub pw_name: *mut ::c_char, pub pw_passwd: *mut ::c_char, @@ -1990,3 +1898,12 @@ cfg_if! { } } +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } else { + mod no_align; + pub use self::no_align::*; + } +} diff --git a/src/unix/uclibc/no_align.rs b/src/unix/uclibc/no_align.rs new file mode 100644 index 0000000000000..26cd64f02144f --- /dev/null +++ b/src/unix/uclibc/no_align.rs @@ -0,0 +1,49 @@ +s! { + pub struct pthread_mutex_t { + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_long; 0], + #[cfg(any(libc_align, + target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } + + pub struct pthread_rwlock_t { + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_long; 0], + #[cfg(not(any( + target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + } + + pub struct pthread_mutexattr_t { + #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64"))] + __align: [::c_int; 0], + #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64")))] + __align: [::c_long; 0], + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + } + + pub struct pthread_cond_t { + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_COND_T], + } + + pub struct pthread_condattr_t { + __align: [::c_int; 0], + size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + } +} diff --git a/src/unix/uclibc/x86_64/align.rs b/src/unix/uclibc/x86_64/align.rs new file mode 100644 index 0000000000000..155e7af20511a --- /dev/null +++ b/src/unix/uclibc/x86_64/align.rs @@ -0,0 +1,64 @@ +s! { + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct sem_t { // ToDo + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(all(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))), + repr(align(8)))] + pub struct pthread_mutex_t { // ToDo + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } + + #[cfg_attr(any(target_pointer_width = "32", + target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64"), + repr(align(4)))] + #[cfg_attr(not(any(target_pointer_width = "32", + target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64")), + repr(align(8)))] + pub struct pthread_mutexattr_t { // ToDo + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[repr(align(8))] + pub struct pthread_cond_t { // ToDo + size: [u8; __SIZEOF_PTHREAD_COND_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { // ToDo + size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + } + + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))), + repr(align(8)))] + pub struct pthread_rwlock_t { // ToDo + size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + } +} diff --git a/src/unix/uclibc/x86_64/mod.rs b/src/unix/uclibc/x86_64/mod.rs index 25de7e15d4389..abc35d14fce16 100644 --- a/src/unix/uclibc/x86_64/mod.rs +++ b/src/unix/uclibc/x86_64/mod.rs @@ -205,111 +205,6 @@ s! { pub c_cc: [::cc_t; ::NCCS], } - #[cfg_attr(all(libc_align, target_pointer_width = "32"), - repr(align(4)))] - #[cfg_attr(all(libc_align, target_pointer_width = "64"), - repr(align(8)))] - pub struct sem_t { // ToDo - #[cfg(target_pointer_width = "32")] - __size: [::c_char; 16], - #[cfg(target_pointer_width = "64")] - __size: [::c_char; 32], - #[cfg(not(libc_align))] - __align: [::c_long; 0], - } - - #[cfg_attr(all(libc_align, - target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")), - repr(align(4)))] - #[cfg_attr(all(libc_align, - any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))), - repr(align(8)))] - pub struct pthread_mutex_t { // ToDo - #[cfg(all(not(libc_align), - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - __align: [::c_long; 0], - #[cfg(not(any(libc_align, - target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], - } - - #[cfg_attr(all(libc_align, - any(target_pointer_width = "32", - target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64")), - repr(align(4)))] - #[cfg_attr(all(libc_align, - not(any(target_pointer_width = "32", - target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"))), - repr(align(8)))] - pub struct pthread_mutexattr_t { // ToDo - #[cfg(all(not(libc_align), - any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64")))] - __align: [::c_int; 0], - #[cfg(all(not(libc_align), - not(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"))))] - __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], - } - - #[cfg_attr(libc_align, repr(align(8)))] - pub struct pthread_cond_t { // ToDo - #[cfg(not(libc_align))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_COND_T], - } - - #[cfg_attr(libc_align, repr(align(4)))] - pub struct pthread_condattr_t { // ToDo - #[cfg(not(libc_align))] - __align: [::c_int; 0], - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], - } - - #[cfg_attr(all(libc_align, - target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")), - repr(align(4)))] - #[cfg_attr(all(libc_align, - any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))), - repr(align(8)))] - pub struct pthread_rwlock_t { // ToDo - #[cfg(all(not(libc_align), - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - __align: [::c_long; 0], - #[cfg(not(any(libc_align, - target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], - } - pub struct sigset_t { // ToDo __val: [::c_ulong; 16], } @@ -414,3 +309,12 @@ cfg_if! { } } +cfg_if! { + if #[cfg(libc_align)] { + mod align; + pub use self::align::*; + } else { + mod no_align; + pub use self::no_align::*; + } +} diff --git a/src/unix/uclibc/x86_64/no_align.rs b/src/unix/uclibc/x86_64/no_align.rs new file mode 100644 index 0000000000000..5cc765276b36c --- /dev/null +++ b/src/unix/uclibc/x86_64/no_align.rs @@ -0,0 +1,55 @@ +s! { + pub struct sem_t { // ToDo + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + __align: [::c_long; 0], + } + + pub struct pthread_mutex_t { // ToDo + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } + + pub struct pthread_mutexattr_t { // ToDo + #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64"))] + __align: [::c_int; 0], + #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64")))] + __align: [::c_long; 0], + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + } + + pub struct pthread_cond_t { // ToDo + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_COND_T], + } + + pub struct pthread_condattr_t { // ToDo + __align: [::c_int; 0], + size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + } + + pub struct pthread_rwlock_t { // ToDo + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + } +} From d86ed84cf18ef74092afaae9ada17351a23ead2e Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 00:02:59 +0100 Subject: [PATCH 47/72] Fix nightly build --- README.md | 2 +- src/fuchsia/align.rs | 12 ++--- src/fuchsia/no_align.rs | 12 ++--- src/redox/net.rs | 2 +- src/unix/notbsd/emscripten/align.rs | 23 +++++---- src/unix/notbsd/emscripten/mod.rs | 71 ++++++++++++++------------ src/unix/notbsd/emscripten/no_align.rs | 23 +++++---- src/unix/notbsd/linux/align.rs | 17 +++--- 8 files changed, 89 insertions(+), 73 deletions(-) diff --git a/README.md b/README.md index 6608e2a650be5..6f04391a2263c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Raw FFI bindings to platform libraries like `libc`. [![Documentation](https://docs.rs/libc/badge.svg)](https://docs.rs/libc) ![License](https://img.shields.io/crates/l/libc.svg** -**NOTE:** The minimum supported Rust version is **Rust 1.25.0** . APIs requiring +**NOTE:** The minimum supported Rust version is **Rust 1.13.0** . APIs requiring newer Rust features are only available on newer Rust versions: | Feature | Version | diff --git a/src/fuchsia/align.rs b/src/fuchsia/align.rs index ca45086b5c308..694e0a8ccf5fb 100644 --- a/src/fuchsia/align.rs +++ b/src/fuchsia/align.rs @@ -12,7 +12,7 @@ s! { )), repr(align(8)))] pub struct pthread_mutexattr_t { - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + pub size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], } #[cfg_attr(target_pointer_width = "32", @@ -20,12 +20,12 @@ s! { #[cfg_attr(target_pointer_width = "64", repr(align(8)))] pub struct pthread_rwlockattr_t { - size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], + pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], } #[repr(align(4))] pub struct pthread_condattr_t { - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + pub size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], } } @@ -40,7 +40,7 @@ s_no_extra_traits! { target_arch = "x86_64"))), repr(align(8)))] pub struct pthread_mutex_t { - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + pub size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], } #[allow(missing_debug_implementations)] @@ -53,7 +53,7 @@ s_no_extra_traits! { target_arch = "x86_64"))), repr(align(8)))] pub struct pthread_rwlock_t { - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], } #[allow(missing_debug_implementations)] @@ -66,6 +66,6 @@ s_no_extra_traits! { #[cfg_attr(not(target_arch = "x86"), repr(align(8)))] pub struct pthread_cond_t { - size: [u8; __SIZEOF_PTHREAD_COND_T], + pub size: [u8; ::__SIZEOF_PTHREAD_COND_T], } } diff --git a/src/fuchsia/no_align.rs b/src/fuchsia/no_align.rs index 9dd5c9bedee28..232aed8412adb 100644 --- a/src/fuchsia/no_align.rs +++ b/src/fuchsia/no_align.rs @@ -4,17 +4,17 @@ s! { __align: [::c_int; 0], #[cfg(not(target_arch = "x86_64"))] __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + pub size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], } pub struct pthread_rwlockattr_t { __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], + pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], } pub struct pthread_condattr_t { __align: [::c_int; 0], - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + pub size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], } } @@ -29,14 +29,14 @@ s_no_extra_traits! { all(target_arch = "x86_64", target_pointer_width = "32"))))] __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + pub size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], } #[allow(missing_debug_implementations)] pub struct pthread_rwlock_t { __align: [::c_long; 0], __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], } #[allow(missing_debug_implementations)] @@ -44,6 +44,6 @@ s_no_extra_traits! { __align: [*const ::c_void; 0], #[cfg(not(target_env = "musl"))] __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_COND_T], + pub size: [u8; ::__SIZEOF_PTHREAD_COND_T], } } diff --git a/src/redox/net.rs b/src/redox/net.rs index f769c83f2d98c..5d962b1649e0b 100644 --- a/src/redox/net.rs +++ b/src/redox/net.rs @@ -15,7 +15,7 @@ s! { } pub struct ipv6_mreq { - pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_multiaddr: ::in6_addr, pub ipv6mr_interface: ::c_uint, } diff --git a/src/unix/notbsd/emscripten/align.rs b/src/unix/notbsd/emscripten/align.rs index a2414dbd85f41..d7d65921f8c3f 100644 --- a/src/unix/notbsd/emscripten/align.rs +++ b/src/unix/notbsd/emscripten/align.rs @@ -1,34 +1,37 @@ s! { #[repr(align(4))] pub struct pthread_mutex_t { - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + pub size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], } #[repr(align(4))] pub struct pthread_rwlock_t { - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], } #[repr(align(4))] pub struct pthread_mutexattr_t { - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + pub size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], } #[repr(align(4))] pub struct pthread_rwlockattr_t { - size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], + pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], } + #[repr(align(4))] + pub struct pthread_condattr_t { + pub size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } +} + +s_no_extra_traits! { #[cfg_attr(target_pointer_width = "32", repr(align(4)))] #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[allow(missing_debug_implementations)] pub struct pthread_cond_t { - size: [u8; __SIZEOF_PTHREAD_COND_T], - } - - #[repr(align(4))] - pub struct pthread_condattr_t { - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + pub size: [u8; ::__SIZEOF_PTHREAD_COND_T], } } diff --git a/src/unix/notbsd/emscripten/mod.rs b/src/unix/notbsd/emscripten/mod.rs index 24c9d47716334..012c371a1cf03 100644 --- a/src/unix/notbsd/emscripten/mod.rs +++ b/src/unix/notbsd/emscripten/mod.rs @@ -43,22 +43,6 @@ impl ::dox::Clone for fpos64_t { } s! { - pub struct dirent { - pub d_ino: ::ino_t, - pub d_off: ::off_t, - pub d_reclen: ::c_ushort, - pub d_type: ::c_uchar, - pub d_name: [::c_char; 256], - } - - pub struct dirent64 { - pub d_ino: ::ino64_t, - pub d_off: ::off64_t, - pub d_reclen: ::c_ushort, - pub d_type: ::c_uchar, - pub d_name: [::c_char; 256], - } - pub struct rlimit64 { pub rlim_cur: rlim64_t, pub rlim_max: rlim64_t, @@ -251,23 +235,6 @@ s! { pub l_pid: ::pid_t, } - pub struct sysinfo { - pub uptime: ::c_ulong, - pub loads: [::c_ulong; 3], - pub totalram: ::c_ulong, - pub freeram: ::c_ulong, - pub sharedram: ::c_ulong, - pub bufferram: ::c_ulong, - pub totalswap: ::c_ulong, - pub freeswap: ::c_ulong, - pub procs: ::c_ushort, - pub pad: ::c_ushort, - pub totalhigh: ::c_ulong, - pub freehigh: ::c_ulong, - pub mem_unit: ::c_uint, - pub __reserved: [::c_char; 256], - } - pub struct pthread_attr_t { __size: [u32; 11] } @@ -442,6 +409,44 @@ s! { } } +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct dirent { + pub d_ino: ::ino_t, + pub d_off: ::off_t, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + #[allow(missing_debug_implementations)] + pub struct dirent64 { + pub d_ino: ::ino64_t, + pub d_off: ::off64_t, + pub d_reclen: ::c_ushort, + pub d_type: ::c_uchar, + pub d_name: [::c_char; 256], + } + + #[allow(missing_debug_implementations)] + pub struct sysinfo { + pub uptime: ::c_ulong, + pub loads: [::c_ulong; 3], + pub totalram: ::c_ulong, + pub freeram: ::c_ulong, + pub sharedram: ::c_ulong, + pub bufferram: ::c_ulong, + pub totalswap: ::c_ulong, + pub freeswap: ::c_ulong, + pub procs: ::c_ushort, + pub pad: ::c_ushort, + pub totalhigh: ::c_ulong, + pub freehigh: ::c_ulong, + pub mem_unit: ::c_uint, + pub __reserved: [::c_char; 256], + } +} + pub const ABDAY_1: ::nl_item = 0x20000; pub const ABDAY_2: ::nl_item = 0x20001; pub const ABDAY_3: ::nl_item = 0x20002; diff --git a/src/unix/notbsd/emscripten/no_align.rs b/src/unix/notbsd/emscripten/no_align.rs index 1ef0d2c4c4f04..022341f3c6004 100644 --- a/src/unix/notbsd/emscripten/no_align.rs +++ b/src/unix/notbsd/emscripten/no_align.rs @@ -1,31 +1,34 @@ s! { pub struct pthread_mutex_t { __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], } pub struct pthread_rwlock_t { __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], } pub struct pthread_mutexattr_t { __align: [::c_int; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], } pub struct pthread_rwlockattr_t { __align: [::c_int; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], - } - - pub struct pthread_cond_t { - __align: [*const ::c_void; 0], - size: [u8; __SIZEOF_PTHREAD_COND_T], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], } pub struct pthread_condattr_t { __align: [::c_int; 0], - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } +} + +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct pthread_cond_t { + __align: [*const ::c_void; 0], + size: [u8; ::__SIZEOF_PTHREAD_COND_T], } } diff --git a/src/unix/notbsd/linux/align.rs b/src/unix/notbsd/linux/align.rs index b3d3926114438..304e3b68e2f1f 100644 --- a/src/unix/notbsd/linux/align.rs +++ b/src/unix/notbsd/linux/align.rs @@ -12,7 +12,8 @@ s! { all(target_arch = "aarch64", target_env = "musl"))), repr(align(8)))] pub struct pthread_mutexattr_t { - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + #[doc(hidden)] + pub size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], } #[cfg_attr(any(target_env = "musl", target_pointer_width = "32"), @@ -21,12 +22,14 @@ s! { target_pointer_width = "64"), repr(align(8)))] pub struct pthread_rwlockattr_t { - size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], + #[doc(hidden)] + pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], } #[repr(align(4))] pub struct pthread_condattr_t { - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + #[doc(hidden)] + pub size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], } } @@ -44,7 +47,8 @@ s_no_extra_traits! { not(target_arch = "x86")), repr(align(8)))] pub struct pthread_cond_t { - size: [u8; __SIZEOF_PTHREAD_COND_T], + #[doc(hidden)] + pub size: [u8; ::__SIZEOF_PTHREAD_COND_T], } #[cfg_attr(all(target_pointer_width = "32", @@ -62,7 +66,8 @@ s_no_extra_traits! { target_arch = "x86"))), repr(align(8)))] pub struct pthread_mutex_t { - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + #[doc(hidden)] + pub size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], } #[cfg_attr(all(target_pointer_width = "32", @@ -80,6 +85,6 @@ s_no_extra_traits! { target_arch = "x86"))), repr(align(8)))] pub struct pthread_rwlock_t { - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], } } From e1e89ff24d1105dc78434fc911b7c583d16fe465 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 00:50:03 +0100 Subject: [PATCH 48/72] Use num::Float in s390x --- src/lib.rs | 2 ++ src/unix/notbsd/linux/s390x/mod.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index bb1005c7ae71a..aa5e87ceb169d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -187,6 +187,8 @@ cfg_if! { use core::fmt; #[allow(unused_imports)] use core::hash; + #[allow(unused_imports)] + use core::num; } } diff --git a/src/unix/notbsd/linux/s390x/mod.rs b/src/unix/notbsd/linux/s390x/mod.rs index 3368cffc2f49a..e2a0a3e1cdf20 100644 --- a/src/unix/notbsd/linux/s390x/mod.rs +++ b/src/unix/notbsd/linux/s390x/mod.rs @@ -345,6 +345,7 @@ cfg_if! { impl ::hash::Hash for fpreg_t { fn hash(&self, state: &mut H) { + use ::num::Float; self.d.to_bits().hash(state); } } From a23301b343bcba7d60026a83ab895de8560e4f6c Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 00:51:05 +0100 Subject: [PATCH 49/72] Fix align on Rust 1.24 --- src/unix/notbsd/linux/no_align.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/unix/notbsd/linux/no_align.rs b/src/unix/notbsd/linux/no_align.rs index 8e85396c94774..199348cbbbed2 100644 --- a/src/unix/notbsd/linux/no_align.rs +++ b/src/unix/notbsd/linux/no_align.rs @@ -10,7 +10,7 @@ s! { target_arch = "sparc64", all(target_arch = "aarch64", target_env = "musl"))))] __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + pub size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], } pub struct pthread_rwlockattr_t { @@ -18,12 +18,12 @@ s! { __align: [::c_int; 0], #[not(target_env = "musl")] __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], + pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], } pub struct pthread_condattr_t { __align: [::c_int; 0], - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + pub size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], } } @@ -33,7 +33,7 @@ s_no_extra_traits! { __align: [*const ::c_void; 0], #[cfg(not(target_env = "musl"))] __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_COND_T], + pub size: [u8; ::__SIZEOF_PTHREAD_COND_T], } pub struct pthread_mutex_t { @@ -49,7 +49,7 @@ s_no_extra_traits! { all(target_arch = "x86_64", target_pointer_width = "32"))))] __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + pub size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], } pub struct pthread_rwlock_t { @@ -65,6 +65,6 @@ s_no_extra_traits! { all(target_arch = "x86_64", target_pointer_width = "32"))))] __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], } } From d54b6380e1eb32f5300a9020ce1e27638c1f1694 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 00:51:32 +0100 Subject: [PATCH 50/72] Fix typo --- src/unix/notbsd/linux/no_align.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/notbsd/linux/no_align.rs b/src/unix/notbsd/linux/no_align.rs index 199348cbbbed2..e91ac6335c891 100644 --- a/src/unix/notbsd/linux/no_align.rs +++ b/src/unix/notbsd/linux/no_align.rs @@ -16,7 +16,7 @@ s! { pub struct pthread_rwlockattr_t { #[cfg(target_env = "musl")] __align: [::c_int; 0], - #[not(target_env = "musl")] + #[cfg(not(target_env = "musl"))] __align: [::c_long; 0], pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], } From 55749a05d5fe50b37cb74104b2cf356fc815c830 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 00:54:20 +0100 Subject: [PATCH 51/72] Fix typo --- src/unix/notbsd/linux/no_align.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/unix/notbsd/linux/no_align.rs b/src/unix/notbsd/linux/no_align.rs index e91ac6335c891..8676bcc338174 100644 --- a/src/unix/notbsd/linux/no_align.rs +++ b/src/unix/notbsd/linux/no_align.rs @@ -4,25 +4,25 @@ s! { target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64", all(target_arch = "aarch64", target_env = "musl")))] - __align: [::c_int; 0], + pub __align: [::c_int; 0], #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64", all(target_arch = "aarch64", target_env = "musl"))))] - __align: [::c_long; 0], + pub __align: [::c_long; 0], pub size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], } pub struct pthread_rwlockattr_t { #[cfg(target_env = "musl")] - __align: [::c_int; 0], + pub __align: [::c_int; 0], #[cfg(not(target_env = "musl"))] - __align: [::c_long; 0], + pub __align: [::c_long; 0], pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], } pub struct pthread_condattr_t { - __align: [::c_int; 0], + pub __align: [::c_int; 0], pub size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], } } @@ -30,9 +30,9 @@ s! { s_no_extra_traits! { pub struct pthread_cond_t { #[cfg(target_env = "musl")] - __align: [*const ::c_void; 0], + pub __align: [*const ::c_void; 0], #[cfg(not(target_env = "musl"))] - __align: [::c_longlong; 0], + pub __align: [::c_longlong; 0], pub size: [u8; ::__SIZEOF_PTHREAD_COND_T], } @@ -42,13 +42,13 @@ s_no_extra_traits! { target_arch = "powerpc", all(target_arch = "x86_64", target_pointer_width = "32")))] - __align: [::c_long; 0], + pub __align: [::c_long; 0], #[cfg(not(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc", all(target_arch = "x86_64", target_pointer_width = "32"))))] - __align: [::c_longlong; 0], + pub __align: [::c_longlong; 0], pub size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], } @@ -58,13 +58,13 @@ s_no_extra_traits! { target_arch = "powerpc", all(target_arch = "x86_64", target_pointer_width = "32")))] - __align: [::c_long; 0], + pub __align: [::c_long; 0], #[cfg(not(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc", all(target_arch = "x86_64", target_pointer_width = "32"))))] - __align: [::c_longlong; 0], + pub __align: [::c_longlong; 0], pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], } } From cfc4412f3d4e332704497f0a9ba1e151e651d5a3 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 00:59:59 +0100 Subject: [PATCH 52/72] Fix typo --- src/fuchsia/no_align.rs | 20 ++++++++++---------- src/unix/newlib/align.rs | 10 +++++----- src/unix/newlib/no_align.rs | 26 +++++++++++++------------- src/unix/notbsd/emscripten/no_align.rs | 24 ++++++++++++------------ src/unix/notbsd/linux/mips/align.rs | 6 ++---- src/unix/uclibc/align.rs | 10 +++++----- src/unix/uclibc/no_align.rs | 26 +++++++++++++------------- src/unix/uclibc/x86_64/no_align.rs | 26 +++++++++++++------------- 8 files changed, 73 insertions(+), 75 deletions(-) diff --git a/src/fuchsia/no_align.rs b/src/fuchsia/no_align.rs index 232aed8412adb..5fb6e064263b0 100644 --- a/src/fuchsia/no_align.rs +++ b/src/fuchsia/no_align.rs @@ -1,19 +1,19 @@ s! { pub struct pthread_mutexattr_t { #[cfg(target_arch = "x86_64")] - __align: [::c_int; 0], + pub __align: [::c_int; 0], #[cfg(not(target_arch = "x86_64"))] - __align: [::c_long; 0], + pub __align: [::c_long; 0], pub size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], } pub struct pthread_rwlockattr_t { - __align: [::c_long; 0], + pub __align: [::c_long; 0], pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], } pub struct pthread_condattr_t { - __align: [::c_int; 0], + pub __align: [::c_int; 0], pub size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], } } @@ -24,26 +24,26 @@ s_no_extra_traits! { #[cfg(any(target_arch = "arm", all(target_arch = "x86_64", target_pointer_width = "32")))] - __align: [::c_long; 0], + pub __align: [::c_long; 0], #[cfg(not(any(target_arch = "arm", all(target_arch = "x86_64", target_pointer_width = "32"))))] - __align: [::c_longlong; 0], + pub __align: [::c_longlong; 0], pub size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], } #[allow(missing_debug_implementations)] pub struct pthread_rwlock_t { - __align: [::c_long; 0], - __align: [::c_longlong; 0], + pub __align: [::c_long; 0], + pub __align: [::c_longlong; 0], pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], } #[allow(missing_debug_implementations)] pub struct pthread_cond_t { - __align: [*const ::c_void; 0], + pub __align: [*const ::c_void; 0], #[cfg(not(target_env = "musl"))] - __align: [::c_longlong; 0], + pub __align: [::c_longlong; 0], pub size: [u8; ::__SIZEOF_PTHREAD_COND_T], } } diff --git a/src/unix/newlib/align.rs b/src/unix/newlib/align.rs index d3e25495bb34a..8179e91c1d5e7 100644 --- a/src/unix/newlib/align.rs +++ b/src/unix/newlib/align.rs @@ -10,7 +10,7 @@ s! { target_arch = "powerpc"))), repr(align(8)))] pub struct pthread_mutex_t { // Unverified - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + pub size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } #[cfg_attr(all(target_pointer_width = "32", @@ -24,7 +24,7 @@ s! { target_arch = "powerpc"))), repr(align(8)))] pub struct pthread_rwlock_t { // Unverified - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + pub size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], } #[cfg_attr(any(target_pointer_width = "32", @@ -38,16 +38,16 @@ s! { target_arch = "sparc64")), repr(align(8)))] pub struct pthread_mutexattr_t { // Unverified - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + pub size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], } #[repr(align(8))] pub struct pthread_cond_t { // Unverified - size: [u8; __SIZEOF_PTHREAD_COND_T], + pub size: [u8; __SIZEOF_PTHREAD_COND_T], } #[repr(align(4))] pub struct pthread_condattr_t { // Unverified - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + pub size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], } } diff --git a/src/unix/newlib/no_align.rs b/src/unix/newlib/no_align.rs index 3ae096854e98d..8bd1fd0f96bfb 100644 --- a/src/unix/newlib/no_align.rs +++ b/src/unix/newlib/no_align.rs @@ -3,45 +3,45 @@ s! { #[cfg(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc"))] - __align: [::c_long; 0], + pub __align: [::c_long; 0], #[cfg(not(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + pub __align: [::c_longlong; 0], + pub size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } pub struct pthread_rwlock_t { // Unverified #[cfg(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc"))] - __align: [::c_long; 0], + pub __align: [::c_long; 0], #[cfg(not(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + pub __align: [::c_longlong; 0], + pub size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], } pub struct pthread_mutexattr_t { // Unverified #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64"))] - __align: [::c_int; 0], + pub __align: [::c_int; 0], #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64")))] - __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + pub __align: [::c_long; 0], + pub size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], } pub struct pthread_cond_t { // Unverified - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_COND_T], + pub __align: [::c_longlong; 0], + pub size: [u8; __SIZEOF_PTHREAD_COND_T], } pub struct pthread_condattr_t { // Unverified - __align: [::c_int; 0], - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + pub __align: [::c_int; 0], + pub size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], } } diff --git a/src/unix/notbsd/emscripten/no_align.rs b/src/unix/notbsd/emscripten/no_align.rs index 022341f3c6004..f3594132c7d4d 100644 --- a/src/unix/notbsd/emscripten/no_align.rs +++ b/src/unix/notbsd/emscripten/no_align.rs @@ -1,34 +1,34 @@ s! { pub struct pthread_mutex_t { - __align: [::c_long; 0], - size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + pub __align: [::c_long; 0], + pub size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], } pub struct pthread_rwlock_t { - __align: [::c_long; 0], - size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + pub __align: [::c_long; 0], + pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], } pub struct pthread_mutexattr_t { - __align: [::c_int; 0], - size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + pub __align: [::c_int; 0], + pub size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], } pub struct pthread_rwlockattr_t { - __align: [::c_int; 0], - size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], + pub __align: [::c_int; 0], + pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], } pub struct pthread_condattr_t { - __align: [::c_int; 0], - size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + pub __align: [::c_int; 0], + pub size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], } } s_no_extra_traits! { #[allow(missing_debug_implementations)] pub struct pthread_cond_t { - __align: [*const ::c_void; 0], - size: [u8; ::__SIZEOF_PTHREAD_COND_T], + pub __align: [*const ::c_void; 0], + pub size: [u8; ::__SIZEOF_PTHREAD_COND_T], } } diff --git a/src/unix/notbsd/linux/mips/align.rs b/src/unix/notbsd/linux/mips/align.rs index 8e5c1ddebd15a..4a0e07460ebb1 100644 --- a/src/unix/notbsd/linux/mips/align.rs +++ b/src/unix/notbsd/linux/mips/align.rs @@ -1,15 +1,13 @@ s! { // FIXME this is actually a union - #[cfg_attr(all(libc_align, target_pointer_width = "32"), + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] - #[cfg_attr(all(libc_align, target_pointer_width = "64"), + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] pub struct sem_t { #[cfg(target_pointer_width = "32")] __size: [::c_char; 16], #[cfg(target_pointer_width = "64")] __size: [::c_char; 32], - #[cfg(not(libc_align))] - __align: [::c_long; 0], } } diff --git a/src/unix/uclibc/align.rs b/src/unix/uclibc/align.rs index 889069f072cde..c461ff29df084 100644 --- a/src/unix/uclibc/align.rs +++ b/src/unix/uclibc/align.rs @@ -10,7 +10,7 @@ s! { target_arch = "powerpc"))), repr(align(8)))] pub struct pthread_mutex_t { - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + pub size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } #[cfg_attr(all(target_pointer_width = "32", @@ -24,7 +24,7 @@ s! { target_arch = "powerpc"))), repr(align(8)))] pub struct pthread_rwlock_t { - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + pub size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], } #[cfg_attr(any(target_pointer_width = "32", @@ -38,16 +38,16 @@ s! { target_arch = "sparc64")), repr(align(8)))] pub struct pthread_mutexattr_t { - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + pub size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], } #[repr(align(8))] pub struct pthread_cond_t { - size: [u8; __SIZEOF_PTHREAD_COND_T], + pub size: [u8; __SIZEOF_PTHREAD_COND_T], } #[repr(align(4))] pub struct pthread_condattr_t { - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + pub size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], } } diff --git a/src/unix/uclibc/no_align.rs b/src/unix/uclibc/no_align.rs index 26cd64f02144f..14ed97c722261 100644 --- a/src/unix/uclibc/no_align.rs +++ b/src/unix/uclibc/no_align.rs @@ -3,47 +3,47 @@ s! { #[cfg(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc"))] - __align: [::c_long; 0], + pub __align: [::c_long; 0], #[cfg(any(libc_align, target_arch = "mips", target_arch = "arm", target_arch = "powerpc"))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + pub __align: [::c_longlong; 0], + pub size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } pub struct pthread_rwlock_t { #[cfg(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc"))] - __align: [::c_long; 0], + pub __align: [::c_long; 0], #[cfg(not(any( target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + pub __align: [::c_longlong; 0], + pub size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], } pub struct pthread_mutexattr_t { #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64"))] - __align: [::c_int; 0], + pub __align: [::c_int; 0], #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64")))] - __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + pub __align: [::c_long; 0], + pub size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], } pub struct pthread_cond_t { - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_COND_T], + pub __align: [::c_longlong; 0], + pub size: [u8; __SIZEOF_PTHREAD_COND_T], } pub struct pthread_condattr_t { - __align: [::c_int; 0], - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + pub __align: [::c_int; 0], + pub size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], } } diff --git a/src/unix/uclibc/x86_64/no_align.rs b/src/unix/uclibc/x86_64/no_align.rs index 5cc765276b36c..1fee8340df155 100644 --- a/src/unix/uclibc/x86_64/no_align.rs +++ b/src/unix/uclibc/x86_64/no_align.rs @@ -11,45 +11,45 @@ s! { #[cfg(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc"))] - __align: [::c_long; 0], + pub __align: [::c_long; 0], #[cfg(not(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + pub __align: [::c_longlong; 0], + pub size: [u8; __SIZEOF_PTHREAD_MUTEX_T], } pub struct pthread_mutexattr_t { // ToDo #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64"))] - __align: [::c_int; 0], + pub __align: [::c_int; 0], #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64")))] - __align: [::c_long; 0], - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + pub __align: [::c_long; 0], + pub size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], } pub struct pthread_cond_t { // ToDo - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_COND_T], + pub __align: [::c_longlong; 0], + pub size: [u8; __SIZEOF_PTHREAD_COND_T], } pub struct pthread_condattr_t { // ToDo - __align: [::c_int; 0], - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + pub __align: [::c_int; 0], + pub size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], } pub struct pthread_rwlock_t { // ToDo #[cfg(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc"))] - __align: [::c_long; 0], + pub __align: [::c_long; 0], #[cfg(not(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")))] - __align: [::c_longlong; 0], - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + pub __align: [::c_longlong; 0], + pub size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], } } From 4e92848be5ee6391bd632d8f8400be7f6a8e1bca Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 01:02:59 +0100 Subject: [PATCH 53/72] extra traits should not enable align --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d20fc69ba86df..d72aa8c97dfcd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ default = ["use_std"] use_std = [] align = [] rustc-dep-of-std = ['align', 'rustc-std-workspace-core'] -extra_traits = ["align"] +extra_traits = [] [workspace] members = ["libc-test"] From bb00074da6dbd3e4a9795854ad9a1370ea52ed0c Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 01:12:00 +0100 Subject: [PATCH 54/72] Transmute to integer instead of using f64::to_bits --- src/lib.rs | 2 ++ src/unix/notbsd/linux/s390x/mod.rs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index aa5e87ceb169d..0b613eedaaa46 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -189,6 +189,8 @@ cfg_if! { use core::hash; #[allow(unused_imports)] use core::num; + #[allow(unused_imports)] + use core::mem; } } diff --git a/src/unix/notbsd/linux/s390x/mod.rs b/src/unix/notbsd/linux/s390x/mod.rs index e2a0a3e1cdf20..d4bc9bd2f4a10 100644 --- a/src/unix/notbsd/linux/s390x/mod.rs +++ b/src/unix/notbsd/linux/s390x/mod.rs @@ -345,8 +345,8 @@ cfg_if! { impl ::hash::Hash for fpreg_t { fn hash(&self, state: &mut H) { - use ::num::Float; - self.d.to_bits().hash(state); + let d: u64 = unsafe { ::mem::transmute(self.d) }; + d.hash(state); } } } From a956165e31c02efe0e3bf72f3ec7e60c61ec7264 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 01:17:38 +0100 Subject: [PATCH 55/72] Style --- src/unix/mod.rs | 1 - src/unix/notbsd/linux/mips/mod.rs | 1 - src/unix/notbsd/linux/mod.rs | 1 - 3 files changed, 3 deletions(-) diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 7292ba68740d9..24779c9b3a5d4 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -1171,7 +1171,6 @@ cfg_if! { } } - cfg_if! { if #[cfg(libc_align)] { mod align; diff --git a/src/unix/notbsd/linux/mips/mod.rs b/src/unix/notbsd/linux/mips/mod.rs index 0c76fbb716704..5d4dec79bf5e7 100644 --- a/src/unix/notbsd/linux/mips/mod.rs +++ b/src/unix/notbsd/linux/mips/mod.rs @@ -949,7 +949,6 @@ cfg_if! { } } - cfg_if! { if #[cfg(libc_align)] { mod align; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index c0a192aace216..0a368bf396cf7 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -2358,7 +2358,6 @@ cfg_if! { } } - cfg_if! { if #[cfg(libc_align)] { mod align; From a4898c6cf82bb45e36f87668999b22090e72a83e Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 01:23:08 +0100 Subject: [PATCH 56/72] Fix uses of const size_of in freebsd --- src/unix/bsd/freebsdlike/freebsd/aarch64.rs | 12 ++++++++++-- src/unix/bsd/freebsdlike/freebsd/arm.rs | 11 +++++++++-- src/unix/bsd/freebsdlike/freebsd/powerpc64.rs | 12 ++++++++++-- src/unix/bsd/freebsdlike/freebsd/x86.rs | 11 +++++++++-- src/unix/bsd/freebsdlike/freebsd/x86_64.rs | 11 +++++++++-- 5 files changed, 47 insertions(+), 10 deletions(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs index a780b08745f72..dac614fd0a1ce 100644 --- a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -33,6 +33,14 @@ s! { } // should be pub(crate), but that requires Rust 1.18.0 -#[doc(hidden)] -pub const _ALIGNBYTES: usize = mem::size_of::<::c_longlong>() - 1; +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = mem::size_of::<::c_longlong>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + pub const MAP_32BIT: ::c_int = 0x00080000; diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs index bc4da64d0e88d..99a761eeef528 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -35,6 +35,13 @@ s! { } // should be pub(crate), but that requires Rust 1.18.0 -#[doc(hidden)] -pub const _ALIGNBYTES: usize = mem::size_of::<::c_int>() - 1; +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = mem::size_of::<::c_int>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 4 - 1; + } +} pub const MAP_32BIT: ::c_int = 0x00080000; diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index c06e1aec820b5..517f2960240b8 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -31,6 +31,14 @@ s! { } // should be pub(crate), but that requires Rust 1.18.0 -#[doc(hidden)] -pub const _ALIGNBYTES: usize = mem::size_of::<::c_long>() - 1; +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + pub const MAP_32BIT: ::c_int = 0x00080000; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index 2eaeec7660b88..b31e335361854 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -34,5 +34,12 @@ s! { } // should be pub(crate), but that requires Rust 1.18.0 -#[doc(hidden)] -pub const _ALIGNBYTES: usize = mem::size_of::<::c_long>() - 1; +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64.rs index e9dcf784e4680..89819fde3c8aa 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64.rs @@ -33,6 +33,13 @@ s! { } // should be pub(crate), but that requires Rust 1.18.0 -#[doc(hidden)] -pub const _ALIGNBYTES: usize = mem::size_of::<::c_long>() - 1; +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} pub const MAP_32BIT: ::c_int = 0x00080000; From 0f7b6a8349062a765330435e3b58db148ae3ecc4 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 01:49:29 +0100 Subject: [PATCH 57/72] Workaround private root module use in Rust 1.13 --- build.rs | 5 +++++ src/lib.rs | 39 ++++++++++++++++++++++++++++----------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/build.rs b/build.rs index e4114eade1f08..9b13376779f65 100644 --- a/build.rs +++ b/build.rs @@ -9,6 +9,11 @@ fn main() { std::env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); let align_cargo_feature = std::env::var("CARGO_FEATURE_ALIGN").is_ok(); + // Rust >= 1.15 supports private module use: + if rustc_minor_ver >= 15 || rustc_dep_of_std { + println!("cargo:rustc-cfg=libc_priv_mod_use"); + } + // Rust >= 1.19 supports unions: if rustc_minor_ver >= 19 || rustc_dep_of_std { println!("cargo:rustc-cfg=libc_union"); diff --git a/src/lib.rs b/src/lib.rs index 0b613eedaaa46..95baffa3507df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -180,17 +180,34 @@ cfg_if! { cfg_if! { if #[cfg(not(cross_platform_docs))] { - #[cfg(libc_core_cvoid)] - #[allow(unused_imports)] - use core::ffi; - #[allow(unused_imports)] - use core::fmt; - #[allow(unused_imports)] - use core::hash; - #[allow(unused_imports)] - use core::num; - #[allow(unused_imports)] - use core::mem; + cfg_if! { + if #[cfg(libc_priv_mod_use)] { + #[cfg(libc_core_cvoid)] + #[allow(unused_imports)] + use core::ffi; + #[allow(unused_imports)] + use core::fmt; + #[allow(unused_imports)] + use core::hash; + #[allow(unused_imports)] + use core::num; + #[allow(unused_imports)] + use core::mem; + } else { + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::fmt; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::hash; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::num; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::mem; + } + } } } From 2ba155d7e1c057c330b23fd1cd58ee27d6cd8bc4 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 02:01:19 +0100 Subject: [PATCH 58/72] Fix attributes on struct patterns --- ci/build.sh | 8 ++++- src/unix/bsd/netbsdlike/netbsd/mod.rs | 42 +++++++++++++++++---------- 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 1782cfe70c800..2d72c55d33602 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -58,7 +58,13 @@ test_target() { TARGETS="wasm32-unknown-unknown" case "${OS}" in linux*) - TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i586-unknown-linux-musl i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf armv7-unknown-linux-musleabihf x86_64-sun-solaris aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu sparc64-unknown-linux-gnu sparcv9-sun-solaris x86_64-unknown-linux-musl x86_64-linux-android wasm32-unknown-emscripten" + TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf armv7-unknown-linux-musleabihf x86_64-sun-solaris aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu sparc64-unknown-linux-gnu sparcv9-sun-solaris x86_64-unknown-linux-musl x86_64-linux-android wasm32-unknown-emscripten" + + if [ "${RUST}" != "+1.13.0" ] && \ + [ "${RUST}" != "+1.19.0" ] && \ + [ "${RUST}" != "+1.24.0" ]; then + TARGETS="${TARGETS} i586-unknown-linux-musl" + fi if [ "${RUST}" = "nightly" ]; then # aarch64-unknown-cloudabi armv7-unknown-cloudabi-eabihf diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 9c611d8d8d5b2..923523c730157 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -736,21 +736,33 @@ pub const FD_SETSIZE: usize = 0x100; pub const ST_NOSUID: ::c_ulong = 8; -pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - ptm_magic: 0x33330003, - ptm_errorcheck: 0, - #[cfg(any(target_arch = "sparc", target_arch = "sparc64", - target_arch = "x86", target_arch = "x86_64"))] - ptm_pad1: [0; 3], - ptm_unused: 0, - #[cfg(any(target_arch = "sparc", target_arch = "sparc64", - target_arch = "x86", target_arch = "x86_64"))] - ptm_pad2: [0; 3], - ptm_waiters: 0 as *mut _, - ptm_owner: 0, - ptm_recursed: 0, - ptm_spare2: 0 as *mut _, -}; + +cfg_if! { + if #[cfg(any(target_arch = "sparc", target_arch = "sparc64", + target_arch = "x86", target_arch = "x86_64"))] { + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + ptm_magic: 0x33330003, + ptm_errorcheck: 0, + ptm_pad1: [0; 3], + ptm_unused: 0, + ptm_pad2: [0; 3], + ptm_waiters: 0 as *mut _, + ptm_owner: 0, + ptm_recursed: 0, + ptm_spare2: 0 as *mut _, + }; + } else { + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + ptm_magic: 0x33330003, + ptm_errorcheck: 0, + ptm_unused: 0, + ptm_waiters: 0 as *mut _, + ptm_owner: 0, + ptm_recursed: 0, + ptm_spare2: 0 as *mut _, + }; + } +} pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { ptc_magic: 0x55550005, From 3b8681784b49ab60a0227b77836d30641486ae94 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 02:09:56 +0100 Subject: [PATCH 59/72] Fix all uses of const size_of --- src/unix/bsd/netbsdlike/netbsd/aarch64.rs | 11 +++++++++-- src/unix/bsd/netbsdlike/netbsd/arm.rs | 11 +++++++++-- src/unix/bsd/netbsdlike/netbsd/powerpc.rs | 11 +++++++++-- src/unix/bsd/netbsdlike/netbsd/x86.rs | 11 +++++++++-- src/unix/bsd/netbsdlike/netbsd/x86_64.rs | 11 +++++++++-- .../bsd/netbsdlike/openbsdlike/openbsd/aarch64.rs | 11 +++++++++-- src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86.rs | 11 +++++++++-- src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs | 11 +++++++++-- 8 files changed, 72 insertions(+), 16 deletions(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs index cda75bc5cdd86..e30d731bbf3ca 100644 --- a/src/unix/bsd/netbsdlike/netbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/aarch64.rs @@ -8,8 +8,15 @@ pub type c_char = u8; pub type __cpu_simple_lock_nv_t = ::c_uchar; // should be pub(crate), but that requires Rust 1.18.0 -#[doc(hidden)] -pub const _ALIGNBYTES: usize = mem::size_of::<::c_int>() - 1; +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = mem::size_of::<::c_int>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 4 - 1; + } +} pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 0; pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 1; diff --git a/src/unix/bsd/netbsdlike/netbsd/arm.rs b/src/unix/bsd/netbsdlike/netbsd/arm.rs index 71c2cb7b7909a..cfcc139647291 100644 --- a/src/unix/bsd/netbsdlike/netbsd/arm.rs +++ b/src/unix/bsd/netbsdlike/netbsd/arm.rs @@ -8,8 +8,15 @@ pub type c_char = u8; pub type __cpu_simple_lock_nv_t = ::c_int; // should be pub(crate), but that requires Rust 1.18.0 -#[doc(hidden)] -pub const _ALIGNBYTES: usize = mem::size_of::<::c_longlong>() - 1; +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = mem::size_of::<::c_longlong>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; diff --git a/src/unix/bsd/netbsdlike/netbsd/powerpc.rs b/src/unix/bsd/netbsdlike/netbsd/powerpc.rs index 3c682c35cf4b4..10cdc73c8142a 100644 --- a/src/unix/bsd/netbsdlike/netbsd/powerpc.rs +++ b/src/unix/bsd/netbsdlike/netbsd/powerpc.rs @@ -8,8 +8,15 @@ pub type c_char = u8; pub type __cpu_simple_lock_nv_t = ::c_int; // should be pub(crate), but that requires Rust 1.18.0 -#[doc(hidden)] -pub const _ALIGNBYTES: usize = mem::size_of::<::c_double>() - 1; +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = mem::size_of::<::c_double>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0; pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; diff --git a/src/unix/bsd/netbsdlike/netbsd/x86.rs b/src/unix/bsd/netbsdlike/netbsd/x86.rs index 4da99685f93da..895e7f8908dd6 100644 --- a/src/unix/bsd/netbsdlike/netbsd/x86.rs +++ b/src/unix/bsd/netbsdlike/netbsd/x86.rs @@ -6,5 +6,12 @@ pub type c_char = i8; pub type __cpu_simple_lock_nv_t = ::c_uchar; // should be pub(crate), but that requires Rust 1.18.0 -#[doc(hidden)] -pub const _ALIGNBYTES: usize = mem::size_of::<::c_int>() - 1; +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = mem::size_of::<::c_int>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 4 - 1; + } +} diff --git a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs index af1b8f8000e8d..e71a82c99bb57 100644 --- a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs @@ -8,8 +8,15 @@ pub type c_char = i8; pub type __cpu_simple_lock_nv_t = ::c_uchar; // should be pub(crate), but that requires Rust 1.18.0 -#[doc(hidden)] -pub const _ALIGNBYTES: usize = mem::size_of::<::c_long>() - 1; +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0; pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; diff --git a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/aarch64.rs b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/aarch64.rs index 2a28c2a88a27b..268e5af4f8d11 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/aarch64.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/aarch64.rs @@ -5,5 +5,12 @@ pub type c_ulong = u64; pub type c_char = u8; // should be pub(crate), but that requires Rust 1.18.0 -#[doc(hidden)] -pub const _ALIGNBYTES: usize = mem::size_of::<::c_long>() - 1; +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} diff --git a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86.rs b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86.rs index b63b69fb63fc8..959c87b42792f 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86.rs @@ -5,5 +5,12 @@ pub type c_ulong = u32; pub type c_char = i8; // should be pub(crate), but that requires Rust 1.18.0 -#[doc(hidden)] -pub const _ALIGNBYTES: usize = mem::size_of::<::c_int>() - 1; +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = mem::size_of::<::c_int>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 4 - 1; + } +} diff --git a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs index 581096fdfa452..b2025a8a9c06b 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs @@ -7,8 +7,15 @@ pub type c_ulong = u64; pub type c_char = i8; // should be pub(crate), but that requires Rust 1.18.0 -#[doc(hidden)] -pub const _ALIGNBYTES: usize = mem::size_of::<::c_long>() - 1; +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0; pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; From 60050ea607793170ebd10a8889f491d272dc55ce Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 02:40:42 +0100 Subject: [PATCH 60/72] Expand align types using a macro --- src/fuchsia/align.rs | 132 ++++++++++--------- src/fuchsia/mod.rs | 5 +- src/fuchsia/no_align.rs | 88 +++++++------ src/unix/bsd/netbsdlike/netbsd/mod.rs | 1 - src/unix/newlib/align.rs | 102 +++++++------- src/unix/newlib/mod.rs | 5 +- src/unix/newlib/no_align.rs | 86 ++++++------ src/unix/notbsd/emscripten/align.rs | 64 ++++----- src/unix/notbsd/emscripten/mod.rs | 6 +- src/unix/notbsd/emscripten/no_align.rs | 58 ++++---- src/unix/notbsd/linux/align.rs | 176 +++++++++++++------------ src/unix/notbsd/linux/mod.rs | 5 +- src/unix/notbsd/linux/no_align.rs | 136 ++++++++++--------- src/unix/uclibc/align.rs | 102 +++++++------- src/unix/uclibc/mod.rs | 6 +- src/unix/uclibc/no_align.rs | 90 +++++++------ src/unix/uclibc/x86_64/align.rs | 120 +++++++++-------- src/unix/uclibc/x86_64/mod.rs | 5 +- src/unix/uclibc/x86_64/no_align.rs | 100 +++++++------- 19 files changed, 682 insertions(+), 605 deletions(-) diff --git a/src/fuchsia/align.rs b/src/fuchsia/align.rs index 694e0a8ccf5fb..8d4040d003df2 100644 --- a/src/fuchsia/align.rs +++ b/src/fuchsia/align.rs @@ -1,71 +1,75 @@ -s! { - #[cfg_attr( - any( - target_pointer_width = "32", - target_arch = "x86_64" - ), - repr(align(4)))] - #[cfg_attr( - not(any( - target_pointer_width = "32", - target_arch = "x86_64" - )), - repr(align(8)))] - pub struct pthread_mutexattr_t { - pub size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], - } +macro_rules! expand_align { + () => { + s! { + #[cfg_attr( + any( + target_pointer_width = "32", + target_arch = "x86_64" + ), + repr(align(4)))] + #[cfg_attr( + not(any( + target_pointer_width = "32", + target_arch = "x86_64" + )), + repr(align(8)))] + pub struct pthread_mutexattr_t { + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } - #[cfg_attr(target_pointer_width = "32", - repr(align(4)))] - #[cfg_attr(target_pointer_width = "64", - repr(align(8)))] - pub struct pthread_rwlockattr_t { - pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], - } + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct pthread_rwlockattr_t { + size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], + } - #[repr(align(4))] - pub struct pthread_condattr_t { - pub size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], - } -} + #[repr(align(4))] + pub struct pthread_condattr_t { + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - #[cfg_attr(all(target_pointer_width = "32", - any(target_arch = "arm", - target_arch = "x86_64")), - repr(align(4)))] - #[cfg_attr(any(target_pointer_width = "64", - not(any(target_arch = "arm", - target_arch = "x86_64"))), - repr(align(8)))] - pub struct pthread_mutex_t { - pub size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], - } + s_no_extra_traits! { + #[allow(missing_debug_implementations)] + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "arm", + target_arch = "x86_64")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "arm", + target_arch = "x86_64"))), + repr(align(8)))] + pub struct pthread_mutex_t { + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } - #[allow(missing_debug_implementations)] - #[cfg_attr(all(target_pointer_width = "32", - any(target_arch = "arm", - target_arch = "x86_64")), - repr(align(4)))] - #[cfg_attr(any(target_pointer_width = "64", - not(any(target_arch = "arm", - target_arch = "x86_64"))), - repr(align(8)))] - pub struct pthread_rwlock_t { - pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], - } + #[allow(missing_debug_implementations)] + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "arm", + target_arch = "x86_64")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "arm", + target_arch = "x86_64"))), + repr(align(8)))] + pub struct pthread_rwlock_t { + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } - #[allow(missing_debug_implementations)] - #[cfg_attr(target_pointer_width = "32", - repr(align(4)))] - #[cfg_attr(target_pointer_width = "64", - repr(align(8)))] - #[cfg_attr(target_arch = "x86", - repr(align(4)))] - #[cfg_attr(not(target_arch = "x86"), - repr(align(8)))] - pub struct pthread_cond_t { - pub size: [u8; ::__SIZEOF_PTHREAD_COND_T], + #[allow(missing_debug_implementations)] + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + #[cfg_attr(target_arch = "x86", + repr(align(4)))] + #[cfg_attr(not(target_arch = "x86"), + repr(align(8)))] + pub struct pthread_cond_t { + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + } } } diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index f19bf513923eb..6f45cc19176ef 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -4010,13 +4010,14 @@ cfg_if! { cfg_if! { if #[cfg(libc_align)] { + #[macro_use] mod align; - pub use self::align::*; } else { + #[macro_use] mod no_align; - pub use self::no_align::*; } } +expand_align!(); cfg_if! { if #[cfg(libc_core_cvoid)] { diff --git a/src/fuchsia/no_align.rs b/src/fuchsia/no_align.rs index 5fb6e064263b0..1b8db5354eb8b 100644 --- a/src/fuchsia/no_align.rs +++ b/src/fuchsia/no_align.rs @@ -1,49 +1,53 @@ -s! { - pub struct pthread_mutexattr_t { - #[cfg(target_arch = "x86_64")] - pub __align: [::c_int; 0], - #[cfg(not(target_arch = "x86_64"))] - pub __align: [::c_long; 0], - pub size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], - } +macro_rules! expand_align { + () => { + s! { + pub struct pthread_mutexattr_t { + #[cfg(target_arch = "x86_64")] + __align: [::c_int; 0], + #[cfg(not(target_arch = "x86_64"))] + __align: [::c_long; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } - pub struct pthread_rwlockattr_t { - pub __align: [::c_long; 0], - pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], - } + pub struct pthread_rwlockattr_t { + __align: [::c_long; 0], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], + } - pub struct pthread_condattr_t { - pub __align: [::c_int; 0], - pub size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], - } -} + pub struct pthread_condattr_t { + __align: [::c_int; 0], + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - pub struct pthread_mutex_t { - #[cfg(any(target_arch = "arm", - all(target_arch = "x86_64", - target_pointer_width = "32")))] - pub __align: [::c_long; 0], - #[cfg(not(any(target_arch = "arm", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - pub __align: [::c_longlong; 0], - pub size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], - } + s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct pthread_mutex_t { + #[cfg(any(target_arch = "arm", + all(target_arch = "x86_64", + target_pointer_width = "32")))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "arm", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } - #[allow(missing_debug_implementations)] - pub struct pthread_rwlock_t { - pub __align: [::c_long; 0], - pub __align: [::c_longlong; 0], - pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], - } + #[allow(missing_debug_implementations)] + pub struct pthread_rwlock_t { + __align: [::c_long; 0], + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } - #[allow(missing_debug_implementations)] - pub struct pthread_cond_t { - pub __align: [*const ::c_void; 0], - #[cfg(not(target_env = "musl"))] - pub __align: [::c_longlong; 0], - pub size: [u8; ::__SIZEOF_PTHREAD_COND_T], + #[allow(missing_debug_implementations)] + pub struct pthread_cond_t { + __align: [*const ::c_void; 0], + #[cfg(not(target_env = "musl"))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + } } } diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 923523c730157..36a5366e6824c 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -736,7 +736,6 @@ pub const FD_SETSIZE: usize = 0x100; pub const ST_NOSUID: ::c_ulong = 8; - cfg_if! { if #[cfg(any(target_arch = "sparc", target_arch = "sparc64", target_arch = "x86", target_arch = "x86_64"))] { diff --git a/src/unix/newlib/align.rs b/src/unix/newlib/align.rs index 8179e91c1d5e7..c018fbcbb09d0 100644 --- a/src/unix/newlib/align.rs +++ b/src/unix/newlib/align.rs @@ -1,53 +1,61 @@ -s! { - #[cfg_attr(all(target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")), - repr(align(4)))] - #[cfg_attr(any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))), - repr(align(8)))] - pub struct pthread_mutex_t { // Unverified - pub size: [u8; __SIZEOF_PTHREAD_MUTEX_T], - } +macro_rules! expand_align { + () => { + s! { + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))), + repr(align(8)))] + pub struct pthread_mutex_t { // Unverified + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } - #[cfg_attr(all(target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")), - repr(align(4)))] - #[cfg_attr(any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))), - repr(align(8)))] - pub struct pthread_rwlock_t { // Unverified - pub size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], - } + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))), + repr(align(8)))] + pub struct pthread_rwlock_t { // Unverified + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } - #[cfg_attr(any(target_pointer_width = "32", - target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"), - repr(align(4)))] - #[cfg_attr(not(any(target_pointer_width = "32", - target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64")), - repr(align(8)))] - pub struct pthread_mutexattr_t { // Unverified - pub size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], - } + #[cfg_attr(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64"), + repr(align(4)))] + #[cfg_attr(not(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64")), + repr(align(8)))] + pub struct pthread_mutexattr_t { // Unverified + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } - #[repr(align(8))] - pub struct pthread_cond_t { // Unverified - pub size: [u8; __SIZEOF_PTHREAD_COND_T], - } + #[repr(align(8))] + pub struct pthread_cond_t { // Unverified + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } - #[repr(align(4))] - pub struct pthread_condattr_t { // Unverified - pub size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + #[repr(align(4))] + pub struct pthread_condattr_t { // Unverified + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } } } diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index fc5158775a835..94bce1e12f467 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -663,10 +663,11 @@ cfg_if! { cfg_if! { if #[cfg(libc_align)] { + #[macro_use] mod align; - pub use self::align::*; } else { + #[macro_use] mod no_align; - pub use self::no_align::*; } } +expand_align!(); diff --git a/src/unix/newlib/no_align.rs b/src/unix/newlib/no_align.rs index 8bd1fd0f96bfb..316c464ed59a8 100644 --- a/src/unix/newlib/no_align.rs +++ b/src/unix/newlib/no_align.rs @@ -1,47 +1,51 @@ -s! { - pub struct pthread_mutex_t { // Unverified - #[cfg(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))] - pub __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - pub __align: [::c_longlong; 0], - pub size: [u8; __SIZEOF_PTHREAD_MUTEX_T], - } +macro_rules! expand_align { + () => { + s! { + pub struct pthread_mutex_t { // Unverified + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } - pub struct pthread_rwlock_t { // Unverified - #[cfg(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))] - pub __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - pub __align: [::c_longlong; 0], - pub size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], - } + pub struct pthread_rwlock_t { // Unverified + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } - pub struct pthread_mutexattr_t { // Unverified - #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"))] - pub __align: [::c_int; 0], - #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64")))] - pub __align: [::c_long; 0], - pub size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], - } + pub struct pthread_mutexattr_t { // Unverified + #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64"))] + __align: [::c_int; 0], + #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64")))] + __align: [::c_long; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } - pub struct pthread_cond_t { // Unverified - pub __align: [::c_longlong; 0], - pub size: [u8; __SIZEOF_PTHREAD_COND_T], - } + pub struct pthread_cond_t { // Unverified + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } - pub struct pthread_condattr_t { // Unverified - pub __align: [::c_int; 0], - pub size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + pub struct pthread_condattr_t { // Unverified + __align: [::c_int; 0], + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } } } diff --git a/src/unix/notbsd/emscripten/align.rs b/src/unix/notbsd/emscripten/align.rs index d7d65921f8c3f..3f36d45d6d71f 100644 --- a/src/unix/notbsd/emscripten/align.rs +++ b/src/unix/notbsd/emscripten/align.rs @@ -1,37 +1,41 @@ -s! { - #[repr(align(4))] - pub struct pthread_mutex_t { - pub size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], - } +macro_rules! expand_align { + () => { + s! { + #[repr(align(4))] + pub struct pthread_mutex_t { + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } - #[repr(align(4))] - pub struct pthread_rwlock_t { - pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], - } + #[repr(align(4))] + pub struct pthread_rwlock_t { + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } - #[repr(align(4))] - pub struct pthread_mutexattr_t { - pub size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], - } + #[repr(align(4))] + pub struct pthread_mutexattr_t { + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } - #[repr(align(4))] - pub struct pthread_rwlockattr_t { - pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], - } + #[repr(align(4))] + pub struct pthread_rwlockattr_t { + size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], + } - #[repr(align(4))] - pub struct pthread_condattr_t { - pub size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], - } -} + #[repr(align(4))] + pub struct pthread_condattr_t { + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } -s_no_extra_traits! { - #[cfg_attr(target_pointer_width = "32", - repr(align(4)))] - #[cfg_attr(target_pointer_width = "64", - repr(align(8)))] - #[allow(missing_debug_implementations)] - pub struct pthread_cond_t { - pub size: [u8; ::__SIZEOF_PTHREAD_COND_T], + s_no_extra_traits! { + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + #[allow(missing_debug_implementations)] + pub struct pthread_cond_t { + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + } } } diff --git a/src/unix/notbsd/emscripten/mod.rs b/src/unix/notbsd/emscripten/mod.rs index 012c371a1cf03..5de7b5ac57608 100644 --- a/src/unix/notbsd/emscripten/mod.rs +++ b/src/unix/notbsd/emscripten/mod.rs @@ -1664,11 +1664,11 @@ extern { cfg_if! { if #[cfg(libc_align)] { + #[macro_use] mod align; - pub use self::align::*; } else { + #[macro_use] mod no_align; - pub use self::no_align::*; } } - +expand_align!(); diff --git a/src/unix/notbsd/emscripten/no_align.rs b/src/unix/notbsd/emscripten/no_align.rs index f3594132c7d4d..cf8880794c168 100644 --- a/src/unix/notbsd/emscripten/no_align.rs +++ b/src/unix/notbsd/emscripten/no_align.rs @@ -1,34 +1,38 @@ -s! { - pub struct pthread_mutex_t { - pub __align: [::c_long; 0], - pub size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], - } +macro_rules! expand_align { + () => { + s! { + pub struct pthread_mutex_t { + __align: [::c_long; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } - pub struct pthread_rwlock_t { - pub __align: [::c_long; 0], - pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], - } + pub struct pthread_rwlock_t { + __align: [::c_long; 0], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } - pub struct pthread_mutexattr_t { - pub __align: [::c_int; 0], - pub size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], - } + pub struct pthread_mutexattr_t { + __align: [::c_int; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } - pub struct pthread_rwlockattr_t { - pub __align: [::c_int; 0], - pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], - } + pub struct pthread_rwlockattr_t { + __align: [::c_int; 0], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], + } - pub struct pthread_condattr_t { - pub __align: [::c_int; 0], - pub size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], - } -} + pub struct pthread_condattr_t { + __align: [::c_int; 0], + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } -s_no_extra_traits! { - #[allow(missing_debug_implementations)] - pub struct pthread_cond_t { - pub __align: [*const ::c_void; 0], - pub size: [u8; ::__SIZEOF_PTHREAD_COND_T], + s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct pthread_cond_t { + __align: [*const ::c_void; 0], + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } + } } } diff --git a/src/unix/notbsd/linux/align.rs b/src/unix/notbsd/linux/align.rs index 304e3b68e2f1f..a35e26913af7f 100644 --- a/src/unix/notbsd/linux/align.rs +++ b/src/unix/notbsd/linux/align.rs @@ -1,90 +1,100 @@ -s! { - #[cfg_attr(any(target_pointer_width = "32", - target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64", - all(target_arch = "aarch64", target_env = "musl")), - repr(align(4)))] - #[cfg_attr(not(any(target_pointer_width = "32", - target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64", - all(target_arch = "aarch64", target_env = "musl"))), - repr(align(8)))] - pub struct pthread_mutexattr_t { - #[doc(hidden)] - pub size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], - } +macro_rules! expand_align { + () => { + s! { + #[cfg_attr(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64", + all(target_arch = "aarch64", + target_env = "musl")), + repr(align(4)))] + #[cfg_attr(not(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64", + all(target_arch = "aarch64", + target_env = "musl"))), + repr(align(8)))] + pub struct pthread_mutexattr_t { + #[doc(hidden)] + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } - #[cfg_attr(any(target_env = "musl", target_pointer_width = "32"), - repr(align(4)))] - #[cfg_attr(all(not(target_env = "musl"), - target_pointer_width = "64"), - repr(align(8)))] - pub struct pthread_rwlockattr_t { - #[doc(hidden)] - pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], - } + #[cfg_attr(any(target_env = "musl", target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(not(target_env = "musl"), + target_pointer_width = "64"), + repr(align(8)))] + pub struct pthread_rwlockattr_t { + #[doc(hidden)] + size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], + } - #[repr(align(4))] - pub struct pthread_condattr_t { - #[doc(hidden)] - pub size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], - } -} + #[repr(align(4))] + pub struct pthread_condattr_t { + #[doc(hidden)] + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } -s_no_extra_traits! { - #[cfg_attr(all(target_env = "musl", - target_pointer_width = "32"), - repr(align(4)))] - #[cfg_attr(all(target_env = "musl", - target_pointer_width = "64"), - repr(align(8)))] - #[cfg_attr(all(not(target_env = "musl"), - target_arch = "x86"), - repr(align(4)))] - #[cfg_attr(all(not(target_env = "musl"), - not(target_arch = "x86")), - repr(align(8)))] - pub struct pthread_cond_t { - #[doc(hidden)] - pub size: [u8; ::__SIZEOF_PTHREAD_COND_T], - } + s_no_extra_traits! { + #[cfg_attr(all(target_env = "musl", + target_pointer_width = "32"), + repr(align(4)))] + #[cfg_attr(all(target_env = "musl", + target_pointer_width = "64"), + repr(align(8)))] + #[cfg_attr(all(not(target_env = "musl"), + target_arch = "x86"), + repr(align(4)))] + #[cfg_attr(all(not(target_env = "musl"), + not(target_arch = "x86")), + repr(align(8)))] + pub struct pthread_cond_t { + #[doc(hidden)] + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } - #[cfg_attr(all(target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - target_arch = "x86_64", - target_arch = "x86")), - repr(align(4)))] - #[cfg_attr(any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - target_arch = "x86_64", - target_arch = "x86"))), - repr(align(8)))] - pub struct pthread_mutex_t { - #[doc(hidden)] - pub size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], - } + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "x86_64", + target_arch = "x86")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "x86_64", + target_arch = "x86"))), + repr(align(8)))] + pub struct pthread_mutex_t { + #[doc(hidden)] + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } - #[cfg_attr(all(target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - target_arch = "x86_64", - target_arch = "x86")), - repr(align(4)))] - #[cfg_attr(any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - target_arch = "x86_64", - target_arch = "x86"))), - repr(align(8)))] - pub struct pthread_rwlock_t { - pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "x86_64", + target_arch = "x86")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "x86_64", + target_arch = "x86"))), + repr(align(8)))] + pub struct pthread_rwlock_t { + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + } } } diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index 0a368bf396cf7..03192e6278e3d 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -2360,10 +2360,11 @@ cfg_if! { cfg_if! { if #[cfg(libc_align)] { + #[macro_use] mod align; - pub use self::align::*; } else { + #[macro_use] mod no_align; - pub use self::no_align::*; } } +expand_align!(); diff --git a/src/unix/notbsd/linux/no_align.rs b/src/unix/notbsd/linux/no_align.rs index 8676bcc338174..1f5f2eea5706d 100644 --- a/src/unix/notbsd/linux/no_align.rs +++ b/src/unix/notbsd/linux/no_align.rs @@ -1,70 +1,80 @@ -s! { - pub struct pthread_mutexattr_t { - #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64", - all(target_arch = "aarch64", target_env = "musl")))] - pub __align: [::c_int; 0], - #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64", - all(target_arch = "aarch64", target_env = "musl"))))] - pub __align: [::c_long; 0], - pub size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], - } +macro_rules! expand_align { + () => { + s! { + pub struct pthread_mutexattr_t { + #[cfg(any(target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64", + all(target_arch = "aarch64", + target_env = "musl")))] + __align: [::c_int; 0], + #[cfg(not(any(target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64", + all(target_arch = "aarch64", + target_env = "musl"))))] + __align: [::c_long; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } - pub struct pthread_rwlockattr_t { - #[cfg(target_env = "musl")] - pub __align: [::c_int; 0], - #[cfg(not(target_env = "musl"))] - pub __align: [::c_long; 0], - pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], - } + pub struct pthread_rwlockattr_t { + #[cfg(target_env = "musl")] + __align: [::c_int; 0], + #[cfg(not(target_env = "musl"))] + __align: [::c_long; 0], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], + } - pub struct pthread_condattr_t { - pub __align: [::c_int; 0], - pub size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], - } -} + pub struct pthread_condattr_t { + __align: [::c_int; 0], + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } -s_no_extra_traits! { - pub struct pthread_cond_t { - #[cfg(target_env = "musl")] - pub __align: [*const ::c_void; 0], - #[cfg(not(target_env = "musl"))] - pub __align: [::c_longlong; 0], - pub size: [u8; ::__SIZEOF_PTHREAD_COND_T], - } + s_no_extra_traits! { + pub struct pthread_cond_t { + #[cfg(target_env = "musl")] + __align: [*const ::c_void; 0], + #[cfg(not(target_env = "musl"))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } - pub struct pthread_mutex_t { - #[cfg(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - all(target_arch = "x86_64", - target_pointer_width = "32")))] - pub __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - pub __align: [::c_longlong; 0], - pub size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], - } + pub struct pthread_mutex_t { + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + all(target_arch = "x86_64", + target_pointer_width = "32")))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } - pub struct pthread_rwlock_t { - #[cfg(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - all(target_arch = "x86_64", - target_pointer_width = "32")))] - pub __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc", - all(target_arch = "x86_64", - target_pointer_width = "32"))))] - pub __align: [::c_longlong; 0], - pub size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + pub struct pthread_rwlock_t { + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + all(target_arch = "x86_64", + target_pointer_width = "32")))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc", + all(target_arch = "x86_64", + target_pointer_width = "32"))))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + } } } diff --git a/src/unix/uclibc/align.rs b/src/unix/uclibc/align.rs index c461ff29df084..bcae2e6b0b7f8 100644 --- a/src/unix/uclibc/align.rs +++ b/src/unix/uclibc/align.rs @@ -1,53 +1,61 @@ -s! { - #[cfg_attr(all(target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")), - repr(align(4)))] - #[cfg_attr(any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))), - repr(align(8)))] - pub struct pthread_mutex_t { - pub size: [u8; __SIZEOF_PTHREAD_MUTEX_T], - } +macro_rules! expand_align { + () => { + s! { + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))), + repr(align(8)))] + pub struct pthread_mutex_t { + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } - #[cfg_attr(all(target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")), - repr(align(4)))] - #[cfg_attr(any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))), - repr(align(8)))] - pub struct pthread_rwlock_t { - pub size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], - } + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))), + repr(align(8)))] + pub struct pthread_rwlock_t { + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } - #[cfg_attr(any(target_pointer_width = "32", - target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"), - repr(align(4)))] - #[cfg_attr(not(any(target_pointer_width = "32", - target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64")), - repr(align(8)))] - pub struct pthread_mutexattr_t { - pub size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], - } + #[cfg_attr(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64"), + repr(align(4)))] + #[cfg_attr(not(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64")), + repr(align(8)))] + pub struct pthread_mutexattr_t { + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } - #[repr(align(8))] - pub struct pthread_cond_t { - pub size: [u8; __SIZEOF_PTHREAD_COND_T], - } + #[repr(align(8))] + pub struct pthread_cond_t { + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } - #[repr(align(4))] - pub struct pthread_condattr_t { - pub size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + #[repr(align(4))] + pub struct pthread_condattr_t { + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } } } diff --git a/src/unix/uclibc/mod.rs b/src/unix/uclibc/mod.rs index 7545212e10d21..cfaef3bd736d8 100644 --- a/src/unix/uclibc/mod.rs +++ b/src/unix/uclibc/mod.rs @@ -1900,10 +1900,12 @@ cfg_if! { cfg_if! { if #[cfg(libc_align)] { + #[macro_use] mod align; - pub use self::align::*; } else { + #[macro_use] mod no_align; - pub use self::no_align::*; } } + +expand_align!(); diff --git a/src/unix/uclibc/no_align.rs b/src/unix/uclibc/no_align.rs index 14ed97c722261..a73dbded57ac7 100644 --- a/src/unix/uclibc/no_align.rs +++ b/src/unix/uclibc/no_align.rs @@ -1,49 +1,53 @@ -s! { - pub struct pthread_mutex_t { - #[cfg(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))] - pub __align: [::c_long; 0], - #[cfg(any(libc_align, - target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))] - pub __align: [::c_longlong; 0], - pub size: [u8; __SIZEOF_PTHREAD_MUTEX_T], - } +macro_rules! expand_align { + () => { + s! { + pub struct pthread_mutex_t { + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_long; 0], + #[cfg(any(libc_align, + target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } - pub struct pthread_rwlock_t { - #[cfg(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))] - pub __align: [::c_long; 0], - #[cfg(not(any( - target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - pub __align: [::c_longlong; 0], - pub size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], - } + pub struct pthread_rwlock_t { + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_long; 0], + #[cfg(not(any( + target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } - pub struct pthread_mutexattr_t { - #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"))] - pub __align: [::c_int; 0], - #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64")))] - pub __align: [::c_long; 0], - pub size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], - } + pub struct pthread_mutexattr_t { + #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64"))] + __align: [::c_int; 0], + #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64")))] + __align: [::c_long; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } - pub struct pthread_cond_t { - pub __align: [::c_longlong; 0], - pub size: [u8; __SIZEOF_PTHREAD_COND_T], - } + pub struct pthread_cond_t { + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } - pub struct pthread_condattr_t { - pub __align: [::c_int; 0], - pub size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + pub struct pthread_condattr_t { + __align: [::c_int; 0], + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } + } } } diff --git a/src/unix/uclibc/x86_64/align.rs b/src/unix/uclibc/x86_64/align.rs index 155e7af20511a..5fb4a4d5185ef 100644 --- a/src/unix/uclibc/x86_64/align.rs +++ b/src/unix/uclibc/x86_64/align.rs @@ -1,64 +1,72 @@ -s! { - #[cfg_attr(target_pointer_width = "32", - repr(align(4)))] - #[cfg_attr(target_pointer_width = "64", - repr(align(8)))] - pub struct sem_t { // ToDo - #[cfg(target_pointer_width = "32")] - __size: [::c_char; 16], - #[cfg(target_pointer_width = "64")] - __size: [::c_char; 32], - } +macro_rules! expand_align { + () = > { + s! { + #[cfg_attr(target_pointer_width = "32", + repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", + repr(align(8)))] + pub struct sem_t { // ToDo + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + } - #[cfg_attr(all(target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")), - repr(align(4)))] - #[cfg_attr(all(any(target_pointer_width = "64", - not(any(target_arch = "mips", + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", target_arch = "arm", - target_arch = "powerpc")))), - repr(align(8)))] - pub struct pthread_mutex_t { // ToDo - size: [u8; __SIZEOF_PTHREAD_MUTEX_T], - } + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(all(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))), + repr(align(8)))] + pub struct pthread_mutex_t { // ToDo + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } - #[cfg_attr(any(target_pointer_width = "32", - target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"), - repr(align(4)))] - #[cfg_attr(not(any(target_pointer_width = "32", - target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64")), - repr(align(8)))] - pub struct pthread_mutexattr_t { // ToDo - size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], - } + #[cfg_attr(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64"), + repr(align(4)))] + #[cfg_attr(not(any(target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64")), + repr(align(8)))] + pub struct pthread_mutexattr_t { // ToDo + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } - #[repr(align(8))] - pub struct pthread_cond_t { // ToDo - size: [u8; __SIZEOF_PTHREAD_COND_T], - } + #[repr(align(8))] + pub struct pthread_cond_t { // ToDo + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } - #[repr(align(4))] - pub struct pthread_condattr_t { // ToDo - size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], - } + #[repr(align(4))] + pub struct pthread_condattr_t { // ToDo + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } - #[cfg_attr(all(target_pointer_width = "32", - any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")), - repr(align(4)))] - #[cfg_attr(any(target_pointer_width = "64", - not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))), - repr(align(8)))] - pub struct pthread_rwlock_t { // ToDo - size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + #[cfg_attr(all(target_pointer_width = "32", + any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")), + repr(align(4)))] + #[cfg_attr(any(target_pointer_width = "64", + not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))), + repr(align(8)))] + pub struct pthread_rwlock_t { // ToDo + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + } } } diff --git a/src/unix/uclibc/x86_64/mod.rs b/src/unix/uclibc/x86_64/mod.rs index abc35d14fce16..bc084394c3c54 100644 --- a/src/unix/uclibc/x86_64/mod.rs +++ b/src/unix/uclibc/x86_64/mod.rs @@ -311,10 +311,11 @@ cfg_if! { cfg_if! { if #[cfg(libc_align)] { + #[macro_use] mod align; - pub use self::align::*; } else { + #[macro_use] mod no_align; - pub use self::no_align::*; } } +expand_align!(); diff --git a/src/unix/uclibc/x86_64/no_align.rs b/src/unix/uclibc/x86_64/no_align.rs index 1fee8340df155..422d78fac25ca 100644 --- a/src/unix/uclibc/x86_64/no_align.rs +++ b/src/unix/uclibc/x86_64/no_align.rs @@ -1,55 +1,59 @@ -s! { - pub struct sem_t { // ToDo - #[cfg(target_pointer_width = "32")] - __size: [::c_char; 16], - #[cfg(target_pointer_width = "64")] - __size: [::c_char; 32], - __align: [::c_long; 0], - } +macro_rules! expand_align { + () => { + s! { + pub struct sem_t { // ToDo + #[cfg(target_pointer_width = "32")] + __size: [::c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [::c_char; 32], + __align: [::c_long; 0], + } - pub struct pthread_mutex_t { // ToDo - #[cfg(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))] - pub __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - pub __align: [::c_longlong; 0], - pub size: [u8; __SIZEOF_PTHREAD_MUTEX_T], - } + pub struct pthread_mutex_t { // ToDo + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEX_T], + } - pub struct pthread_mutexattr_t { // ToDo - #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64"))] - pub __align: [::c_int; 0], - #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", - target_arch = "mips64", target_arch = "s390x", - target_arch = "sparc64")))] - pub __align: [::c_long; 0], - pub size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], - } + pub struct pthread_mutexattr_t { // ToDo + #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64"))] + __align: [::c_int; 0], + #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", + target_arch = "mips64", target_arch = "s390x", + target_arch = "sparc64")))] + __align: [::c_long; 0], + size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], + } - pub struct pthread_cond_t { // ToDo - pub __align: [::c_longlong; 0], - pub size: [u8; __SIZEOF_PTHREAD_COND_T], - } + pub struct pthread_cond_t { // ToDo + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_COND_T], + } - pub struct pthread_condattr_t { // ToDo - pub __align: [::c_int; 0], - pub size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], - } + pub struct pthread_condattr_t { // ToDo + __align: [::c_int; 0], + size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T], + } - pub struct pthread_rwlock_t { // ToDo - #[cfg(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc"))] - pub __align: [::c_long; 0], - #[cfg(not(any(target_arch = "mips", - target_arch = "arm", - target_arch = "powerpc")))] - pub __align: [::c_longlong; 0], - pub size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + pub struct pthread_rwlock_t { // ToDo + #[cfg(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc"))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", + target_arch = "arm", + target_arch = "powerpc")))] + __align: [::c_longlong; 0], + size: [u8; ::__SIZEOF_PTHREAD_RWLOCK_T], + } + } } } From fad7e0ce9764d9129b8728b7995818c5d4a44935 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 02:51:11 +0100 Subject: [PATCH 61/72] don't test armv7-unknown-linux-musleabihf in old Rust versions --- ci/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 2d72c55d33602..3fd0b08357ff0 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -58,12 +58,12 @@ test_target() { TARGETS="wasm32-unknown-unknown" case "${OS}" in linux*) - TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf armv7-unknown-linux-musleabihf x86_64-sun-solaris aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu sparc64-unknown-linux-gnu sparcv9-sun-solaris x86_64-unknown-linux-musl x86_64-linux-android wasm32-unknown-emscripten" + TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf x86_64-sun-solaris aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu sparc64-unknown-linux-gnu sparcv9-sun-solaris x86_64-unknown-linux-musl x86_64-linux-android wasm32-unknown-emscripten" if [ "${RUST}" != "+1.13.0" ] && \ [ "${RUST}" != "+1.19.0" ] && \ [ "${RUST}" != "+1.24.0" ]; then - TARGETS="${TARGETS} i586-unknown-linux-musl" + TARGETS="${TARGETS} i586-unknown-linux-musl armv7-unknown-linux-musleabihf " fi if [ "${RUST}" = "nightly" ]; then From 756701b252f91f9cebbb415d20389d42d185ed6b Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 02:51:55 +0100 Subject: [PATCH 62/72] don't test x86_64-sun-solaris on old Rust versions --- ci/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 3fd0b08357ff0..82a95504d69ed 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -58,12 +58,12 @@ test_target() { TARGETS="wasm32-unknown-unknown" case "${OS}" in linux*) - TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf x86_64-sun-solaris aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu sparc64-unknown-linux-gnu sparcv9-sun-solaris x86_64-unknown-linux-musl x86_64-linux-android wasm32-unknown-emscripten" + TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu sparc64-unknown-linux-gnu sparcv9-sun-solaris x86_64-unknown-linux-musl x86_64-linux-android wasm32-unknown-emscripten" if [ "${RUST}" != "+1.13.0" ] && \ [ "${RUST}" != "+1.19.0" ] && \ [ "${RUST}" != "+1.24.0" ]; then - TARGETS="${TARGETS} i586-unknown-linux-musl armv7-unknown-linux-musleabihf " + TARGETS="${TARGETS} i586-unknown-linux-musl armv7-unknown-linux-musleabihf x86_64-sun-solaris" fi if [ "${RUST}" = "nightly" ]; then From 70a0a7a794c6ba223d5d4a2cca2a99f8e416c78e Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 02:55:52 +0100 Subject: [PATCH 63/72] Fix typos in build.sh --- ci/build.sh | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 82a95504d69ed..f688784c11c61 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -40,18 +40,14 @@ test_target() { cargo "+${RUST}" build -vv $opt --target "${TARGET}" fi - # Test that libc builds with the `extra_traits` feature if Rust >= 1.25.0 - if [ "${RUST}" != "+1.13.0" ] && \ - [ "${RUST}" != "+1.19.0" ] && \ - [ "${RUST}" != "+1.24.0" ]; then - cargo "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}" \ - --features extra_traits + # Test that libc builds with the `extra_traits` feature + cargo "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}" \ + --features extra_traits - # Also test that it builds with `extra_traits` and default features: - if [ "$NO_STD" != "1" ]; then - cargo "+${RUST}" build -vv $opt --target "${TARGET}" \ - --features extra_traits - fi + # Also test that it builds with `extra_traits` and default features: + if [ "$NO_STD" != "1" ]; then + cargo "+${RUST}" build -vv $opt --target "${TARGET}" \ + --features extra_traits fi } @@ -60,9 +56,9 @@ case "${OS}" in linux*) TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu sparc64-unknown-linux-gnu sparcv9-sun-solaris x86_64-unknown-linux-musl x86_64-linux-android wasm32-unknown-emscripten" - if [ "${RUST}" != "+1.13.0" ] && \ - [ "${RUST}" != "+1.19.0" ] && \ - [ "${RUST}" != "+1.24.0" ]; then + if [ "${RUST}" != "1.13.0" ] && \ + [ "${RUST}" != "1.19.0" ] && \ + [ "${RUST}" != "1.24.0" ]; then TARGETS="${TARGETS} i586-unknown-linux-musl armv7-unknown-linux-musleabihf x86_64-sun-solaris" fi From 4a6a90be0bcd6aee3c9f3bcd781ef9feca319fe1 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 03:07:24 +0100 Subject: [PATCH 64/72] don't test sparc64-unknown-linux-gnu on old Rust versions --- ci/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index f688784c11c61..3c15f3753feb1 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -54,12 +54,12 @@ test_target() { TARGETS="wasm32-unknown-unknown" case "${OS}" in linux*) - TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu sparc64-unknown-linux-gnu sparcv9-sun-solaris x86_64-unknown-linux-musl x86_64-linux-android wasm32-unknown-emscripten" + TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu sparcv9-sun-solaris x86_64-unknown-linux-musl x86_64-linux-android wasm32-unknown-emscripten" if [ "${RUST}" != "1.13.0" ] && \ [ "${RUST}" != "1.19.0" ] && \ [ "${RUST}" != "1.24.0" ]; then - TARGETS="${TARGETS} i586-unknown-linux-musl armv7-unknown-linux-musleabihf x86_64-sun-solaris" + TARGETS="${TARGETS} i586-unknown-linux-musl armv7-unknown-linux-musleabihf x86_64-sun-solaris sparc64-unknown-linux-gnu" fi if [ "${RUST}" = "nightly" ]; then From 891ce1a2e322858453a980274a5938fbe6d6bddb Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 03:16:49 +0100 Subject: [PATCH 65/72] don't test sparcv9-sun-solaris on old Rust versions --- ci/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 3c15f3753feb1..c432024ef637f 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -54,12 +54,12 @@ test_target() { TARGETS="wasm32-unknown-unknown" case "${OS}" in linux*) - TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu sparcv9-sun-solaris x86_64-unknown-linux-musl x86_64-linux-android wasm32-unknown-emscripten" + TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu x86_64-unknown-linux-musl x86_64-linux-android wasm32-unknown-emscripten" if [ "${RUST}" != "1.13.0" ] && \ [ "${RUST}" != "1.19.0" ] && \ [ "${RUST}" != "1.24.0" ]; then - TARGETS="${TARGETS} i586-unknown-linux-musl armv7-unknown-linux-musleabihf x86_64-sun-solaris sparc64-unknown-linux-gnu" + TARGETS="${TARGETS} i586-unknown-linux-musl armv7-unknown-linux-musleabihf x86_64-sun-solaris sparc64-unknown-linux-gnu sparcv9-sun-solaris" fi if [ "${RUST}" = "nightly" ]; then From a98fdcbec002579c760b4654aaf03064b4d159b8 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 03:30:41 +0100 Subject: [PATCH 66/72] don't test x86_64-linux-android on old Rust versions --- ci/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index c432024ef637f..0d0f93ebbdc0e 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -54,12 +54,12 @@ test_target() { TARGETS="wasm32-unknown-unknown" case "${OS}" in linux*) - TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu x86_64-unknown-linux-musl x86_64-linux-android wasm32-unknown-emscripten" + TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu x86_64-unknown-linux-musl wasm32-unknown-emscripten" if [ "${RUST}" != "1.13.0" ] && \ [ "${RUST}" != "1.19.0" ] && \ [ "${RUST}" != "1.24.0" ]; then - TARGETS="${TARGETS} i586-unknown-linux-musl armv7-unknown-linux-musleabihf x86_64-sun-solaris sparc64-unknown-linux-gnu sparcv9-sun-solaris" + TARGETS="${TARGETS} i586-unknown-linux-musl armv7-unknown-linux-musleabihf x86_64-sun-solaris sparc64-unknown-linux-gnu sparcv9-sun-solaris x86_64-linux-android" fi if [ "${RUST}" = "nightly" ]; then From dc632af82727a018f9413b8760a021b0a5ca9f91 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 03:32:21 +0100 Subject: [PATCH 67/72] Fix bug in build script --- ci/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 0d0f93ebbdc0e..fdf15cf7edee3 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -51,7 +51,7 @@ test_target() { fi } -TARGETS="wasm32-unknown-unknown" +TARGETS="" case "${OS}" in linux*) TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu x86_64-unknown-linux-musl wasm32-unknown-emscripten" @@ -59,7 +59,7 @@ case "${OS}" in if [ "${RUST}" != "1.13.0" ] && \ [ "${RUST}" != "1.19.0" ] && \ [ "${RUST}" != "1.24.0" ]; then - TARGETS="${TARGETS} i586-unknown-linux-musl armv7-unknown-linux-musleabihf x86_64-sun-solaris sparc64-unknown-linux-gnu sparcv9-sun-solaris x86_64-linux-android" + TARGETS="${TARGETS} i586-unknown-linux-musl armv7-unknown-linux-musleabihf x86_64-sun-solaris sparc64-unknown-linux-gnu sparcv9-sun-solaris x86_64-linux-android wasm32-unknown-unknown" fi if [ "${RUST}" = "nightly" ]; then From 92cc83de45e8e8b5d7ab090d7d0e92dd55c9567d Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 09:56:42 +0100 Subject: [PATCH 68/72] test more platforms --- ci/build.sh | 20 ++++++++++++-------- src/lib.rs | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index fdf15cf7edee3..3503910436b1b 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -54,12 +54,16 @@ test_target() { TARGETS="" case "${OS}" in linux*) - TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu x86_64-unknown-linux-musl wasm32-unknown-emscripten" - - if [ "${RUST}" != "1.13.0" ] && \ - [ "${RUST}" != "1.19.0" ] && \ - [ "${RUST}" != "1.24.0" ]; then - TARGETS="${TARGETS} i586-unknown-linux-musl armv7-unknown-linux-musleabihf x86_64-sun-solaris sparc64-unknown-linux-gnu sparcv9-sun-solaris x86_64-linux-android wasm32-unknown-unknown" + TARGETS=" aarch64-apple-ios i686-apple-darwin x86_64-apple-darwin armv7-apple-ios armv7s-apple-ios x86_64-apple-ios i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu x86_64-unknown-linux-musl" + + if [ "${RUST}" != "1.13.0" ]; then + TARGETS="${TARGETS} i586-unknown-linux-musl armv7-unknown-linux-musleabihf x86_64-sun-solaris x86_64-linux-android wasm32-unknown-emscripten sparc64-unknown-linux-gnu sparcv9-sun-solaris wasm32-unknown-unknown x86_64-rumprun-netbsd x86_64-unknown-cloudabi" + if [ "${RUST}" != "1.19.0" ]; then + TARGETS="${TARGETS}" + if [ "${RUST}" != "1.24.0" ]; then + TARGETS="${TARGETS}" + fi + fi fi if [ "${RUST}" = "nightly" ]; then @@ -69,12 +73,12 @@ case "${OS}" in # i686-unknown-haiku mipsel-unknown-unknown-linux-uclib # sparc64-unknown-netbsd x86_64-unknown-bitrig x86_64-unknown-haiku # x86_64-unknown-openbsd i686-unknown-netbsd - TARGETS="${TARGETS} aarch64-fuchsia x86_64-fuchsia x86_64-rumprun-netbsd x86_64-unknown-cloudabi x86_64-unknown-redox thumbv6m-none-eabi thumbv7em-none-eabi thumbv7em-none-eabihf thumbv7m-none-eabi x86_64-fortanix-unknown-sgx" + TARGETS="${TARGETS} aarch64-fuchsia x86_64-fuchsia x86_64-unknown-redox thumbv6m-none-eabi thumbv7em-none-eabi thumbv7em-none-eabihf thumbv7m-none-eabi x86_64-fortanix-unknown-sgx" fi ;; osx*) - TARGETS="i686-apple-darwin x86_64-apple-darwin aarch64-apple-ios armv7-apple-ios armv7s-apple-ios x86_64-apple-ios" + TARGETS="aarch64-apple-ios i686-apple-darwin x86_64-apple-darwin armv7-apple-ios armv7s-apple-ios x86_64-apple-ios" ;; *) ;; diff --git a/src/lib.rs b/src/lib.rs index 95baffa3507df..72e93aaf62def 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ //! Crate docs -#![allow(bad_style, overflowing_literals, improper_ctypes)] +#![allow(bad_style, overflowing_literals, improper_ctypes, unknown_lints)] #![crate_type = "rlib"] #![crate_name = "libc"] #![cfg_attr(cross_platform_docs, feature(no_core, lang_items, const_fn))] From 2d686747b0e22dc55328704ec90953c80c3e1edb Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 10:33:19 +0100 Subject: [PATCH 69/72] test more platforms --- ci/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build.sh b/ci/build.sh index 3503910436b1b..2baa0758c4698 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -54,7 +54,7 @@ test_target() { TARGETS="" case "${OS}" in linux*) - TARGETS=" aarch64-apple-ios i686-apple-darwin x86_64-apple-darwin armv7-apple-ios armv7s-apple-ios x86_64-apple-ios i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu x86_64-unknown-linux-musl" + TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu x86_64-unknown-linux-musl" if [ "${RUST}" != "1.13.0" ]; then TARGETS="${TARGETS} i586-unknown-linux-musl armv7-unknown-linux-musleabihf x86_64-sun-solaris x86_64-linux-android wasm32-unknown-emscripten sparc64-unknown-linux-gnu sparcv9-sun-solaris wasm32-unknown-unknown x86_64-rumprun-netbsd x86_64-unknown-cloudabi" From b62033cfbd0f7fb24708b03c0ebc3a62dc8bc9e9 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 10:52:39 +0100 Subject: [PATCH 70/72] Refactor build script --- ci/build.sh | 99 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 87 insertions(+), 12 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 2baa0758c4698..9f14fe37392af 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -51,34 +51,109 @@ test_target() { fi } +RUST_LINUX_TARGETS="\ +aarch64-linux-android \ +aarch64-unknown-linux-gnu \ +aarch64-unknown-linux-musl \ +arm-linux-androideabi \ +arm-unknown-linux-gnueabi \ +arm-unknown-linux-gnueabihf \ +arm-unknown-linux-musleabi \ +arm-unknown-linux-musleabihf \ +armv7-linux-androideabi \ +armv7-unknown-linux-gnueabihf \ +i586-unknown-linux-gnu \ +i686-linux-android \ +i686-unknown-freebsd \ +i686-unknown-linux-gnu \ +i686-unknown-linux-musl \ +mips-unknown-linux-gnu \ +mips-unknown-linux-musl \ +mips64-unknown-linux-gnuabi64 \ +mips64el-unknown-linux-gnuabi64 \ +mipsel-unknown-linux-gnu \ +mipsel-unknown-linux-gnu \ +mipsel-unknown-linux-musl \ +powerpc-unknown-linux-gnu \ +powerpc64-unknown-linux-gnu \ +powerpc64le-unknown-linux-gnu \ +s390x-unknown-linux-gnu \ +x86_64-unknown-freebsd \ +x86_64-unknown-linux-gnu \ +x86_64-unknown-linux-musl \ +x86_64-unknown-netbsd \ +" + +RUST_GT_1_13_LINUX_TARGETS="\ +armv7-unknown-linux-musleabihf \ +i586-unknown-linux-musl \ +sparc64-unknown-linux-gnu \ +sparcv9-sun-solaris \ +wasm32-unknown-emscripten \ +wasm32-unknown-unknown \ +x86_64-linux-android \ +x86_64-rumprun-netbsd \ +x86_64-sun-solaris \ +x86_64-unknown-cloudabi \ +" +RUST_GT_1_19_LINUX_TARGETS= +RUST_GT_1_24_LINUX_TARGETS= + +RUST_NIGHTLY_LINUX_TARGETS="\ +aarch64-fuchsia \ +thumbv6m-none-eabi \ +thumbv7em-none-eabi \ +thumbv7em-none-eabihf \ +thumbv7m-none-eabi \ +thumbv7neon-linux-androideabi \ +thumbv7neon-unknown-linux-gnueabihf \ +x86_64-fortanix-unknown-sgx \ +x86_64-fuchsia \ +x86_64-unknown-linux-gnux32 \ +x86_64-unknown-redox \ +" +# FIXME: these do not have a rust-std component available +# aarch64-unknown-cloudabi armv7-unknown-cloudabi-eabihf +# i686-unknown-cloudabi powerpc-unknown-linux-gnuspe +# sparc-unknown-linux-gnu mips-unknown-linux-uclib +# i686-unknown-haiku mipsel-unknown-unknown-linux-uclib +# sparc64-unknown-netbsd x86_64-unknown-bitrig x86_64-unknown-haiku +# x86_64-unknown-openbsd i686-unknown-netbsd + + +RUST_OSX_TARGETS="\ +aarch64-apple-ios \ +armv7-apple-ios \ +armv7s-apple-ios \ +i386-apple-ios \ +i686-apple-darwin \ +x86_64-apple-darwin \ +x86_64-apple-ios \ +" + +# The targets are listed here alphabetically TARGETS="" case "${OS}" in linux*) - TARGETS="i686-unknown-linux-gnu x86_64-unknown-linux-gnu x86_64-unknown-freebsd x86_64-unknown-netbsd i586-unknown-linux-gnu i686-linux-android i686-unknown-freebsd mipsel-unknown-linux-gnu mips64-unknown-linux-gnuabi64 mips64el-unknown-linux-gnuabi64 mipsel-unknown-linux-gnu mipsel-unknown-linux-musl armv7-linux-androideabi armv7-unknown-linux-gnueabihf aarch64-linux-android powerpc-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu s390x-unknown-linux-gnu x86_64-unknown-linux-musl" + TARGETS="${RUST_LINUX_TARGETS}" if [ "${RUST}" != "1.13.0" ]; then - TARGETS="${TARGETS} i586-unknown-linux-musl armv7-unknown-linux-musleabihf x86_64-sun-solaris x86_64-linux-android wasm32-unknown-emscripten sparc64-unknown-linux-gnu sparcv9-sun-solaris wasm32-unknown-unknown x86_64-rumprun-netbsd x86_64-unknown-cloudabi" + TARGETS="${TARGETS} ${RUST_GT_1_13_LINUX_TARGETS}" if [ "${RUST}" != "1.19.0" ]; then - TARGETS="${TARGETS}" + TARGETS="${TARGETS} ${RUST_GT_1_19_LINUX_TARGETS}" if [ "${RUST}" != "1.24.0" ]; then - TARGETS="${TARGETS}" + TARGETS="${TARGETS} ${RUST_GT_1_24_LINUX_TARGETS}" fi fi fi if [ "${RUST}" = "nightly" ]; then - # aarch64-unknown-cloudabi armv7-unknown-cloudabi-eabihf - # i686-unknown-cloudabi powerpc-unknown-linux-gnuspe - # sparc-unknown-linux-gnu mips-unknown-unknown-linux-uclib - # i686-unknown-haiku mipsel-unknown-unknown-linux-uclib - # sparc64-unknown-netbsd x86_64-unknown-bitrig x86_64-unknown-haiku - # x86_64-unknown-openbsd i686-unknown-netbsd - TARGETS="${TARGETS} aarch64-fuchsia x86_64-fuchsia x86_64-unknown-redox thumbv6m-none-eabi thumbv7em-none-eabi thumbv7em-none-eabihf thumbv7m-none-eabi x86_64-fortanix-unknown-sgx" + TARGETS="${TARGETS} ${RUST_NIGHTLY_LINUX_TARGETS}" fi ;; osx*) - TARGETS="aarch64-apple-ios i686-apple-darwin x86_64-apple-darwin armv7-apple-ios armv7s-apple-ios x86_64-apple-ios" + TARGETS="${RUST_OSX_TARGETS}" ;; *) ;; From f3d799b8c41a8f1c9b968ad9cfca2efed995b5ba Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 11:18:21 +0100 Subject: [PATCH 71/72] fixup --- ci/build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 9f14fe37392af..dea0507234ec4 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -54,7 +54,6 @@ test_target() { RUST_LINUX_TARGETS="\ aarch64-linux-android \ aarch64-unknown-linux-gnu \ -aarch64-unknown-linux-musl \ arm-linux-androideabi \ arm-unknown-linux-gnueabi \ arm-unknown-linux-gnueabihf \ @@ -96,7 +95,9 @@ x86_64-rumprun-netbsd \ x86_64-sun-solaris \ x86_64-unknown-cloudabi \ " -RUST_GT_1_19_LINUX_TARGETS= +RUST_GT_1_19_LINUX_TARGETS="\ +aarch64-unknown-linux-musl \ +" RUST_GT_1_24_LINUX_TARGETS= RUST_NIGHTLY_LINUX_TARGETS="\ @@ -120,7 +121,6 @@ x86_64-unknown-redox \ # sparc64-unknown-netbsd x86_64-unknown-bitrig x86_64-unknown-haiku # x86_64-unknown-openbsd i686-unknown-netbsd - RUST_OSX_TARGETS="\ aarch64-apple-ios \ armv7-apple-ios \ From 9f577e159bbb568418142495c0eb3d9c023459b4 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 7 Feb 2019 11:27:24 +0100 Subject: [PATCH 72/72] fixup --- ci/build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index dea0507234ec4..f5c9b20f87247 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -85,7 +85,6 @@ x86_64-unknown-netbsd \ RUST_GT_1_13_LINUX_TARGETS="\ armv7-unknown-linux-musleabihf \ -i586-unknown-linux-musl \ sparc64-unknown-linux-gnu \ sparcv9-sun-solaris \ wasm32-unknown-emscripten \ @@ -98,7 +97,9 @@ x86_64-unknown-cloudabi \ RUST_GT_1_19_LINUX_TARGETS="\ aarch64-unknown-linux-musl \ " -RUST_GT_1_24_LINUX_TARGETS= +RUST_GT_1_24_LINUX_TARGETS="\ +i586-unknown-linux-musl \ +" RUST_NIGHTLY_LINUX_TARGETS="\ aarch64-fuchsia \