@@ -2,6 +2,7 @@ use std::{cmp, fmt, ops};
22use std:: time:: Duration ;
33use std:: convert:: From ;
44use libc:: { c_long, timespec, timeval} ;
5+ #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
56pub use libc:: { time_t, suseconds_t} ;
67
78pub trait TimeValLike : Sized {
@@ -69,6 +70,7 @@ impl From<timespec> for TimeSpec {
6970
7071impl From < Duration > for TimeSpec {
7172 fn from ( duration : Duration ) -> Self {
73+ #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
7274 TimeSpec ( timespec {
7375 tv_sec : duration. as_secs ( ) as time_t ,
7476 tv_nsec : duration. subsec_nanos ( ) as c_long
@@ -117,6 +119,7 @@ impl TimeValLike for TimeSpec {
117119 fn seconds ( seconds : i64 ) -> TimeSpec {
118120 assert ! ( seconds >= TS_MIN_SECONDS && seconds <= TS_MAX_SECONDS ,
119121 "TimeSpec out of bounds; seconds={}" , seconds) ;
122+ #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
120123 TimeSpec ( timespec { tv_sec : seconds as time_t , tv_nsec : 0 } )
121124 }
122125
@@ -143,6 +146,7 @@ impl TimeValLike for TimeSpec {
143146 let ( secs, nanos) = div_mod_floor_64 ( nanoseconds, NANOS_PER_SEC ) ;
144147 assert ! ( secs >= TS_MIN_SECONDS && secs <= TS_MAX_SECONDS ,
145148 "TimeSpec out of bounds" ) ;
149+ #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
146150 TimeSpec ( timespec { tv_sec : secs as time_t ,
147151 tv_nsec : nanos as c_long } )
148152 }
@@ -179,6 +183,7 @@ impl TimeSpec {
179183 }
180184 }
181185
186+ #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
182187 pub fn tv_sec ( & self ) -> time_t {
183188 self . 0 . tv_sec
184189 }
@@ -315,6 +320,7 @@ impl TimeValLike for TimeVal {
315320 fn seconds ( seconds : i64 ) -> TimeVal {
316321 assert ! ( seconds >= TV_MIN_SECONDS && seconds <= TV_MAX_SECONDS ,
317322 "TimeVal out of bounds; seconds={}" , seconds) ;
323+ #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
318324 TimeVal ( timeval { tv_sec : seconds as time_t , tv_usec : 0 } )
319325 }
320326
@@ -332,6 +338,7 @@ impl TimeValLike for TimeVal {
332338 let ( secs, micros) = div_mod_floor_64 ( microseconds, MICROS_PER_SEC ) ;
333339 assert ! ( secs >= TV_MIN_SECONDS && secs <= TV_MAX_SECONDS ,
334340 "TimeVal out of bounds" ) ;
341+ #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
335342 TimeVal ( timeval { tv_sec : secs as time_t ,
336343 tv_usec : micros as suseconds_t } )
337344 }
@@ -344,6 +351,7 @@ impl TimeValLike for TimeVal {
344351 let ( secs, micros) = div_mod_floor_64 ( microseconds, MICROS_PER_SEC ) ;
345352 assert ! ( secs >= TV_MIN_SECONDS && secs <= TV_MAX_SECONDS ,
346353 "TimeVal out of bounds" ) ;
354+ #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
347355 TimeVal ( timeval { tv_sec : secs as time_t ,
348356 tv_usec : micros as suseconds_t } )
349357 }
@@ -380,6 +388,7 @@ impl TimeVal {
380388 }
381389 }
382390
391+ #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
383392 pub fn tv_sec ( & self ) -> time_t {
384393 self . 0 . tv_sec
385394 }
0 commit comments