From be1d0ad0b4683bf10c2491518a60868cb3b077cc Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Tue, 29 Aug 2023 19:45:37 +0000 Subject: [PATCH] Add GNU/Hurd support Signed-off-by: Samuel Thibault --- .github/workflows/tests.yml | 2 ++ src/lib.rs | 3 ++- src/use_file.rs | 1 + src/util_libc.rs | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 13fe973f..02769ae7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -303,6 +303,8 @@ jobs: # `std` support still in progress. Can be moved up with the other # apple targets after https://github.com/rust-lang/rust/pull/103503 aarch64-apple-tvos, + # `std` support being commited, see https://github.com/rust-lang/rust/pull/116527 + i686-unknown-hurd-gnu, ] include: # Supported tier 3 targets with libstd support diff --git a/src/lib.rs b/src/lib.rs index fbfe7295..17fb62e2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,6 +25,7 @@ //! | Redox | `*‑redox` | `/dev/urandom` //! | Haiku | `*‑haiku` | `/dev/urandom` (identical to `/dev/random`) //! | Hermit | `*-hermit` | [`sys_read_entropy`] +//! | Hurd | `*-hurd-gnu` | `/dev/urandom` //! | SGX | `x86_64‑*‑sgx` | [`RDRAND`] //! | VxWorks | `*‑wrs‑vxworks‑*` | `randABytes` after checking entropy pool initialization with `randSecure` //! | ESP-IDF | `*‑espidf` | [`esp_fill_random`] @@ -216,7 +217,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", target_os = "aix"))] { + if #[cfg(any(target_os = "haiku", target_os = "hurd", 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"))] { diff --git a/src/use_file.rs b/src/use_file.rs index a6ef0d23..d867aa97 100644 --- a/src/use_file.rs +++ b/src/use_file.rs @@ -31,6 +31,7 @@ const FILE_PATH: &str = "/dev/random\0"; target_os = "redox", target_os = "dragonfly", target_os = "haiku", + target_os = "hurd", target_os = "macos", target_os = "nto", ))] diff --git a/src/util_libc.rs b/src/util_libc.rs index 4b94144d..99bee382 100644 --- a/src/util_libc.rs +++ b/src/util_libc.rs @@ -19,7 +19,7 @@ use libc::c_void; cfg_if! { if #[cfg(any(target_os = "netbsd", target_os = "openbsd", target_os = "android"))] { use libc::__errno as errno_location; - } else if #[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "redox"))] { + } else if #[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "hurd", target_os = "redox"))] { use libc::__errno_location as errno_location; } else if #[cfg(any(target_os = "solaris", target_os = "illumos"))] { use libc::___errno as errno_location;