2
2
3
3
use crate :: backend:: c;
4
4
use crate :: backend:: conv:: ret;
5
- #[ cfg( any( linux_kernel, target_os = "fuchsia" ) ) ]
5
+ #[ cfg( any(
6
+ linux_kernel,
7
+ target_os = "freebsd" ,
8
+ target_os = "fuchsia" ,
9
+ target_os = "illumos" ,
10
+ target_os = "netbsd"
11
+ ) ) ]
6
12
#[ cfg( any( all( target_env = "gnu" , fix_y2038) , not( fix_y2038) ) ) ]
7
13
use crate :: backend:: time:: types:: LibcItimerspec ;
8
14
#[ cfg( not( target_os = "wasi" ) ) ]
@@ -21,7 +27,13 @@ use crate::timespec::as_libc_timespec_ptr;
21
27
use crate :: timespec:: LibcTimespec ;
22
28
use crate :: timespec:: Timespec ;
23
29
use core:: mem:: MaybeUninit ;
24
- #[ cfg( any( linux_kernel, target_os = "fuchsia" ) ) ]
30
+ #[ cfg( any(
31
+ linux_kernel,
32
+ target_os = "freebsd" ,
33
+ target_os = "fuchsia" ,
34
+ target_os = "illumos" ,
35
+ target_os = "netbsd"
36
+ ) ) ]
25
37
use {
26
38
crate :: backend:: conv:: { borrowed_fd, ret_owned_fd} ,
27
39
crate :: fd:: { BorrowedFd , OwnedFd } ,
@@ -34,10 +46,10 @@ weak!(fn __clock_gettime64(c::clockid_t, *mut LibcTimespec) -> c::c_int);
34
46
weak ! ( fn __clock_settime64( c:: clockid_t, * const LibcTimespec ) -> c:: c_int) ;
35
47
#[ cfg( all( target_env = "gnu" , fix_y2038) ) ]
36
48
weak ! ( fn __clock_getres64( c:: clockid_t, * mut LibcTimespec ) -> c:: c_int) ;
37
- #[ cfg( any( linux_kernel, target_os = "fuchsia" ) ) ]
49
+ #[ cfg( any( linux_kernel, target_os = "freebsd" , target_os = " fuchsia") ) ]
38
50
#[ cfg( all( target_env = "gnu" , fix_y2038) ) ]
39
51
weak ! ( fn __timerfd_gettime64( c:: c_int, * mut LibcItimerspec ) -> c:: c_int) ;
40
- #[ cfg( any( linux_kernel, target_os = "fuchsia" ) ) ]
52
+ #[ cfg( any( linux_kernel, target_os = "freebsd" , target_os = " fuchsia") ) ]
41
53
#[ cfg( all( target_env = "gnu" , fix_y2038) ) ]
42
54
weak ! ( fn __timerfd_settime64( c:: c_int, c:: c_int, * const LibcItimerspec , * mut LibcItimerspec ) -> c:: c_int) ;
43
55
@@ -172,7 +184,7 @@ pub(crate) fn clock_gettime_dynamic(id: DynamicClockId<'_>) -> io::Result<Timesp
172
184
return Err ( io:: Errno :: INVAL ) ;
173
185
}
174
186
175
- #[ cfg( linux_kernel) ]
187
+ #[ cfg( any ( linux_kernel, target_os = "fuchsia" ) ) ]
176
188
DynamicClockId :: RealtimeAlarm => c:: CLOCK_REALTIME_ALARM ,
177
189
178
190
#[ cfg( linux_kernel) ]
@@ -298,12 +310,24 @@ fn clock_settime_old(id: ClockId, timespec: Timespec) -> io::Result<()> {
298
310
unsafe { ret ( c:: clock_settime ( id as c:: clockid_t , & old_timespec) ) }
299
311
}
300
312
301
- #[ cfg( any( linux_kernel, target_os = "fuchsia" ) ) ]
313
+ #[ cfg( any(
314
+ linux_kernel,
315
+ target_os = "freebsd" ,
316
+ target_os = "fuchsia" ,
317
+ target_os = "illumos" ,
318
+ target_os = "netbsd"
319
+ ) ) ]
302
320
pub ( crate ) fn timerfd_create ( id : TimerfdClockId , flags : TimerfdFlags ) -> io:: Result < OwnedFd > {
303
321
unsafe { ret_owned_fd ( c:: timerfd_create ( id as c:: clockid_t , bitflags_bits ! ( flags) ) ) }
304
322
}
305
323
306
- #[ cfg( any( linux_kernel, target_os = "fuchsia" ) ) ]
324
+ #[ cfg( any(
325
+ linux_kernel,
326
+ target_os = "freebsd" ,
327
+ target_os = "fuchsia" ,
328
+ target_os = "illumos" ,
329
+ target_os = "netbsd"
330
+ ) ) ]
307
331
pub ( crate ) fn timerfd_settime (
308
332
fd : BorrowedFd < ' _ > ,
309
333
flags : TimerfdTimerFlags ,
@@ -345,7 +369,13 @@ pub(crate) fn timerfd_settime(
345
369
}
346
370
}
347
371
348
- #[ cfg( any( linux_kernel, target_os = "fuchsia" ) ) ]
372
+ #[ cfg( any(
373
+ linux_kernel,
374
+ target_os = "freebsd" ,
375
+ target_os = "fuchsia" ,
376
+ target_os = "illumos" ,
377
+ target_os = "netbsd"
378
+ ) ) ]
349
379
#[ cfg( fix_y2038) ]
350
380
fn timerfd_settime_old (
351
381
fd : BorrowedFd < ' _ > ,
@@ -412,7 +442,13 @@ fn timerfd_settime_old(
412
442
} )
413
443
}
414
444
415
- #[ cfg( any( linux_kernel, target_os = "fuchsia" ) ) ]
445
+ #[ cfg( any(
446
+ linux_kernel,
447
+ target_os = "freebsd" ,
448
+ target_os = "fuchsia" ,
449
+ target_os = "illumos" ,
450
+ target_os = "netbsd"
451
+ ) ) ]
416
452
pub ( crate ) fn timerfd_gettime ( fd : BorrowedFd < ' _ > ) -> io:: Result < Itimerspec > {
417
453
// Old 32-bit version: libc has `timerfd_gettime` but it is not y2038 safe
418
454
// by default. But there may be a `__timerfd_gettime64` we can use.
@@ -443,7 +479,13 @@ pub(crate) fn timerfd_gettime(fd: BorrowedFd<'_>) -> io::Result<Itimerspec> {
443
479
}
444
480
}
445
481
446
- #[ cfg( any( linux_kernel, target_os = "fuchsia" ) ) ]
482
+ #[ cfg( any(
483
+ linux_kernel,
484
+ target_os = "freebsd" ,
485
+ target_os = "fuchsia" ,
486
+ target_os = "illumos" ,
487
+ target_os = "netbsd"
488
+ ) ) ]
447
489
#[ cfg( fix_y2038) ]
448
490
fn timerfd_gettime_old ( fd : BorrowedFd < ' _ > ) -> io:: Result < Itimerspec > {
449
491
let mut old_result = MaybeUninit :: < c:: itimerspec > :: uninit ( ) ;
0 commit comments