}
}
-#[cfg(not(test))]
-pub fn init() {}
+// SAFETY: must be called only once during runtime initialization.
+// NOTE: this is not guaranteed to run, for example when Rust code is called externally.
+pub unsafe fn init(_argc: isize, _argv: *const *const u8) {
+ stack_overflow::init();
+}
+
+// SAFETY: must be called only once during runtime cleanup.
+// NOTE: this is not guaranteed to run, for example when the program aborts.
+pub unsafe fn cleanup() {
+ net::cleanup();
+}
pub fn decode_error_kind(errno: i32) -> ErrorKind {
match errno as c::DWORD {
| c::ERROR_IPSEC_IKE_TIMED_OUT
| c::ERROR_RUNLEVEL_SWITCH_TIMEOUT
| c::ERROR_RUNLEVEL_SWITCH_AGENT_TIMEOUT => return ErrorKind::TimedOut,
+ c::ERROR_CALL_NOT_IMPLEMENTED => return ErrorKind::Unsupported,
_ => {}
}
fn inner(s: &OsStr) -> crate::io::Result<Vec<u16>> {
let mut maybe_result: Vec<u16> = s.encode_wide().collect();
if unrolled_find_u16s(0, &maybe_result).is_some() {
- return Err(crate::io::Error::new(
+ return Err(crate::io::Error::new_const(
ErrorKind::InvalidInput,
- "strings passed to WinAPI cannot contain NULs",
+ &"strings passed to WinAPI cannot contain NULs",
));
}
maybe_result.push(0);