Skip to content

Commit 1d61638

Browse files
bors[bot]spencercw
andauthored
Merge #2077
2077: Enable socket timestamping options on Android r=asomers a=spencercw Requires rust-lang/libc#3267 which landed in libc 0.2.147. Co-authored-by: Chris Spencer <[email protected]>
2 parents c3e6e6a + 87190da commit 1d61638

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
2020
([#2040](https://github.com/nix-rust/nix/pull/2040))
2121
- Added `SOF_TIMESTAMPING_OPT_ID` and `SOF_TIMESTAMPING_OPT_TSONLY` to `nix::sys::socket::TimestampingFlag`.
2222
([#2048](https://github.com/nix-rust/nix/pull/2048))
23+
- Enabled socket timestamping options on Android. ([#2077](https://github.com/nix-rust/nix/pull/2077))
2324

2425
### Changed
2526

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ targets = [
2727
]
2828

2929
[dependencies]
30-
libc = { version = "0.2.141", features = ["extra_traits"] }
30+
libc = { version = "0.2.147", features = ["extra_traits"] }
3131
bitflags = "2.3.1"
3232
cfg-if = "1.0"
3333
pin-utils = { version = "0.1.0", optional = true }

src/sys/socket/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Socket interface functions
22
//!
33
//! [Further reading](https://man7.org/linux/man-pages/man7/socket.7.html)
4-
#[cfg(target_os = "linux")]
4+
#[cfg(any(target_os = "android", target_os = "linux"))]
55
#[cfg(feature = "uio")]
66
use crate::sys::time::TimeSpec;
77
#[cfg(not(target_os = "redox"))]
@@ -236,7 +236,7 @@ impl SockProtocol {
236236
#[allow(non_upper_case_globals)]
237237
pub const CanBcm: SockProtocol = SockProtocol::NetlinkUserSock; // Matches libc::CAN_BCM
238238
}
239-
#[cfg(target_os = "linux")]
239+
#[cfg(any(target_os = "android", target_os = "linux"))]
240240
libc_bitflags! {
241241
/// Configuration flags for `SO_TIMESTAMPING` interface
242242
///
@@ -737,12 +737,12 @@ pub enum ControlMessageOwned {
737737
/// A set of nanosecond resolution timestamps
738738
///
739739
/// [Further reading](https://www.kernel.org/doc/html/latest/networking/timestamping.html)
740-
#[cfg(all(target_os = "linux"))]
740+
#[cfg(any(target_os = "android", target_os = "linux"))]
741741
ScmTimestampsns(Timestamps),
742742
/// Nanoseconds resolution timestamp
743743
///
744744
/// [Further reading](https://www.kernel.org/doc/html/latest/networking/timestamping.html)
745-
#[cfg(all(target_os = "linux"))]
745+
#[cfg(any(target_os = "android", target_os = "linux"))]
746746
#[cfg_attr(docsrs, doc(cfg(all())))]
747747
ScmTimestampns(TimeSpec),
748748
#[cfg(any(
@@ -839,7 +839,7 @@ pub enum ControlMessageOwned {
839839
}
840840

841841
/// For representing packet timestamps via `SO_TIMESTAMPING` interface
842-
#[cfg(all(target_os = "linux"))]
842+
#[cfg(any(target_os = "android", target_os = "linux"))]
843843
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
844844
pub struct Timestamps {
845845
/// software based timestamp, usually one containing data
@@ -892,12 +892,12 @@ impl ControlMessageOwned {
892892
let tv: libc::timeval = ptr::read_unaligned(p as *const _);
893893
ControlMessageOwned::ScmTimestamp(TimeVal::from(tv))
894894
},
895-
#[cfg(all(target_os = "linux"))]
895+
#[cfg(any(target_os = "android", target_os = "linux"))]
896896
(libc::SOL_SOCKET, libc::SCM_TIMESTAMPNS) => {
897897
let ts: libc::timespec = ptr::read_unaligned(p as *const _);
898898
ControlMessageOwned::ScmTimestampns(TimeSpec::from(ts))
899899
}
900-
#[cfg(all(target_os = "linux"))]
900+
#[cfg(any(target_os = "android", target_os = "linux"))]
901901
(libc::SOL_SOCKET, libc::SCM_TIMESTAMPING) => {
902902
let tp = p as *const libc::timespec;
903903
let ts: libc::timespec = ptr::read_unaligned(tp);

src/sys/socket/sockopt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ sockopt_impl!(
683683
libc::IP6T_SO_ORIGINAL_DST,
684684
libc::sockaddr_in6
685685
);
686-
#[cfg(target_os = "linux")]
686+
#[cfg(any(target_os = "android", target_os = "linux"))]
687687
sockopt_impl!(
688688
/// Specifies exact type of timestamping information collected by the kernel
689689
/// [Further reading](https://www.kernel.org/doc/html/latest/networking/timestamping.html)
@@ -702,7 +702,7 @@ sockopt_impl!(
702702
libc::SO_TIMESTAMP,
703703
bool
704704
);
705-
#[cfg(target_os = "linux")]
705+
#[cfg(any(target_os = "android", target_os = "linux"))]
706706
sockopt_impl!(
707707
/// Enable or disable the receiving of the `SO_TIMESTAMPNS` control message.
708708
ReceiveTimestampns,

0 commit comments

Comments
 (0)