/// Update time zone information from the system. /// /// For safety documentation, see [`time::util::refresh_tz`]. #[inline] pub(super) unsafefn refresh_tz_unchecked() { unsafeextern"C" { #[cfg_attr(target_os = "netbsd", link_name = "__tzset50")] fn tzset();
}
// Safety: The caller must uphold the safety requirements. unsafe { tzset() };
}
/// Attempt to update time zone information from the system. Returns `None` if the call is not known /// to be sound. #[inline] pub(super) fn refresh_tz() -> Option<()> { // Refresh $TZ if and only if the call is known to be sound. // // Soundness can be guaranteed either by knowledge of the operating system or knowledge that the // process is single-threaded. If the process is single-threaded, then the environment cannot // be mutated by a different thread in the process while execution of this function is taking // place, which can cause a segmentation fault by dereferencing a dangling pointer. // // If the `num_threads` crate is incapable of determining the number of running threads, then // we conservatively return `None` to avoid a soundness bug.
if OS_HAS_THREAD_SAFE_ENVIRONMENT || num_threads::is_single_threaded() == Some(true) { // Safety: The caller must uphold the safety requirements. unsafe { refresh_tz_unchecked() };
Some(())
} else {
None
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.25 Sekunden
(vorverarbeitet am 2026-08-25)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.