1- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ]
1+ #[ cfg_attr(
2+ any( target_env = "musl" , target_env = "ohos" ) ,
3+ allow( deprecated)
4+ ) ]
25// https://github.com/rust-lang/libc/issues/1848
36pub use libc:: { suseconds_t, time_t} ;
47use libc:: { timespec, timeval} ;
@@ -13,7 +16,10 @@ const fn zero_init_timespec() -> timespec {
1316}
1417
1518#[ cfg( any(
16- all( feature = "time" , any( target_os = "android" , target_os = "linux" ) ) ,
19+ all(
20+ feature = "time" ,
21+ any( target_os = "android" , target_os = "linux" , target_env = "ohos" )
22+ ) ,
1723 all(
1824 any(
1925 target_os = "freebsd" ,
@@ -253,7 +259,10 @@ impl PartialOrd for TimeSpec {
253259
254260impl TimeValLike for TimeSpec {
255261 #[ inline]
256- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ]
262+ #[ cfg_attr(
263+ any( target_env = "musl" , target_env = "ohos" ) ,
264+ allow( deprecated)
265+ ) ]
257266 // https://github.com/rust-lang/libc/issues/1848
258267 fn seconds ( seconds : i64 ) -> TimeSpec {
259268 assert ! (
@@ -286,7 +295,10 @@ impl TimeValLike for TimeSpec {
286295
287296 /// Makes a new `TimeSpec` with given number of nanoseconds.
288297 #[ inline]
289- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ]
298+ #[ cfg_attr(
299+ any( target_env = "musl" , target_env = "ohos" ) ,
300+ allow( deprecated)
301+ ) ]
290302 // https://github.com/rust-lang/libc/issues/1848
291303 fn nanoseconds ( nanoseconds : i64 ) -> TimeSpec {
292304 let ( secs, nanos) = div_mod_floor_64 ( nanoseconds, NANOS_PER_SEC ) ;
@@ -340,7 +352,10 @@ impl TimeSpec {
340352 TimeSpec :: new ( 0 , libc:: UTIME_NOW as timespec_tv_nsec_t ) ;
341353
342354 /// Construct a new `TimeSpec` from its components
343- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
355+ #[ cfg_attr(
356+ any( target_env = "musl" , target_env = "ohos" ) ,
357+ allow( deprecated)
358+ ) ] // https://github.com/rust-lang/libc/issues/1848
344359 pub const fn new ( seconds : time_t , nanoseconds : timespec_tv_nsec_t ) -> Self {
345360 let mut ts = zero_init_timespec ( ) ;
346361 ts. tv_sec = seconds;
@@ -356,7 +371,10 @@ impl TimeSpec {
356371 }
357372 }
358373
359- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
374+ #[ cfg_attr(
375+ any( target_env = "musl" , target_env = "ohos" ) ,
376+ allow( deprecated)
377+ ) ] // https://github.com/rust-lang/libc/issues/1848
360378 pub const fn tv_sec ( & self ) -> time_t {
361379 self . 0 . tv_sec
362380 }
@@ -365,7 +383,10 @@ impl TimeSpec {
365383 self . 0 . tv_nsec
366384 }
367385
368- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ]
386+ #[ cfg_attr(
387+ any( target_env = "musl" , target_env = "ohos" ) ,
388+ allow( deprecated)
389+ ) ]
369390 // https://github.com/rust-lang/libc/issues/1848
370391 pub const fn from_duration ( duration : Duration ) -> Self {
371392 let mut ts = zero_init_timespec ( ) ;
@@ -506,7 +527,10 @@ impl TimeValLike for TimeVal {
506527 ( TV_MIN_SECONDS ..=TV_MAX_SECONDS ) . contains( & seconds) ,
507528 "TimeVal out of bounds; seconds={seconds}"
508529 ) ;
509- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ]
530+ #[ cfg_attr(
531+ any( target_env = "musl" , target_env = "ohos" ) ,
532+ allow( deprecated)
533+ ) ]
510534 // https://github.com/rust-lang/libc/issues/1848
511535 TimeVal ( timeval {
512536 tv_sec : seconds as time_t ,
@@ -531,7 +555,10 @@ impl TimeValLike for TimeVal {
531555 ( TV_MIN_SECONDS ..=TV_MAX_SECONDS ) . contains( & secs) ,
532556 "TimeVal out of bounds"
533557 ) ;
534- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ]
558+ #[ cfg_attr(
559+ any( target_env = "musl" , target_env = "ohos" ) ,
560+ allow( deprecated)
561+ ) ]
535562 // https://github.com/rust-lang/libc/issues/1848
536563 TimeVal ( timeval {
537564 tv_sec : secs as time_t ,
@@ -549,7 +576,10 @@ impl TimeValLike for TimeVal {
549576 ( TV_MIN_SECONDS ..=TV_MAX_SECONDS ) . contains( & secs) ,
550577 "TimeVal out of bounds"
551578 ) ;
552- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ]
579+ #[ cfg_attr(
580+ any( target_env = "musl" , target_env = "ohos" ) ,
581+ allow( deprecated)
582+ ) ]
553583 // https://github.com/rust-lang/libc/issues/1848
554584 TimeVal ( timeval {
555585 tv_sec : secs as time_t ,
@@ -586,7 +616,10 @@ impl TimeValLike for TimeVal {
586616
587617impl TimeVal {
588618 /// Construct a new `TimeVal` from its components
589- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
619+ #[ cfg_attr(
620+ any( target_env = "musl" , target_env = "ohos" ) ,
621+ allow( deprecated)
622+ ) ] // https://github.com/rust-lang/libc/issues/1848
590623 pub const fn new ( seconds : time_t , microseconds : suseconds_t ) -> Self {
591624 Self ( timeval {
592625 tv_sec : seconds,
@@ -602,7 +635,10 @@ impl TimeVal {
602635 }
603636 }
604637
605- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
638+ #[ cfg_attr(
639+ any( target_env = "musl" , target_env = "ohos" ) ,
640+ allow( deprecated)
641+ ) ] // https://github.com/rust-lang/libc/issues/1848
606642 pub const fn tv_sec ( & self ) -> time_t {
607643 self . 0 . tv_sec
608644 }
0 commit comments