summaryrefslogtreecommitdiff
path: root/libc/src/unix/bsd/apple/mod.rs
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2019-01-29 17:57:50 -0800
committerDaniel Mueller <deso@posteo.net>2019-01-29 17:57:50 -0800
commit73d48b35269bf297d66b2333040b296f26b403a1 (patch)
tree952fda784782d55183fb57d80a32a61255f1c572 /libc/src/unix/bsd/apple/mod.rs
parent750c5dfef0e4d06a342d7f6fd5fb1b98e87043e0 (diff)
downloadnitrocli-73d48b35269bf297d66b2333040b296f26b403a1.tar.gz
nitrocli-73d48b35269bf297d66b2333040b296f26b403a1.tar.bz2
Update libc crate to 0.2.48
This change updates the libc crate to version 0.2.48. Import subrepo libc/:libc at 42cd3ba27254c423e03f6f4324de57075047f6a0
Diffstat (limited to 'libc/src/unix/bsd/apple/mod.rs')
-rw-r--r--libc/src/unix/bsd/apple/mod.rs39
1 files changed, 39 insertions, 0 deletions
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::<u32>() - 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
}