aboutsummaryrefslogtreecommitdiff
path: root/libc/src/unix/bsd/netbsdlike
diff options
context:
space:
mode:
Diffstat (limited to 'libc/src/unix/bsd/netbsdlike')
-rw-r--r--libc/src/unix/bsd/netbsdlike/mod.rs80
-rw-r--r--libc/src/unix/bsd/netbsdlike/netbsd/aarch64.rs13
-rw-r--r--libc/src/unix/bsd/netbsdlike/netbsd/arm.rs13
-rw-r--r--libc/src/unix/bsd/netbsdlike/netbsd/mod.rs535
-rw-r--r--libc/src/unix/bsd/netbsdlike/netbsd/powerpc.rs13
-rw-r--r--libc/src/unix/bsd/netbsdlike/netbsd/x86.rs13
-rw-r--r--libc/src/unix/bsd/netbsdlike/netbsd/x86_64.rs13
-rw-r--r--libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/mod.rs113
-rw-r--r--libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86.rs2
-rw-r--r--libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs10
-rw-r--r--libc/src/unix/bsd/netbsdlike/openbsdlike/mod.rs295
-rw-r--r--libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/aarch64.rs13
-rw-r--r--libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs294
-rw-r--r--libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86.rs13
-rw-r--r--libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs13
15 files changed, 1045 insertions, 388 deletions
diff --git a/libc/src/unix/bsd/netbsdlike/mod.rs b/libc/src/unix/bsd/netbsdlike/mod.rs
index 291c081..29b4dd7 100644
--- a/libc/src/unix/bsd/netbsdlike/mod.rs
+++ b/libc/src/unix/bsd/netbsdlike/mod.rs
@@ -1,5 +1,3 @@
-use dox::mem;
-
pub type time_t = i64;
pub type mode_t = u32;
pub type nlink_t = ::uint32_t;
@@ -13,8 +11,18 @@ pub type clockid_t = ::c_int;
pub type id_t = ::uint32_t;
pub type sem_t = *mut sem;
+#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum timezone {}
+impl ::Copy for timezone {}
+impl ::Clone for timezone {
+ fn clone(&self) -> timezone { *self }
+}
+#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum sem {}
+impl ::Copy for sem {}
+impl ::Clone for sem {
+ fn clone(&self) -> sem { *self }
+}
s! {
pub struct sigaction {
@@ -29,14 +37,6 @@ s! {
pub ss_flags: ::c_int,
}
- pub struct sockaddr_in {
- pub sin_len: u8,
- pub sin_family: ::sa_family_t,
- pub sin_port: ::in_port_t,
- pub sin_addr: ::in_addr,
- pub sin_zero: [::int8_t; 8],
- }
-
pub struct in6_pktinfo {
pub ipi6_addr: ::in6_addr,
pub ipi6_ifindex: ::c_uint,
@@ -595,58 +595,15 @@ pub const SF_APPEND: ::c_ulong = 0x00040000;
pub const TIMER_ABSTIME: ::c_int = 1;
-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 WSTOPSIG(status: ::c_int) -> ::c_int {
- status >> 8
- }
-
- pub fn WIFSIGNALED(status: ::c_int) -> bool {
- (status & 0o177) != 0o177 && (status & 0o177) != 0
- }
-
- pub fn WIFSTOPPED(status: ::c_int) -> bool {
- (status & 0o177) == 0o177
- }
-}
-
#[link(name = "util")]
extern {
+ pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
+ pub fn sem_init(sem: *mut sem_t,
+ pshared: ::c_int,
+ value: ::c_uint)
+ -> ::c_int;
+
+ pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
pub fn mincore(addr: *mut ::c_void, len: ::size_t,
vec: *mut ::c_char) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__clock_getres50")]
@@ -686,6 +643,7 @@ extern {
name: *mut ::c_char,
termp: *mut termios,
winp: *mut ::winsize) -> ::pid_t;
+ pub fn login_tty(fd: ::c_int) -> ::c_int;
pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int;
pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int;
@@ -718,7 +676,7 @@ cfg_if! {
if #[cfg(target_os = "netbsd")] {
mod netbsd;
pub use self::netbsd::*;
- } else if #[cfg(any(target_os = "openbsd", target_os = "bitrig"))] {
+ } else if #[cfg(target_os = "openbsd")] {
mod openbsdlike;
pub use self::openbsdlike::*;
} else {
diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/aarch64.rs b/libc/src/unix/bsd/netbsdlike/netbsd/aarch64.rs
index cda75bc..58c4cf7 100644
--- a/libc/src/unix/bsd/netbsdlike/netbsd/aarch64.rs
+++ b/libc/src/unix/bsd/netbsdlike/netbsd/aarch64.rs
@@ -1,5 +1,3 @@
-use dox::mem;
-
use PT_FIRSTMACH;
pub type c_long = i64;
@@ -8,8 +6,15 @@ pub type c_char = u8;
pub type __cpu_simple_lock_nv_t = ::c_uchar;
// should be pub(crate), but that requires Rust 1.18.0
-#[doc(hidden)]
-pub const _ALIGNBYTES: usize = mem::size_of::<::c_int>() - 1;
+cfg_if! {
+ if #[cfg(libc_const_size_of)] {
+ #[doc(hidden)]
+ pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;
+ } else {
+ #[doc(hidden)]
+ pub const _ALIGNBYTES: usize = 4 - 1;
+ }
+}
pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 0;
pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 1;
diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/arm.rs b/libc/src/unix/bsd/netbsdlike/netbsd/arm.rs
index 71c2cb7..4bf3ccd 100644
--- a/libc/src/unix/bsd/netbsdlike/netbsd/arm.rs
+++ b/libc/src/unix/bsd/netbsdlike/netbsd/arm.rs
@@ -1,5 +1,3 @@
-use dox::mem;
-
use PT_FIRSTMACH;
pub type c_long = i32;
@@ -8,8 +6,15 @@ pub type c_char = u8;
pub type __cpu_simple_lock_nv_t = ::c_int;
// should be pub(crate), but that requires Rust 1.18.0
-#[doc(hidden)]
-pub const _ALIGNBYTES: usize = mem::size_of::<::c_longlong>() - 1;
+cfg_if! {
+ if #[cfg(libc_const_size_of)] {
+ #[doc(hidden)]
+ pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1;
+ } else {
+ #[doc(hidden)]
+ pub const _ALIGNBYTES: usize = 8 - 1;
+ }
+}
pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1;
pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2;
diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs b/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs
index d3acfb9..ad53c19 100644
--- a/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs
+++ b/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs
@@ -1,5 +1,3 @@
-use dox::mem;
-
pub type clock_t = ::c_uint;
pub type suseconds_t = ::c_int;
pub type dev_t = u64;
@@ -9,6 +7,7 @@ pub type fsfilcnt_t = ::uint64_t;
pub type idtype_t = ::c_int;
pub type mqd_t = ::c_int;
type __pthread_spin_t = __cpu_simple_lock_nv_t;
+pub type vm_size_t = ::uintptr_t;
s! {
pub struct aiocb {
@@ -24,14 +23,6 @@ s! {
_retval: ::ssize_t
}
- pub struct dirent {
- pub d_fileno: ::ino_t,
- pub d_reclen: u16,
- pub d_namlen: u16,
- pub d_type: u8,
- pub d_name: [::c_char; 512],
- }
-
pub struct glob_t {
pub gl_pathc: ::size_t,
pub gl_matchc: ::size_t,
@@ -91,41 +82,7 @@ s! {
pub st_spare: [::uint32_t; 2],
}
- pub struct statvfs {
- pub f_flag: ::c_ulong,
- pub f_bsize: ::c_ulong,
- pub f_frsize: ::c_ulong,
- pub f_iosize: ::c_ulong,
-
- pub f_blocks: ::fsblkcnt_t,
- pub f_bfree: ::fsblkcnt_t,
- pub f_bavail: ::fsblkcnt_t,
- pub f_bresvd: ::fsblkcnt_t,
-
- pub f_files: ::fsfilcnt_t,
- pub f_ffree: ::fsfilcnt_t,
- pub f_favail: ::fsfilcnt_t,
- pub f_fresvd: ::fsfilcnt_t,
-
- pub f_syncreads: ::uint64_t,
- pub f_syncwrites: ::uint64_t,
-
- pub f_asyncreads: ::uint64_t,
- pub f_asyncwrites: ::uint64_t,
-
- pub f_fsidx: ::fsid_t,
- pub f_fsid: ::c_ulong,
- pub f_namemax: ::c_ulong,
- pub f_owner: ::uid_t,
-
- pub f_spare: [::uint32_t; 4],
-
- pub f_fstypename: [::c_char; 32],
- pub f_mntonname: [::c_char; 1024],
- pub f_mntfromname: [::c_char; 1024],
- }
-
- pub struct addrinfo {
+ pub struct addrinfo {
pub ai_flags: ::c_int,
pub ai_family: ::c_int,
pub ai_socktype: ::c_int,
@@ -136,14 +93,6 @@ s! {
pub ai_next: *mut ::addrinfo,
}
- pub struct sockaddr_storage {
- pub ss_len: u8,
- pub ss_family: ::sa_family_t,
- __ss_pad1: [u8; 6],
- __ss_pad2: i64,
- __ss_pad3: [u8; 112],
- }
-
pub struct siginfo_t {
pub si_signo: ::c_int,
pub si_code: ::c_int,
@@ -319,6 +268,13 @@ s! {
pub sdl_data: [::c_char; 12],
}
+ pub struct mmsghdr {
+ pub msg_hdr: ::msghdr,
+ pub msg_len: ::c_uint,
+ }
+}
+
+s_no_extra_traits! {
pub struct in_pktinfo {
pub ipi_addr: ::in_addr,
pub ipi_ifindex: ::c_uint,
@@ -332,6 +288,377 @@ s! {
pub ar_pln: u8,
pub ar_op: u16,
}
+
+ #[repr(packed)]
+ pub struct in_addr {
+ pub s_addr: ::in_addr_t,
+ }
+
+ pub struct ip_mreq {
+ pub imr_multiaddr: in_addr,
+ pub imr_interface: in_addr,
+ }
+
+ pub struct sockaddr_in {
+ pub sin_len: u8,
+ pub sin_family: ::sa_family_t,
+ pub sin_port: ::in_port_t,
+ pub sin_addr: ::in_addr,
+ pub sin_zero: [::int8_t; 8],
+ }
+
+ pub struct dirent {
+ pub d_fileno: ::ino_t,
+ pub d_reclen: u16,
+ pub d_namlen: u16,
+ pub d_type: u8,
+ pub d_name: [::c_char; 512],
+ }
+
+ pub struct statvfs {
+ pub f_flag: ::c_ulong,
+ pub f_bsize: ::c_ulong,
+ pub f_frsize: ::c_ulong,
+ pub f_iosize: ::c_ulong,
+
+ pub f_blocks: ::fsblkcnt_t,
+ pub f_bfree: ::fsblkcnt_t,
+ pub f_bavail: ::fsblkcnt_t,
+ pub f_bresvd: ::fsblkcnt_t,
+
+ pub f_files: ::fsfilcnt_t,
+ pub f_ffree: ::fsfilcnt_t,
+ pub f_favail: ::fsfilcnt_t,
+ pub f_fresvd: ::fsfilcnt_t,
+
+ pub f_syncreads: ::uint64_t,
+ pub f_syncwrites: ::uint64_t,
+
+ pub f_asyncreads: ::uint64_t,
+ pub f_asyncwrites: ::uint64_t,
+
+ pub f_fsidx: ::fsid_t,
+ pub f_fsid: ::c_ulong,
+ pub f_namemax: ::c_ulong,
+ pub f_owner: ::uid_t,
+
+ pub f_spare: [::uint32_t; 4],
+
+ pub f_fstypename: [::c_char; 32],
+ pub f_mntonname: [::c_char; 1024],
+ pub f_mntfromname: [::c_char; 1024],
+ }
+
+ pub struct sockaddr_storage {
+ pub ss_len: u8,
+ pub ss_family: ::sa_family_t,
+ __ss_pad1: [u8; 6],
+ __ss_pad2: i64,
+ __ss_pad3: [u8; 112],
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for in_pktinfo {
+ fn eq(&self, other: &in_pktinfo) -> bool {
+ self.ipi_addr == other.ipi_addr
+ && self.ipi_ifindex == other.ipi_ifindex
+ }
+ }
+ impl Eq for in_pktinfo {}
+ impl ::fmt::Debug for in_pktinfo {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("in_pktinfo")
+ .field("ipi_addr", &self.ipi_addr)
+ .field("ipi_ifindex", &self.ipi_ifindex)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for in_pktinfo {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.ipi_addr.hash(state);
+ self.ipi_ifindex.hash(state);
+ }
+ }
+
+ impl PartialEq for arphdr {
+ fn eq(&self, other: &arphdr) -> bool {
+ self.ar_hrd == other.ar_hrd
+ && self.ar_pro == other.ar_pro
+ && self.ar_hln == other.ar_hln
+ && self.ar_pln == other.ar_pln
+ && self.ar_op == other.ar_op
+ }
+ }
+ impl Eq for arphdr {}
+ impl ::fmt::Debug for arphdr {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ let ar_hrd = self.ar_hrd;
+ let ar_pro = self.ar_pro;
+ let ar_op = self.ar_op;
+ f.debug_struct("arphdr")
+ .field("ar_hrd", &ar_hrd)
+ .field("ar_pro", &ar_pro)
+ .field("ar_hln", &self.ar_hln)
+ .field("ar_pln", &self.ar_pln)
+ .field("ar_op", &ar_op)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for arphdr {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ let ar_hrd = self.ar_hrd;
+ let ar_pro = self.ar_pro;
+ let ar_op = self.ar_op;
+ ar_hrd.hash(state);
+ ar_pro.hash(state);
+ self.ar_hln.hash(state);
+ self.ar_pln.hash(state);
+ ar_op.hash(state);
+ }
+ }
+
+ impl PartialEq for in_addr {
+ fn eq(&self, other: &in_addr) -> bool {
+ self.s_addr == other.s_addr
+ }
+ }
+ impl Eq for in_addr {}
+ impl ::fmt::Debug for in_addr {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ let s_addr = self.s_addr;
+ f.debug_struct("in_addr")
+ .field("s_addr", &s_addr)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for in_addr {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ let s_addr = self.s_addr;
+ s_addr.hash(state);
+ }
+ }
+
+ impl PartialEq for ip_mreq {
+ fn eq(&self, other: &ip_mreq) -> bool {
+ self.imr_multiaddr == other.imr_multiaddr
+ && self.imr_interface == other.imr_interface
+ }
+ }
+ impl Eq for ip_mreq {}
+ impl ::fmt::Debug for ip_mreq {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("ip_mreq")
+ .field("imr_multiaddr", &self.imr_multiaddr)
+ .field("imr_interface", &self.imr_interface)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for ip_mreq {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.imr_multiaddr.hash(state);
+ self.imr_interface.hash(state);
+ }
+ }
+
+ impl PartialEq for sockaddr_in {
+ fn eq(&self, other: &sockaddr_in) -> bool {
+ self.sin_len == other.sin_len
+ && self.sin_family == other.sin_family
+ && self.sin_port == other.sin_port
+ && self.sin_addr == other.sin_addr
+ && self.sin_zero == other.sin_zero
+ }
+ }
+ impl Eq for sockaddr_in {}
+ impl ::fmt::Debug for sockaddr_in {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("sockaddr_in")
+ .field("sin_len", &self.sin_len)
+ .field("sin_family", &self.sin_family)
+ .field("sin_port", &self.sin_port)
+ .field("sin_addr", &self.sin_addr)
+ .field("sin_zero", &self.sin_zero)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for sockaddr_in {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.sin_len.hash(state);
+ self.sin_family.hash(state);
+ self.sin_port.hash(state);
+ self.sin_addr.hash(state);
+ self.sin_zero.hash(state);
+ }
+ }
+
+ impl PartialEq for dirent {
+ fn eq(&self, other: &dirent) -> bool {
+ self.d_fileno == other.d_fileno
+ && self.d_reclen == other.d_reclen
+ && self.d_namlen == other.d_namlen
+ && self.d_type == other.d_type
+ && self
+ .d_name
+ .iter()
+ .zip(other.d_name.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+ impl Eq for dirent {}
+ impl ::fmt::Debug for dirent {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("dirent")
+ .field("d_fileno", &self.d_fileno)
+ .field("d_reclen", &self.d_reclen)
+ .field("d_namlen", &self.d_namlen)
+ .field("d_type", &self.d_type)
+ // FIXME: .field("d_name", &self.d_name)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for dirent {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.d_fileno.hash(state);
+ self.d_reclen.hash(state);
+ self.d_namlen.hash(state);
+ self.d_type.hash(state);
+ self.d_name.hash(state);
+ }
+ }
+
+ impl PartialEq for statvfs {
+ fn eq(&self, other: &statvfs) -> bool {
+ self.f_flag == other.f_flag
+ && self.f_bsize == other.f_bsize
+ && self.f_frsize == other.f_frsize
+ && self.f_iosize == other.f_iosize
+ && self.f_blocks == other.f_blocks
+ && self.f_bfree == other.f_bfree
+ && self.f_bavail == other.f_bavail
+ && self.f_bresvd == other.f_bresvd
+ && self.f_files == other.f_files
+ && self.f_ffree == other.f_ffree
+ && self.f_favail == other.f_favail
+ && self.f_fresvd == other.f_fresvd
+ && self.f_syncreads == other.f_syncreads
+ && self.f_syncwrites == other.f_syncwrites
+ && self.f_asyncreads == other.f_asyncreads
+ && self.f_asyncwrites == other.f_asyncwrites
+ && self.f_fsidx == other.f_fsidx
+ && self.f_fsid == other.f_fsid
+ && self.f_namemax == other.f_namemax
+ && self.f_owner == other.f_owner
+ && self.f_spare == other.f_spare
+ && self.f_fstypename == other.f_fstypename
+ && self
+ .f_mntonname
+ .iter()
+ .zip(other.f_mntonname.iter())
+ .all(|(a,b)| a == b)
+ && self
+ .f_mntfromname
+ .iter()
+ .zip(other.f_mntfromname.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+ impl Eq for statvfs {}
+ impl ::fmt::Debug for statvfs {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("statvfs")
+ .field("f_flag", &self.f_flag)
+ .field("f_bsize", &self.f_bsize)
+ .field("f_frsize", &self.f_frsize)
+ .field("f_iosize", &self.f_iosize)
+ .field("f_blocks", &self.f_blocks)
+ .field("f_bfree", &self.f_bfree)
+ .field("f_bavail", &self.f_bavail)
+ .field("f_bresvd", &self.f_bresvd)
+ .field("f_files", &self.f_files)
+ .field("f_ffree", &self.f_ffree)
+ .field("f_favail", &self.f_favail)
+ .field("f_fresvd", &self.f_fresvd)
+ .field("f_syncreads", &self.f_syncreads)
+ .field("f_syncwrites", &self.f_syncwrites)
+ .field("f_asyncreads", &self.f_asyncreads)
+ .field("f_asyncwrites", &self.f_asyncwrites)
+ .field("f_fsidx", &self.f_fsidx)
+ .field("f_fsid", &self.f_fsid)
+ .field("f_namemax", &self.f_namemax)
+ .field("f_owner", &self.f_owner)
+ .field("f_spare", &self.f_spare)
+ .field("f_fstypename", &self.f_fstypename)
+ // FIXME: .field("f_mntonname", &self.f_mntonname)
+ // FIXME: .field("f_mntfromname", &self.f_mntfromname)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for statvfs {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.f_flag.hash(state);
+ self.f_bsize.hash(state);
+ self.f_frsize.hash(state);
+ self.f_iosize.hash(state);
+ self.f_blocks.hash(state);
+ self.f_bfree.hash(state);
+ self.f_bavail.hash(state);
+ self.f_bresvd.hash(state);
+ self.f_files.hash(state);
+ self.f_ffree.hash(state);
+ self.f_favail.hash(state);
+ self.f_fresvd.hash(state);
+ self.f_syncreads.hash(state);
+ self.f_syncwrites.hash(state);
+ self.f_asyncreads.hash(state);
+ self.f_asyncwrites.hash(state);
+ self.f_fsidx.hash(state);
+ self.f_fsid.hash(state);
+ self.f_namemax.hash(state);
+ self.f_owner.hash(state);
+ self.f_spare.hash(state);
+ self.f_fstypename.hash(state);
+ self.f_mntonname.hash(state);
+ self.f_mntfromname.hash(state);
+ }
+ }
+
+ impl PartialEq for sockaddr_storage {
+ fn eq(&self, other: &sockaddr_storage) -> bool {
+ self.ss_len == other.ss_len
+ && self.ss_family == other.ss_family
+ && self.__ss_pad1 == other.__ss_pad1
+ && self.__ss_pad2 == other.__ss_pad2
+ && self
+ .__ss_pad3
+ .iter()
+ .zip(other.__ss_pad3.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+ impl Eq for sockaddr_storage {}
+ impl ::fmt::Debug for sockaddr_storage {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("sockaddr_storage")
+ .field("ss_len", &self.ss_len)
+ .field("ss_family", &self.ss_family)
+ .field("__ss_pad1", &self.__ss_pad1)
+ .field("__ss_pad2", &self.__ss_pad2)
+ // FIXME: .field("__ss_pad3", &self.__ss_pad3)
+ .finish()
+ }
+ }
+ impl ::hash::Hash for sockaddr_storage {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.ss_len.hash(state);
+ self.ss_family.hash(state);
+ self.__ss_pad1.hash(state);
+ self.__ss_pad2.hash(state);
+ self.__ss_pad3.hash(state);
+ }
+ }
+ }
}
pub const AT_FDCWD: ::c_int = -100;
@@ -708,21 +1035,32 @@ pub const FD_SETSIZE: usize = 0x100;
pub const ST_NOSUID: ::c_ulong = 8;
-pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
- ptm_magic: 0x33330003,
- ptm_errorcheck: 0,
- #[cfg(any(target_arch = "sparc", target_arch = "sparc64",
- target_arch = "x86", target_arch = "x86_64"))]
- ptm_pad1: [0; 3],
- ptm_unused: 0,
- #[cfg(any(target_arch = "sparc", target_arch = "sparc64",
- target_arch = "x86", target_arch = "x86_64"))]
- ptm_pad2: [0; 3],
- ptm_waiters: 0 as *mut _,
- ptm_owner: 0,
- ptm_recursed: 0,
- ptm_spare2: 0 as *mut _,
-};
+cfg_if! {
+ if #[cfg(any(target_arch = "sparc", target_arch = "sparc64",
+ target_arch = "x86", target_arch = "x86_64"))] {
+ pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
+ ptm_magic: 0x33330003,
+ ptm_errorcheck: 0,
+ ptm_pad1: [0; 3],
+ ptm_unused: 0,
+ ptm_pad2: [0; 3],
+ ptm_waiters: 0 as *mut _,
+ ptm_owner: 0,
+ ptm_recursed: 0,
+ ptm_spare2: 0 as *mut _,
+ };
+ } else {
+ pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
+ ptm_magic: 0x33330003,
+ ptm_errorcheck: 0,
+ ptm_unused: 0,
+ ptm_waiters: 0 as *mut _,
+ ptm_owner: 0,
+ ptm_recursed: 0,
+ ptm_spare2: 0 as *mut _,
+ };
+ }
+}
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
ptc_magic: 0x55550005,
@@ -1018,10 +1356,58 @@ pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;
pub const SF_LOG: ::c_ulong = 0x00400000;
pub const SF_SNAPINVAL: ::c_ulong = 0x00800000;
-// dirfd() is a macro on netbsd to access
-// the first field of the struct where dirp points to:
-// http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36
+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 WSTOPSIG(status: ::c_int) -> ::c_int {
+ status >> 8
+ }
+
+ pub fn WIFSIGNALED(status: ::c_int) -> bool {
+ (status & 0o177) != 0o177 && (status & 0o177) != 0
+ }
+
+ pub fn WIFSTOPPED(status: ::c_int) -> bool {
+ (status & 0o177) == 0o177
+ }
+
+ // dirfd() is a macro on netbsd to access
+ // the first field of the struct where dirp points to:
+ // http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36
pub fn dirfd(dirp: *mut ::DIR) -> ::c_int {
*(dirp as *const ::c_int)
}
@@ -1036,7 +1422,7 @@ f! {
} else {
0
};
- mem::size_of::<sockcred>() + mem::size_of::<::gid_t>() * ngrps
+ ::mem::size_of::<sockcred>() + ::mem::size_of::<::gid_t>() * ngrps
}
}
@@ -1199,6 +1585,11 @@ extern {
pub fn settimeofday(tv: *const ::timeval, tz: *const ::c_void) -> ::c_int;
pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
+
+ pub fn sendmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
+ flags: ::c_int) -> ::c_int;
+ pub fn recvmmsg(sockfd: ::c_int, msgvec: *mut ::mmsghdr, vlen: ::c_uint,
+ flags: ::c_int, timeout: *mut ::timespec) -> ::c_int;
}
#[link(name = "util")]
diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/powerpc.rs b/libc/src/unix/bsd/netbsdlike/netbsd/powerpc.rs
index 3c682c3..e12fd5e 100644
--- a/libc/src/unix/bsd/netbsdlike/netbsd/powerpc.rs
+++ b/libc/src/unix/bsd/netbsdlike/netbsd/powerpc.rs
@@ -1,5 +1,3 @@
-use dox::mem;
-
use PT_FIRSTMACH;
pub type c_long = i32;
@@ -8,8 +6,15 @@ pub type c_char = u8;
pub type __cpu_simple_lock_nv_t = ::c_int;
// should be pub(crate), but that requires Rust 1.18.0
-#[doc(hidden)]
-pub const _ALIGNBYTES: usize = mem::size_of::<::c_double>() - 1;
+cfg_if! {
+ if #[cfg(libc_const_size_of)] {
+ #[doc(hidden)]
+ pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_double>() - 1;
+ } else {
+ #[doc(hidden)]
+ pub const _ALIGNBYTES: usize = 8 - 1;
+ }
+}
pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0;
pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1;
diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/x86.rs b/libc/src/unix/bsd/netbsdlike/netbsd/x86.rs
index 4da9968..daa89a1 100644
--- a/libc/src/unix/bsd/netbsdlike/netbsd/x86.rs
+++ b/libc/src/unix/bsd/netbsdlike/netbsd/x86.rs
@@ -1,10 +1,15 @@
-use dox::mem;
-
pub type c_long = i32;
pub type c_ulong = u32;
pub type c_char = i8;
pub type __cpu_simple_lock_nv_t = ::c_uchar;
// should be pub(crate), but that requires Rust 1.18.0
-#[doc(hidden)]
-pub const _ALIGNBYTES: usize = mem::size_of::<::c_int>() - 1;
+cfg_if! {
+ if #[cfg(libc_const_size_of)] {
+ #[doc(hidden)]
+ pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;
+ } else {
+ #[doc(hidden)]
+ pub const _ALIGNBYTES: usize = 4 - 1;
+ }
+}
diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/x86_64.rs b/libc/src/unix/bsd/netbsdlike/netbsd/x86_64.rs
index af1b8f8..0860d4f 100644
--- a/libc/src/unix/bsd/netbsdlike/netbsd/x86_64.rs
+++ b/libc/src/unix/bsd/netbsdlike/netbsd/x86_64.rs
@@ -1,5 +1,3 @@
-use dox::mem;
-
use PT_FIRSTMACH;
pub type c_long = i64;
@@ -8,8 +6,15 @@ pub type c_char = i8;
pub type __cpu_simple_lock_nv_t = ::c_uchar;
// should be pub(crate), but that requires Rust 1.18.0
-#[doc(hidden)]
-pub const _ALIGNBYTES: usize = mem::size_of::<::c_long>() - 1;
+cfg_if! {
+ if #[cfg(libc_const_size_of)] {
+ #[doc(hidden)]
+ pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
+ } else {
+ #[doc(hidden)]
+ pub const _ALIGNBYTES: usize = 8 - 1;
+ }
+}
pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0;
pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1;
diff --git a/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/mod.rs b/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/mod.rs
deleted file mode 100644
index e5f0219..0000000
--- a/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/mod.rs
+++ /dev/null
@@ -1,113 +0,0 @@
-pub type c_char = i8;
-
-s! {
- pub struct lconv {
- pub decimal_point: *mut ::c_char,
- pub thousands_sep: *mut ::c_char,
- pub grouping: *mut ::c_char,
- pub int_curr_symbol: *mut ::c_char,
- pub currency_symbol: *mut ::c_char,
- pub mon_decimal_point: *mut ::c_char,
- pub mon_thousands_sep: *mut ::c_char,
- pub mon_grouping: *mut ::c_char,
- pub positive_sign: *mut ::c_char,
- pub negative_sign: *mut ::c_char,
- pub int_frac_digits: ::c_char,
- pub frac_digits: ::c_char,
- pub p_cs_precedes: ::c_char,
- pub p_sep_by_space: ::c_char,
- pub n_cs_precedes: ::c_char,
- pub n_sep_by_space: ::c_char,
- pub p_sign_posn: ::c_char,
- pub n_sign_posn: ::c_char,
- pub int_p_cs_precedes: ::c_char,
- pub int_n_cs_precedes: ::c_char,
- pub int_p_sep_by_space: ::c_char,
- pub int_n_sep_by_space: ::c_char,
- pub int_p_sign_posn: ::c_char,
- pub int_n_sign_posn: ::c_char,
- }
-}
-
-pub const LC_COLLATE_MASK: ::c_int = (1 << 0);
-pub const LC_CTYPE_MASK: ::c_int = (1 << 1);
-pub const LC_MESSAGES_MASK: ::c_int = (1 << 2);
-pub const LC_MONETARY_MASK: ::c_int = (1 << 3);
-pub const LC_NUMERIC_MASK: ::c_int = (1 << 4);
-pub const LC_TIME_MASK: ::c_int = (1 << 5);
-pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK
- | LC_CTYPE_MASK
- | LC_MESSAGES_MASK
- | LC_MONETARY_MASK
- | LC_NUMERIC_MASK
- | LC_TIME_MASK;
-
-pub const ERA: ::nl_item = 52;
-pub const ERA_D_FMT: ::nl_item = 53;
-pub const ERA_D_T_FMT: ::nl_item = 54;
-pub const ERA_T_FMT: ::nl_item = 55;
-pub const ALT_DIGITS: ::nl_item = 56;
-
-pub const D_MD_ORDER: ::nl_item = 57;
-
-pub const ALTMON_1: ::nl_item = 58;
-pub const ALTMON_2: ::nl_item = 59;
-pub const ALTMON_3: ::nl_item = 60;
-pub const ALTMON_4: ::nl_item = 61;
-pub const ALTMON_5: ::nl_item = 62;
-pub const ALTMON_6: ::nl_item = 63;
-pub const ALTMON_7: ::nl_item = 64;
-pub const ALTMON_8: ::nl_item = 65;
-pub const ALTMON_9: ::nl_item = 66;
-pub const ALTMON_10: ::nl_item = 67;
-pub const ALTMON_11: ::nl_item = 68;
-pub const ALTMON_12: ::nl_item = 69;
-
-pub const KERN_RND: ::c_int = 31;
-
-// https://github.com/bitrig/bitrig/blob/master/sys/net/if.h#L187
-pub const IFF_UP: ::c_int = 0x1; // interface is up
-pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid
-pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging
-pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net
-pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link
-pub const IFF_NOTRAILERS: ::c_int = 0x20; // avoid use of trailers
-pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated
-pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol
-pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets
-pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets
-pub const IFF_OACTIVE: ::c_int = 0x400; // transmission in progress
-pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions
-pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit
-pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit
-pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
-pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
-
-pub const SIGSTKSZ : ::size_t = 40960;
-
-pub const PT_FIRSTMACH: ::c_int = 32;
-
-extern {
- pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;
- pub fn duplocale(base: ::locale_t) -> ::locale_t;
- pub fn freelocale(loc: ::locale_t) -> ::c_int;
- pub fn newlocale(mask: ::c_int,
- locale: *const ::c_char,
- base: ::locale_t) -> ::locale_t;
- pub fn uselocale(loc: ::locale_t) -> ::locale_t;
- pub fn pledge(promises: *const ::c_char,
- paths: *mut *const ::c_char) -> ::c_int;
- pub fn querylocale(mask: ::c_int, loc: ::locale_t) -> *const ::c_char;
-}
-
-cfg_if! {
- if #[cfg(target_arch = "x86")] {
- mod x86;
- pub use self::x86::*;
- } else if #[cfg(target_arch = "x86_64")] {
- mod x86_64;
- pub use self::x86_64::*;
- } else {
- // Unknown target_arch
- }
-}
diff --git a/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86.rs b/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86.rs
deleted file mode 100644
index 9b0b338..0000000
--- a/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-pub type c_long = i32;
-pub type c_ulong = u32;
diff --git a/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs b/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs
deleted file mode 100644
index d3971aa..0000000
--- a/libc/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-use PT_FIRSTMACH;
-
-pub type c_long = i64;
-pub type c_ulong = u64;
-
-pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0;
-pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1;
-pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2;
-pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 3;
-pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 4;
diff --git a/libc/src/unix/bsd/netbsdlike/openbsdlike/mod.rs b/libc/src/unix/bsd/netbsdlike/openbsdlike/mod.rs
index 1c2e47d..223064b 100644
--- a/libc/src/unix/bsd/netbsdlike/openbsdlike/mod.rs
+++ b/libc/src/unix/bsd/netbsdlike/openbsdlike/mod.rs
@@ -17,29 +17,21 @@ pub type pthread_rwlockattr_t = *mut ::c_void;
pub type caddr_t = *mut ::c_char;
s! {
- pub struct dirent {
- pub d_fileno: ::ino_t,
- pub d_off: ::off_t,
- pub d_reclen: u16,
- pub d_type: u8,
- pub d_namlen: u8,
- __d_padding: [u8; 4],
- pub d_name: [::c_char; 256],
+ pub struct ip_mreq {
+ pub imr_multiaddr: in_addr,
+ pub imr_interface: in_addr,
+ }
+
+ pub struct in_addr {
+ pub s_addr: ::in_addr_t,
}
- pub struct glob_t {
- pub gl_pathc: ::c_int,
- pub gl_matchc: ::c_int,
- pub gl_offs: ::c_int,
- pub gl_flags: ::c_int,
- pub gl_pathv: *mut *mut ::c_char,
- __unused1: *mut ::c_void,
- __unused2: *mut ::c_void,
- __unused3: *mut ::c_void,
- __unused4: *mut ::c_void,
- __unused5: *mut ::c_void,
- __unused6: *mut ::c_void,
- __unused7: *mut ::c_void,
+ pub struct sockaddr_in {
+ pub sin_len: u8,
+ pub sin_family: ::sa_family_t,
+ pub sin_port: ::in_port_t,
+ pub sin_addr: ::in_addr,
+ pub sin_zero: [::int8_t; 8],
}
pub struct kevent {
@@ -99,25 +91,6 @@ s! {
pub ai_next: *mut ::addrinfo,
}
- pub struct sockaddr_storage {
- pub ss_len: u8,
- pub ss_family: ::sa_family_t,
- __ss_pad1: [u8; 6],
- __ss_pad2: i64,
- __ss_pad3: [u8; 240],
- }
-
- pub struct siginfo_t {
- pub si_signo: ::c_int,
- pub si_code: ::c_int,
- pub si_errno: ::c_int,
- pub si_addr: *mut ::c_char,
- #[cfg(target_pointer_width = "32")]
- __pad: [u8; 112],
- #[cfg(target_pointer_width = "64")]
- __pad: [u8; 108],
- }
-
pub struct Dl_info {
pub dli_fname: *const ::c_char,
pub dli_fbase: *mut ::c_void,
@@ -125,19 +98,6 @@ s! {
pub dli_saddr: *mut ::c_void,
}
- pub struct lastlog {
- ll_time: ::time_t,
- ll_line: [::c_char; UT_LINESIZE],
- ll_host: [::c_char; UT_HOSTSIZE],
- }
-
- pub struct utmp {
- pub ut_line: [::c_char; UT_LINESIZE],
- pub ut_name: [::c_char; UT_NAMESIZE],
- pub ut_host: [::c_char; UT_HOSTSIZE],
- pub ut_time: ::time_t,
- }
-
pub struct if_data {
pub ifi_type: ::c_uchar,
pub ifi_addrlen: ::c_uchar,
@@ -204,6 +164,230 @@ s! {
}
}
+s_no_extra_traits! {
+ pub struct dirent {
+ pub d_fileno: ::ino_t,
+ pub d_off: ::off_t,
+ pub d_reclen: u16,
+ pub d_type: u8,
+ pub d_namlen: u8,
+ __d_padding: [u8; 4],
+ pub d_name: [::c_char; 256],
+ }
+
+ pub struct sockaddr_storage {
+ pub ss_len: u8,
+ pub ss_family: ::sa_family_t,
+ __ss_pad1: [u8; 6],
+ __ss_pad2: i64,
+ __ss_pad3: [u8; 240],
+ }
+
+ pub struct siginfo_t {
+ pub si_signo: ::c_int,
+ pub si_code: ::c_int,
+ pub si_errno: ::c_int,
+ pub si_addr: *mut ::c_char,
+ #[cfg(target_pointer_width = "32")]
+ __pad: [u8; 112],
+ #[cfg(target_pointer_width = "64")]
+ __pad: [u8; 108],
+ }
+
+ pub struct lastlog {
+ ll_time: ::time_t,
+ ll_line: [::c_char; UT_LINESIZE],
+ ll_host: [::c_char; UT_HOSTSIZE],
+ }
+
+ pub struct utmp {
+ pub ut_line: [::c_char; UT_LINESIZE],
+ pub ut_name: [::c_char; UT_NAMESIZE],
+ pub ut_host: [::c_char; UT_HOSTSIZE],
+ pub ut_time: ::time_t,
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for dirent {
+ fn eq(&self, other: &dirent) -> bool {
+ self.d_fileno == other.d_fileno
+ && self.d_off == other.d_off
+ && self.d_reclen == other.d_reclen
+ && self.d_type == other.d_type
+ && self.d_namlen == other.d_namlen
+ && self
+ .d_name
+ .iter()
+ .zip(other.d_name.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+
+ impl Eq for dirent {}
+
+ impl ::fmt::Debug for dirent {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("dirent")
+ .field("d_fileno", &self.d_fileno)
+ .field("d_off", &self.d_off)
+ .field("d_reclen", &self.d_reclen)
+ .field("d_type", &self.d_type)
+ .field("d_namlen", &self.d_namlen)
+ // FIXME: .field("d_name", &self.d_name)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for dirent {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.d_fileno.hash(state);
+ self.d_off.hash(state);
+ self.d_reclen.hash(state);
+ self.d_type.hash(state);
+ self.d_namlen.hash(state);
+ self.d_name.hash(state);
+ }
+ }
+
+ impl PartialEq for sockaddr_storage {
+ fn eq(&self, other: &sockaddr_storage) -> bool {
+ self.ss_len == other.ss_len
+ && self.ss_family == other.ss_family
+ }
+ }
+
+ impl Eq for sockaddr_storage {}
+
+ impl ::fmt::Debug for sockaddr_storage {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("sockaddr_storage")
+ .field("ss_len", &self.ss_len)
+ .field("ss_family", &self.ss_family)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for sockaddr_storage {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.ss_len.hash(state);
+ self.ss_family.hash(state);
+ }
+ }
+
+ impl PartialEq for siginfo_t {
+ fn eq(&self, other: &siginfo_t) -> bool {
+ self.si_signo == other.si_signo
+ && self.si_code == other.si_code
+ && self.si_errno == other.si_errno
+ && self.si_addr == other.si_addr
+ }
+ }
+
+ impl Eq for siginfo_t {}
+
+ impl ::fmt::Debug for siginfo_t {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("siginfo_t")
+ .field("si_signo", &self.si_signo)
+ .field("si_code", &self.si_code)
+ .field("si_errno", &self.si_errno)
+ .field("si_addr", &self.si_addr)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for siginfo_t {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.si_signo.hash(state);
+ self.si_code.hash(state);
+ self.si_errno.hash(state);
+ self.si_addr.hash(state);
+ }
+ }
+
+ impl PartialEq for lastlog {
+ fn eq(&self, other: &lastlog) -> bool {
+ self.ll_time == other.ll_time
+ && self
+ .ll_line
+ .iter()
+ .zip(other.ll_line.iter())
+ .all(|(a,b)| a == b)
+ && self
+ .ll_host
+ .iter()
+ .zip(other.ll_host.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+
+ impl Eq for lastlog {}
+
+ impl ::fmt::Debug for lastlog {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("lastlog")
+ .field("ll_time", &self.ll_time)
+ // FIXME: .field("ll_line", &self.ll_line)
+ // FIXME: .field("ll_host", &self.ll_host)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for lastlog {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.ll_time.hash(state);
+ self.ll_line.hash(state);
+ self.ll_host.hash(state);
+ }
+ }
+
+ impl PartialEq for utmp {
+ fn eq(&self, other: &utmp) -> bool {
+ self.ut_time == other.ut_time
+ && self
+ .ut_line
+ .iter()
+ .zip(other.ut_line.iter())
+ .all(|(a,b)| a == b)
+ && self
+ .ut_name
+ .iter()
+ .zip(other.ut_name.iter())
+ .all(|(a,b)| a == b)
+ && self
+ .ut_host
+ .iter()
+ .zip(other.ut_host.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+
+ impl Eq for utmp {}
+
+ impl ::fmt::Debug for utmp {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("utmp")
+ // FIXME: .field("ut_line", &self.ut_line)
+ // FIXME: .field("ut_name", &self.ut_name)
+ // FIXME: .field("ut_host", &self.ut_host)
+ .field("ut_time", &self.ut_time)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for utmp {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.ut_line.hash(state);
+ self.ut_name.hash(state);
+ self.ut_host.hash(state);
+ self.ut_time.hash(state);
+ }
+ }
+ }
+}
+
pub const UT_NAMESIZE: usize = 32;
pub const UT_LINESIZE: usize = 8;
pub const UT_HOSTSIZE: usize = 256;
@@ -215,8 +399,6 @@ pub const O_RSYNC: ::c_int = O_SYNC;
pub const MS_SYNC : ::c_int = 0x0002;
pub const MS_INVALIDATE : ::c_int = 0x0004;
-pub const PTHREAD_STACK_MIN : ::size_t = 2048;
-
pub const POLLNORM: ::c_short = ::POLLRDNORM;
pub const ENOATTR : ::c_int = 83;
@@ -757,9 +939,6 @@ cfg_if! {
if #[cfg(target_os = "openbsd")] {
mod openbsd;
pub use self::openbsd::*;
- } else if #[cfg(target_os = "bitrig")] {
- mod bitrig;
- pub use self::bitrig::*;
} else {
// Unknown target_os
}
diff --git a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/aarch64.rs b/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/aarch64.rs
index 2a28c2a..6a8cbb5 100644
--- a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/aarch64.rs
+++ b/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/aarch64.rs
@@ -1,9 +1,14 @@
-use dox::mem;
-
pub type c_long = i64;
pub type c_ulong = u64;
pub type c_char = u8;
// should be pub(crate), but that requires Rust 1.18.0
-#[doc(hidden)]
-pub const _ALIGNBYTES: usize = mem::size_of::<::c_long>() - 1;
+cfg_if! {
+ if #[cfg(libc_const_size_of)] {
+ #[doc(hidden)]
+ pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
+ } else {
+ #[doc(hidden)]
+ pub const _ALIGNBYTES: usize = 8 - 1;
+ }
+}
diff --git a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs b/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs
index a2a7a30..c168711 100644
--- a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs
+++ b/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs
@@ -1,4 +1,19 @@
s! {
+ pub struct glob_t {
+ pub gl_pathc: ::size_t,
+ pub gl_matchc: ::size_t,
+ pub gl_offs: ::size_t,
+ pub gl_flags: ::c_int,
+ pub gl_pathv: *mut *mut ::c_char,
+ __unused1: *mut ::c_void,
+ __unused2: *mut ::c_void,
+ __unused3: *mut ::c_void,
+ __unused4: *mut ::c_void,
+ __unused5: *mut ::c_void,
+ __unused6: *mut ::c_void,
+ __unused7: *mut ::c_void,
+ }
+
pub struct lconv {
pub decimal_point: *mut ::c_char,
pub thousands_sep: *mut ::c_char,
@@ -26,42 +41,6 @@ s! {
pub int_n_sign_posn: ::c_char,
}
- pub struct statfs {
- pub f_flags: ::uint32_t,
- pub f_bsize: ::uint32_t,
- pub f_iosize: ::uint32_t,
- pub f_blocks: ::uint64_t,
- pub f_bfree: ::uint64_t,
- pub f_bavail: ::int64_t,
- pub f_files: ::uint64_t,
- pub f_ffree: ::uint64_t,
- pub f_favail: ::int64_t,
- pub f_syncwrites: ::uint64_t,
- pub f_syncreads: ::uint64_t,
- pub f_asyncwrites: ::uint64_t,
- pub f_asyncreads: ::uint64_t,
- pub f_fsid: ::fsid_t,
- pub f_namemax: ::uint32_t,
- pub f_owner: ::uid_t,
- pub f_ctime: ::uint64_t,
- pub f_fstypename: [::c_char; 16],
- pub f_mntonname: [::c_char; 90],
- pub f_mntfromname: [::c_char; 90],
- pub f_mntfromspec: [::c_char; 90],
- pub mount_info: mount_info,
- }
-
- pub union mount_info {
- pub ufs_args: ufs_args,
- pub mfs_args: mfs_args,
- pub nfs_args: nfs_args,
- pub iso_args: iso_args,
- pub msdosfs_args: msdosfs_args,
- pub ntfs_args: ntfs_args,
- pub tmpfs_args: tmpfs_args,
- align: [::c_char; 160],
- }
-
pub struct ufs_args {
pub fspec: *mut ::c_char,
pub export_info: export_args,
@@ -165,6 +144,184 @@ s! {
}
}
+s_no_extra_traits! {
+ pub union mount_info {
+ pub ufs_args: ufs_args,
+ pub mfs_args: mfs_args,
+ pub nfs_args: nfs_args,
+ pub iso_args: iso_args,
+ pub msdosfs_args: msdosfs_args,
+ pub ntfs_args: ntfs_args,
+ pub tmpfs_args: tmpfs_args,
+ align: [::c_char; 160],
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for mount_info {
+ fn eq(&self, other: &mount_info) -> bool {
+ unsafe {
+ self.align
+ .iter()
+ .zip(other.align.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+ }
+
+ impl Eq for mount_info { }
+
+ impl ::fmt::Debug for mount_info {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("mount_info")
+ // FIXME: .field("align", &self.align)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for mount_info {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ unsafe { self.align.hash(state) };
+ }
+ }
+ }
+}
+
+cfg_if! {
+ if #[cfg(libc_union)] {
+ s_no_extra_traits! {
+ // This type uses the union mount_info:
+ pub struct statfs {
+ pub f_flags: ::uint32_t,
+ pub f_bsize: ::uint32_t,
+ pub f_iosize: ::uint32_t,
+ pub f_blocks: ::uint64_t,
+ pub f_bfree: ::uint64_t,
+ pub f_bavail: ::int64_t,
+ pub f_files: ::uint64_t,
+ pub f_ffree: ::uint64_t,
+ pub f_favail: ::int64_t,
+ pub f_syncwrites: ::uint64_t,
+ pub f_syncreads: ::uint64_t,
+ pub f_asyncwrites: ::uint64_t,
+ pub f_asyncreads: ::uint64_t,
+ pub f_fsid: ::fsid_t,
+ pub f_namemax: ::uint32_t,
+ pub f_owner: ::uid_t,
+ pub f_ctime: ::uint64_t,
+ pub f_fstypename: [::c_char; 16],
+ pub f_mntonname: [::c_char; 90],
+ pub f_mntfromname: [::c_char; 90],
+ pub f_mntfromspec: [::c_char; 90],
+ pub mount_info: mount_info,
+ }
+ }
+
+ cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for statfs {
+ fn eq(&self, other: &statfs) -> bool {
+ self.f_flags == other.f_flags
+ && self.f_bsize == other.f_bsize
+ && self.f_iosize == other.f_iosize
+ && self.f_blocks == other.f_blocks
+ && self.f_bfree == other.f_bfree
+ && self.f_bavail == other.f_bavail
+ && self.f_files == other.f_files
+ && self.f_ffree == other.f_ffree
+ && self.f_favail == other.f_favail
+ && self.f_syncwrites == other.f_syncwrites
+ && self.f_syncreads == other.f_syncreads
+ && self.f_asyncwrites == other.f_asyncwrites
+ && self.f_asyncreads == other.f_asyncreads
+ && self.f_fsid == other.f_fsid
+ && self.f_namemax == other.f_namemax
+ && self.f_owner == other.f_owner
+ && self.f_ctime == other.f_ctime
+ && self.f_fstypename
+ .iter()
+ .zip(other.f_fstypename.iter())
+ .all(|(a,b)| a == b)
+ && self.f_mntonname
+ .iter()
+ .zip(other.f_mntonname.iter())
+ .all(|(a,b)| a == b)
+ && self.f_mntfromname
+ .iter()
+ .zip(other.f_mntfromname.iter())
+ .all(|(a,b)| a == b)
+ && self.f_mntfromspec
+ .iter()
+ .zip(other.f_mntfromspec.iter())
+ .all(|(a,b)| a == b)
+ && self.mount_info == other.mount_info
+ }
+ }
+
+ impl Eq for statfs { }
+
+ impl ::fmt::Debug for statfs {
+ fn fmt(&self, f: &mut ::fmt::Formatter)
+ -> ::fmt::Result {
+ f.debug_struct("statfs")
+ .field("f_flags", &self.f_flags)
+ .field("f_bsize", &self.f_bsize)
+ .field("f_iosize", &self.f_iosize)
+ .field("f_blocks", &self.f_blocks)
+ .field("f_bfree", &self.f_bfree)
+ .field("f_bavail", &self.f_bavail)
+ .field("f_files", &self.f_files)
+ .field("f_ffree", &self.f_ffree)
+ .field("f_favail", &self.f_favail)
+ .field("f_syncwrites", &self.f_syncwrites)
+ .field("f_syncreads", &self.f_syncreads)
+ .field("f_asyncwrites", &self.f_asyncwrites)
+ .field("f_asyncreads", &self.f_asyncreads)
+ .field("f_fsid", &self.f_fsid)
+ .field("f_namemax", &self.f_namemax)
+ .field("f_owner", &self.f_owner)
+ .field("f_ctime", &self.f_ctime)
+ // FIXME: .field("f_fstypename", &self.f_fstypename)
+ // FIXME: .field("f_mntonname", &self.f_mntonname)
+ // FIXME: .field("f_mntfromname", &self.f_mntfromname)
+ // FIXME: .field("f_mntfromspec", &self.f_mntfromspec)
+ .field("mount_info", &self.mount_info)
+ .finish()
+ }
+ }
+
+ impl ::hash::Hash for statfs {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.f_flags.hash(state);
+ self.f_bsize.hash(state);
+ self.f_iosize.hash(state);
+ self.f_blocks.hash(state);
+ self.f_bfree.hash(state);
+ self.f_bavail.hash(state);
+ self.f_files.hash(state);
+ self.f_ffree.hash(state);
+ self.f_favail.hash(state);
+ self.f_syncwrites.hash(state);
+ self.f_syncreads.hash(state);
+ self.f_asyncwrites.hash(state);
+ self.f_asyncreads.hash(state);
+ self.f_fsid.hash(state);
+ self.f_namemax.hash(state);
+ self.f_owner.hash(state);
+ self.f_ctime.hash(state);
+ self.f_fstypename.hash(state);
+ self.f_mntonname.hash(state);
+ self.f_mntfromname.hash(state);
+ self.f_mntfromspec.hash(state);
+ self.mount_info.hash(state);
+ }
+ }
+ }
+ }
+ }
+}
+
//https://github.com/openbsd/src/blob/master/sys/sys/mount.h
pub const ISOFSMNT_NORRIP: ::c_int = 0x1; // disable Rock Ridge Ext
pub const ISOFSMNT_GENS: ::c_int = 0x2; // enable generation numbers
@@ -246,10 +403,61 @@ pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit
pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
+pub const PTHREAD_STACK_MIN : ::size_t = 4096;
pub const SIGSTKSZ : ::size_t = 28672;
pub const PT_FIRSTMACH: ::c_int = 32;
+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 WSTOPSIG(status: ::c_int) -> ::c_int {
+ status >> 8
+ }
+
+ pub fn WIFSIGNALED(status: ::c_int) -> bool {
+ (status & 0o177) != 0o177 && (status & 0o177) != 0
+ }
+
+ pub fn WIFSTOPPED(status: ::c_int) -> bool {
+ (status & 0o177) == 0o177
+ }
+}
+
extern {
pub fn accept4(s: ::c_int, addr: *mut ::sockaddr,
addrlen: *mut ::socklen_t, flags: ::c_int) -> ::c_int;
@@ -260,14 +468,20 @@ extern {
pub fn strtonum(nptr: *const ::c_char, minval: ::c_longlong,
maxval: ::c_longlong,
errstr: *mut *const ::c_char) -> ::c_longlong;
-
- pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
- pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
-
pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
}
cfg_if! {
+ if #[cfg(libc_union)] {
+ extern {
+ // these functions use statfs which uses the union mount_info:
+ pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
+ pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
+ }
+ }
+}
+
+cfg_if! {
if #[cfg(target_arch = "x86")] {
mod x86;
pub use self::x86::*;
diff --git a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86.rs b/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86.rs
index b63b69f..05538cd 100644
--- a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86.rs
+++ b/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86.rs
@@ -1,9 +1,14 @@
-use dox::mem;
-
pub type c_long = i32;
pub type c_ulong = u32;
pub type c_char = i8;
// should be pub(crate), but that requires Rust 1.18.0
-#[doc(hidden)]
-pub const _ALIGNBYTES: usize = mem::size_of::<::c_int>() - 1;
+cfg_if! {
+ if #[cfg(libc_const_size_of)] {
+ #[doc(hidden)]
+ pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1;
+ } else {
+ #[doc(hidden)]
+ pub const _ALIGNBYTES: usize = 4 - 1;
+ }
+}
diff --git a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs b/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs
index 581096f..7daa9d8 100644
--- a/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs
+++ b/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd/x86_64.rs
@@ -1,5 +1,3 @@
-use dox::mem;
-
use PT_FIRSTMACH;
pub type c_long = i64;
@@ -7,8 +5,15 @@ pub type c_ulong = u64;
pub type c_char = i8;
// should be pub(crate), but that requires Rust 1.18.0
-#[doc(hidden)]
-pub const _ALIGNBYTES: usize = mem::size_of::<::c_long>() - 1;
+cfg_if! {
+ if #[cfg(libc_const_size_of)] {
+ #[doc(hidden)]
+ pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1;
+ } else {
+ #[doc(hidden)]
+ pub const _ALIGNBYTES: usize = 8 - 1;
+ }
+}
pub const PT_STEP: ::c_int = PT_FIRSTMACH + 0;
pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1;