Skip to content

Commit

Permalink
Added FreeBSD's SCM_REALTIME and SCM_MONOTONIC into sys::socket::Cont…
Browse files Browse the repository at this point in the history
…rolMessageOwned.
  • Loading branch information
recatek committed Nov 13, 2023
1 parent 1057092 commit c60b743
Showing 1 changed file with 23 additions and 1 deletion.
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

0 comments on commit c60b743

Please sign in to comment.