Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added FreeBSD's SCM_REALTIME and SCM_MONOTONIC into sys::socket::Cont…
…rolMessageOwned.
  • Loading branch information
recatek committed Nov 13, 2023
commit c60b7436a8dec17795f95e3b58d88a85ab69384a
24 changes: 23 additions & 1 deletion src/sys/socket/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Socket interface functions
//!
//! [Further reading](https://man7.org/linux/man-pages/man7/socket.7.html)
#[cfg(any(target_os = "android", target_os = "linux"))]
#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
#[cfg(feature = "uio")]
use crate::sys::time::TimeSpec;
#[cfg(not(target_os = "redox"))]
Expand Down Expand Up @@ -779,6 +779,18 @@ pub enum ControlMessageOwned {
#[cfg(any(target_os = "android", target_os = "linux"))]
#[cfg_attr(docsrs, doc(cfg(all())))]
ScmTimestampns(TimeSpec),
/// Realtime clock timestamp
///
/// [Further reading](https://man.freebsd.org/cgi/man.cgi?setsockopt)
#[cfg(any(target_os = "freebsd"))]
#[cfg_attr(docsrs, doc(cfg(all())))]
ScmRealtime(TimeSpec),
/// Monotonic clock timestamp
///
/// [Further reading](https://man.freebsd.org/cgi/man.cgi?setsockopt)
#[cfg(any(target_os = "freebsd"))]
#[cfg_attr(docsrs, doc(cfg(all())))]
ScmMonotonic(TimeSpec),
#[cfg(any(
target_os = "android",
apple_targets,
Expand Down Expand Up @@ -958,6 +970,16 @@ impl ControlMessageOwned {
let ts: libc::timespec = ptr::read_unaligned(p as *const _);
ControlMessageOwned::ScmTimestampns(TimeSpec::from(ts))
}
#[cfg(any(target_os = "freebsd"))]
(libc::SOL_SOCKET, libc::SCM_REALTIME) => {
let ts: libc::timespec = ptr::read_unaligned(p as *const _);
ControlMessageOwned::ScmRealtime(TimeSpec::from(ts))
}
#[cfg(any(target_os = "freebsd"))]
(libc::SOL_SOCKET, libc::SCM_MONOTONIC) => {
let ts: libc::timespec = ptr::read_unaligned(p as *const _);
ControlMessageOwned::ScmMonotonic(TimeSpec::from(ts))
}
#[cfg(any(target_os = "android", target_os = "linux"))]
(libc::SOL_SOCKET, libc::SCM_TIMESTAMPING) => {
let tp = p as *const libc::timespec;
Expand Down