Use passing by-value in gmtime, mktime
Per the recommendation of the now-removed FIXME.
This commit is contained in:
parent
3941f78a1b
commit
379460558b
2 changed files with 14 additions and 15 deletions
|
@ -22,11 +22,11 @@ pub mod rustrt {
|
||||||
pub unsafe fn precise_time_ns(ns: &mut u64);
|
pub unsafe fn precise_time_ns(ns: &mut u64);
|
||||||
|
|
||||||
pub unsafe fn rust_tzset();
|
pub unsafe fn rust_tzset();
|
||||||
// FIXME: The i64 values can be passed by-val when #2064 is fixed.
|
|
||||||
pub unsafe fn rust_gmtime(sec: i64, nsec: i32, result: &mut Tm);
|
pub unsafe fn rust_gmtime(sec: i64, nsec: i32, result: &mut Tm);
|
||||||
pub unsafe fn rust_localtime(sec: i64, nsec: i32, result: &mut Tm);
|
pub unsafe fn rust_localtime(sec: i64, nsec: i32, result: &mut Tm);
|
||||||
pub unsafe fn rust_timegm(tm: &Tm, sec: &mut i64);
|
pub unsafe fn rust_timegm(tm: &Tm) -> i64;
|
||||||
pub unsafe fn rust_mktime(tm: &Tm, sec: &mut i64);
|
pub unsafe fn rust_mktime(tm: &Tm) -> i64;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,12 +177,11 @@ pub impl Tm {
|
||||||
/// Convert time to the seconds from January 1, 1970
|
/// Convert time to the seconds from January 1, 1970
|
||||||
fn to_timespec(&self) -> Timespec {
|
fn to_timespec(&self) -> Timespec {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut sec = 0i64;
|
let sec = match self.tm_gmtoff {
|
||||||
if self.tm_gmtoff == 0_i32 {
|
0_i32 => rustrt::rust_timegm(self),
|
||||||
rustrt::rust_timegm(self, &mut sec);
|
_ => rustrt::rust_mktime(self)
|
||||||
} else {
|
};
|
||||||
rustrt::rust_mktime(self, &mut sec);
|
|
||||||
}
|
|
||||||
Timespec::new(sec, self.tm_nsec)
|
Timespec::new(sec, self.tm_nsec)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -459,18 +459,18 @@ rust_localtime(int64_t sec, int32_t nsec, rust_tm *timeptr) {
|
||||||
tm_to_rust_tm(&tm, timeptr, gmtoff, zone, nsec);
|
tm_to_rust_tm(&tm, timeptr, gmtoff, zone, nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" CDECL void
|
extern "C" CDECL int64_t
|
||||||
rust_timegm(rust_tm* timeptr, int64_t *out) {
|
rust_timegm(rust_tm* timeptr) {
|
||||||
tm t;
|
tm t;
|
||||||
rust_tm_to_tm(timeptr, &t);
|
rust_tm_to_tm(timeptr, &t);
|
||||||
*out = TIMEGM(&t);
|
return TIMEGM(&t);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" CDECL void
|
extern "C" CDECL int64_t
|
||||||
rust_mktime(rust_tm* timeptr, int64_t *out) {
|
rust_mktime(rust_tm* timeptr) {
|
||||||
tm t;
|
tm t;
|
||||||
rust_tm_to_tm(timeptr, &t);
|
rust_tm_to_tm(timeptr, &t);
|
||||||
*out = mktime(&t);
|
return mktime(&t);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" CDECL rust_sched_id
|
extern "C" CDECL rust_sched_id
|
||||||
|
|
Loading…
Reference in a new issue