Skip to content

Commit a55ea8d

Browse files
authored
Backport Cygwin support (#654)
1 parent cf65e83 commit a55ea8d

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [0.2.16] - 2025-04-22
8+
### Added
9+
- Backport cygwin support [#654]
10+
11+
[#654]: https://github.com/rust-random/getrandom/pull/654
12+
713
## [0.2.15] - 2024-05-06
814
### Added
915
- Apple visionOS support [#410]

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
//! | PS Vita | `*-vita-*` | [`getentropy`][13]
3131
//! | QNX Neutrino | `*‑nto-qnx*` | [`/dev/urandom`][14] (identical to `/dev/random`)
3232
//! | AIX | `*-ibm-aix` | [`/dev/urandom`][15]
33+
//! | Cygwin | `*-cygwin` | [`getrandom`][19] (based on [`RtlGenRandom`])
3334
//!
3435
//! Pull Requests that add support for new targets to `getrandom` are always welcome.
3536
//!
@@ -181,8 +182,10 @@
181182
//! [16]: https://man.netbsd.org/getrandom.2
182183
//! [17]: https://www.gnu.org/software/libc/manual/html_mono/libc.html#index-getrandom
183184
//! [18]: https://github.com/rust3ds/shim-3ds/commit/b01d2568836dea2a65d05d662f8e5f805c64389d
185+
//! [19]: https://github.com/cygwin/cygwin/blob/main/winsup/cygwin/libc/getentropy.cc
184186
//!
185187
//! [`BCryptGenRandom`]: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom
188+
//! [`RtlGenRandom`]: https://learn.microsoft.com/en-us/windows/win32/api/ntsecapi/nf-ntsecapi-rtlgenrandom
186189
//! [`Crypto.getRandomValues`]: https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues
187190
//! [`RDRAND`]: https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide
188191
//! [`CCRandomGenerateBytes`]: https://opensource.apple.com/source/CommonCrypto/CommonCrypto-60074/include/CommonRandom.h.auto.html
@@ -251,6 +254,7 @@ cfg_if! {
251254
// Check for target_arch = "arm" to only include the 3DS. Does not
252255
// include the Nintendo Switch (which is target_arch = "aarch64").
253256
all(target_os = "horizon", target_arch = "arm"),
257+
target_os = "cygwin",
254258
))] {
255259
mod util_libc;
256260
#[path = "getrandom.rs"] mod imp;

src/util_libc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use core::{
99
use libc::c_void;
1010

1111
cfg_if! {
12-
if #[cfg(any(target_os = "netbsd", target_os = "openbsd", target_os = "android"))] {
12+
if #[cfg(any(target_os = "netbsd", target_os = "openbsd", target_os = "android", target_os = "cygwin"))] {
1313
use libc::__errno as errno_location;
1414
} else if #[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "hurd", target_os = "redox", target_os = "dragonfly"))] {
1515
use libc::__errno_location as errno_location;

0 commit comments

Comments
 (0)