|
5 | 5 | // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your |
6 | 6 | // option. This file may not be copied, modified, or distributed |
7 | 7 | // except according to those terms. |
| 8 | +#![no_std] |
| 9 | + |
| 10 | +#[cfg(not(target_env = "sgx"))] |
| 11 | +#[macro_use] extern crate std; |
| 12 | + |
| 13 | +#[cfg(any( |
| 14 | + target_os = "android", |
| 15 | + target_os = "netbsd", |
| 16 | + target_os = "solaris", |
| 17 | + target_os = "redox", |
| 18 | + target_os = "dragonfly", |
| 19 | + target_os = "haiku", |
| 20 | + target_os = "emscripten", |
| 21 | + target_os = "linux", |
| 22 | +))] |
| 23 | +mod utils; |
| 24 | +mod error; |
| 25 | +pub use error::{Error, UNKNOWN_ERROR, UNAVAILABLE_ERROR}; |
| 26 | + |
| 27 | +macro_rules! mod_use { |
| 28 | + ($cond:meta, $module:ident) => { |
| 29 | + #[$cond] |
| 30 | + mod $module; |
| 31 | + #[$cond] |
| 32 | + pub use $module::getrandom; |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | +mod_use!(cfg(target_os = "android"), linux_android); |
| 37 | +mod_use!(cfg(target_os = "bitrig"), openbsd_bitrig); |
| 38 | +mod_use!(cfg(target_os = "cloudabi"), cloudabi); |
| 39 | +mod_use!(cfg(target_os = "dragonfly"), dragonfly_haiku); |
| 40 | +mod_use!(cfg(target_os = "emscripten"), emscripten); |
| 41 | +mod_use!(cfg(target_os = "freebsd"), freebsd); |
| 42 | +mod_use!(cfg(target_os = "fuchsia"), fuchsia); |
| 43 | +mod_use!(cfg(target_os = "haiku"), dragonfly_haiku); |
| 44 | +mod_use!(cfg(target_os = "ios"), macos); |
| 45 | +mod_use!(cfg(target_os = "linux"), linux_android); |
| 46 | +mod_use!(cfg(target_os = "macos"), macos); |
| 47 | +mod_use!(cfg(target_os = "netbsd"), netbsd); |
| 48 | +mod_use!(cfg(target_os = "openbsd"), openbsd_bitrig); |
| 49 | +mod_use!(cfg(target_os = "redox"), redox); |
| 50 | +mod_use!(cfg(target_os = "solaris"), solaris); |
| 51 | +mod_use!(cfg(windows), windows); |
| 52 | +mod_use!(cfg(target_env = "sgx"), sgx); |
| 53 | + |
| 54 | +mod_use!( |
| 55 | + cfg(all( |
| 56 | + target_arch = "wasm32", |
| 57 | + not(target_os = "emscripten"), |
| 58 | + feature = "wasm-bindgen" |
| 59 | + )), |
| 60 | + wasm32_bindgen |
| 61 | +); |
| 62 | + |
| 63 | +mod_use!( |
| 64 | + cfg(all( |
| 65 | + target_arch = "wasm32", |
| 66 | + not(target_os = "emscripten"), |
| 67 | + not(feature = "wasm-bindgen"), |
| 68 | + feature = "stdweb", |
| 69 | + )), |
| 70 | + wasm32_stdweb |
| 71 | +); |
| 72 | + |
| 73 | +mod_use!( |
| 74 | + cfg(not(any( |
| 75 | + target_os = "android", |
| 76 | + target_os = "bitrig", |
| 77 | + target_os = "cloudabi", |
| 78 | + target_os = "dragonfly", |
| 79 | + target_os = "emscripten", |
| 80 | + target_os = "freebsd", |
| 81 | + target_os = "fuchsia", |
| 82 | + target_os = "haiku", |
| 83 | + target_os = "ios", |
| 84 | + target_os = "linux", |
| 85 | + target_os = "macos", |
| 86 | + target_os = "netbsd", |
| 87 | + target_os = "openbsd", |
| 88 | + target_os = "redox", |
| 89 | + target_os = "solaris", |
| 90 | + target_env = "sgx", |
| 91 | + windows, |
| 92 | + all( |
| 93 | + target_arch = "wasm32", |
| 94 | + any( |
| 95 | + target_os = "emscripten", |
| 96 | + feature = "wasm-bindgen", |
| 97 | + feature = "stdweb", |
| 98 | + ), |
| 99 | + ), |
| 100 | + ))), |
| 101 | + dummy |
| 102 | +); |
0 commit comments