Skip to content

Commit 3ba857b

Browse files
authored
Remove linux_android.rs and use getrandom.rs instead (#603)
1 parent ce3b017 commit 3ba857b

File tree

6 files changed

+21
-47
lines changed

6 files changed

+21
-47
lines changed

.github/workflows/nopanic.yaml

+2-7
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ jobs:
4242
- name: Check (linux_android_with_fallback.rs)
4343
run: (exit $( grep -c panic target/release/libgetrandom_wrapper.so ))
4444

45-
- name: Build (linux_android.rs)
45+
- name: Build (getrandom.rs)
4646
env:
4747
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_getrandom"
4848
run: cargo build --release
49-
- name: Check (linux_android.rs)
49+
- name: Check (getrandom.rs)
5050
run: (exit $( grep -c panic target/release/libgetrandom_wrapper.so ))
5151

5252
- name: Build (rdrand.rs)
@@ -98,11 +98,6 @@ jobs:
9898
- name: Check (rndr.rs)
9999
run: (exit $( grep -c panic target/aarch64-unknown-linux-gnu/release/libgetrandom_wrapper.so ))
100100

101-
- name: Build (getrandom.rs)
102-
run: cross build --release --target=x86_64-unknown-freebsd
103-
- name: Check (getrandom.rs)
104-
run: (exit $( grep -c panic target/x86_64-unknown-freebsd/release/libgetrandom_wrapper.so ))
105-
106101
- name: Build (netbsd.rs)
107102
run: cross build --release --target=x86_64-unknown-netbsd
108103
- name: Check (netbsd.rs)

.github/workflows/workspace.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ jobs:
4141
run: cargo clippy -Zbuild-std=core --target x86_64-unknown-fuchsia
4242
- name: OpenBSD (getentropy.rs)
4343
run: cargo clippy -Zbuild-std=core --target x86_64-unknown-openbsd
44-
- name: FreeBSD (getrandom.rs)
45-
run: cargo clippy -Zbuild-std=core --target x86_64-unknown-freebsd
4644
- name: Hermit (hermit.rs)
4745
run: cargo clippy -Zbuild-std=core --target x86_64-unknown-hermit
4846
- name: Web WASM (wasm_js.rs)
@@ -53,7 +51,7 @@ jobs:
5351
env:
5452
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="wasm_js" -Ctarget-feature=+atomics,+bulk-memory
5553
run: cargo clippy -Zbuild-std --target wasm32-unknown-unknown --features wasm_js
56-
- name: Linux (linux_android.rs)
54+
- name: Linux (getrandom.rs)
5755
env:
5856
RUSTFLAGS: -Dwarnings --cfg getrandom_backend="linux_getrandom"
5957
run: cargo clippy --target x86_64-unknown-linux-gnu

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ cfg-if = "1"
3030
compiler_builtins = { version = "0.1", optional = true }
3131
core = { version = "1.0", optional = true, package = "rustc-std-workspace-core" }
3232

33-
# linux_android / linux_android_with_fallback
33+
# getrandom / linux_android_with_fallback
3434
[target.'cfg(all(any(target_os = "linux", target_os = "android"), not(any(getrandom_backend = "custom", getrandom_backend = "rdrand", getrandom_backend = "rndr"))))'.dependencies]
3535
libc = { version = "0.2.154", default-features = false }
3636

src/backends.rs

+15-16
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ cfg_if! {
1111
mod custom;
1212
pub use custom::*;
1313
} else if #[cfg(getrandom_backend = "linux_getrandom")] {
14-
mod linux_android;
15-
pub use linux_android::*;
14+
mod getrandom;
15+
pub use getrandom::*;
1616
} else if #[cfg(getrandom_backend = "rdrand")] {
1717
mod rdrand;
1818
pub use rdrand::*;
@@ -51,17 +51,6 @@ cfg_if! {
5151
))] {
5252
mod getentropy;
5353
pub use getentropy::*;
54-
} else if #[cfg(any(
55-
target_os = "dragonfly",
56-
target_os = "freebsd",
57-
target_os = "hurd",
58-
target_os = "illumos",
59-
// Check for target_arch = "arm" to only include the 3DS. Does not
60-
// include the Nintendo Switch (which is target_arch = "aarch64").
61-
all(target_os = "horizon", target_arch = "arm"),
62-
))] {
63-
mod getrandom;
64-
pub use getrandom::*;
6554
} else if #[cfg(any(
6655
// Rust supports Android API level 19 (KitKat) [0] and the next upgrade targets
6756
// level 21 (Lollipop) [1], while `getrandom(2)` was added only in
@@ -102,9 +91,19 @@ cfg_if! {
10291
mod use_file;
10392
mod linux_android_with_fallback;
10493
pub use linux_android_with_fallback::*;
105-
} else if #[cfg(any(target_os = "android", target_os = "linux"))] {
106-
mod linux_android;
107-
pub use linux_android::*;
94+
} else if #[cfg(any(
95+
target_os = "android",
96+
target_os = "linux",
97+
target_os = "dragonfly",
98+
target_os = "freebsd",
99+
target_os = "hurd",
100+
target_os = "illumos",
101+
// Check for target_arch = "arm" to only include the 3DS. Does not
102+
// include the Nintendo Switch (which is target_arch = "aarch64").
103+
all(target_os = "horizon", target_arch = "arm"),
104+
))] {
105+
mod getrandom;
106+
pub use getrandom::*;
108107
} else if #[cfg(target_os = "solaris")] {
109108
mod solaris;
110109
pub use solaris::*;

src/backends/getrandom.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//! nothing. On illumos, the default pool is used to implement getentropy(2),
1717
//! so we assume it is acceptable here.
1818
use crate::Error;
19-
use core::{ffi::c_void, mem::MaybeUninit};
19+
use core::mem::MaybeUninit;
2020

2121
pub use crate::util::{inner_u32, inner_u64};
2222

@@ -26,6 +26,6 @@ mod util_libc;
2626
#[inline]
2727
pub fn fill_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
2828
util_libc::sys_fill_exact(dest, |buf| unsafe {
29-
libc::getrandom(buf.as_mut_ptr().cast::<c_void>(), buf.len(), 0)
29+
libc::getrandom(buf.as_mut_ptr().cast(), buf.len(), 0)
3030
})
3131
}

src/backends/linux_android.rs

-18
This file was deleted.

0 commit comments

Comments
 (0)