From 714e25217901097efb17e81d6c4de0c29efabb1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E9=80=B8?= Date: Tue, 22 Apr 2025 19:39:39 +0800 Subject: [PATCH 1/2] Backport cygwin support Co-authored-by: Ookiineko --- src/lib.rs | 4 ++++ src/util_libc.rs | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index bc3695b6..22bffd32 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,6 +30,7 @@ //! | PS Vita | `*-vita-*` | [`getentropy`][13] //! | QNX Neutrino | `*‑nto-qnx*` | [`/dev/urandom`][14] (identical to `/dev/random`) //! | AIX | `*-ibm-aix` | [`/dev/urandom`][15] +//! | Cygwin | `*-cygwin` | [`getrandom`][19] (based on [`RtlGenRandom`]) //! //! Pull Requests that add support for new targets to `getrandom` are always welcome. //! @@ -181,8 +182,10 @@ //! [16]: https://man.netbsd.org/getrandom.2 //! [17]: https://www.gnu.org/software/libc/manual/html_mono/libc.html#index-getrandom //! [18]: https://github.com/rust3ds/shim-3ds/commit/b01d2568836dea2a65d05d662f8e5f805c64389d +//! [19]: https://github.com/cygwin/cygwin/blob/main/winsup/cygwin/libc/getentropy.cc //! //! [`BCryptGenRandom`]: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom +//! [`RtlGenRandom`]: https://learn.microsoft.com/en-us/windows/win32/api/ntsecapi/nf-ntsecapi-rtlgenrandom //! [`Crypto.getRandomValues`]: https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues //! [`RDRAND`]: https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide //! [`CCRandomGenerateBytes`]: https://opensource.apple.com/source/CommonCrypto/CommonCrypto-60074/include/CommonRandom.h.auto.html @@ -251,6 +254,7 @@ cfg_if! { // Check for target_arch = "arm" to only include the 3DS. Does not // include the Nintendo Switch (which is target_arch = "aarch64"). all(target_os = "horizon", target_arch = "arm"), + target_os = "cygwin", ))] { mod util_libc; #[path = "getrandom.rs"] mod imp; diff --git a/src/util_libc.rs b/src/util_libc.rs index 129362d5..f488b415 100644 --- a/src/util_libc.rs +++ b/src/util_libc.rs @@ -9,7 +9,7 @@ use core::{ use libc::c_void; cfg_if! { - if #[cfg(any(target_os = "netbsd", target_os = "openbsd", target_os = "android"))] { + if #[cfg(any(target_os = "netbsd", target_os = "openbsd", target_os = "android", target_os = "cygwin"))] { use libc::__errno as errno_location; } else if #[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "hurd", target_os = "redox", target_os = "dragonfly"))] { use libc::__errno_location as errno_location; From c261d84c37cb685caf02c5c406480ba2be52af06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E9=80=B8?= Date: Tue, 22 Apr 2025 19:42:17 +0800 Subject: [PATCH 2/2] Add changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6763b58..b20634ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.16] - 2025-04-22 +### Added +- Backport cygwin support [#654] + +[#654]: https://github.com/rust-random/getrandom/pull/654 + ## [0.2.15] - 2024-05-06 ### Added - Apple visionOS support [#410]