Skip to content

Commit

Permalink
Enable v0.1 std-trait workaround for additional targets (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephlr committed Dec 7, 2020
1 parent 445e929 commit b33dcdd
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 26 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ matrix:
- cargo build --target=x86_64-unknown-netbsd
- cargo build --target=x86_64-unknown-redox
- cargo build --target=x86_64-fortanix-unknown-sgx
- cargo xbuild --target=x86_64-unknown-cloudabi
# This builds currently fails with:
# Could not find specification for target "x86_64-unknown-cloudabi"
#- cargo xbuild --target=x86_64-unknown-cloudabi
- cargo xbuild --target=x86_64-unknown-uefi
- cargo xbuild --target=x86_64-unknown-hermit
- cargo xbuild --target=x86_64-unknown-l4re-uclibc
Expand All @@ -158,7 +160,7 @@ matrix:
- cargo build --target=x86_64-unknown-netbsd
- cargo build --target=x86_64-unknown-redox
- cargo build --target=x86_64-fortanix-unknown-sgx
- cargo xbuild --target=x86_64-unknown-cloudabi
#- cargo xbuild --target=x86_64-unknown-cloudabi
- cargo xbuild --target=x86_64-unknown-uefi
- cargo xbuild --target=x86_64-unknown-hermit
- cargo xbuild --target=x86_64-unknown-l4re-uclibc
Expand Down Expand Up @@ -229,3 +231,4 @@ notifications:
branches:
only:
- master
- 0.1
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ test_script:
branches:
only:
- master
- 0.1
56 changes: 33 additions & 23 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,75 +158,85 @@ cfg_if! {
mod error;
pub use crate::error::Error;

#[allow(dead_code)]
mod util;

#[cfg(target_os = "vxworks")]
#[allow(dead_code)]
mod util_libc;

cfg_if! {
// Unlike the other Unix, Fuchsia and iOS don't use the libc to make any calls.
if #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "emscripten",
target_os = "freebsd", target_os = "haiku", target_os = "illumos",
target_os = "linux", target_os = "macos", target_os = "netbsd",
target_os = "openbsd", target_os = "redox", target_os = "solaris"))] {
#[allow(dead_code)]
mod util_libc;
// Keep std-only trait definitions for backwards compatibility
mod error_impls;
} else if #[cfg(feature = "std")] {
mod error_impls;
}
}

// These targets read from a file as a fallback method.
// For backwards compatibility, we provide the std-only trait implementations
// for some platforms, even if they don't enable the "std" feature.
#[cfg(any(
feature = "std",
all(windows, not(getrandom_uwp)),
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
target_os = "solaris",
target_os = "illumos",
))]
mod use_file;
mod error_impls;

// System-specific implementations.
//
// These should all provide getrandom_inner with the same signature as getrandom.
cfg_if! {
if #[cfg(target_os = "android")] {
mod util_libc;
mod use_file;
#[path = "linux_android.rs"] mod imp;
} else if #[cfg(target_os = "cloudabi")] {
#[path = "cloudabi.rs"] mod imp;
} else if #[cfg(target_os = "dragonfly")] {
mod util_libc;
#[path = "use_file.rs"] mod imp;
} else if #[cfg(target_os = "emscripten")] {
mod util_libc;
#[path = "use_file.rs"] mod imp;
} else if #[cfg(target_os = "freebsd")] {
mod util_libc;
#[path = "bsd_arandom.rs"] mod imp;
} else if #[cfg(target_os = "fuchsia")] {
#[path = "fuchsia.rs"] mod imp;
} else if #[cfg(target_os = "haiku")] {
mod util_libc;
#[path = "use_file.rs"] mod imp;
} else if #[cfg(target_os = "illumos")] {
mod util_libc;
mod use_file;
#[path = "solaris_illumos.rs"] mod imp;
} else if #[cfg(target_os = "ios")] {
#[path = "ios.rs"] mod imp;
} else if #[cfg(target_os = "linux")] {
mod util_libc;
mod use_file;
#[path = "linux_android.rs"] mod imp;
} else if #[cfg(target_os = "macos")] {
mod util_libc;
mod use_file;
#[path = "macos.rs"] mod imp;
} else if #[cfg(target_os = "netbsd")] {
mod util_libc;
#[path = "bsd_arandom.rs"] mod imp;
} else if #[cfg(target_os = "openbsd")] {
mod util_libc;
#[path = "openbsd.rs"] mod imp;
} else if #[cfg(target_os = "redox")] {
mod util_libc;
#[path = "use_file.rs"] mod imp;
} else if #[cfg(target_os = "solaris")] {
mod util_libc;
mod use_file;
#[path = "solaris_illumos.rs"] mod imp;
} else if #[cfg(target_os = "wasi")] {
#[path = "wasi.rs"] mod imp;
} else if #[cfg(target_os = "vxworks")] {
mod util_libc;
#[path = "vxworks.rs"] mod imp;
} else if #[cfg(all(windows, getrandom_uwp))] {
#[path = "windows_uwp.rs"] mod imp;
Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![allow(dead_code)]
use core::sync::atomic::{AtomicUsize, Ordering::Relaxed};

// This structure represents a lazily initialized static usize value. Useful
Expand Down
1 change: 1 addition & 0 deletions src/util_libc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(dead_code)]
use crate::error::ERRNO_NOT_POSITIVE;
use crate::util::LazyUsize;
use crate::Error;
Expand Down

0 comments on commit b33dcdd

Please sign in to comment.