@@ -2,6 +2,7 @@ use std::{cmp, fmt, ops};
2
2
use std:: time:: Duration ;
3
3
use std:: convert:: From ;
4
4
use libc:: { c_long, timespec, timeval} ;
5
+ #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
5
6
pub use libc:: { time_t, suseconds_t} ;
6
7
7
8
pub trait TimeValLike : Sized {
@@ -70,6 +71,7 @@ impl From<timespec> for TimeSpec {
70
71
impl From < Duration > for TimeSpec {
71
72
fn from ( duration : Duration ) -> Self {
72
73
TimeSpec ( timespec {
74
+ #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
73
75
tv_sec : duration. as_secs ( ) as time_t ,
74
76
tv_nsec : duration. subsec_nanos ( ) as c_long
75
77
} )
@@ -117,6 +119,7 @@ impl TimeValLike for TimeSpec {
117
119
fn seconds ( seconds : i64 ) -> TimeSpec {
118
120
assert ! ( seconds >= TS_MIN_SECONDS && seconds <= TS_MAX_SECONDS ,
119
121
"TimeSpec out of bounds; seconds={}" , seconds) ;
122
+ #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
120
123
TimeSpec ( timespec { tv_sec : seconds as time_t , tv_nsec : 0 } )
121
124
}
122
125
@@ -143,6 +146,7 @@ impl TimeValLike for TimeSpec {
143
146
let ( secs, nanos) = div_mod_floor_64 ( nanoseconds, NANOS_PER_SEC ) ;
144
147
assert ! ( secs >= TS_MIN_SECONDS && secs <= TS_MAX_SECONDS ,
145
148
"TimeSpec out of bounds" ) ;
149
+ #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
146
150
TimeSpec ( timespec { tv_sec : secs as time_t ,
147
151
tv_nsec : nanos as c_long } )
148
152
}
@@ -179,6 +183,7 @@ impl TimeSpec {
179
183
}
180
184
}
181
185
186
+ #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
182
187
pub fn tv_sec ( & self ) -> time_t {
183
188
self . 0 . tv_sec
184
189
}
@@ -315,6 +320,7 @@ impl TimeValLike for TimeVal {
315
320
fn seconds ( seconds : i64 ) -> TimeVal {
316
321
assert ! ( seconds >= TV_MIN_SECONDS && seconds <= TV_MAX_SECONDS ,
317
322
"TimeVal out of bounds; seconds={}" , seconds) ;
323
+ #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
318
324
TimeVal ( timeval { tv_sec : seconds as time_t , tv_usec : 0 } )
319
325
}
320
326
@@ -332,6 +338,7 @@ impl TimeValLike for TimeVal {
332
338
let ( secs, micros) = div_mod_floor_64 ( microseconds, MICROS_PER_SEC ) ;
333
339
assert ! ( secs >= TV_MIN_SECONDS && secs <= TV_MAX_SECONDS ,
334
340
"TimeVal out of bounds" ) ;
341
+ #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
335
342
TimeVal ( timeval { tv_sec : secs as time_t ,
336
343
tv_usec : micros as suseconds_t } )
337
344
}
@@ -344,6 +351,7 @@ impl TimeValLike for TimeVal {
344
351
let ( secs, micros) = div_mod_floor_64 ( microseconds, MICROS_PER_SEC ) ;
345
352
assert ! ( secs >= TV_MIN_SECONDS && secs <= TV_MAX_SECONDS ,
346
353
"TimeVal out of bounds" ) ;
354
+ #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
347
355
TimeVal ( timeval { tv_sec : secs as time_t ,
348
356
tv_usec : micros as suseconds_t } )
349
357
}
@@ -380,6 +388,7 @@ impl TimeVal {
380
388
}
381
389
}
382
390
391
+ #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
383
392
pub fn tv_sec ( & self ) -> time_t {
384
393
self . 0 . tv_sec
385
394
}
0 commit comments