Skip to content

Commit 5cbb285

Browse files
committed
move helpers above their users, fix add_100_millis helper
1 parent 424a8ed commit 5cbb285

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/tools/miri/tests/pass-dep/libc/libc-time.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,23 @@ fn test_nanosleep() {
356356
mod test_clock_nanosleep {
357357
use super::*;
358358

359+
/// Helper function used to create an instant in the future
360+
fn add_100_millis(mut ts: libc::timespec) -> libc::timespec {
361+
const SECOND: i64 = 1_000_000_000;
362+
ts.tv_nsec += SECOND / 10;
363+
ts.tv_sec = ts.tv_nsec / SECOND;
364+
ts.tv_nsec %= SECOND;
365+
ts
366+
}
367+
368+
/// Helper function to get the current time for testing relative sleeps
369+
fn timespec_now(clock: libc::clockid_t) -> libc::timespec {
370+
let mut timespec = mem::MaybeUninit::<libc::timespec>::uninit();
371+
let is_error = unsafe { libc::clock_gettime(clock, timespec.as_mut_ptr()) };
372+
assert_eq!(is_error, 0);
373+
unsafe { timespec.assume_init() }
374+
}
375+
359376
pub fn absolute() {
360377
let start_test_sleep = Instant::now();
361378
let before_start = libc::timespec { tv_sec: 0, tv_nsec: 0 };
@@ -408,22 +425,5 @@ mod test_clock_nanosleep {
408425
assert_eq!(error, 0);
409426
assert!(start_test_sleep.elapsed() > Duration::from_millis(100));
410427
}
411-
412-
/// Helper function to get the current time for testing relative sleeps
413-
fn timespec_now(clock: libc::clockid_t) -> libc::timespec {
414-
let mut timespec = mem::MaybeUninit::<libc::timespec>::uninit();
415-
let is_error = unsafe { libc::clock_gettime(clock, timespec.as_mut_ptr()) };
416-
assert_eq!(is_error, 0);
417-
unsafe { timespec.assume_init() }
418-
}
419-
420-
/// Helper function used to create an instant in the future
421-
fn add_100_millis(mut ts: libc::timespec) -> libc::timespec {
422-
const SECOND: i64 = 1_000_000_000;
423-
ts.tv_nsec += SECOND / 10;
424-
ts.tv_sec = ts.tv_nsec / SECOND;
425-
ts.tv_nsec %= SECOND;
426-
ts
427-
}
428428
}
429429

0 commit comments

Comments
 (0)