Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rust-random/getrandom
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ad9a971e83dfe92c0c6d792cbe6859f4a12f82c7
Choose a base ref
..
head repository: rust-random/getrandom
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 193ff54c9767a96b9c98298aff272e34448bb23f
Choose a head ref
Showing with 15 additions and 12 deletions.
  1. +6 −4 .github/workflows/tests.yml
  2. +2 −2 CHANGELOG.md
  3. +3 −1 src/lib.rs
  4. +1 −0 src/use_file.rs
  5. +3 −5 src/util_libc.rs
10 changes: 6 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -171,9 +171,11 @@ jobs:
matrix:
target: [
sparcv9-sun-solaris,
x86_64-unknown-illumos,
x86_64-unknown-freebsd,
x86_64-unknown-netbsd,
# These jobs currently result in a linking error:
# https://github.com/rust-random/getrandom/actions/runs/3835874649/jobs/6529484986
# x86_64-unknown-illumos,
# x86_64-unknown-freebsd,
# x86_64-unknown-netbsd,
]
steps:
- uses: actions/checkout@v3
@@ -198,7 +200,7 @@ jobs:
host: x86_64-unknown-linux-musl
- os: windows-2022
host: x86_64-pc-windows-msvc
# Reenable when Safari tests start working
# Re-enable when Safari tests start working
# - os: macos-12
# host: x86_64-apple-darwin
runs-on: ${{ matrix.os }}
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -104,7 +104,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.2.2] - 2021-01-19
### Changed
- Forward `rustc-dep-of-std` to dependencies. [#198]
- Highlight feature-dependend functionality in documentation using the `doc_cfg` feature. [#200]
- Highlight feature-dependent functionality in documentation using the `doc_cfg` feature. [#200]

[#198]: https://github.com/rust-random/getrandom/pull/198
[#200]: https://github.com/rust-random/getrandom/pull/200
@@ -234,7 +234,7 @@ disabled `dummy` feature. [#90]
## [0.1.9] - 2019-08-14 [YANKED]
### Changed
- Remove `std` dependency for opening and reading files. [#58]
- Use `wasi` isntead of `libc` on WASI target. [#64]
- Use `wasi` instead of `libc` on WASI target. [#64]
- By default emit a compile-time error when built for an unsupported target.
This behaviour can be disabled by using the `dummy` feature. [#71]

4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@
//! | SOLID | `*-kmc-solid_*` | `SOLID_RNG_SampleRandomBytes`
//! | Nintendo 3DS | `armv6k-nintendo-3ds` | [`getrandom`][1]
//! | QNX Neutrino | `*‑nto-qnx*` | [`/dev/urandom`][14] (identical to `/dev/random`)
//! | AIX | `*-ibm-aix` | [`/dev/urandom`][15]
//!
//! There is no blanket implementation on `unix` targets that reads from
//! `/dev/urandom`. This ensures all supported targets are using the recommended
@@ -162,6 +163,7 @@
//! [12]: https://docs.oracle.com/cd/E86824_01/html/E54777/random-7d.html
//! [13]: https://github.com/emscripten-core/emscripten/pull/12240
//! [14]: https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.utilities/topic/r/random.html
//! [15]: https://www.ibm.com/docs/en/aix/7.3?topic=files-random-urandom-devices
//!
//! [`BCryptGenRandom`]: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom
//! [`Crypto.getRandomValues`]: https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues
@@ -211,7 +213,7 @@ pub use crate::error::Error;
// The function MUST NOT ever write uninitialized bytes into `dest`,
// regardless of what value it returns.
cfg_if! {
if #[cfg(any(target_os = "haiku", target_os = "redox", target_os = "nto"))] {
if #[cfg(any(target_os = "haiku", target_os = "redox", target_os = "nto", target_os = "aix"))] {
mod util_libc;
#[path = "use_file.rs"] mod imp;
} else if #[cfg(any(target_os = "android", target_os = "linux"))] {
1 change: 1 addition & 0 deletions src/use_file.rs
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ use core::{
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
const FILE_PATH: &str = "/dev/random\0";
#[cfg(any(
target_os = "aix",
target_os = "android",
target_os = "linux",
target_os = "redox",
8 changes: 3 additions & 5 deletions src/util_libc.rs
Original file line number Diff line number Diff line change
@@ -34,6 +34,8 @@ cfg_if! {
fn __errno() -> *mut libc::c_int;
}
use __errno as errno_location;
} else if #[cfg(target_os = "aix")] {
use libc::_Errno as errno_location;
}
}

@@ -139,11 +141,7 @@ impl Weak {
}

cfg_if! {
if #[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "emscripten"))] {
use libc::open64 as open;
} else {
use libc::open;
}
use libc::open;
}

// SAFETY: path must be null terminated, FD must be manually closed.