diff options
-rw-r--r-- | libc-test/build.rs | 4 | ||||
-rw-r--r-- | src/fuchsia/mod.rs | 55 | ||||
-rw-r--r-- | src/unix/bsd/freebsdlike/freebsd/mod.rs | 1 |
3 files changed, 60 insertions, 0 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs index ed1b176bbf..04cc19c6c7 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1824,6 +1824,10 @@ fn test_freebsd(target: &str) { // base system anyway. "CTL_MAXID" | "KERN_MAXID" | "HW_MAXID" | "USER_MAXID" => true, + // This constant was removed in FreeBSD 13 (svn r363622), and never + // had any legitimate use outside of the base system anyway. + "CTL_P1003_1B_MAXID" => true, + // This was renamed in FreeBSD 12.2 and 13 (r352486). "CTL_UNSPEC" | "CTL_SYSCTL" => true, diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 4717089492..b3ff29f1e5 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -3250,6 +3250,61 @@ f! { dev |= (minor & 0xffffff00) << 12; dev } + + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { + cmsg.offset(1) as *mut c_uchar + } + + pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) + -> *mut cmsghdr + { + if ((*cmsg).cmsg_len as ::size_t) < ::mem::size_of::<cmsghdr>() { + 0 as *mut cmsghdr + } else if __CMSG_NEXT(cmsg).add(::mem::size_of::<cmsghdr>()) + >= __MHDR_END(mhdr) { + 0 as *mut cmsghdr + } else { + __CMSG_NEXT(cmsg).cast() + } + } + + pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { + if (*mhdr).msg_controllen as ::size_t >= ::mem::size_of::<cmsghdr>() { + (*mhdr).msg_control.cast() + } else { + 0 as *mut cmsghdr + } + } + + pub fn CMSG_ALIGN(len: ::size_t) -> ::size_t { + (len + ::mem::size_of::<::size_t>() - 1) + & !(::mem::size_of::<::size_t>() - 1) + } + + pub fn CMSG_SPACE(len: ::c_uint) -> ::c_uint { + (CMSG_ALIGN(len as ::size_t) + CMSG_ALIGN(::mem::size_of::<cmsghdr>())) + as ::c_uint + } + + pub fn CMSG_LEN(len: ::c_uint) -> ::c_uint { + (CMSG_ALIGN(::mem::size_of::<cmsghdr>()) + len as ::size_t) as ::c_uint + } +} + +fn __CMSG_LEN(cmsg: *const cmsghdr) -> ::ssize_t { + ((unsafe { (*cmsg).cmsg_len as ::size_t } + ::mem::size_of::<::c_long>() + - 1) + & !(::mem::size_of::<::c_long>() - 1)) as ::ssize_t +} + +fn __CMSG_NEXT(cmsg: *const cmsghdr) -> *mut c_uchar { + (unsafe { cmsg.offset(__CMSG_LEN(cmsg)) }) as *mut c_uchar +} + +fn __MHDR_END(mhdr: *const msghdr) -> *mut c_uchar { + unsafe { + (*mhdr).msg_control.offset((*mhdr).msg_controllen as isize) + }.cast() } // EXTERN_FN diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 4b224d0573..1ca003959c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1056,6 +1056,7 @@ pub const HW_MAXID: ::c_int = 13; #[deprecated(since = "0.2.54", note = "Removed in FreeBSD 11")] pub const USER_MAXID: ::c_int = 21; #[doc(hidden)] +#[deprecated(since = "0.2.74", note = "Removed in FreeBSD 13")] pub const CTL_P1003_1B_MAXID: ::c_int = 26; pub const MSG_NOTIFICATION: ::c_int = 0x00002000; |