@@ -356,6 +356,23 @@ fn test_nanosleep() {
356
356
mod test_clock_nanosleep {
357
357
use super :: * ;
358
358
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
+
359
376
pub fn absolute ( ) {
360
377
let start_test_sleep = Instant :: now ( ) ;
361
378
let before_start = libc:: timespec { tv_sec : 0 , tv_nsec : 0 } ;
@@ -408,22 +425,5 @@ mod test_clock_nanosleep {
408
425
assert_eq ! ( error, 0 ) ;
409
426
assert ! ( start_test_sleep. elapsed( ) > Duration :: from_millis( 100 ) ) ;
410
427
}
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
- }
428
428
}
429
429
0 commit comments