From 73d48b35269bf297d66b2333040b296f26b403a1 Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Tue, 29 Jan 2019 17:57:50 -0800 Subject: Update libc crate to 0.2.48 This change updates the libc crate to version 0.2.48. Import subrepo libc/:libc at 42cd3ba27254c423e03f6f4324de57075047f6a0 --- libc/src/unix/bsd/apple/mod.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'libc/src/unix/bsd/apple/mod.rs') diff --git a/libc/src/unix/bsd/apple/mod.rs b/libc/src/unix/bsd/apple/mod.rs index 13da82c..837efff 100644 --- a/libc/src/unix/bsd/apple/mod.rs +++ b/libc/src/unix/bsd/apple/mod.rs @@ -1,6 +1,7 @@ //! Apple (ios/darwin)-specific definitions //! //! This covers *-apple-* triples currently +use dox::mem; pub type c_char = i8; pub type clock_t = c_ulong; @@ -2383,7 +2384,45 @@ pub const SF_IMMUTABLE: ::c_uint = 0x00020000; pub const SF_APPEND: ::c_uint = 0x00040000; pub const UF_HIDDEN: ::c_uint = 0x00008000; +fn __DARWIN_ALIGN32(p: usize) -> usize { + const __DARWIN_ALIGNBYTES32: usize = mem::size_of::() - 1; + p + __DARWIN_ALIGNBYTES32 & !__DARWIN_ALIGNBYTES32 +} + f! { + pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, + cmsg: *const ::cmsghdr) -> *mut ::cmsghdr { + if cmsg.is_null() { + return ::CMSG_FIRSTHDR(mhdr); + }; + let cmsg_len = (*cmsg).cmsg_len as usize; + let next = cmsg as usize + __DARWIN_ALIGN32(cmsg_len as usize) + + __DARWIN_ALIGN32(mem::size_of::<::cmsghdr>()); + let max = (*mhdr).msg_control as usize + + (*mhdr).msg_controllen as usize; + if next > max { + 0 as *mut ::cmsghdr + } else { + next as *mut ::cmsghdr + } + } + + pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar { + (cmsg as *mut ::c_uchar) + .offset(__DARWIN_ALIGN32(mem::size_of::<::cmsghdr>()) as isize) + } + + pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { + (__DARWIN_ALIGN32(mem::size_of::<::cmsghdr>()) + + __DARWIN_ALIGN32(length as usize)) + as ::c_uint + } + + pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { + __DARWIN_ALIGN32(mem::size_of::<::cmsghdr>() + length as usize) + as ::c_uint + } + pub fn WSTOPSIG(status: ::c_int) -> ::c_int { status >> 8 } -- cgit v1.2.1