summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2020-03-07 09:59:11 +0900
committerGitHub <noreply@github.com>2020-03-07 09:59:11 +0900
commit00e8c79f6041f7653b22344c38734f0ed7dc559e (patch)
treec7faaac3bd96457df5a8c33963719d0fb956b48b
parent7477c68275b1b6da3e8ce81d0545c9484236b35f (diff)
parent51f1aa42c017d6f2e4f58fd69093318a36b9f07d (diff)
downloadrust-libc-00e8c79f6041f7653b22344c38734f0ed7dc559e.tar.gz
Merge pull request #1642 from dfoxfranke/sys-timex
<sys/timex.h>
-rw-r--r--libc-test/build.rs9
-rw-r--r--src/unix/bsd/apple/mod.rs83
-rw-r--r--src/unix/bsd/freebsdlike/mod.rs83
-rw-r--r--src/unix/bsd/netbsdlike/netbsd/mod.rs86
-rw-r--r--src/unix/linux_like/linux/gnu/mod.rs155
-rw-r--r--src/unix/solarish/mod.rs82
6 files changed, 497 insertions, 1 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs
index b8e8ac85c0..d16f094559 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -150,6 +150,7 @@ fn test_apple(target: &str) {
"sys/sysctl.h",
"sys/time.h",
"sys/times.h",
+ "sys/timex.h",
"sys/types.h",
"sys/uio.h",
"sys/un.h",
@@ -706,6 +707,7 @@ fn test_solaris(target: &str) {
"sys/statvfs.h",
"sys/time.h",
"sys/times.h",
+ "sys/timex.h",
"sys/types.h",
"sys/uio.h",
"sys/un.h",
@@ -819,6 +821,7 @@ fn test_netbsd(target: &str) {
"sys/sysctl.h",
"sys/time.h",
"sys/times.h",
+ "sys/timex.h",
"sys/uio.h",
"sys/un.h",
"sys/utsname.h",
@@ -1569,6 +1572,7 @@ fn test_freebsd(target: &str) {
"sys/sysctl.h",
"sys/time.h",
"sys/times.h",
+ "sys/timex.h",
"sys/types.h",
"sys/uio.h",
"sys/un.h",
@@ -2183,6 +2187,7 @@ fn test_linux(target: &str) {
"sys/time.h",
"sys/timerfd.h",
"sys/times.h",
+ "sys/timex.h",
"sys/types.h",
"sys/uio.h",
"sys/un.h",
@@ -2513,7 +2518,9 @@ fn test_linux(target: &str) {
"sched_ss_max_repl",
].contains(&field) && musl) ||
// FIXME: After musl 1.1.24, the type becomes `int` instead of `unsigned short`.
- (struct_ == "ipc_perm" && field == "__seq" && aarch64_musl)
+ (struct_ == "ipc_perm" && field == "__seq" && aarch64_musl) ||
+ // glibc uses unnamed fields here and Rust doesn't support that yet
+ (struct_ == "timex" && field.starts_with("__unused"))
});
cfg.skip_roundtrip(move |s| match s {
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index 6ec48f36d9..432e73e19d 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -506,6 +506,34 @@ s! {
pub sae_dstaddr: *const ::sockaddr, // destination address
pub sae_dstaddrlen: ::socklen_t, // size of destination address
}
+
+ pub struct timex {
+ pub modes: ::c_uint,
+ pub offset: ::c_long,
+ pub freq: ::c_long,
+ pub maxerror: ::c_long,
+ pub esterror: ::c_long,
+ pub status: ::c_int,
+ pub constant: ::c_long,
+ pub precision: ::c_long,
+ pub tolerance: ::c_long,
+ pub ppsfreq: ::c_long,
+ pub jitter: ::c_long,
+ pub shift: ::c_int,
+ pub stabil: ::c_long,
+ pub jitcnt: ::c_long,
+ pub calcnt: ::c_long,
+ pub errcnt: ::c_long,
+ pub stbcnt: ::c_long,
+ }
+
+ pub struct ntptimeval {
+ pub time: ::timespec,
+ pub maxerror: ::c_long,
+ pub esterror: ::c_long,
+ pub tai: ::c_long,
+ pub time_state: ::c_int,
+ }
}
s_no_extra_traits! {
@@ -3063,6 +3091,58 @@ pub const SF_IMMUTABLE: ::c_uint = 0x00020000;
pub const SF_APPEND: ::c_uint = 0x00040000;
pub const UF_HIDDEN: ::c_uint = 0x00008000;
+//<sys/timex.h>
+pub const NTP_API: ::c_int = 4;
+pub const MAXPHASE: ::c_long = 500000000;
+pub const MAXFREQ: ::c_long = 500000;
+pub const MINSEC: ::c_int = 256;
+pub const MAXSEC: ::c_int = 2048;
+pub const NANOSECOND: ::c_long = 1000000000;
+pub const SCALE_PPM: ::c_int = 65;
+pub const MAXTC: ::c_int = 10;
+pub const MOD_OFFSET: ::c_uint = 0x0001;
+pub const MOD_FREQUENCY: ::c_uint = 0x0002;
+pub const MOD_MAXERROR: ::c_uint = 0x0004;
+pub const MOD_ESTERROR: ::c_uint = 0x0008;
+pub const MOD_STATUS: ::c_uint = 0x0010;
+pub const MOD_TIMECONST: ::c_uint = 0x0020;
+pub const MOD_PPSMAX: ::c_uint = 0x0040;
+pub const MOD_TAI: ::c_uint = 0x0080;
+pub const MOD_MICRO: ::c_uint = 0x1000;
+pub const MOD_NANO: ::c_uint = 0x2000;
+pub const MOD_CLKB: ::c_uint = 0x4000;
+pub const MOD_CLKA: ::c_uint = 0x8000;
+pub const STA_PLL: ::c_int = 0x0001;
+pub const STA_PPSFREQ: ::c_int = 0x0002;
+pub const STA_PPSTIME: ::c_int = 0x0004;
+pub const STA_FLL: ::c_int = 0x0008;
+pub const STA_INS: ::c_int = 0x0010;
+pub const STA_DEL: ::c_int = 0x0020;
+pub const STA_UNSYNC: ::c_int = 0x0040;
+pub const STA_FREQHOLD: ::c_int = 0x0080;
+pub const STA_PPSSIGNAL: ::c_int = 0x0100;
+pub const STA_PPSJITTER: ::c_int = 0x0200;
+pub const STA_PPSWANDER: ::c_int = 0x0400;
+pub const STA_PPSERROR: ::c_int = 0x0800;
+pub const STA_CLOCKERR: ::c_int = 0x1000;
+pub const STA_NANO: ::c_int = 0x2000;
+pub const STA_MODE: ::c_int = 0x4000;
+pub const STA_CLK: ::c_int = 0x8000;
+pub const STA_RONLY: ::c_int = STA_PPSSIGNAL
+ | STA_PPSJITTER
+ | STA_PPSWANDER
+ | STA_PPSERROR
+ | STA_CLOCKERR
+ | STA_NANO
+ | STA_MODE
+ | STA_CLK;
+pub const TIME_OK: ::c_int = 0;
+pub const TIME_INS: ::c_int = 1;
+pub const TIME_DEL: ::c_int = 2;
+pub const TIME_OOP: ::c_int = 3;
+pub const TIME_WAIT: ::c_int = 4;
+pub const TIME_ERROR: ::c_int = 5;
+
cfg_if! {
if #[cfg(libc_const_size_of)] {
fn __DARWIN_ALIGN32(p: usize) -> usize {
@@ -3576,6 +3656,9 @@ extern "C" {
associd: sae_associd_t,
connid: sae_connid_t,
) -> ::c_int;
+
+ pub fn ntp_adjtime(buf: *mut timex) -> ::c_int;
+ pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
}
cfg_if! {
diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs
index 1b7804cb27..d0510466db 100644
--- a/src/unix/bsd/freebsdlike/mod.rs
+++ b/src/unix/bsd/freebsdlike/mod.rs
@@ -190,6 +190,34 @@ s! {
pub ar_pln: u8,
pub ar_op: u16,
}
+
+ pub struct timex {
+ pub modes: ::c_uint,
+ pub offset: ::c_long,
+ pub freq: ::c_long,
+ pub maxerror: ::c_long,
+ pub esterror: ::c_long,
+ pub status: ::c_int,
+ pub constant: ::c_long,
+ pub precision: ::c_long,
+ pub tolerance: ::c_long,
+ pub ppsfreq: ::c_long,
+ pub jitter: ::c_long,
+ pub shift: ::c_int,
+ pub stabil: ::c_long,
+ pub jitcnt: ::c_long,
+ pub calcnt: ::c_long,
+ pub errcnt: ::c_long,
+ pub stbcnt: ::c_long,
+ }
+
+ pub struct ntptimeval {
+ pub time: ::timespec,
+ pub maxerror: ::c_long,
+ pub esterror: ::c_long,
+ pub tai: ::c_long,
+ pub time_state: ::c_int,
+ }
}
s_no_extra_traits! {
@@ -1101,6 +1129,58 @@ pub const SF_NOUNLINK: ::c_ulong = 0x00100000;
pub const TIMER_ABSTIME: ::c_int = 1;
+//<sys/timex.h>
+pub const NTP_API: ::c_int = 4;
+pub const MAXPHASE: ::c_long = 500000000;
+pub const MAXFREQ: ::c_long = 500000;
+pub const MINSEC: ::c_int = 256;
+pub const MAXSEC: ::c_int = 2048;
+pub const NANOSECOND: ::c_long = 1000000000;
+pub const SCALE_PPM: ::c_int = 65;
+pub const MAXTC: ::c_int = 10;
+pub const MOD_OFFSET: ::c_uint = 0x0001;
+pub const MOD_FREQUENCY: ::c_uint = 0x0002;
+pub const MOD_MAXERROR: ::c_uint = 0x0004;
+pub const MOD_ESTERROR: ::c_uint = 0x0008;
+pub const MOD_STATUS: ::c_uint = 0x0010;
+pub const MOD_TIMECONST: ::c_uint = 0x0020;
+pub const MOD_PPSMAX: ::c_uint = 0x0040;
+pub const MOD_TAI: ::c_uint = 0x0080;
+pub const MOD_MICRO: ::c_uint = 0x1000;
+pub const MOD_NANO: ::c_uint = 0x2000;
+pub const MOD_CLKB: ::c_uint = 0x4000;
+pub const MOD_CLKA: ::c_uint = 0x8000;
+pub const STA_PLL: ::c_int = 0x0001;
+pub const STA_PPSFREQ: ::c_int = 0x0002;
+pub const STA_PPSTIME: ::c_int = 0x0004;
+pub const STA_FLL: ::c_int = 0x0008;
+pub const STA_INS: ::c_int = 0x0010;
+pub const STA_DEL: ::c_int = 0x0020;
+pub const STA_UNSYNC: ::c_int = 0x0040;
+pub const STA_FREQHOLD: ::c_int = 0x0080;
+pub const STA_PPSSIGNAL: ::c_int = 0x0100;
+pub const STA_PPSJITTER: ::c_int = 0x0200;
+pub const STA_PPSWANDER: ::c_int = 0x0400;
+pub const STA_PPSERROR: ::c_int = 0x0800;
+pub const STA_CLOCKERR: ::c_int = 0x1000;
+pub const STA_NANO: ::c_int = 0x2000;
+pub const STA_MODE: ::c_int = 0x4000;
+pub const STA_CLK: ::c_int = 0x8000;
+pub const STA_RONLY: ::c_int = STA_PPSSIGNAL
+ | STA_PPSJITTER
+ | STA_PPSWANDER
+ | STA_PPSERROR
+ | STA_CLOCKERR
+ | STA_NANO
+ | STA_MODE
+ | STA_CLK;
+pub const TIME_OK: ::c_int = 0;
+pub const TIME_INS: ::c_int = 1;
+pub const TIME_DEL: ::c_int = 2;
+pub const TIME_OOP: ::c_int = 3;
+pub const TIME_WAIT: ::c_int = 4;
+pub const TIME_ERROR: ::c_int = 5;
+
f! {
pub fn WIFCONTINUED(status: ::c_int) -> bool {
status == 0x13
@@ -1433,6 +1513,9 @@ extern "C" {
times: *const ::timespec,
flag: ::c_int,
) -> ::c_int;
+
+ pub fn ntp_adjtime(buf: *mut timex) -> ::c_int;
+ pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
}
#[link(name = "util")]
diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs
index 48c9038631..09dfb22dbc 100644
--- a/src/unix/bsd/netbsdlike/netbsd/mod.rs
+++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs
@@ -312,6 +312,35 @@ s! {
pub ll_host: [::c_char; UT_HOSTSIZE],
pub ll_time: ::time_t
}
+
+ pub struct timex {
+ pub modes: ::c_uint,
+ pub offset: ::c_long,
+ pub freq: ::c_long,
+ pub maxerror: ::c_long,
+ pub esterror: ::c_long,
+ pub status: ::c_int,
+ pub constant: ::c_long,
+ pub precision: ::c_long,
+ pub tolerance: ::c_long,
+ pub ppsfreq: ::c_long,
+ pub jitter: ::c_long,
+ pub shift: ::c_int,
+ pub stabil: ::c_long,
+ pub jitcnt: ::c_long,
+ pub calcnt: ::c_long,
+ pub errcnt: ::c_long,
+ pub stbcnt: ::c_long,
+ }
+
+ pub struct ntptimeval {
+ pub time: ::timespec,
+ pub maxerror: ::c_long,
+ pub esterror: ::c_long,
+ pub tai: ::c_long,
+ pub time_state: ::c_int,
+ }
+
}
s_no_extra_traits! {
@@ -1233,6 +1262,58 @@ pub const BIOCSDLT: ::c_ulong = 0x80044278;
pub const BIOCGSEESENT: ::c_ulong = 0x40044276;
pub const BIOCSSEESENT: ::c_ulong = 0x80044277;
+//<sys/timex.h>
+pub const NTP_API: ::c_int = 4;
+pub const MAXPHASE: ::c_long = 500000000;
+pub const MAXFREQ: ::c_long = 500000;
+pub const MINSEC: ::c_int = 256;
+pub const MAXSEC: ::c_int = 2048;
+pub const NANOSECOND: ::c_long = 1000000000;
+pub const SCALE_PPM: ::c_int = 65;
+pub const MAXTC: ::c_int = 10;
+pub const MOD_OFFSET: ::c_uint = 0x0001;
+pub const MOD_FREQUENCY: ::c_uint = 0x0002;
+pub const MOD_MAXERROR: ::c_uint = 0x0004;
+pub const MOD_ESTERROR: ::c_uint = 0x0008;
+pub const MOD_STATUS: ::c_uint = 0x0010;
+pub const MOD_TIMECONST: ::c_uint = 0x0020;
+pub const MOD_PPSMAX: ::c_uint = 0x0040;
+pub const MOD_TAI: ::c_uint = 0x0080;
+pub const MOD_MICRO: ::c_uint = 0x1000;
+pub const MOD_NANO: ::c_uint = 0x2000;
+pub const MOD_CLKB: ::c_uint = 0x4000;
+pub const MOD_CLKA: ::c_uint = 0x8000;
+pub const STA_PLL: ::c_int = 0x0001;
+pub const STA_PPSFREQ: ::c_int = 0x0002;
+pub const STA_PPSTIME: ::c_int = 0x0004;
+pub const STA_FLL: ::c_int = 0x0008;
+pub const STA_INS: ::c_int = 0x0010;
+pub const STA_DEL: ::c_int = 0x0020;
+pub const STA_UNSYNC: ::c_int = 0x0040;
+pub const STA_FREQHOLD: ::c_int = 0x0080;
+pub const STA_PPSSIGNAL: ::c_int = 0x0100;
+pub const STA_PPSJITTER: ::c_int = 0x0200;
+pub const STA_PPSWANDER: ::c_int = 0x0400;
+pub const STA_PPSERROR: ::c_int = 0x0800;
+pub const STA_CLOCKERR: ::c_int = 0x1000;
+pub const STA_NANO: ::c_int = 0x2000;
+pub const STA_MODE: ::c_int = 0x4000;
+pub const STA_CLK: ::c_int = 0x8000;
+pub const STA_RONLY: ::c_int = STA_PPSSIGNAL
+ | STA_PPSJITTER
+ | STA_PPSWANDER
+ | STA_PPSERROR
+ | STA_CLOCKERR
+ | STA_NANO
+ | STA_MODE
+ | STA_CLK;
+pub const TIME_OK: ::c_int = 0;
+pub const TIME_INS: ::c_int = 1;
+pub const TIME_DEL: ::c_int = 2;
+pub const TIME_OOP: ::c_int = 3;
+pub const TIME_WAIT: ::c_int = 4;
+pub const TIME_ERROR: ::c_int = 5;
+
cfg_if! {
if #[cfg(any(target_arch = "sparc", target_arch = "sparc64",
target_arch = "x86", target_arch = "x86_64"))] {
@@ -1649,6 +1730,11 @@ f! {
}
}
+extern "C" {
+ pub fn ntp_adjtime(buf: *mut timex) -> ::c_int;
+ pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
+}
+
#[link(name = "rt")]
extern "C" {
pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int;
diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs
index 39269d792b..a79d73cc62 100644
--- a/src/unix/linux_like/linux/gnu/mod.rs
+++ b/src/unix/linux_like/linux/gnu/mod.rs
@@ -183,6 +183,96 @@ s! {
pub rt_window: ::c_ulong,
pub rt_irtt: ::c_ushort,
}
+
+ pub struct timex {
+ pub modes: ::c_uint,
+ #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+ pub offset: i64,
+ #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
+ pub offset: ::c_long,
+ #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+ pub freq: i64,
+ #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
+ pub freq: ::c_long,
+ #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+ pub maxerror: i64,
+ #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
+ pub maxerror: ::c_long,
+ #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+ pub esterror: i64,
+ #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
+ pub esterror: ::c_long,
+ pub status: ::c_int,
+ #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+ pub constant: i64,
+ #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
+ pub constant: ::c_long,
+ #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+ pub precision: i64,
+ #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
+ pub precision: ::c_long,
+ #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+ pub tolerance: i64,
+ #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
+ pub tolerance: ::c_long,
+ pub time: ::timeval,
+ #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+ pub tick: i64,
+ #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
+ pub tick: ::c_long,
+ #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+ pub ppsfreq: i64,
+ #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
+ pub ppsfreq: ::c_long,
+ #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+ pub jitter: i64,
+ #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
+ pub jitter: ::c_long,
+ pub shift: ::c_int,
+ #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+ pub stabil: i64,
+ #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
+ pub stabil: ::c_long,
+ #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+ pub jitcnt: i64,
+ #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
+ pub jitcnt: ::c_long,
+ #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+ pub calcnt: i64,
+ #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
+ pub calcnt: ::c_long,
+ #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+ pub errcnt: i64,
+ #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
+ pub errcnt: ::c_long,
+ #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))]
+ pub stbcnt: i64,
+ #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))]
+ pub stbcnt: ::c_long,
+ pub tai: ::c_int,
+ pub __unused1: i32,
+ pub __unused2: i32,
+ pub __unused3: i32,
+ pub __unused4: i32,
+ pub __unused5: i32,
+ pub __unused6: i32,
+ pub __unused7: i32,
+ pub __unused8: i32,
+ pub __unused9: i32,
+ pub __unused10: i32,
+ pub __unused11: i32,
+ }
+
+ pub struct ntptimeval {
+ pub time: ::timeval,
+ pub maxerror: ::c_long,
+ pub esterror: ::c_long,
+ pub tai: ::c_long,
+ pub __glibc_reserved1: ::c_long,
+ pub __glibc_reserved2: ::c_long,
+ pub __glibc_reserved3: ::c_long,
+ pub __glibc_reserved4: ::c_long,
+ }
}
impl siginfo_t {
@@ -902,6 +992,65 @@ pub const AT_HWCAP2: ::c_ulong = 26;
pub const AT_EXECFN: ::c_ulong = 31;
+//sys/timex.h
+pub const ADJ_OFFSET: ::c_uint = 0x0001;
+pub const ADJ_FREQUENCY: ::c_uint = 0x0002;
+pub const ADJ_MAXERROR: ::c_uint = 0x0004;
+pub const ADJ_ESTERROR: ::c_uint = 0x0008;
+pub const ADJ_STATUS: ::c_uint = 0x0010;
+pub const ADJ_TIMECONST: ::c_uint = 0x0020;
+pub const ADJ_TAI: ::c_uint = 0x0080;
+pub const ADJ_SETOFFSET: ::c_uint = 0x0100;
+pub const ADJ_MICRO: ::c_uint = 0x1000;
+pub const ADJ_NANO: ::c_uint = 0x2000;
+pub const ADJ_TICK: ::c_uint = 0x4000;
+pub const ADJ_OFFSET_SINGLESHOT: ::c_uint = 0x8001;
+pub const ADJ_OFFSET_SS_READ: ::c_uint = 0xa001;
+pub const MOD_OFFSET: ::c_uint = ADJ_OFFSET;
+pub const MOD_FREQUENCY: ::c_uint = ADJ_FREQUENCY;
+pub const MOD_MAXERROR: ::c_uint = ADJ_MAXERROR;
+pub const MOD_ESTERROR: ::c_uint = ADJ_ESTERROR;
+pub const MOD_STATUS: ::c_uint = ADJ_STATUS;
+pub const MOD_TIMECONST: ::c_uint = ADJ_TIMECONST;
+pub const MOD_CLKB: ::c_uint = ADJ_TICK;
+pub const MOD_CLKA: ::c_uint = ADJ_OFFSET_SINGLESHOT;
+pub const MOD_TAI: ::c_uint = ADJ_TAI;
+pub const MOD_MICRO: ::c_uint = ADJ_MICRO;
+pub const MOD_NANO: ::c_uint = ADJ_NANO;
+pub const STA_PLL: ::c_int = 0x0001;
+pub const STA_PPSFREQ: ::c_int = 0x0002;
+pub const STA_PPSTIME: ::c_int = 0x0004;
+pub const STA_FLL: ::c_int = 0x0008;
+pub const STA_INS: ::c_int = 0x0010;
+pub const STA_DEL: ::c_int = 0x0020;
+pub const STA_UNSYNC: ::c_int = 0x0040;
+pub const STA_FREQHOLD: ::c_int = 0x0080;
+pub const STA_PPSSIGNAL: ::c_int = 0x0100;
+pub const STA_PPSJITTER: ::c_int = 0x0200;
+pub const STA_PPSWANDER: ::c_int = 0x0400;
+pub const STA_PPSERROR: ::c_int = 0x0800;
+pub const STA_CLOCKERR: ::c_int = 0x1000;
+pub const STA_NANO: ::c_int = 0x2000;
+pub const STA_MODE: ::c_int = 0x4000;
+pub const STA_CLK: ::c_int = 0x8000;
+pub const STA_RONLY: ::c_int = STA_PPSSIGNAL
+ | STA_PPSJITTER
+ | STA_PPSWANDER
+ | STA_PPSERROR
+ | STA_CLOCKERR
+ | STA_NANO
+ | STA_MODE
+ | STA_CLK;
+pub const NTP_API: ::c_int = 4;
+pub const TIME_OK: ::c_int = 0;
+pub const TIME_INS: ::c_int = 1;
+pub const TIME_DEL: ::c_int = 2;
+pub const TIME_OOP: ::c_int = 3;
+pub const TIME_WAIT: ::c_int = 4;
+pub const TIME_ERROR: ::c_int = 5;
+pub const TIME_BAD: ::c_int = TIME_ERROR;
+pub const MAXTC: ::c_long = 6;
+
cfg_if! {
if #[cfg(any(
target_arch = "arm",
@@ -1001,6 +1150,7 @@ extern "C" {
buflen: ::size_t,
flags: ::c_uint,
) -> ::ssize_t;
+
pub fn memmem(
haystack: *const ::c_void,
haystacklen: ::size_t,
@@ -1008,6 +1158,11 @@ extern "C" {
needlelen: ::size_t,
) -> *mut ::c_void;
pub fn getauxval(type_: ::c_ulong) -> ::c_ulong;
+
+ pub fn adjtimex(buf: *mut timex) -> ::c_int;
+ pub fn ntp_adjtime(buf: *mut timex) -> ::c_int;
+ #[link_name = "ntp_gettimex"]
+ pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
}
#[link(name = "util")]
diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs
index 136136705d..f5f4686e27 100644
--- a/src/unix/solarish/mod.rs
+++ b/src/unix/solarish/mod.rs
@@ -401,6 +401,33 @@ s! {
pub ut_exit: exit_status,
pub ut_time: ::time_t,
}
+
+ pub struct timex {
+ pub modes: u32,
+ pub offset: i32,
+ pub freq: i32,
+ pub maxerror: i32,
+ pub esterror: i32,
+ pub status: i32,
+ pub constant: i32,
+ pub precision: i32,
+ pub tolerance: i32,
+ pub ppsfreq: i32,
+ pub jitter: i32,
+ pub shift: i32,
+ pub stabil: i32,
+ pub jitcnt: i32,
+ pub calcnt: i32,
+ pub errcnt: i32,
+ pub stbcnt: i32,
+ }
+
+ pub struct ntptimeval {
+ pub time: ::timeval,
+ pub maxerror: i32,
+ pub esterror: i32,
+ }
+
}
s_no_extra_traits! {
@@ -1963,6 +1990,58 @@ pub const SOCK_CLOEXEC: ::c_int = 0x080000;
pub const SOCK_NONBLOCK: ::c_int = 0x100000;
pub const SOCK_NDELAY: ::c_int = 0x200000;
+//<sys/timex.h>
+pub const SCALE_KG: ::c_int = 1 << 6;
+pub const SCALE_KF: ::c_int = 1 << 16;
+pub const SCALE_KH: ::c_int = 1 << 2;
+pub const MAXTC: ::c_int = 1 << 6;
+pub const SCALE_PHASE: ::c_int = 1 << 22;
+pub const SCALE_USEC: ::c_int = 1 << 16;
+pub const SCALE_UPDATE: ::c_int = SCALE_KG * MAXTC;
+pub const FINEUSEC: ::c_int = 1 << 22;
+pub const MAXPHASE: ::c_int = 512000;
+pub const MAXFREQ: ::c_int = 512 * SCALE_USEC;
+pub const MAXTIME: ::c_int = 200 << PPS_AVG;
+pub const MINSEC: ::c_int = 16;
+pub const MAXSEC: ::c_int = 1200;
+pub const PPS_AVG: ::c_int = 2;
+pub const PPS_SHIFT: ::c_int = 2;
+pub const PPS_SHIFTMAX: ::c_int = 8;
+pub const PPS_VALID: ::c_int = 120;
+pub const MAXGLITCH: ::c_int = 30;
+pub const MOD_OFFSET: u32 = 0x0001;
+pub const MOD_FREQUENCY: u32 = 0x0002;
+pub const MOD_MAXERROR: u32 = 0x0004;
+pub const MOD_ESTERROR: u32 = 0x0008;
+pub const MOD_STATUS: u32 = 0x0010;
+pub const MOD_TIMECONST: u32 = 0x0020;
+pub const MOD_CLKB: u32 = 0x4000;
+pub const MOD_CLKA: u32 = 0x8000;
+pub const STA_PLL: u32 = 0x0001;
+pub const STA_PPSFREQ: i32 = 0x0002;
+pub const STA_PPSTIME: i32 = 0x0004;
+pub const STA_FLL: i32 = 0x0008;
+pub const STA_INS: i32 = 0x0010;
+pub const STA_DEL: i32 = 0x0020;
+pub const STA_UNSYNC: i32 = 0x0040;
+pub const STA_FREQHOLD: i32 = 0x0080;
+pub const STA_PPSSIGNAL: i32 = 0x0100;
+pub const STA_PPSJITTER: i32 = 0x0200;
+pub const STA_PPSWANDER: i32 = 0x0400;
+pub const STA_PPSERROR: i32 = 0x0800;
+pub const STA_CLOCKERR: i32 = 0x1000;
+pub const STA_RONLY: i32 = STA_PPSSIGNAL
+ | STA_PPSJITTER
+ | STA_PPSWANDER
+ | STA_PPSERROR
+ | STA_CLOCKERR;
+pub const TIME_OK: i32 = 0;
+pub const TIME_INS: i32 = 1;
+pub const TIME_DEL: i32 = 2;
+pub const TIME_OOP: i32 = 3;
+pub const TIME_WAIT: i32 = 4;
+pub const TIME_ERROR: i32 = 5;
+
f! {
pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
@@ -2496,6 +2575,9 @@ extern "C" {
pub fn getutmp(ux: *const utmpx, u: *mut utmp);
pub fn getutmpx(u: *const utmp, ux: *mut utmpx);
pub fn updwtmp(file: *const ::c_char, u: *mut utmp);
+
+ pub fn ntp_adjtime(buf: *mut timex) -> ::c_int;
+ pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
}
mod compat;