@@ -17,7 +17,6 @@ pub fn hashmap_random_keys() -> (u64, u64) {
17
17
not( target_os = "tvos" ) ,
18
18
not( target_os = "watchos" ) ,
19
19
not( target_os = "openbsd" ) ,
20
- not( target_os = "freebsd" ) ,
21
20
not( target_os = "netbsd" ) ,
22
21
not( target_os = "fuchsia" ) ,
23
22
not( target_os = "redox" ) ,
@@ -68,11 +67,25 @@ mod imp {
68
67
unsafe { libc:: getrandom ( buf. as_mut_ptr ( ) . cast ( ) , buf. len ( ) , 0 ) }
69
68
}
70
69
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
+
71
83
#[ cfg( not( any(
72
84
target_os = "linux" ,
73
85
target_os = "android" ,
74
86
target_os = "espidf" ,
75
- target_os = "horizon"
87
+ target_os = "horizon" ,
88
+ target_os = "freebsd"
76
89
) ) ) ]
77
90
fn getrandom_fill_bytes ( _buf : & mut [ u8 ] ) -> bool {
78
91
false
@@ -82,7 +95,8 @@ mod imp {
82
95
target_os = "linux" ,
83
96
target_os = "android" ,
84
97
target_os = "espidf" ,
85
- target_os = "horizon"
98
+ target_os = "horizon" ,
99
+ target_os = "freebsd"
86
100
) ) ]
87
101
fn getrandom_fill_bytes ( v : & mut [ u8 ] ) -> bool {
88
102
use crate :: sync:: atomic:: { AtomicBool , Ordering } ;
@@ -222,7 +236,7 @@ mod imp {
222
236
}
223
237
}
224
238
225
- #[ cfg( any ( target_os = "freebsd" , target_os = " netbsd") ) ]
239
+ #[ cfg( target_os = "netbsd" ) ]
226
240
mod imp {
227
241
use crate :: ptr;
228
242
0 commit comments