From ce5cb0354428d00de4cf1487c6f2606bc3271c45 Mon Sep 17 00:00:00 2001 From: Daniil Bondarev Date: Wed, 19 Aug 2020 00:07:36 -0700 Subject: [PATCH] Added clock_getcpuclockid to more targets Previously clock_getcpuclockid was enabled only on linux, with this change it is enabled on all linux_like and freebsdlike. --- libc-test/build.rs | 20 +++++++++++++---- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 21 ------------------ src/unix/bsd/freebsdlike/freebsd/mod.rs | 22 ------------------ src/unix/bsd/freebsdlike/mod.rs | 27 +++++++++++++++++++++++ src/unix/linux_like/linux/mod.rs | 5 ----- src/unix/linux_like/mod.rs | 6 +++++ 6 files changed, 49 insertions(+), 52 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 8c538fb5dc239..0bb9d1d0a7ffa 100755 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1590,10 +1590,22 @@ fn test_android(target: &str) { // FIXME: Somehow we cannot find these fns on aarch64. // https://github.com/rust-lang/libc/issues/1765 - "lockf" | "preadv64" | "pwritev64" | "openpty" | "forkpty" - | "login_tty" | "getifaddrs" | "freeifaddrs" | "sethostname" - | "getgrgid_r" | "getgrnam_r" | "sigtimedwait" | "fmemopen" - | "open_memstream" | "open_wmemstream" + "lockf" + | "preadv64" + | "pwritev64" + | "openpty" + | "forkpty" + | "login_tty" + | "getifaddrs" + | "freeifaddrs" + | "sethostname" + | "getgrgid_r" + | "getgrnam_r" + | "sigtimedwait" + | "fmemopen" + | "open_memstream" + | "open_wmemstream" + | "clock_getcpuclockid" if aarch64 => { true diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 5841947f33467..4a15c3b89a88e 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -460,21 +460,6 @@ pub const RLIM_NLIMITS: ::rlim_t = 12; pub const Q_GETQUOTA: ::c_int = 0x300; pub const Q_SETQUOTA: ::c_int = 0x400; -pub const CLOCK_REALTIME: ::clockid_t = 0; -pub const CLOCK_VIRTUAL: ::clockid_t = 1; -pub const CLOCK_PROF: ::clockid_t = 2; -pub const CLOCK_MONOTONIC: ::clockid_t = 4; -pub const CLOCK_UPTIME: ::clockid_t = 5; -pub const CLOCK_UPTIME_PRECISE: ::clockid_t = 7; -pub const CLOCK_UPTIME_FAST: ::clockid_t = 8; -pub const CLOCK_REALTIME_PRECISE: ::clockid_t = 9; -pub const CLOCK_REALTIME_FAST: ::clockid_t = 10; -pub const CLOCK_MONOTONIC_PRECISE: ::clockid_t = 11; -pub const CLOCK_MONOTONIC_FAST: ::clockid_t = 12; -pub const CLOCK_SECOND: ::clockid_t = 13; -pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 14; -pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 15; - pub const CTL_UNSPEC: ::c_int = 0; pub const CTL_KERN: ::c_int = 1; pub const CTL_VM: ::c_int = 2; @@ -1065,12 +1050,6 @@ extern "C" { len: ::size_t, prot: ::c_int, ) -> ::c_int; - pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; - pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; - pub fn clock_settime( - clk_id: ::clockid_t, - tp: *const ::timespec, - ) -> ::c_int; pub fn setutxdb(_type: ::c_uint, file: *mut ::c_char) -> ::c_int; diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 1ca003959cb00..6359196138709 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -447,21 +447,6 @@ pub const NOTE_NSECONDS: u32 = 0x00000008; pub const MADV_PROTECT: ::c_int = 10; pub const RUSAGE_THREAD: ::c_int = 1; -pub const CLOCK_REALTIME: ::clockid_t = 0; -pub const CLOCK_VIRTUAL: ::clockid_t = 1; -pub const CLOCK_PROF: ::clockid_t = 2; -pub const CLOCK_MONOTONIC: ::clockid_t = 4; -pub const CLOCK_UPTIME: ::clockid_t = 5; -pub const CLOCK_UPTIME_PRECISE: ::clockid_t = 7; -pub const CLOCK_UPTIME_FAST: ::clockid_t = 8; -pub const CLOCK_REALTIME_PRECISE: ::clockid_t = 9; -pub const CLOCK_REALTIME_FAST: ::clockid_t = 10; -pub const CLOCK_MONOTONIC_PRECISE: ::clockid_t = 11; -pub const CLOCK_MONOTONIC_FAST: ::clockid_t = 12; -pub const CLOCK_SECOND: ::clockid_t = 13; -pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 14; -pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 15; - #[doc(hidden)] #[deprecated( since = "0.2.72", @@ -1222,13 +1207,6 @@ f! { extern "C" { pub fn __error() -> *mut ::c_int; - pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; - pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; - pub fn clock_settime( - clk_id: ::clockid_t, - tp: *const ::timespec, - ) -> ::c_int; - pub fn extattr_delete_fd( fd: ::c_int, attrnamespace: ::c_int, diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index e9f70579ea677..f70b8a5e6e36a 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -638,6 +638,21 @@ pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; pub const RUSAGE_SELF: ::c_int = 0; pub const RUSAGE_CHILDREN: ::c_int = -1; +pub const CLOCK_REALTIME: ::clockid_t = 0; +pub const CLOCK_VIRTUAL: ::clockid_t = 1; +pub const CLOCK_PROF: ::clockid_t = 2; +pub const CLOCK_MONOTONIC: ::clockid_t = 4; +pub const CLOCK_UPTIME: ::clockid_t = 5; +pub const CLOCK_UPTIME_PRECISE: ::clockid_t = 7; +pub const CLOCK_UPTIME_FAST: ::clockid_t = 8; +pub const CLOCK_REALTIME_PRECISE: ::clockid_t = 9; +pub const CLOCK_REALTIME_FAST: ::clockid_t = 10; +pub const CLOCK_MONOTONIC_PRECISE: ::clockid_t = 11; +pub const CLOCK_MONOTONIC_FAST: ::clockid_t = 12; +pub const CLOCK_SECOND: ::clockid_t = 13; +pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 14; +pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 15; + pub const MADV_NORMAL: ::c_int = 0; pub const MADV_RANDOM: ::c_int = 1; pub const MADV_SEQUENTIAL: ::c_int = 2; @@ -1242,6 +1257,18 @@ extern "C" { flags: ::c_ulong, atflag: ::c_int, ) -> ::c_int; + + pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; + pub fn clock_settime( + clk_id: ::clockid_t, + tp: *const ::timespec, + ) -> ::c_int; + pub fn clock_getcpuclockid( + pid: ::pid_t, + clk_id: *mut ::clockid_t, + ) -> ::c_int; + pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; pub fn duplocale(base: ::locale_t) -> ::locale_t; pub fn endutxent(); diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index dc6512df1fe8d..421e131ba4791 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -2761,11 +2761,6 @@ extern "C" { sevp: *mut ::sigevent, ) -> ::c_int; - pub fn clock_getcpuclockid( - pid: ::pid_t, - clk_id: *mut ::clockid_t, - ) -> ::c_int; - pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; pub fn setpwent(); diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index feb3f0fc8431e..e59ff5c62277e 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1310,12 +1310,18 @@ extern "C" { len: ::size_t, vec: *mut ::c_uchar, ) -> ::c_int; + pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int; pub fn clock_settime( clk_id: ::clockid_t, tp: *const ::timespec, ) -> ::c_int; + pub fn clock_getcpuclockid( + pid: ::pid_t, + clk_id: *mut ::clockid_t, + ) -> ::c_int; + pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; pub fn pthread_getattr_np(