@@ -186,11 +186,10 @@ mod imp {
186186 }
187187
188188 #[ cfg( all( target_os = "linux" ,
189- any( target_arch = "x86_64" ,
190- target_arch = "x86" ,
191- target_arch = "arm" ,
192- target_arch = "aarch64" ,
193- target_arch = "powerpc" ) ) ) ]
189+ any( target_arch = "x86_64" , target_arch = "x86" ,
190+ target_arch = "arm" , target_arch = "aarch64" ,
191+ target_arch = "s390x" , target_arch = "powerpc" ,
192+ target_arch = "mips" , target_arch = "mips64" ) ) ) ]
194193 fn getrandom ( buf : & mut [ u8 ] ) -> libc:: c_long {
195194 extern "C" {
196195 fn syscall ( number : libc:: c_long , ...) -> libc:: c_long ;
@@ -204,16 +203,29 @@ mod imp {
204203 const NR_GETRANDOM : libc:: c_long = 384 ;
205204 #[ cfg( target_arch = "aarch64" ) ]
206205 const NR_GETRANDOM : libc:: c_long = 278 ;
206+ #[ cfg( target_arch = "s390x" ) ]
207+ const NR_GETRANDOM : libc:: c_long = 349 ;
207208 #[ cfg( target_arch = "powerpc" ) ]
208- const NR_GETRANDOM : libc:: c_long = 384 ;
209-
209+ const NR_GETRANDOM : libc:: c_long = 359 ;
210+ #[ cfg( target_arch = "mips" ) ]
211+ const NR_GETRANDOM : libc:: c_long = 4353 ;
212+ #[ cfg( target_arch = "mips64" ) ]
213+ const NR_GETRANDOM : libc:: c_long = 5313 ;
214+
210215 const GRND_NONBLOCK : libc:: c_uint = 0x0001 ;
211216
212217 unsafe {
213218 syscall ( NR_GETRANDOM , buf. as_mut_ptr ( ) , buf. len ( ) , GRND_NONBLOCK )
214219 }
215220 }
216221
222+ #[ cfg( not( all( target_os = "linux" ,
223+ any( target_arch = "x86_64" , target_arch = "x86" ,
224+ target_arch = "arm" , target_arch = "aarch64" ,
225+ target_arch = "s390x" , target_arch = "powerpc" ,
226+ target_arch = "mips" , target_arch = "mips64" ) ) ) ) ]
227+ fn getrandom ( _buf : & mut [ u8 ] ) -> libc:: c_long { }
228+
217229 fn getrandom_try_fill ( dest : & mut [ u8 ] ) -> Result < ( ) , Error > {
218230 trace ! ( "OsRng: reading {} bytes via getrandom" , dest. len( ) ) ;
219231 let mut read = 0 ;
@@ -249,11 +261,10 @@ mod imp {
249261 }
250262
251263 #[ cfg( all( target_os = "linux" ,
252- any( target_arch = "x86_64" ,
253- target_arch = "x86" ,
254- target_arch = "arm" ,
255- target_arch = "aarch64" ,
256- target_arch = "powerpc" ) ) ) ]
264+ any( target_arch = "x86_64" , target_arch = "x86" ,
265+ target_arch = "arm" , target_arch = "aarch64" ,
266+ target_arch = "s390x" , target_arch = "powerpc" ,
267+ target_arch = "mips" , target_arch = "mips64" ) ) ) ]
257268 fn is_getrandom_available ( ) -> bool {
258269 use std:: sync:: atomic:: { AtomicBool , ATOMIC_BOOL_INIT , Ordering } ;
259270 use std:: sync:: { Once , ONCE_INIT } ;
@@ -279,11 +290,10 @@ mod imp {
279290 }
280291
281292 #[ cfg( not( all( target_os = "linux" ,
282- any( target_arch = "x86_64" ,
283- target_arch = "x86" ,
284- target_arch = "arm" ,
285- target_arch = "aarch64" ,
286- target_arch = "powerpc" ) ) ) ) ]
293+ any( target_arch = "x86_64" , target_arch = "x86" ,
294+ target_arch = "arm" , target_arch = "aarch64" ,
295+ target_arch = "s390x" , target_arch = "powerpc" ,
296+ target_arch = "mips" , target_arch = "mips64" ) ) ) ) ]
287297 fn is_getrandom_available ( ) -> bool { false }
288298
289299 // TODO: remove outer Option when `Mutex::new(None)` is a constant expression
0 commit comments