|
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,48 @@ 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 = "linux_disable_fallback"), |
| 228 | + any( |
| 229 | + // Rust supports Android API level 19 (KitKat) [0] and the next upgrade targets |
| 230 | + // level 21 (Lollipop) [1], while `getrandom(2)` was added only in |
| 231 | + // level 23 (Marshmallow). Note that it applies only to the "old" `target_arch`es, |
| 232 | + // RISC-V Android targets sufficiently new API level, same will apply for potential |
| 233 | + // new Android `target_arch`es. |
| 234 | + // [0]: https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html |
| 235 | + // [1]: https://github.com/rust-lang/rust/pull/120593 |
| 236 | + all( |
| 237 | + target_os = "android", |
| 238 | + any( |
| 239 | + target_arch = "aarch64", |
| 240 | + target_arch = "arm", |
| 241 | + target_arch = "x86", |
| 242 | + target_arch = "x86_64", |
| 243 | + ), |
| 244 | + ), |
| 245 | + // Only on these `target_arch`es Rust supports Linux kernel versions (3.2+) |
| 246 | + // that precede the version (3.17) in which `getrandom(2)` was added: |
| 247 | + // https://doc.rust-lang.org/stable/rustc/platform-support.html |
| 248 | + all( |
| 249 | + target_os = "linux", |
| 250 | + any( |
| 251 | + target_arch = "aarch64", |
| 252 | + target_arch = "arm", |
| 253 | + target_arch = "powerpc", |
| 254 | + target_arch = "powerpc64", |
| 255 | + target_arch = "s390x", |
| 256 | + target_arch = "x86", |
| 257 | + target_arch = "x86_64", |
| 258 | + ), |
| 259 | + ) |
| 260 | + ), |
| 261 | + ))] { |
224 | 262 | mod util_libc;
|
225 | 263 | mod use_file;
|
226 | 264 | mod lazy;
|
| 265 | + #[path = "linux_android_with_fallback.rs"] mod imp; |
| 266 | + } else if #[cfg(any(target_os = "android", target_os = "linux"))] { |
| 267 | + mod util_libc; |
227 | 268 | #[path = "linux_android.rs"] mod imp;
|
228 | 269 | } else if #[cfg(any(target_os = "illumos", target_os = "solaris"))] {
|
229 | 270 | mod util_libc;
|
|
0 commit comments