aboutsummaryrefslogtreecommitdiff
path: root/libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2019-05-24 18:07:22 -0700
committerDaniel Mueller <deso@posteo.net>2019-05-24 18:07:22 -0700
commit82cf43dd887801b8b22b8aae8c02854d921915d5 (patch)
treeb1bf3710bd07fe83e396a5db8563f3e6c5e85689 /libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd
parent06722702ea35434189d7de2b13a00209b2ebbd6d (diff)
downloadnitrocli-82cf43dd887801b8b22b8aae8c02854d921915d5.tar.gz
nitrocli-82cf43dd887801b8b22b8aae8c02854d921915d5.tar.bz2
Update libc crate to 0.2.55
This change updates the libc crate to version 0.2.55. Import subrepo libc/:libc at caf17a0641d29dc624621177f5756804dd180c13
Diffstat (limited to 'libc/src/unix/bsd/netbsdlike/openbsdlike/openbsd')
-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
4 files changed, 281 insertions, 52 deletions
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;