Tighten targets where tzset is defined

It doesn't need to be public in oldtime, and it is only used in the
illumos/solaris environments.
This commit is contained in:
Brandon W Maister 2020-09-30 09:55:25 -04:00
parent f3bbc958a8
commit f91e7e139c
2 changed files with 9 additions and 14 deletions

View File

@ -67,19 +67,6 @@ impl Timespec {
}
}
#[cfg(not(any(windows, target_env = "sgx")))]
#[allow(dead_code)] // only used on some architectures
pub fn tzset() {
extern "C" {
fn tzset();
}
unsafe { tzset() }
}
#[cfg(any(windows, target_env = "sgx"))]
#[allow(dead_code)] // only used on some architectures
pub fn tzset() {}
/// Holds a calendar date and time broken down into its components (year, month,
/// day, and so on), also called a broken-down time value.
// FIXME: use c_int instead of i32?

View File

@ -19,6 +19,14 @@ extern "C" {
static altzone: time_t;
}
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
fn tzset() {
extern "C" {
fn tzset();
}
unsafe { tzset() }
}
fn rust_tm_to_tm(rust_tm: &Tm, tm: &mut libc::tm) {
tm.tm_sec = rust_tm.tm_sec;
tm.tm_min = rust_tm.tm_min;
@ -78,7 +86,7 @@ pub fn time_to_local_tm(sec: i64, tm: &mut Tm) {
}
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
let gmtoff = {
::oldtime::tzset();
tzset();
// < 0 means we don't know; assume we're not in DST.
if out.tm_isdst == 0 {
// timezone is seconds west of UTC, tm_gmtoff is seconds east