Skip to content

Commit b3e609f

Browse files
josephlrnewpavlov
authored andcommitted
Add support for hermit and l4re (#61)
1 parent 9e0d7c7 commit b3e609f

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

.travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ matrix:
123123
# - cargo build --target=x86_64-unknown-redox --all-features
124124
- cargo build --target=x86_64-fortanix-unknown-sgx --all-features
125125
- cargo xbuild --target=x86_64-unknown-uefi
126+
- cargo xbuild --target=x86_64-unknown-hermit
127+
- cargo xbuild --target=x86_64-unknown-l4re-uclibc
126128
# also test minimum dependency versions are usable
127129
- cargo generate-lockfile -Z minimal-versions
128130
- cargo build --target=x86_64-sun-solaris --all-features
@@ -133,6 +135,8 @@ matrix:
133135
# - cargo build --target=x86_64-unknown-redox --all-features
134136
- cargo build --target=x86_64-fortanix-unknown-sgx --all-features
135137
- cargo xbuild --target=x86_64-unknown-uefi
138+
- cargo xbuild --target=x86_64-unknown-hermit
139+
- cargo xbuild --target=x86_64-unknown-l4re-uclibc
136140

137141
# Trust cross-built/emulated targets. We must repeat all non-default values.
138142
- rust: stable

src/lib.rs

+38-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
//! | Redox | [`rand:`][12]
2626
//! | CloudABI | [`cloudabi_sys_random_get`][13]
2727
//! | Haiku | `/dev/random` (identical to `/dev/urandom`)
28-
//! | SGX, UEFI | [RDRAND][18]
28+
//! | L4RE, SGX, UEFI | [RDRAND][18]
29+
//! | Hermit | [RDRAND][18] as [`sys_rand`][22] is currently broken.
2930
//! | Web browsers | [`Crypto.getRandomValues`][14] (see [Support for WebAssembly and ams.js][14])
3031
//! | Node.js | [`crypto.randomBytes`][15] (see [Support for WebAssembly and ams.js][16])
3132
//! | WASI | [`__wasi_random_get`][17]
@@ -119,6 +120,7 @@
119120
//! [19]: https://www.unix.com/man-page/mojave/2/getentropy/
120121
//! [20]: https://www.unix.com/man-page/mojave/4/random/
121122
//! [21]: https://www.freebsd.org/cgi/man.cgi?query=getrandom&manpath=FreeBSD+12.0-stable
123+
//! [22]: https://github.com/hermitcore/libhermit-rs/blob/09c38b0371cee6f56a541400ba453e319e43db53/src/syscalls/random.rs#L21
122124
123125
#![doc(
124126
html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
@@ -152,12 +154,39 @@ pub use crate::error::Error;
152154

153155
#[allow(dead_code)]
154156
mod util;
155-
#[cfg(any(unix, target_os = "redox"))]
157+
#[cfg(any(
158+
target_os = "android",
159+
target_os = "dragonfly",
160+
target_os = "emscripten",
161+
target_os = "freebsd",
162+
target_os = "haiku",
163+
target_os = "illumos",
164+
target_os = "linux",
165+
target_os = "macos",
166+
target_os = "netbsd",
167+
target_os = "openbsd",
168+
target_os = "redox",
169+
target_os = "solaris",
170+
))]
156171
#[allow(dead_code)]
157172
mod util_libc;
158173

159174
// std-only trait definitions (also need for use_file)
160-
#[cfg(any(feature = "std", unix, target_os = "redox"))]
175+
#[cfg(any(
176+
feature = "std",
177+
target_os = "android",
178+
target_os = "dragonfly",
179+
target_os = "emscripten",
180+
target_os = "freebsd",
181+
target_os = "haiku",
182+
target_os = "illumos",
183+
target_os = "linux",
184+
target_os = "macos",
185+
target_os = "netbsd",
186+
target_os = "openbsd",
187+
target_os = "redox",
188+
target_os = "solaris",
189+
))]
161190
mod error_impls;
162191

163192
// These targets read from a file as a fallback method.
@@ -209,9 +238,12 @@ cfg_if! {
209238
#[path = "wasi.rs"] mod imp;
210239
} else if #[cfg(windows)] {
211240
#[path = "windows.rs"] mod imp;
212-
} else if #[cfg(target_env = "sgx")] {
213-
#[path = "rdrand.rs"] mod imp;
214-
} else if #[cfg(all(target_arch = "x86_64", target_os = "uefi"))] {
241+
} else if #[cfg(all(target_arch = "x86_64", any(
242+
target_os = "hermit",
243+
target_os = "l4re",
244+
target_os = "uefi",
245+
target_env = "sgx",
246+
)))] {
215247
#[path = "rdrand.rs"] mod imp;
216248
} else if #[cfg(target_arch = "wasm32")] {
217249
cfg_if! {

0 commit comments

Comments
 (0)