summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-04-03 21:49:55 +0000
committerbors <bors@rust-lang.org>2023-04-03 21:49:55 +0000
commit2dc31a7f72b64d04346f0f1f4bb7e57cafd1ad5d (patch)
tree2e159eb7647ef5aead028c1ee148f9bb8899a292
parentc64bfc5fb36414e02ad7977b32df765876632383 (diff)
parent494999832f7342ab3c3ef8123a45fc69f434f1ab (diff)
downloadrust-libc-2dc31a7f72b64d04346f0f1f4bb7e57cafd1ad5d.tar.gz
Auto merge of #3155 - folkertdev:hardware-timestamping, r=JohnTitor
definitions for linux hardware timestamping Definitions can be found here https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/net_tstamp.h#L76 These definitions are relevant for (PTP and NTP) hardware timestamping
-rw-r--r--libc-test/build.rs5
-rw-r--r--libc-test/semver/linux.txt23
-rw-r--r--src/unix/linux_like/linux/mod.rs55
3 files changed, 82 insertions, 1 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 7c2834a807..ac0f996fc4 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -3394,7 +3394,7 @@ fn test_linux(target: &str) {
}
// FIXME(https://github.com/rust-lang/libc/issues/1558): passing by
// value corrupts the value for reasons not understood.
- if (gnu && sparc64) && ty == "ip_mreqn" {
+ if (gnu && sparc64) && (ty == "ip_mreqn" || ty == "hwtstamp_config") {
return true;
}
match ty {
@@ -3724,6 +3724,9 @@ fn test_linux(target: &str) {
=> true,
"SCTP_FUTURE_ASSOC" | "SCTP_CURRENT_ASSOC" | "SCTP_ALL_ASSOC" | "SCTP_PEER_ADDR_THLDS_V2" => true, // linux 5.5+
+ // FIXME: Requires more recent kernel headers
+ "HWTSTAMP_TX_ONESTEP_P2P" if sparc64 || musl => true, // linux v5.6+
+
_ => false,
}
});
diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt
index 53410113b9..178f76d946 100644
--- a/libc-test/semver/linux.txt
+++ b/libc-test/semver/linux.txt
@@ -818,6 +818,26 @@ GLOB_NOSPACE
GRND_NONBLOCK
GRND_RANDOM
GRND_INSECURE
+HWTSTAMP_TX_OFF
+HWTSTAMP_TX_ON
+HWTSTAMP_TX_ONESTEP_SYNC
+HWTSTAMP_TX_ONESTEP_P2P
+HWTSTAMP_FILTER_NONE
+HWTSTAMP_FILTER_ALL
+HWTSTAMP_FILTER_SOME
+HWTSTAMP_FILTER_PTP_V1_L4_EVENT
+HWTSTAMP_FILTER_PTP_V1_L4_SYNC
+HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ
+HWTSTAMP_FILTER_PTP_V2_L4_EVENT
+HWTSTAMP_FILTER_PTP_V2_L4_SYNC
+HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ
+HWTSTAMP_FILTER_PTP_V2_L2_EVENT
+HWTSTAMP_FILTER_PTP_V2_L2_SYNC
+HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ
+HWTSTAMP_FILTER_PTP_V2_EVENT
+HWTSTAMP_FILTER_PTP_V2_SYNC
+HWTSTAMP_FILTER_PTP_V2_DELAY_REQ
+HWTSTAMP_FILTER_NTP_ALL
IBSHIFT
IFA_ADDRESS
IFA_ANYCAST
@@ -2316,6 +2336,7 @@ SIOCDIFADDR
SIOCDRARP
SIOCETHTOOL
SIOCGARP
+SIOCGHWTSTAMP
SIOCGIFADDR
SIOCGIFBR
SIOCGIFBRDADDR
@@ -2341,6 +2362,7 @@ SIOGIFINDEX
SIOCGMIIPHY
SIOCGMIIREG
SIOCSARP
+SIOCSHWTSTAMP
SIOCSIFADDR
SIOCSIFBR
SIOCSIFBRDADDR
@@ -3128,6 +3150,7 @@ getspnam_r
gettid
getxattr
hasmntopt
+hwtstamp_config
iconv
iconv_close
iconv_open
diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs
index a1e1900747..a982901113 100644
--- a/src/unix/linux_like/linux/mod.rs
+++ b/src/unix/linux_like/linux/mod.rs
@@ -798,6 +798,12 @@ s_no_extra_traits! {
#[cfg(not(libc_union))]
pub ifr_ifru: ::sockaddr,
}
+
+ pub struct hwtstamp_config {
+ pub flags: ::c_int,
+ pub tx_type: ::c_int,
+ pub rx_filter: ::c_int,
+ }
}
s_no_extra_traits! {
@@ -1221,6 +1227,31 @@ cfg_if! {
.finish()
}
}
+
+ impl ::fmt::Debug for hwtstamp_config {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("hwtstamp_config")
+ .field("flags", &self.flags)
+ .field("tx_type", &self.tx_type)
+ .field("rx_filter", &self.rx_filter)
+ .finish()
+ }
+ }
+ impl PartialEq for hwtstamp_config {
+ fn eq(&self, other: &hwtstamp_config) -> bool {
+ self.flags == other.flags &&
+ self.tx_type == other.tx_type &&
+ self.rx_filter == other.rx_filter
+ }
+ }
+ impl Eq for hwtstamp_config {}
+ impl ::hash::Hash for hwtstamp_config {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.flags.hash(state);
+ self.tx_type.hash(state);
+ self.rx_filter.hash(state);
+ }
+ }
}
}
@@ -2771,6 +2802,8 @@ pub const SIOCGRARP: ::c_ulong = 0x00008961;
pub const SIOCSRARP: ::c_ulong = 0x00008962;
pub const SIOCGIFMAP: ::c_ulong = 0x00008970;
pub const SIOCSIFMAP: ::c_ulong = 0x00008971;
+pub const SIOCSHWTSTAMP: ::c_ulong = 0x000089b0;
+pub const SIOCGHWTSTAMP: ::c_ulong = 0x000089b1;
pub const IPTOS_TOS_MASK: u8 = 0x1E;
pub const IPTOS_PREC_MASK: u8 = 0xE0;
@@ -3129,6 +3162,28 @@ pub const SOF_TIMESTAMPING_OPT_TX_SWHW: ::c_uint = 1 << 14;
pub const SOF_TXTIME_DEADLINE_MODE: u32 = 1 << 0;
pub const SOF_TXTIME_REPORT_ERRORS: u32 = 1 << 1;
+pub const HWTSTAMP_TX_OFF: ::c_uint = 0;
+pub const HWTSTAMP_TX_ON: ::c_uint = 1;
+pub const HWTSTAMP_TX_ONESTEP_SYNC: ::c_uint = 2;
+pub const HWTSTAMP_TX_ONESTEP_P2P: ::c_uint = 3;
+
+pub const HWTSTAMP_FILTER_NONE: ::c_uint = 0;
+pub const HWTSTAMP_FILTER_ALL: ::c_uint = 1;
+pub const HWTSTAMP_FILTER_SOME: ::c_uint = 2;
+pub const HWTSTAMP_FILTER_PTP_V1_L4_EVENT: ::c_uint = 3;
+pub const HWTSTAMP_FILTER_PTP_V1_L4_SYNC: ::c_uint = 4;
+pub const HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ: ::c_uint = 5;
+pub const HWTSTAMP_FILTER_PTP_V2_L4_EVENT: ::c_uint = 6;
+pub const HWTSTAMP_FILTER_PTP_V2_L4_SYNC: ::c_uint = 7;
+pub const HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ: ::c_uint = 8;
+pub const HWTSTAMP_FILTER_PTP_V2_L2_EVENT: ::c_uint = 9;
+pub const HWTSTAMP_FILTER_PTP_V2_L2_SYNC: ::c_uint = 10;
+pub const HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ: ::c_uint = 11;
+pub const HWTSTAMP_FILTER_PTP_V2_EVENT: ::c_uint = 12;
+pub const HWTSTAMP_FILTER_PTP_V2_SYNC: ::c_uint = 13;
+pub const HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: ::c_uint = 14;
+pub const HWTSTAMP_FILTER_NTP_ALL: ::c_uint = 15;
+
// linux/if_alg.h
pub const ALG_SET_KEY: ::c_int = 1;
pub const ALG_SET_IV: ::c_int = 2;