Skip to content

Commit 04412d0

Browse files
committed
Auto merge of #777 - ekmartin:macos_gettime, r=alexcrichton
Add clock_gettime related functions to macOS Fixes #776. The constants were retrieved on macOS 10.12.6. Tried adding `clock_nanosleep` too, but it doesn't seem like macOS' libc includes that yet.
2 parents ef6c252 + ffba97f commit 04412d0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/unix/bsd/apple/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub type rlim_t = u64;
1414
pub type mach_timebase_info_data_t = mach_timebase_info;
1515
pub type pthread_key_t = c_ulong;
1616
pub type sigset_t = u32;
17+
pub type clockid_t = ::c_uint;
1718
pub type fsblkcnt_t = ::c_uint;
1819
pub type fsfilcnt_t = ::c_uint;
1920
pub type speed_t = ::c_ulong;
@@ -493,6 +494,11 @@ pub const ABMON_10: ::nl_item = 42;
493494
pub const ABMON_11: ::nl_item = 43;
494495
pub const ABMON_12: ::nl_item = 44;
495496

497+
pub const CLOCK_REALTIME: ::clockid_t = 0;
498+
pub const CLOCK_MONOTONIC: ::clockid_t = 6;
499+
pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 12;
500+
pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 16;
501+
496502
pub const ERA: ::nl_item = 45;
497503
pub const ERA_D_FMT: ::nl_item = 46;
498504
pub const ERA_D_T_FMT: ::nl_item = 47;
@@ -1976,6 +1982,9 @@ extern {
19761982
pub fn aio_suspend(aiocb_list: *const *const aiocb, nitems: ::c_int,
19771983
timeout: *const ::timespec) -> ::c_int;
19781984
pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
1985+
pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
1986+
pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
1987+
pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int;
19791988
pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb,
19801989
nitems: ::c_int, sevp: *mut sigevent) -> ::c_int;
19811990

0 commit comments

Comments
 (0)