@@ -16,7 +16,6 @@ pub fn hashmap_random_keys() -> (u64, u64) {
16
16
not( target_os = "ios" ) ,
17
17
not( target_os = "watchos" ) ,
18
18
not( target_os = "openbsd" ) ,
19
- not( target_os = "freebsd" ) ,
20
19
not( target_os = "netbsd" ) ,
21
20
not( target_os = "fuchsia" ) ,
22
21
not( target_os = "redox" ) ,
@@ -65,11 +64,25 @@ mod imp {
65
64
unsafe { libc:: getrandom ( buf. as_mut_ptr ( ) . cast ( ) , buf. len ( ) , 0 ) }
66
65
}
67
66
67
+ #[ cfg( target_os = "freebsd" ) ]
68
+ fn getrandom ( buf : & mut [ u8 ] ) -> libc:: ssize_t {
69
+ // FIXME: using the above when libary std's libc is updated
70
+ extern "C" {
71
+ fn getrandom (
72
+ buffer : * mut libc:: c_void ,
73
+ length : libc:: size_t ,
74
+ flags : libc:: c_uint ,
75
+ ) -> libc:: ssize_t ;
76
+ }
77
+ unsafe { getrandom ( buf. as_mut_ptr ( ) . cast ( ) , buf. len ( ) , 0 ) }
78
+ }
79
+
68
80
#[ cfg( not( any(
69
81
target_os = "linux" ,
70
82
target_os = "android" ,
71
83
target_os = "espidf" ,
72
- target_os = "horizon"
84
+ target_os = "horizon" ,
85
+ target_os = "freebsd"
73
86
) ) ) ]
74
87
fn getrandom_fill_bytes ( _buf : & mut [ u8 ] ) -> bool {
75
88
false
@@ -79,7 +92,8 @@ mod imp {
79
92
target_os = "linux" ,
80
93
target_os = "android" ,
81
94
target_os = "espidf" ,
82
- target_os = "horizon"
95
+ target_os = "horizon" ,
96
+ target_os = "freebsd"
83
97
) ) ]
84
98
fn getrandom_fill_bytes ( v : & mut [ u8 ] ) -> bool {
85
99
use crate :: sync:: atomic:: { AtomicBool , Ordering } ;
@@ -219,7 +233,7 @@ mod imp {
219
233
}
220
234
}
221
235
222
- #[ cfg( any ( target_os = "freebsd" , target_os = " netbsd") ) ]
236
+ #[ cfg( target_os = "netbsd" ) ]
223
237
mod imp {
224
238
use crate :: ptr;
225
239
0 commit comments