Skip to content

Commit f7f36a8

Browse files
committed
auto merge of #6766 : fdr/rust/time-by-value, r=catamorphism
Per the recommendation of the now-removed FIXME.
2 parents 6264df5 + c6f3577 commit f7f36a8

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

src/libextra/time.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -22,11 +22,11 @@ pub mod rustrt {
2222
pub unsafe fn precise_time_ns(ns: &mut u64);
2323

2424
pub unsafe fn rust_tzset();
25-
// FIXME: The i64 values can be passed by-val when #2064 is fixed.
25+
2626
pub unsafe fn rust_gmtime(sec: i64, nsec: i32, result: &mut Tm);
2727
pub unsafe fn rust_localtime(sec: i64, nsec: i32, result: &mut Tm);
28-
pub unsafe fn rust_timegm(tm: &Tm, sec: &mut i64);
29-
pub unsafe fn rust_mktime(tm: &Tm, sec: &mut i64);
28+
pub unsafe fn rust_timegm(tm: &Tm) -> i64;
29+
pub unsafe fn rust_mktime(tm: &Tm) -> i64;
3030
}
3131
}
3232

@@ -177,12 +177,11 @@ pub impl Tm {
177177
/// Convert time to the seconds from January 1, 1970
178178
fn to_timespec(&self) -> Timespec {
179179
unsafe {
180-
let mut sec = 0i64;
181-
if self.tm_gmtoff == 0_i32 {
182-
rustrt::rust_timegm(self, &mut sec);
183-
} else {
184-
rustrt::rust_mktime(self, &mut sec);
185-
}
180+
let sec = match self.tm_gmtoff {
181+
0_i32 => rustrt::rust_timegm(self),
182+
_ => rustrt::rust_mktime(self)
183+
};
184+
186185
Timespec::new(sec, self.tm_nsec)
187186
}
188187
}

src/rt/rust_builtin.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -459,18 +459,18 @@ rust_localtime(int64_t sec, int32_t nsec, rust_tm *timeptr) {
459459
tm_to_rust_tm(&tm, timeptr, gmtoff, zone, nsec);
460460
}
461461

462-
extern "C" CDECL void
463-
rust_timegm(rust_tm* timeptr, int64_t *out) {
462+
extern "C" CDECL int64_t
463+
rust_timegm(rust_tm* timeptr) {
464464
tm t;
465465
rust_tm_to_tm(timeptr, &t);
466-
*out = TIMEGM(&t);
466+
return TIMEGM(&t);
467467
}
468468

469-
extern "C" CDECL void
470-
rust_mktime(rust_tm* timeptr, int64_t *out) {
469+
extern "C" CDECL int64_t
470+
rust_mktime(rust_tm* timeptr) {
471471
tm t;
472472
rust_tm_to_tm(timeptr, &t);
473-
*out = mktime(&t);
473+
return mktime(&t);
474474
}
475475

476476
extern "C" CDECL rust_sched_id

0 commit comments

Comments
 (0)