File tree Expand file tree Collapse file tree 4 files changed +39
-1
lines changed Expand file tree Collapse file tree 4 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -314,6 +314,8 @@ jobs:
314314 run : cargo build -Z build-std=core --features=rdrand --target=x86_64-unknown-l4re-uclibc
315315 - name : VxWorks
316316 run : cargo build -Z build-std=core --target=x86_64-wrs-vxworks
317+ - name : SOLID
318+ run : cargo build -Z build-std=core --target=aarch64-kmc-solid_asp3
317319
318320 clippy-fmt :
319321 name : Clippy + rustfmt
Original file line number Diff line number Diff line change @@ -73,7 +73,14 @@ impl Error {
7373 #[ inline]
7474 pub fn raw_os_error ( self ) -> Option < i32 > {
7575 if self . 0 . get ( ) < Self :: INTERNAL_START {
76- Some ( self . 0 . get ( ) as i32 )
76+ match ( ) {
77+ #[ cfg( target_os = "solid_asp3" ) ]
78+ // On SOLID, negate the error code again to obtain the original
79+ // error code.
80+ ( ) => Some ( -( self . 0 . get ( ) as i32 ) ) ,
81+ #[ cfg( not( target_os = "solid_asp3" ) ) ]
82+ ( ) => Some ( self . 0 . get ( ) as i32 ) ,
83+ }
7784 } else {
7885 None
7986 }
Original file line number Diff line number Diff line change 3030//! | WASI | `wasm32‑wasi` | [`random_get`][17]
3131//! | Web Browser | `wasm32‑*‑unknown` | [`Crypto.getRandomValues()`][14], see [WebAssembly support][16]
3232//! | Node.js | `wasm32‑*‑unknown` | [`crypto.randomBytes`][15], see [WebAssembly support][16]
33+ //! | SOLID | `*-kmc-solid_*` | `SOLID_RNG_SampleRandomBytes`
3334//!
3435//! There is no blanket implementation on `unix` targets that reads from
3536//! `/dev/urandom`. This ensures all supported targets are using the recommended
@@ -203,6 +204,8 @@ cfg_if! {
203204 } else if #[ cfg( target_os = "vxworks" ) ] {
204205 mod util_libc;
205206 #[ path = "vxworks.rs" ] mod imp;
207+ } else if #[ cfg( target_os = "solid_asp3" ) ] {
208+ #[ path = "solid.rs" ] mod imp;
206209 } else if #[ cfg( windows) ] {
207210 #[ path = "windows.rs" ] mod imp;
208211 } else if #[ cfg( all( target_arch = "x86_64" , target_env = "sgx" ) ) ] {
Original file line number Diff line number Diff line change 1+ // Copyright 2021 Developers of the Rand project.
2+ //
3+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4+ // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5+ // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6+ // option. This file may not be copied, modified, or distributed
7+ // except according to those terms.
8+
9+ //! Implementation for SOLID
10+ use crate :: Error ;
11+ use core:: num:: NonZeroU32 ;
12+
13+ extern "C" {
14+ pub fn SOLID_RNG_SampleRandomBytes ( buffer : * mut u8 , length : usize ) -> i32 ;
15+ }
16+
17+ pub fn getrandom_inner ( dest : & mut [ u8 ] ) -> Result < ( ) , Error > {
18+ let ret = unsafe { SOLID_RNG_SampleRandomBytes ( dest. as_mut_ptr ( ) , dest. len ( ) ) } ;
19+ if ret >= 0 {
20+ Ok ( ( ) )
21+ } else {
22+ // ITRON error numbers are always negative, so we negate it so that it
23+ // falls in the dedicated OS error range (1..INTERNAL_START).
24+ Err ( NonZeroU32 :: new ( ( -ret) as u32 ) . unwrap ( ) . into ( ) )
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments