@@ -17,7 +17,6 @@ pub fn hashmap_random_keys() -> (u64, u64) {
1717 not( target_os = "tvos" ) ,
1818 not( target_os = "watchos" ) ,
1919 not( target_os = "openbsd" ) ,
20- not( target_os = "freebsd" ) ,
2120 not( target_os = "netbsd" ) ,
2221 not( target_os = "fuchsia" ) ,
2322 not( target_os = "redox" ) ,
@@ -68,11 +67,25 @@ mod imp {
6867 unsafe { libc:: getrandom ( buf. as_mut_ptr ( ) . cast ( ) , buf. len ( ) , 0 ) }
6968 }
7069
70+ #[ cfg( target_os = "freebsd" ) ]
71+ fn getrandom ( buf : & mut [ u8 ] ) -> libc:: ssize_t {
72+ // FIXME: using the above when libary std's libc is updated
73+ extern "C" {
74+ fn getrandom (
75+ buffer : * mut libc:: c_void ,
76+ length : libc:: size_t ,
77+ flags : libc:: c_uint ,
78+ ) -> libc:: ssize_t ;
79+ }
80+ unsafe { getrandom ( buf. as_mut_ptr ( ) . cast ( ) , buf. len ( ) , 0 ) }
81+ }
82+
7183 #[ cfg( not( any(
7284 target_os = "linux" ,
7385 target_os = "android" ,
7486 target_os = "espidf" ,
75- target_os = "horizon"
87+ target_os = "horizon" ,
88+ target_os = "freebsd"
7689 ) ) ) ]
7790 fn getrandom_fill_bytes ( _buf : & mut [ u8 ] ) -> bool {
7891 false
@@ -82,7 +95,8 @@ mod imp {
8295 target_os = "linux" ,
8396 target_os = "android" ,
8497 target_os = "espidf" ,
85- target_os = "horizon"
98+ target_os = "horizon" ,
99+ target_os = "freebsd"
86100 ) ) ]
87101 fn getrandom_fill_bytes ( v : & mut [ u8 ] ) -> bool {
88102 use crate :: sync:: atomic:: { AtomicBool , Ordering } ;
@@ -222,7 +236,7 @@ mod imp {
222236 }
223237}
224238
225- #[ cfg( any ( target_os = "freebsd" , target_os = " netbsd") ) ]
239+ #[ cfg( target_os = "netbsd" ) ]
226240mod imp {
227241 use crate :: ptr;
228242
0 commit comments