|
99 | 99 | //! This crate will then use the provided `webcrypto` implementation.
|
100 | 100 | //!
|
101 | 101 | //! ### Platform Support
|
102 |
| -//! This crate generally supports the same operating system and platform versions that the Rust standard library does. |
103 |
| -//! Additional targets may be supported using pluggable custom implementations. |
| 102 | +//! This crate generally supports the same operating system and platform versions |
| 103 | +//! that the Rust standard library does. Additional targets may be supported using |
| 104 | +//! pluggable custom implementations. |
104 | 105 | //!
|
105 |
| -//! This means that as Rust drops support for old versions of operating systems (such as old Linux kernel versions, Android API levels, etc) |
106 |
| -//! in stable releases, `getrandom` may create new patch releases (`0.N.x`) that remove support for outdated platform versions. |
| 106 | +//! This means that as Rust drops support for old versions of operating systems |
| 107 | +//! (such as old Linux kernel versions, Android API levels, etc) in stable releases, |
| 108 | +//! `getrandom` may create new patch releases (`0.N.x`) that remove support for |
| 109 | +//! outdated platform versions. |
107 | 110 | //!
|
108 | 111 | //! ### Custom implementations
|
109 | 112 | //!
|
@@ -220,10 +223,35 @@ cfg_if! {
|
220 | 223 | if #[cfg(any(target_os = "haiku", target_os = "redox", target_os = "nto", target_os = "aix"))] {
|
221 | 224 | mod util_libc;
|
222 | 225 | #[path = "use_file.rs"] mod imp;
|
223 |
| - } else if #[cfg(any(target_os = "android", target_os = "linux"))] { |
| 226 | + } else if #[cfg(all( |
| 227 | + not(feature = "disable_urandom_fallback"), |
| 228 | + any( |
| 229 | + // Rust supports Android API level 19 (KitKat) [0], while `getrandom(2)` |
| 230 | + // was added only in level 23 (Marshmallow). |
| 231 | + // [0]: https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html |
| 232 | + target_os = "android", |
| 233 | + all( |
| 234 | + target_os = "linux", |
| 235 | + // Only on these `target_arch`es Rust supports Linux kernel versions (3.2+) |
| 236 | + // that precede the version (3.17) in which `getrandom(2)` was added: |
| 237 | + // https://doc.rust-lang.org/stable/rustc/platform-support.html |
| 238 | + any( |
| 239 | + target_arch = "arm", |
| 240 | + target_arch = "powerpc", |
| 241 | + target_arch = "powerpc64", |
| 242 | + target_arch = "s390x", |
| 243 | + target_arch = "x86", |
| 244 | + target_arch = "x86_64", |
| 245 | + ), |
| 246 | + ) |
| 247 | + ), |
| 248 | + ))] { |
224 | 249 | mod util_libc;
|
225 | 250 | mod use_file;
|
226 | 251 | mod lazy;
|
| 252 | + #[path = "linux_with_fallback.rs"] mod imp; |
| 253 | + } else if #[cfg(any(target_os = "android", target_os = "linux"))] { |
| 254 | + mod util_libc; |
227 | 255 | #[path = "linux_android.rs"] mod imp;
|
228 | 256 | } else if #[cfg(any(target_os = "illumos", target_os = "solaris"))] {
|
229 | 257 | mod util_libc;
|
|
0 commit comments