Fix some tests for linux gnux32

This commit is contained in:
Marco A L Barbosa 2017-10-19 15:49:59 -02:00
parent dbcd1bec61
commit e57ee3d0bf
7 changed files with 16 additions and 16 deletions

View file

@ -92,14 +92,15 @@ impl Condvar {
assert_eq!(r, 0);
// Nanosecond calculations can't overflow because both values are below 1e9.
let nsec = dur.subsec_nanos() as libc::c_long + now.tv_nsec as libc::c_long;
let nsec = dur.subsec_nanos() + now.tv_nsec as u32;
let sec = saturating_cast_to_time_t(dur.as_secs())
.checked_add((nsec / 1_000_000_000) as libc::time_t)
.and_then(|s| s.checked_add(now.tv_sec));
let nsec = nsec % 1_000_000_000;
let timeout = sec.map(|s| {
libc::timespec { tv_sec: s, tv_nsec: nsec }
libc::timespec { tv_sec: s, tv_nsec: nsec as _}
}).unwrap_or(TIMESPEC_MAX);
let r = libc::pthread_cond_timedwait(self.inner.get(), mutex::raw(mutex),

View file

@ -132,14 +132,14 @@ impl FileAttr {
pub fn modified(&self) -> io::Result<SystemTime> {
Ok(SystemTime::from(libc::timespec {
tv_sec: self.stat.st_mtime as libc::time_t,
tv_nsec: self.stat.st_mtime_nsec as libc::c_long,
tv_nsec: self.stat.st_mtime_nsec as _,
}))
}
pub fn accessed(&self) -> io::Result<SystemTime> {
Ok(SystemTime::from(libc::timespec {
tv_sec: self.stat.st_atime as libc::time_t,
tv_nsec: self.stat.st_atime_nsec as libc::c_long,
tv_nsec: self.stat.st_atime_nsec as _,
}))
}

View file

@ -149,7 +149,7 @@ impl Thread {
pub fn sleep(dur: Duration) {
let mut secs = dur.as_secs();
let mut nsecs = dur.subsec_nanos() as libc::c_long;
let mut nsecs = dur.subsec_nanos() as _;
// If we're awoken with a signal then the return value will be -1 and
// nanosleep will fill in `ts` with the remaining time.

View file

@ -60,7 +60,7 @@ impl Timespec {
Timespec {
t: libc::timespec {
tv_sec: secs,
tv_nsec: nsec as libc::c_long,
tv_nsec: nsec as _,
},
}
}
@ -83,7 +83,7 @@ impl Timespec {
Timespec {
t: libc::timespec {
tv_sec: secs,
tv_nsec: nsec as libc::c_long,
tv_nsec: nsec as _,
},
}
}