diff options
Diffstat (limited to 'libc/src/unix/bsd/freebsdlike/freebsd')
| -rw-r--r-- | libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs | 5 | ||||
| -rw-r--r-- | libc/src/unix/bsd/freebsdlike/freebsd/mod.rs | 44 | ||||
| -rw-r--r-- | libc/src/unix/bsd/freebsdlike/freebsd/x86.rs | 6 | ||||
| -rw-r--r-- | libc/src/unix/bsd/freebsdlike/freebsd/x86_64.rs | 5 | 
4 files changed, 60 insertions, 0 deletions
| diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs index 3d61f88..d33b475 100644 --- a/libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs +++ b/libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -1,3 +1,5 @@ +use dox::mem; +  pub type c_long = i64;  pub type c_ulong = u64;  pub type time_t = i64; @@ -29,4 +31,7 @@ s! {      }  } +// should be pub(crate), but that requires Rust 1.18.0 +#[doc(hidden)] +pub const _ALIGNBYTES: usize = mem::size_of::<::c_longlong>() - 1;  pub const MAP_32BIT: ::c_int = 0x00080000; diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs b/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs index 878deea..91eab30 100644 --- a/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1,3 +1,5 @@ +use dox::mem; +  pub type fflags_t = u32;  pub type clock_t = i32;  pub type ino_t = u32; @@ -182,6 +184,12 @@ s! {          pub sdl_slen: ::c_uchar,          pub sdl_data: [::c_char; 46],      } + +    pub struct stack_t { +        pub ss_sp: *mut ::c_void, +        pub ss_size: ::size_t, +        pub ss_flags: ::c_int, +    }  }  pub const SIGEV_THREAD_ID: ::c_int = 4; @@ -962,7 +970,43 @@ pub const UF_READONLY:  ::c_ulong = 0x00001000;  pub const UF_HIDDEN:    ::c_ulong = 0x00008000;  pub const SF_SNAPSHOT:  ::c_ulong = 0x00200000; +fn _ALIGN(p: usize) -> usize { +    (p + _ALIGNBYTES) & !_ALIGNBYTES +} +  f! { +    pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar { +        (cmsg as *mut ::c_uchar) +            .offset(_ALIGN(mem::size_of::<::cmsghdr>()) as isize) +    } + +    pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { +        _ALIGN(mem::size_of::<::cmsghdr>()) as ::c_uint + length +    } + +    pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr) +        -> *mut ::cmsghdr +    { +        if cmsg.is_null() { +            return ::CMSG_FIRSTHDR(mhdr); +        }; +        let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) +            + _ALIGN(mem::size_of::<::cmsghdr>()); +        let max = (*mhdr).msg_control as usize +            + (*mhdr).msg_controllen as usize; +        if next > max { +            0 as *mut ::cmsghdr +        } else { +            (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) +                as *mut ::cmsghdr +        } +    } + +    pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { +        (_ALIGN(mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize)) +            as ::c_uint +    } +      pub fn uname(buf: *mut ::utsname) -> ::c_int {          __xuname(256, buf as *mut ::c_void)      } diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs b/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs index 8a5e5f9..a5495aa 100644 --- a/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -1,3 +1,5 @@ +use dox::mem; +  pub type c_long = i32;  pub type c_ulong = u32;  pub type time_t = i32; @@ -29,3 +31,7 @@ s! {          __unused: [u8; 8],      }  } + +// should be pub(crate), but that requires Rust 1.18.0 +#[doc(hidden)] +pub const _ALIGNBYTES: usize = mem::size_of::<::c_long>() - 1; diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/x86_64.rs b/libc/src/unix/bsd/freebsdlike/freebsd/x86_64.rs index 3d61f88..711feb7 100644 --- a/libc/src/unix/bsd/freebsdlike/freebsd/x86_64.rs +++ b/libc/src/unix/bsd/freebsdlike/freebsd/x86_64.rs @@ -1,3 +1,5 @@ +use dox::mem; +  pub type c_long = i64;  pub type c_ulong = u64;  pub type time_t = i64; @@ -29,4 +31,7 @@ s! {      }  } +// should be pub(crate), but that requires Rust 1.18.0 +#[doc(hidden)] +pub const _ALIGNBYTES: usize = mem::size_of::<::c_long>() - 1;  pub const MAP_32BIT: ::c_int = 0x00080000; | 
