1
- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ]
1
+ #[ cfg_attr(
2
+ any( target_env = "musl" , target_env = "ohos" ) ,
3
+ allow( deprecated)
4
+ ) ]
2
5
// https://github.com/rust-lang/libc/issues/1848
3
6
pub use libc:: { suseconds_t, time_t} ;
4
7
use libc:: { timespec, timeval} ;
@@ -253,7 +256,10 @@ impl PartialOrd for TimeSpec {
253
256
254
257
impl TimeValLike for TimeSpec {
255
258
#[ inline]
256
- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ]
259
+ #[ cfg_attr(
260
+ any( target_env = "musl" , target_env = "ohos" ) ,
261
+ allow( deprecated)
262
+ ) ]
257
263
// https://github.com/rust-lang/libc/issues/1848
258
264
fn seconds ( seconds : i64 ) -> TimeSpec {
259
265
assert ! (
@@ -286,7 +292,10 @@ impl TimeValLike for TimeSpec {
286
292
287
293
/// Makes a new `TimeSpec` with given number of nanoseconds.
288
294
#[ inline]
289
- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ]
295
+ #[ cfg_attr(
296
+ any( target_env = "musl" , target_env = "ohos" ) ,
297
+ allow( deprecated)
298
+ ) ]
290
299
// https://github.com/rust-lang/libc/issues/1848
291
300
fn nanoseconds ( nanoseconds : i64 ) -> TimeSpec {
292
301
let ( secs, nanos) = div_mod_floor_64 ( nanoseconds, NANOS_PER_SEC ) ;
@@ -340,7 +349,10 @@ impl TimeSpec {
340
349
TimeSpec :: new ( 0 , libc:: UTIME_NOW as timespec_tv_nsec_t ) ;
341
350
342
351
/// Construct a new `TimeSpec` from its components
343
- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
352
+ #[ cfg_attr(
353
+ any( target_env = "musl" , target_env = "ohos" ) ,
354
+ allow( deprecated)
355
+ ) ] // https://github.com/rust-lang/libc/issues/1848
344
356
pub const fn new ( seconds : time_t , nanoseconds : timespec_tv_nsec_t ) -> Self {
345
357
let mut ts = zero_init_timespec ( ) ;
346
358
ts. tv_sec = seconds;
@@ -356,7 +368,10 @@ impl TimeSpec {
356
368
}
357
369
}
358
370
359
- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
371
+ #[ cfg_attr(
372
+ any( target_env = "musl" , target_env = "ohos" ) ,
373
+ allow( deprecated)
374
+ ) ] // https://github.com/rust-lang/libc/issues/1848
360
375
pub const fn tv_sec ( & self ) -> time_t {
361
376
self . 0 . tv_sec
362
377
}
@@ -365,7 +380,10 @@ impl TimeSpec {
365
380
self . 0 . tv_nsec
366
381
}
367
382
368
- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ]
383
+ #[ cfg_attr(
384
+ any( target_env = "musl" , target_env = "ohos" ) ,
385
+ allow( deprecated)
386
+ ) ]
369
387
// https://github.com/rust-lang/libc/issues/1848
370
388
pub const fn from_duration ( duration : Duration ) -> Self {
371
389
let mut ts = zero_init_timespec ( ) ;
@@ -506,7 +524,10 @@ impl TimeValLike for TimeVal {
506
524
( TV_MIN_SECONDS ..=TV_MAX_SECONDS ) . contains( & seconds) ,
507
525
"TimeVal out of bounds; seconds={seconds}"
508
526
) ;
509
- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ]
527
+ #[ cfg_attr(
528
+ any( target_env = "musl" , target_env = "ohos" ) ,
529
+ allow( deprecated)
530
+ ) ]
510
531
// https://github.com/rust-lang/libc/issues/1848
511
532
TimeVal ( timeval {
512
533
tv_sec : seconds as time_t ,
@@ -531,7 +552,10 @@ impl TimeValLike for TimeVal {
531
552
( TV_MIN_SECONDS ..=TV_MAX_SECONDS ) . contains( & secs) ,
532
553
"TimeVal out of bounds"
533
554
) ;
534
- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ]
555
+ #[ cfg_attr(
556
+ any( target_env = "musl" , target_env = "ohos" ) ,
557
+ allow( deprecated)
558
+ ) ]
535
559
// https://github.com/rust-lang/libc/issues/1848
536
560
TimeVal ( timeval {
537
561
tv_sec : secs as time_t ,
@@ -549,7 +573,10 @@ impl TimeValLike for TimeVal {
549
573
( TV_MIN_SECONDS ..=TV_MAX_SECONDS ) . contains( & secs) ,
550
574
"TimeVal out of bounds"
551
575
) ;
552
- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ]
576
+ #[ cfg_attr(
577
+ any( target_env = "musl" , target_env = "ohos" ) ,
578
+ allow( deprecated)
579
+ ) ]
553
580
// https://github.com/rust-lang/libc/issues/1848
554
581
TimeVal ( timeval {
555
582
tv_sec : secs as time_t ,
@@ -586,7 +613,10 @@ impl TimeValLike for TimeVal {
586
613
587
614
impl TimeVal {
588
615
/// Construct a new `TimeVal` from its components
589
- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
616
+ #[ cfg_attr(
617
+ any( target_env = "musl" , target_env = "ohos" ) ,
618
+ allow( deprecated)
619
+ ) ] // https://github.com/rust-lang/libc/issues/1848
590
620
pub const fn new ( seconds : time_t , microseconds : suseconds_t ) -> Self {
591
621
Self ( timeval {
592
622
tv_sec : seconds,
@@ -602,7 +632,10 @@ impl TimeVal {
602
632
}
603
633
}
604
634
605
- #[ cfg_attr( target_env = "musl" , allow( deprecated) ) ] // https://github.com/rust-lang/libc/issues/1848
635
+ #[ cfg_attr(
636
+ any( target_env = "musl" , target_env = "ohos" ) ,
637
+ allow( deprecated)
638
+ ) ] // https://github.com/rust-lang/libc/issues/1848
606
639
pub const fn tv_sec ( & self ) -> time_t {
607
640
self . 0 . tv_sec
608
641
}
0 commit comments