Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,8 @@
unused_results,
warnings
)]
#![cfg_attr(
any(
target_os = "redox",
all(
not(test),
not(feature = "use_heap"),
unix,
not(any(target_os = "macos", target_os = "ios")),
any(not(target_os = "linux"), feature = "dev_urandom_fallback")
)
),
no_std
)]
// std is only used in tests or when gated with #[cfg(use_heap)]
#![cfg_attr(not(any(test, feature = "use_heap")), no_std)]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment here isn't necessary since it's just duplicating the code, so let's remove it.

#![cfg_attr(feature = "internal_benches", allow(unstable_features))]
#![cfg_attr(feature = "internal_benches", feature(test))]

Expand Down
19 changes: 9 additions & 10 deletions src/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ impl sealed::Sealed for SystemRandom {}
target_os = "macos",
target_os = "ios",
target_os = "fuchsia",
windows
target_os = "windows"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How should fill_impl be implemented for UEFI targets? Please provide an implementation.

))
))]
use self::urandom::fill as fill_impl;

#[cfg(any(
all(target_os = "linux", not(feature = "dev_urandom_fallback")),
windows
target_os = "windows",
))]
use self::sysrand::fill as fill_impl;

Expand Down Expand Up @@ -158,7 +158,7 @@ mod sysrand_chunk {
}
}

#[cfg(windows)]
#[cfg(target_os = "windows")]
mod sysrand_chunk {
use crate::{error, polyfill};
use core;
Expand All @@ -183,7 +183,7 @@ mod sysrand_chunk {
}
}

#[cfg(any(target_os = "linux", windows))]
#[cfg(any(target_os = "linux", target_os = "windows"))]
mod sysrand {
use super::sysrand_chunk::chunk;
use crate::error;
Expand All @@ -198,13 +198,13 @@ mod sysrand {
}
}

// Keep the `cfg` conditions in sync with the conditions in lib.rs.
#[cfg(all(
feature = "use_heap",
any(target_os = "redox", unix),
not(any(target_os = "macos", target_os = "ios")),
not(all(target_os = "linux", not(feature = "dev_urandom_fallback"))),
not(any(target_os = "fuchsia")),
not(target_os = "macos"),
not(target_os = "ios"),
not(target_os = "fuchsia"),
not(target_os = "windows"),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am planning to switch this to a whitelist approach because I want to avoid using /dev/urandom whenever practical. So I think that while this may work right now, it will soon (in a matter of days) stop working.

))]
mod urandom {
use crate::error;
Expand All @@ -215,7 +215,7 @@ mod urandom {

#[cfg(target_os = "redox")]
static RANDOM_PATH: &str = "rand:";
#[cfg(unix)]
#[cfg(not(target_os = "redox"))]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was wrong with cfg(unix) here? It seems better to me.

static RANDOM_PATH: &str = "/dev/urandom";

lazy_static! {
Expand All @@ -233,7 +233,6 @@ mod urandom {
}
}

// Keep the `cfg` conditions in sync with the conditions in lib.rs.
#[cfg(all(target_os = "linux", feature = "dev_urandom_fallback"))]
mod sysrand_or_urandom {
use crate::error;
Expand Down