Skip to content

Commit 2b821f3

Browse files
committed
Add more archs for timestampns
1 parent d9130b4 commit 2b821f3

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

src/sys/socket/mod.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ use libc::{self, c_void, c_int, iovec, socklen_t, size_t,
77
CMSG_FIRSTHDR, CMSG_NXTHDR, CMSG_DATA, CMSG_LEN};
88
use std::{mem, ptr, slice};
99
use std::os::unix::io::RawFd;
10-
#[cfg(all(target_os = "linux", any(target_arch = "x86_64"), target_env = "gnu"))]
10+
#[cfg(all(target_os = "linux", any(
11+
target_arch = "x86",
12+
target_arch = "x86_64",
13+
target_arch = "aarch64",
14+
), not(target_env = "musl")))]
1115
use crate::sys::time::TimeSpec;
1216
use crate::sys::time::TimeVal;
1317
use crate::sys::uio::IoVec;
@@ -559,7 +563,11 @@ pub enum ControlMessageOwned {
559563
/// Nanoseconds resolution timestamp
560564
///
561565
/// [Further reading](https://www.kernel.org/doc/html/latest/networking/timestamping.html)
562-
#[cfg(all(target_os = "linux", any(target_arch = "x86_64"), target_env = "gnu"))]
566+
#[cfg(all(target_os = "linux", any(
567+
target_arch = "x86",
568+
target_arch = "x86_64",
569+
target_arch = "aarch64",
570+
), not(target_env = "musl")))]
563571
ScmTimestampns(TimeSpec),
564572
#[cfg(any(
565573
target_os = "android",
@@ -652,7 +660,11 @@ impl ControlMessageOwned {
652660
let tv: libc::timeval = ptr::read_unaligned(p as *const _);
653661
ControlMessageOwned::ScmTimestamp(TimeVal::from(tv))
654662
},
655-
#[cfg(all(target_os = "linux", any(target_arch = "x86_64"), target_env = "gnu"))]
663+
#[cfg(all(target_os = "linux", any(
664+
target_arch = "x86",
665+
target_arch = "x86_64",
666+
target_arch = "aarch64",
667+
), not(target_env = "musl")))]
656668
(libc::SOL_SOCKET, libc::SCM_TIMESTAMPNS) => {
657669
let ts: libc::timespec = ptr::read_unaligned(p as *const _);
658670
ControlMessageOwned::ScmTimestampns(TimeSpec::from(ts))

src/sys/socket/sockopt.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,11 @@ sockopt_impl!(Both, BindToDevice, libc::SOL_SOCKET, libc::SO_BINDTODEVICE, OsStr
272272
#[cfg(any(target_os = "android", target_os = "linux"))]
273273
sockopt_impl!(GetOnly, OriginalDst, libc::SOL_IP, libc::SO_ORIGINAL_DST, libc::sockaddr_in);
274274
sockopt_impl!(Both, ReceiveTimestamp, libc::SOL_SOCKET, libc::SO_TIMESTAMP, bool);
275-
#[cfg(all(target_os = "linux", any(target_arch = "x86_64"), target_env = "gnu"))]
275+
#[cfg(all(target_os = "linux", any(
276+
target_arch = "x86",
277+
target_arch = "x86_64",
278+
target_arch = "aarch64",
279+
), not(target_env = "musl")))]
276280
sockopt_impl!(Both, ReceiveTimestampns, libc::SOL_SOCKET, libc::SO_TIMESTAMPNS, bool);
277281
#[cfg(any(target_os = "android", target_os = "linux"))]
278282
sockopt_impl!(Both, IpTransparent, libc::SOL_IP, libc::IP_TRANSPARENT, bool);

test/sys/test_socket.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,14 @@ pub fn test_vsock() {
15361536
thr.join().unwrap();
15371537
}
15381538

1539-
#[cfg(all(target_os = "linux", any(target_arch = "x86_64"), target_env = "gnu"))]
1539+
// Disable the test on emulated platforms because it fails in Cirrus-CI. Lack of QEMU
1540+
// support is suspected.
1541+
#[cfg_attr(all(not(any(target_arch = "x86_64")), any(target_env = "musl")), ignore)]
1542+
#[cfg(all(target_os = "linux", any(
1543+
target_arch = "x86",
1544+
target_arch = "x86_64",
1545+
target_arch = "aarch64",
1546+
), not(target_env = "musl")))]
15401547
#[test]
15411548
fn test_recvmsg_timestampns() {
15421549
use nix::sys::socket::*;
@@ -1584,7 +1591,14 @@ fn test_recvmsg_timestampns() {
15841591
nix::unistd::close(in_socket).unwrap();
15851592
}
15861593

1587-
#[cfg(all(target_os = "linux", any(target_arch = "x86_64"), target_env = "gnu"))]
1594+
// Disable the test on emulated platforms because it fails in Cirrus-CI. Lack of QEMU
1595+
// support is suspected.
1596+
#[cfg_attr(all(not(any(target_arch = "x86_64")), any(target_env = "musl")), ignore)]
1597+
#[cfg(all(target_os = "linux", any(
1598+
target_arch = "x86",
1599+
target_arch = "x86_64",
1600+
target_arch = "aarch64",
1601+
), not(target_env = "musl")))]
15881602
#[test]
15891603
fn test_recvmmsg_timestampns() {
15901604
use nix::sys::socket::*;

0 commit comments

Comments
 (0)