Skip to content

Commit 00a0290

Browse files
committed
NetBSD: Introduce timex.rs
Move `timex.h` types to the `new/` module. (backport <#4782>) (cherry picked from commit fb74b6f)
1 parent 4ad7970 commit 00a0290

File tree

4 files changed

+96
-80
lines changed

4 files changed

+96
-80
lines changed

src/new/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ cfg_if! {
185185
} else if #[cfg(target_os = "netbsd")] {
186186
pub use sys::ipc::*;
187187
pub use sys::statvfs::*;
188+
pub use sys::timex::*;
188189
pub use sys::types::*;
189190
pub use utmp_::*;
190191
pub use utmpx_::*;

src/new/netbsd/sys/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
55
pub(crate) mod ipc;
66
pub(crate) mod statvfs;
7+
pub(crate) mod timex;
78
pub(crate) mod types;

src/new/netbsd/sys/timex.rs

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
//! Header: `sys/timex.h`
2+
//!
3+
//! <https://github.com/NetBSD/src/tree/trunk/sys/sys/timex.h>
4+
5+
use crate::prelude::*;
6+
7+
pub const MAXPHASE: c_long = 500000000;
8+
pub const MAXFREQ: c_long = 500000;
9+
pub const MINSEC: c_int = 256;
10+
pub const MAXSEC: c_int = 2048;
11+
pub const NANOSECOND: c_long = 1000000000;
12+
pub const SCALE_PPM: c_int = 65;
13+
pub const MAXTC: c_int = 10;
14+
15+
pub const MOD_OFFSET: c_uint = 0x0001;
16+
pub const MOD_FREQUENCY: c_uint = 0x0002;
17+
pub const MOD_MAXERROR: c_uint = 0x0004;
18+
pub const MOD_ESTERROR: c_uint = 0x0008;
19+
pub const MOD_STATUS: c_uint = 0x0010;
20+
pub const MOD_TIMECONST: c_uint = 0x0020;
21+
pub const MOD_PPSMAX: c_uint = 0x0040;
22+
pub const MOD_TAI: c_uint = 0x0080;
23+
pub const MOD_MICRO: c_uint = 0x1000;
24+
pub const MOD_NANO: c_uint = 0x2000;
25+
pub const MOD_CLKB: c_uint = 0x4000;
26+
pub const MOD_CLKA: c_uint = 0x8000;
27+
28+
pub const STA_PLL: c_int = 0x0001;
29+
pub const STA_PPSFREQ: c_int = 0x0002;
30+
pub const STA_PPSTIME: c_int = 0x0004;
31+
pub const STA_FLL: c_int = 0x0008;
32+
pub const STA_INS: c_int = 0x0010;
33+
pub const STA_DEL: c_int = 0x0020;
34+
pub const STA_UNSYNC: c_int = 0x0040;
35+
pub const STA_FREQHOLD: c_int = 0x0080;
36+
pub const STA_PPSSIGNAL: c_int = 0x0100;
37+
pub const STA_PPSJITTER: c_int = 0x0200;
38+
pub const STA_PPSWANDER: c_int = 0x0400;
39+
pub const STA_PPSERROR: c_int = 0x0800;
40+
pub const STA_CLOCKERR: c_int = 0x1000;
41+
pub const STA_NANO: c_int = 0x2000;
42+
pub const STA_MODE: c_int = 0x4000;
43+
pub const STA_CLK: c_int = 0x8000;
44+
45+
pub const STA_RONLY: c_int = STA_PPSSIGNAL
46+
| STA_PPSJITTER
47+
| STA_PPSWANDER
48+
| STA_PPSERROR
49+
| STA_CLOCKERR
50+
| STA_NANO
51+
| STA_MODE
52+
| STA_CLK;
53+
54+
pub const TIME_OK: c_int = 0;
55+
pub const TIME_INS: c_int = 1;
56+
pub const TIME_DEL: c_int = 2;
57+
pub const TIME_OOP: c_int = 3;
58+
pub const TIME_WAIT: c_int = 4;
59+
pub const TIME_ERROR: c_int = 5;
60+
61+
s! {
62+
pub struct ntptimeval {
63+
pub time: crate::timespec,
64+
pub maxerror: c_long,
65+
pub esterror: c_long,
66+
pub tai: c_long,
67+
pub time_state: c_int,
68+
}
69+
70+
pub struct timex {
71+
pub modes: c_uint,
72+
pub offset: c_long,
73+
pub freq: c_long,
74+
pub maxerror: c_long,
75+
pub esterror: c_long,
76+
pub status: c_int,
77+
pub constant: c_long,
78+
pub precision: c_long,
79+
pub tolerance: c_long,
80+
pub ppsfreq: c_long,
81+
pub jitter: c_long,
82+
pub shift: c_int,
83+
pub stabil: c_long,
84+
pub jitcnt: c_long,
85+
pub calcnt: c_long,
86+
pub errcnt: c_long,
87+
pub stbcnt: c_long,
88+
}
89+
}
90+
91+
extern "C" {
92+
pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int;
93+
pub fn ntp_adjtime(buf: *mut timex) -> c_int;
94+
}

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -426,34 +426,6 @@ s! {
426426
_shm_internal: *mut c_void,
427427
}
428428

429-
pub struct timex {
430-
pub modes: c_uint,
431-
pub offset: c_long,
432-
pub freq: c_long,
433-
pub maxerror: c_long,
434-
pub esterror: c_long,
435-
pub status: c_int,
436-
pub constant: c_long,
437-
pub precision: c_long,
438-
pub tolerance: c_long,
439-
pub ppsfreq: c_long,
440-
pub jitter: c_long,
441-
pub shift: c_int,
442-
pub stabil: c_long,
443-
pub jitcnt: c_long,
444-
pub calcnt: c_long,
445-
pub errcnt: c_long,
446-
pub stbcnt: c_long,
447-
}
448-
449-
pub struct ntptimeval {
450-
pub time: crate::timespec,
451-
pub maxerror: c_long,
452-
pub esterror: c_long,
453-
pub tai: c_long,
454-
pub time_state: c_int,
455-
}
456-
457429
// elf.h
458430

459431
pub struct Elf32_Phdr {
@@ -1368,59 +1340,9 @@ pub const fn _IOC(inout: c_ulong, group: c_ulong, num: c_ulong, len: c_ulong) ->
13681340
| (num)
13691341
}
13701342

1371-
//<sys/timex.h>
13721343
pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 2;
13731344
pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 4;
13741345
pub const NTP_API: c_int = 4;
1375-
pub const MAXPHASE: c_long = 500000000;
1376-
pub const MAXFREQ: c_long = 500000;
1377-
pub const MINSEC: c_int = 256;
1378-
pub const MAXSEC: c_int = 2048;
1379-
pub const NANOSECOND: c_long = 1000000000;
1380-
pub const SCALE_PPM: c_int = 65;
1381-
pub const MAXTC: c_int = 10;
1382-
pub const MOD_OFFSET: c_uint = 0x0001;
1383-
pub const MOD_FREQUENCY: c_uint = 0x0002;
1384-
pub const MOD_MAXERROR: c_uint = 0x0004;
1385-
pub const MOD_ESTERROR: c_uint = 0x0008;
1386-
pub const MOD_STATUS: c_uint = 0x0010;
1387-
pub const MOD_TIMECONST: c_uint = 0x0020;
1388-
pub const MOD_PPSMAX: c_uint = 0x0040;
1389-
pub const MOD_TAI: c_uint = 0x0080;
1390-
pub const MOD_MICRO: c_uint = 0x1000;
1391-
pub const MOD_NANO: c_uint = 0x2000;
1392-
pub const MOD_CLKB: c_uint = 0x4000;
1393-
pub const MOD_CLKA: c_uint = 0x8000;
1394-
pub const STA_PLL: c_int = 0x0001;
1395-
pub const STA_PPSFREQ: c_int = 0x0002;
1396-
pub const STA_PPSTIME: c_int = 0x0004;
1397-
pub const STA_FLL: c_int = 0x0008;
1398-
pub const STA_INS: c_int = 0x0010;
1399-
pub const STA_DEL: c_int = 0x0020;
1400-
pub const STA_UNSYNC: c_int = 0x0040;
1401-
pub const STA_FREQHOLD: c_int = 0x0080;
1402-
pub const STA_PPSSIGNAL: c_int = 0x0100;
1403-
pub const STA_PPSJITTER: c_int = 0x0200;
1404-
pub const STA_PPSWANDER: c_int = 0x0400;
1405-
pub const STA_PPSERROR: c_int = 0x0800;
1406-
pub const STA_CLOCKERR: c_int = 0x1000;
1407-
pub const STA_NANO: c_int = 0x2000;
1408-
pub const STA_MODE: c_int = 0x4000;
1409-
pub const STA_CLK: c_int = 0x8000;
1410-
pub const STA_RONLY: c_int = STA_PPSSIGNAL
1411-
| STA_PPSJITTER
1412-
| STA_PPSWANDER
1413-
| STA_PPSERROR
1414-
| STA_CLOCKERR
1415-
| STA_NANO
1416-
| STA_MODE
1417-
| STA_CLK;
1418-
pub const TIME_OK: c_int = 0;
1419-
pub const TIME_INS: c_int = 1;
1420-
pub const TIME_DEL: c_int = 2;
1421-
pub const TIME_OOP: c_int = 3;
1422-
pub const TIME_WAIT: c_int = 4;
1423-
pub const TIME_ERROR: c_int = 5;
14241346

14251347
pub const LITTLE_ENDIAN: c_int = 1234;
14261348
pub const BIG_ENDIAN: c_int = 4321;
@@ -2001,8 +1923,6 @@ safe_f! {
20011923
}
20021924

20031925
extern "C" {
2004-
pub fn ntp_adjtime(buf: *mut timex) -> c_int;
2005-
pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int;
20061926
pub fn clock_nanosleep(
20071927
clk_id: crate::clockid_t,
20081928
flags: c_int,

0 commit comments

Comments
 (0)