summaryrefslogtreecommitdiff
path: root/src/unix/bsd
diff options
context:
space:
mode:
authorgnzlbg <gonzalobg88@gmail.com>2019-05-16 14:53:51 +0200
committergnzlbg <gonzalobg88@gmail.com>2019-05-24 20:04:17 +0200
commit7437d0a6f18625b90a9d2fc40f3ecbc98a2e95fc (patch)
treec2a8655e7d01d6ff20f64325d4cdd2d7309edde0 /src/unix/bsd
parent5653a6014f18dbc2594ba756e40bb5e2f69866f7 (diff)
downloadrust-libc-7437d0a6f18625b90a9d2fc40f3ecbc98a2e95fc.tar.gz
Add a FreeBSD 12 build job and test FreeBSD12 APIs
This commits adds a second FreeBSD 12 build job, and splits the implementation of the FreeBSD module into two modules, one for FreeBSD 11, and one for FreeBSD 12. The FreeBSD 11 module is compiled always by default, and is mostly forward compatible with FreeBSD 12 systems. The FreeBSD 12 module is only built for now in libc's CI, and uses FreeBSD 12 data types and APIs, linking to symbols that are only available in FreeBSD 12. Basically, when LIBC_CI env variable is defined, and the host system is a FreeBSD 12 system, then the FreeBSD 12 module is automatically built and tested. Conditional compilation is done using a `cfg(freebsd12)` flag. This commit also re-enables many tests, and documents why some remain disabled.
Diffstat (limited to 'src/unix/bsd')
-rw-r--r--src/unix/bsd/apple/mod.rs8
-rw-r--r--src/unix/bsd/freebsdlike/dragonfly/mod.rs11
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs214
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs30
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs207
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs32
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/mod.rs205
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/x86_64.rs26
-rw-r--r--src/unix/bsd/freebsdlike/mod.rs24
-rw-r--r--src/unix/bsd/mod.rs11
-rw-r--r--src/unix/bsd/netbsdlike/mod.rs1
11 files changed, 548 insertions, 221 deletions
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index 53463abbc8..60dd70fc21 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -2419,6 +2419,7 @@ pub const NOTE_NONE: ::uint32_t = 0x00000080;
pub const NOTE_EXIT: ::uint32_t = 0x80000000;
pub const NOTE_FORK: ::uint32_t = 0x40000000;
pub const NOTE_EXEC: ::uint32_t = 0x20000000;
+#[doc(hidden)]
#[deprecated(since="0.2.49", note="Deprecated since MacOSX 10.9")]
pub const NOTE_REAP: ::uint32_t = 0x10000000;
pub const NOTE_SIGNAL: ::uint32_t = 0x08000000;
@@ -2426,6 +2427,7 @@ pub const NOTE_EXITSTATUS: ::uint32_t = 0x04000000;
pub const NOTE_EXIT_DETAIL: ::uint32_t = 0x02000000;
pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff;
pub const NOTE_PCTRLMASK: ::uint32_t = 0xfff00000;
+#[doc(hidden)]
#[deprecated(since="0.2.49", note="Deprecated since MacOSX 10.9")]
pub const NOTE_EXIT_REPARENTED: ::uint32_t = 0x00080000;
pub const NOTE_EXIT_DETAIL_MASK: ::uint32_t = 0x00070000;
@@ -2632,8 +2634,10 @@ pub const KERN_KDSETRTCDEC: ::c_int = 15;
pub const KERN_KDGETENTROPY: ::c_int = 16;
pub const KERN_KDWRITETR: ::c_int = 17;
pub const KERN_KDWRITEMAP: ::c_int = 18;
+#[doc(hidden)]
#[deprecated(since = "0.2.49", note ="Removed in MacOSX 10.12")]
pub const KERN_KDENABLE_BG_TRACE: ::c_int = 19;
+#[doc(hidden)]
#[deprecated(since = "0.2.49", note ="Removed in MacOSX 10.12")]
pub const KERN_KDDISABLE_BG_TRACE: ::c_int = 20;
pub const KERN_KDREADCURTHRMAP: ::c_int = 21;
@@ -3014,11 +3018,15 @@ f! {
}
extern {
+ pub fn setgrent();
+ #[doc(hidden)]
#[deprecated(since="0.2.49", note="Deprecated in MacOSX 10.5")]
#[link_name = "daemon$1050"]
pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
+ #[doc(hidden)]
#[deprecated(since="0.2.49", note="Deprecated in MacOSX 10.10")]
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
+ #[doc(hidden)]
#[deprecated(since="0.2.49", note="Deprecated in MacOSX 10.10")]
pub fn sem_init(sem: *mut sem_t,
pshared: ::c_int,
diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs
index e91b351cc4..b0604a2b19 100644
--- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs
+++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs
@@ -1,3 +1,4 @@
+pub type dev_t = u32;
pub type c_char = i8;
pub type clock_t = u64;
pub type ino_t = u64;
@@ -27,6 +28,15 @@ impl ::Clone for sem {
}
s! {
+ pub struct kevent {
+ pub ident: ::uintptr_t,
+ pub filter: ::c_short,
+ pub flags: ::c_ushort,
+ pub fflags: ::c_uint,
+ pub data: ::intptr_t,
+ pub udata: *mut ::c_void,
+ }
+
pub struct exit_status {
pub e_termination: u16,
pub e_exit: u16
@@ -1008,6 +1018,7 @@ f! {
}
extern {
+ pub fn setgrent();
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
-> ::c_int;
pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs
new file mode 100644
index 0000000000..7667b63b6f
--- /dev/null
+++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs
@@ -0,0 +1,214 @@
+// APIs that had breaking changes after FreeBSD 11
+
+// The type of `nlink_t` changed from `u16` to `uint64_t` in FreeBSD 12:
+pub type nlink_t = u16;
+// Type of `dev_t` changed from `u32` to `uint64_t` in FreeBSD 12:
+pub type dev_t = u32;
+// Type of `ino_t` changed from `unsigned int` to `unsigned long` in FreeBSD 12:
+pub type ino_t = u32;
+
+s! {
+ pub struct kevent {
+ pub ident: ::uintptr_t,
+ pub filter: ::c_short,
+ pub flags: ::c_ushort,
+ pub fflags: ::c_uint,
+ pub data: ::intptr_t,
+ pub udata: *mut ::c_void,
+ }
+
+ pub struct shmid_ds {
+ pub shm_perm: ::ipc_perm,
+ pub shm_segsz: ::size_t,
+ pub shm_lpid: ::pid_t,
+ pub shm_cpid: ::pid_t,
+ // Type of shm_nattc changed from `int` to `shmatt_t` (aka `unsigned
+ // int`) in FreeBSD 12:
+ pub shm_nattch: ::c_int,
+ pub shm_atime: ::time_t,
+ pub shm_dtime: ::time_t,
+ pub shm_ctime: ::time_t,
+ }
+}
+
+s_no_extra_traits! {
+ pub struct dirent {
+ pub d_fileno: ::ino_t,
+ pub d_reclen: u16,
+ pub d_type: u8,
+ // Type of `d_namlen` changed from `char` to `uint16_t` in FreeBSD 12:
+ pub d_namlen: u8,
+ pub d_name: [::c_char; 256],
+ }
+
+ pub struct statfs {
+ pub f_version: ::uint32_t,
+ pub f_type: ::uint32_t,
+ pub f_flags: ::uint64_t,
+ pub f_bsize: ::uint64_t,
+ pub f_iosize: ::uint64_t,
+ pub f_blocks: ::uint64_t,
+ pub f_bfree: ::uint64_t,
+ pub f_bavail: ::int64_t,
+ pub f_files: ::uint64_t,
+ pub f_ffree: ::int64_t,
+ pub f_syncwrites: ::uint64_t,
+ pub f_asyncwrites: ::uint64_t,
+ pub f_syncreads: ::uint64_t,
+ pub f_asyncreads: ::uint64_t,
+ f_spare: [::uint64_t; 10],
+ pub f_namemax: ::uint32_t,
+ pub f_owner: ::uid_t,
+ pub f_fsid: ::fsid_t,
+ f_charspare: [::c_char; 80],
+ pub f_fstypename: [::c_char; 16],
+ // Array length changed from 88 to 1024 in FreeBSD 12:
+ pub f_mntfromname: [::c_char; 88],
+ // Array length changed from 88 to 1024 in FreeBSD 12:
+ pub f_mntonname: [::c_char; 88],
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for statfs {
+ fn eq(&self, other: &statfs) -> bool {
+ self.f_version == other.f_version
+ && self.f_type == other.f_type
+ && 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_syncwrites == other.f_syncwrites
+ && self.f_asyncwrites == other.f_asyncwrites
+ && self.f_syncreads == other.f_syncreads
+ && self.f_asyncreads == other.f_asyncreads
+ && self.f_namemax == other.f_namemax
+ && self.f_owner == other.f_owner
+ && self.f_fsid == other.f_fsid
+ && self.f_fstypename == other.f_fstypename
+ && self
+ .f_mntfromname
+ .iter()
+ .zip(other.f_mntfromname.iter())
+ .all(|(a,b)| a == b)
+ && self
+ .f_mntonname
+ .iter()
+ .zip(other.f_mntonname.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+ impl Eq for statfs {}
+ impl ::fmt::Debug for statfs {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("statfs")
+ .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_syncwrites", &self.f_syncwrites)
+ .field("f_asyncwrites", &self.f_asyncwrites)
+ .field("f_syncreads", &self.f_syncreads)
+ .field("f_asyncreads", &self.f_asyncreads)
+ .field("f_namemax", &self.f_namemax)
+ .field("f_owner", &self.f_owner)
+ .field("f_fsid", &self.f_fsid)
+ .field("f_fstypename", &self.f_fstypename)
+ .field("f_mntfromname", &&self.f_mntfromname[..])
+ .field("f_mntonname", &&self.f_mntonname[..])
+ .finish()
+ }
+ }
+ impl ::hash::Hash for statfs {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.f_version.hash(state);
+ self.f_type.hash(state);
+ 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_syncwrites.hash(state);
+ self.f_asyncwrites.hash(state);
+ self.f_syncreads.hash(state);
+ self.f_asyncreads.hash(state);
+ self.f_namemax.hash(state);
+ self.f_owner.hash(state);
+ self.f_fsid.hash(state);
+ self.f_fstypename.hash(state);
+ self.f_mntfromname.hash(state);
+ self.f_mntonname.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_type == other.d_type
+ && self.d_namlen == other.d_namlen
+ && self
+ .d_name[..self.d_namlen as _]
+ .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_type", &self.d_type)
+ .field("d_namlen", &self.d_namlen)
+ .field("d_name", &&self.d_name[..self.d_namlen as _])
+ .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_type.hash(state);
+ self.d_namlen.hash(state);
+ self.d_name[..self.d_namlen as _].hash(state);
+ }
+ }
+ }
+}
+
+extern {
+ // Return type ::c_int was removed in FreeBSD 12
+ pub fn setgrent() -> ::c_int;
+
+ // Type of `addr` argument changed from `const void*` to `void*`
+ // in FreeBSD 12
+ pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
+ -> ::c_int;
+
+ // Return type ::c_int was removed in FreeBSD 12
+ pub fn freelocale(loc: ::locale_t) -> ::c_int;
+
+ // Return type ::c_int changed to ::ssize_t in FreeBSD 12:
+ pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t,
+ msgtyp: ::c_long, msgflg: ::c_int) -> ::c_int;
+}
+
+cfg_if! {
+ if #[cfg(target_arch = "x86_64")] {
+ mod x86_64;
+ pub use self::x86_64::*;
+ }
+}
diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs
new file mode 100644
index 0000000000..bba277e700
--- /dev/null
+++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/x86_64.rs
@@ -0,0 +1,30 @@
+#[repr(C)]
+#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
+pub struct stat {
+ pub st_dev: ::dev_t,
+ pub st_ino: ::ino_t,
+ pub st_mode: ::mode_t,
+ pub st_nlink: ::nlink_t,
+ pub st_uid: ::uid_t,
+ pub st_gid: ::gid_t,
+ pub st_rdev: ::dev_t,
+ pub st_atime: ::time_t,
+ pub st_atime_nsec: ::c_long,
+ pub st_mtime: ::time_t,
+ pub st_mtime_nsec: ::c_long,
+ pub st_ctime: ::time_t,
+ pub st_ctime_nsec: ::c_long,
+ pub st_size: ::off_t,
+ pub st_blocks: ::blkcnt_t,
+ pub st_blksize: ::blksize_t,
+ pub st_flags: ::fflags_t,
+ pub st_gen: u32,
+ pub st_lspare: i32,
+ pub st_birthtime: ::time_t,
+ pub st_birthtime_nsec: ::c_long,
+}
+
+impl ::Copy for ::stat {}
+impl ::Clone for ::stat {
+ fn clone(&self) -> ::stat { *self }
+}
diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs
new file mode 100644
index 0000000000..85e1d2b9f1
--- /dev/null
+++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs
@@ -0,0 +1,207 @@
+// APIs that changed in FreeBSD12
+
+pub type nlink_t = u64;
+pub type dev_t = u64;
+pub type ino_t = ::c_ulong;
+pub type shmatt_t = ::c_uint;
+
+s! {
+ pub struct shmid_ds {
+ pub shm_perm: ::ipc_perm,
+ pub shm_segsz: ::size_t,
+ pub shm_lpid: ::pid_t,
+ pub shm_cpid: ::pid_t,
+ pub shm_nattch: ::shmatt_t,
+ pub shm_atime: ::time_t,
+ pub shm_dtime: ::time_t,
+ pub shm_ctime: ::time_t,
+ }
+
+ pub struct kevent {
+ pub ident: ::uintptr_t,
+ pub filter: ::c_short,
+ pub flags: ::c_ushort,
+ pub fflags: ::c_uint,
+ pub data: ::intptr_t,
+ pub udata: *mut ::c_void,
+ pub ext: [u64; 4],
+ }
+}
+
+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,
+ d_pad0: u8,
+ pub d_namlen: u16,
+ d_pad1: u16,
+ pub d_name: [::c_char; 256],
+ }
+
+ pub struct statfs {
+ pub f_version: ::uint32_t,
+ pub f_type: ::uint32_t,
+ pub f_flags: ::uint64_t,
+ pub f_bsize: ::uint64_t,
+ pub f_iosize: ::uint64_t,
+ pub f_blocks: ::uint64_t,
+ pub f_bfree: ::uint64_t,
+ pub f_bavail: ::int64_t,
+ pub f_files: ::uint64_t,
+ pub f_ffree: ::int64_t,
+ pub f_syncwrites: ::uint64_t,
+ pub f_asyncwrites: ::uint64_t,
+ pub f_syncreads: ::uint64_t,
+ pub f_asyncreads: ::uint64_t,
+ f_spare: [::uint64_t; 10],
+ pub f_namemax: ::uint32_t,
+ pub f_owner: ::uid_t,
+ pub f_fsid: ::fsid_t,
+ f_charspare: [::c_char; 80],
+ pub f_fstypename: [::c_char; 16],
+ pub f_mntfromname: [::c_char; 1024],
+ pub f_mntonname: [::c_char; 1024],
+ }
+}
+
+cfg_if! {
+ if #[cfg(feature = "extra_traits")] {
+ impl PartialEq for statfs {
+ fn eq(&self, other: &statfs) -> bool {
+ self.f_version == other.f_version
+ && self.f_type == other.f_type
+ && 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_syncwrites == other.f_syncwrites
+ && self.f_asyncwrites == other.f_asyncwrites
+ && self.f_syncreads == other.f_syncreads
+ && self.f_asyncreads == other.f_asyncreads
+ && self.f_namemax == other.f_namemax
+ && self.f_owner == other.f_owner
+ && self.f_fsid == other.f_fsid
+ && self.f_fstypename == other.f_fstypename
+ && self
+ .f_mntfromname
+ .iter()
+ .zip(other.f_mntfromname.iter())
+ .all(|(a,b)| a == b)
+ && self
+ .f_mntonname
+ .iter()
+ .zip(other.f_mntonname.iter())
+ .all(|(a,b)| a == b)
+ }
+ }
+ impl Eq for statfs {}
+ impl ::fmt::Debug for statfs {
+ fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+ f.debug_struct("statfs")
+ .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_syncwrites", &self.f_syncwrites)
+ .field("f_asyncwrites", &self.f_asyncwrites)
+ .field("f_syncreads", &self.f_syncreads)
+ .field("f_asyncreads", &self.f_asyncreads)
+ .field("f_namemax", &self.f_namemax)
+ .field("f_owner", &self.f_owner)
+ .field("f_fsid", &self.f_fsid)
+ .field("f_fstypename", &self.f_fstypename)
+ .field("f_mntfromname", &&self.f_mntfromname[..])
+ .field("f_mntonname", &&self.f_mntonname[..])
+ .finish()
+ }
+ }
+ impl ::hash::Hash for statfs {
+ fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
+ self.f_version.hash(state);
+ self.f_type.hash(state);
+ 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_syncwrites.hash(state);
+ self.f_asyncwrites.hash(state);
+ self.f_syncreads.hash(state);
+ self.f_asyncreads.hash(state);
+ self.f_namemax.hash(state);
+ self.f_owner.hash(state);
+ self.f_fsid.hash(state);
+ self.f_charspare.hash(state);
+ self.f_fstypename.hash(state);
+ self.f_mntfromname.hash(state);
+ self.f_mntonname.hash(state);
+ }
+ }
+
+ 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[..self.d_namlen as _]
+ .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)
+ .field("d_name", &&self.d_name[..self.d_namlen as _])
+ .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[..self.d_namlen as _].hash(state);
+ }
+ }
+ }
+}
+
+extern {
+ pub fn setgrent();
+ pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
+ -> ::c_int;
+ pub fn freelocale(loc: ::locale_t);
+ pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t,
+ msgtyp: ::c_long, msgflg: ::c_int) -> ::ssize_t;
+}
+
+cfg_if! {
+ if #[cfg(target_arch = "x86_64")] {
+ mod x86_64;
+ pub use self::x86_64::*;
+ }
+}
diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs
new file mode 100644
index 0000000000..dbaa4ae2f9
--- /dev/null
+++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs
@@ -0,0 +1,32 @@
+#[repr(C)]
+#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
+pub struct stat {
+ pub st_dev: ::dev_t,
+ pub st_ino: ::ino_t,
+ pub st_nlink: ::nlink_t,
+ pub st_mode: ::mode_t,
+ st_padding0: i16,
+ pub st_uid: ::uid_t,
+ pub st_gid: ::gid_t,
+ st_padding1: i32,
+ pub st_rdev: ::dev_t,
+ pub st_atime: ::time_t,
+ pub st_atime_nsec: ::c_long,
+ pub st_mtime: ::time_t,
+ pub st_mtime_nsec: ::c_long,
+ pub st_ctime: ::time_t,
+ pub st_ctime_nsec: ::c_long,
+ pub st_birthtime: ::time_t,
+ pub st_birthtime_nsec: ::c_long,
+ pub st_size: ::off_t,
+ pub st_blocks: ::blkcnt_t,
+ pub st_blksize: ::blksize_t,
+ pub st_flags: ::fflags_t,
+ pub st_gen: u64,
+ pub st_spare: [u64; 10],
+}
+
+impl ::Copy for ::stat {}
+impl ::Clone for ::stat {
+ fn clone(&self) -> ::stat { *self }
+}
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index 3ce96e8966..948ba174a9 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -1,8 +1,7 @@
pub type fflags_t = u32;
pub type clock_t = i32;
-pub type ino_t = u32;
+
pub type lwpid_t = i32;
-pub type nlink_t = u16;
pub type blksize_t = i32;
pub type clockid_t = ::c_int;
pub type sem_t = _sem;
@@ -110,17 +109,6 @@ s! {
pub msg_ctime: ::time_t,
}
- pub struct shmid_ds {
- pub shm_perm: ::ipc_perm,
- pub shm_segsz: ::size_t,
- pub shm_lpid: ::pid_t,
- pub shm_cpid: ::pid_t,
- pub shm_nattch: ::c_int,
- pub shm_atime: ::time_t,
- pub shm_dtime: ::time_t,
- pub shm_ctime: ::time_t,
- }
-
pub struct xucred {
pub cr_version: ::c_uint,
pub cr_uid: ::uid_t,
@@ -153,39 +141,6 @@ s_no_extra_traits! {
pub __ut_spare: [::c_char; 64],
}
- pub struct dirent {
- pub d_fileno: u32,
- pub d_reclen: u16,
- pub d_type: u8,
- pub d_namlen: u8,
- pub d_name: [::c_char; 256],
- }
-
- pub struct statfs {
- pub f_version: ::uint32_t,
- pub f_type: ::uint32_t,
- pub f_flags: ::uint64_t,
- pub f_bsize: ::uint64_t,
- pub f_iosize: ::uint64_t,
- pub f_blocks: ::uint64_t,
- pub f_bfree: ::uint64_t,
- pub f_bavail: ::int64_t,
- pub f_files: ::uint64_t,
- pub f_ffree: ::int64_t,
- pub f_syncwrites: ::uint64_t,
- pub f_asyncwrites: ::uint64_t,
- pub f_syncreads: ::uint64_t,
- pub f_asyncreads: ::uint64_t,
- f_spare: [::uint64_t; 10],
- pub f_namemax: ::uint32_t,
- pub f_owner: ::uid_t,
- pub f_fsid: ::fsid_t,
- f_charspare: [::c_char; 80],
- pub f_fstypename: [::c_char; 16],
- pub f_mntfromname: [::c_char; 88],
- pub f_mntonname: [::c_char; 88],
- }
-
pub struct sockaddr_dl {
pub sdl_len: ::c_uchar,
pub sdl_family: ::c_uchar,
@@ -248,132 +203,6 @@ cfg_if! {
}
}
- impl PartialEq for dirent {
- fn eq(&self, other: &dirent) -> bool {
- self.d_fileno == other.d_fileno
- && 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_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_reclen.hash(state);
- self.d_type.hash(state);
- self.d_namlen.hash(state);
- self.d_name.hash(state);
- }
- }
-
- impl PartialEq for statfs {
- fn eq(&self, other: &statfs) -> bool {
- self.f_version == other.f_version
- && self.f_type == other.f_type
- && 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_syncwrites == other.f_syncwrites
- && self.f_asyncwrites == other.f_asyncwrites
- && self.f_syncreads == other.f_syncreads
- && self.f_asyncreads == other.f_asyncreads
- && self.f_spare == other.f_spare
- && self.f_namemax == other.f_namemax
- && self.f_owner == other.f_owner
- && self.f_fsid == other.f_fsid
- && self
- .f_charspare
- .iter()
- .zip(other.f_charspare.iter())
- .all(|(a,b)| a == b)
- && self.f_fstypename == other.f_fstypename
- && self
- .f_mntfromname
- .iter()
- .zip(other.f_mntfromname.iter())
- .all(|(a,b)| a == b)
- && self
- .f_mntonname
- .iter()
- .zip(other.f_mntonname.iter())
- .all(|(a,b)| a == b)
- }
- }
- impl Eq for statfs {}
- impl ::fmt::Debug for statfs {
- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
- f.debug_struct("statfs")
- .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_syncwrites", &self.f_syncwrites)
- .field("f_asyncwrites", &self.f_asyncwrites)
- .field("f_syncreads", &self.f_syncreads)
- .field("f_asyncreads", &self.f_asyncreads)
- .field("f_spare", &self.f_spare)
- .field("f_namemax", &self.f_namemax)
- .field("f_owner", &self.f_owner)
- .field("f_fsid", &self.f_fsid)
- // FIXME: .field("f_charspare", &self.f_charspare)
- .field("f_fstypename", &self.f_fstypename)
- // FIXME: .field("f_mntfromname", &self.f_mntfromname)
- // FIXME: .field("f_mntonname", &self.f_mntonname)
- .finish()
- }
- }
- impl ::hash::Hash for statfs {
- fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
- self.f_version.hash(state);
- self.f_type.hash(state);
- 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_syncwrites.hash(state);
- self.f_asyncwrites.hash(state);
- self.f_syncreads.hash(state);
- self.f_asyncreads.hash(state);
- self.f_spare.hash(state);
- self.f_namemax.hash(state);
- self.f_owner.hash(state);
- self.f_fsid.hash(state);
- self.f_charspare.hash(state);
- self.f_fstypename.hash(state);
- self.f_mntfromname.hash(state);
- self.f_mntonname.hash(state);
- }
- }
-
impl PartialEq for sockaddr_dl {
fn eq(&self, other: &sockaddr_dl) -> bool {
self.sdl_len == other.sdl_len
@@ -779,14 +608,21 @@ pub const IFF_POINTOPOINT: ::c_int = 0x10; // (i) is a point-to-point link
// 0x20 was IFF_SMART
pub const IFF_RUNNING: ::c_int = 0x40; // (d) resources allocated
#[doc(hidden)]
-// IFF_DRV_RUNNING is deprecated. Use the portable `IFF_RUNNING` instead
+#[doc(hidden)]
+#[deprecated(
+ since="0.2.54",
+ note="IFF_DRV_RUNNING is deprecated. Use the portable IFF_RUNNING instead"
+)]
pub const IFF_DRV_RUNNING: ::c_int = 0x40;
pub const IFF_NOARP: ::c_int = 0x80; // (n) no address resolution protocol
pub const IFF_PROMISC: ::c_int = 0x100; // (n) receive all packets
pub const IFF_ALLMULTI: ::c_int = 0x200; // (n) receive all multicast packets
pub const IFF_OACTIVE: ::c_int = 0x400; // (d) tx hardware queue is full
#[doc(hidden)]
-// IFF_DRV_OACTIVE is deprecated. Use the portable `IFF_OACTIVE` instead
+#[deprecated(
+ since = "0.2.54",
+ note = "Use the portable `IFF_OACTIVE` instead",
+)]
pub const IFF_DRV_OACTIVE: ::c_int = 0x400;
pub const IFF_SIMPLEX: ::c_int = 0x800; // (i) can't hear own transmissions
pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit
@@ -1106,14 +942,19 @@ pub const SHM_ANON: *mut ::c_char = 1 as *mut ::c_char;
// they were all removed in svn r262489. They remain here for backwards
// compatibility only, and are scheduled to be removed in libc 1.0.0.
#[doc(hidden)]
+#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")]
pub const NET_MAXID: ::c_int = AF_MAX;
#[doc(hidden)]
+#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")]
pub const CTL_MAXID: ::c_int = 10;
#[doc(hidden)]
+#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")]
pub const KERN_MAXID: ::c_int = 38;
#[doc(hidden)]
+#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")]
pub const HW_MAXID: ::c_int = 13;
#[doc(hidden)]
+#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")]
pub const USER_MAXID: ::c_int = 21;
#[doc(hidden)]
pub const CTL_P1003_1B_MAXID: ::c_int = 26;
@@ -1251,9 +1092,6 @@ f! {
extern {
pub fn __error() -> *mut ::c_int;
- pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
- -> ::c_int;
-
pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int;
@@ -1335,7 +1173,6 @@ extern {
timeout: *mut ::timespec) -> ::ssize_t;
pub fn mq_getfd_np(mqd: ::mqd_t) -> ::c_int;
- pub fn freelocale(loc: ::locale_t) -> ::c_int;
pub fn waitid(idtype: idtype_t, id: ::id_t, infop: *mut ::siginfo_t,
options: ::c_int) -> ::c_int;
@@ -1349,8 +1186,6 @@ extern {
pub fn msgctl(msqid: ::c_int, cmd: ::c_int,
buf: *mut ::msqid_ds) -> ::c_int;
pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int;
- pub fn msgrcv(msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t,
- msgtyp: ::c_long, msgflg: ::c_int) -> ::c_int;
pub fn msgsnd(msqid: ::c_int, msgp: *const ::c_void, msgsz: ::size_t,
msgflg: ::c_int) -> ::c_int;
pub fn cfmakesane(termios: *mut ::termios);
@@ -1452,6 +1287,16 @@ extern {
}
cfg_if! {
+ if #[cfg(freebsd12)] {
+ mod freebsd12;
+ pub use self::freebsd12::*;
+ } else {
+ mod freebsd11;
+ pub use self::freebsd11::*;
+ }
+}
+
+cfg_if! {
if #[cfg(target_arch = "x86")] {
mod x86;
pub use self::x86::*;
diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64.rs
index 323d1ab7b3..5220cde915 100644
--- a/src/unix/bsd/freebsdlike/freebsd/x86_64.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/x86_64.rs
@@ -4,32 +4,6 @@ pub type c_ulong = u64;
pub type time_t = i64;
pub type suseconds_t = i64;
-s! {
- pub struct stat {
- pub st_dev: ::dev_t,
- pub st_ino: ::ino_t,
- pub st_mode: ::mode_t,
- pub st_nlink: ::nlink_t,
- pub st_uid: ::uid_t,
- pub st_gid: ::gid_t,
- pub st_rdev: ::dev_t,
- pub st_atime: ::time_t,
- pub st_atime_nsec: ::c_long,
- pub st_mtime: ::time_t,
- pub st_mtime_nsec: ::c_long,
- pub st_ctime: ::time_t,
- pub st_ctime_nsec: ::c_long,
- pub st_size: ::off_t,
- pub st_blocks: ::blkcnt_t,
- pub st_blksize: ::blksize_t,
- pub st_flags: ::fflags_t,
- pub st_gen: ::uint32_t,
- pub st_lspare: ::int32_t,
- pub st_birthtime: ::time_t,
- pub st_birthtime_nsec: ::c_long,
- }
-}
-
// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
if #[cfg(libc_const_size_of)] {
diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs
index 5e0853bf51..64168ebe28 100644
--- a/src/unix/bsd/freebsdlike/mod.rs
+++ b/src/unix/bsd/freebsdlike/mod.rs
@@ -1,4 +1,3 @@
-pub type dev_t = u32;
pub type mode_t = u16;
pub type pthread_attr_t = *mut ::c_void;
pub type rlim_t = i64;
@@ -46,15 +45,6 @@ s! {
__unused8: *mut ::c_void,
}
- pub struct kevent {
- pub ident: ::uintptr_t,
- pub filter: ::c_short,
- pub flags: ::c_ushort,
- pub fflags: ::c_uint,
- pub data: ::intptr_t,
- pub udata: *mut ::c_void,
- }
-
pub struct addrinfo {
pub ai_flags: ::c_int,
pub ai_family: ::c_int,
@@ -758,7 +748,11 @@ pub const LOCK_NB: ::c_int = 4;
pub const LOCK_UN: ::c_int = 8;
pub const MAP_COPY: ::c_int = 0x0002;
+#[doc(hidden)]
+#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")]
pub const MAP_RENAME: ::c_int = 0x0020;
+#[doc(hidden)]
+#[deprecated(since="0.2.54",note="Removed in FreeBSD 11")]
pub const MAP_NORESERVE: ::c_int = 0x0040;
pub const MAP_HASSEMAPHORE: ::c_int = 0x0200;
pub const MAP_STACK: ::c_int = 0x0400;
@@ -1141,7 +1135,10 @@ extern {
pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
pub fn initgroups(name: *const ::c_char, basegid: ::gid_t) -> ::c_int;
- #[cfg_attr(target_os = "freebsd", link_name = "kevent@FBSD_1.0")]
+ #[cfg_attr(
+ all(target_os = "freebsd", not(freebsd12)),
+ link_name = "kevent@FBSD_1.0"
+ )]
pub fn kevent(kq: ::c_int,
changelist: *const ::kevent,
nchanges: ::c_int,
@@ -1157,7 +1154,10 @@ extern {
n: ::size_t) -> *mut ::c_void;
pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,
mode: ::mode_t) -> ::c_int;
- #[cfg_attr(target_os = "freebsd", link_name = "mknodat@FBSD_1.1")]
+ #[cfg_attr(
+ all(target_os = "freebsd", not(freebsd12)),
+ link_name = "mknodat@FBSD_1.1"
+ )]
pub fn mknodat(dirfd: ::c_int, pathname: *const ::c_char,
mode: ::mode_t, dev: dev_t) -> ::c_int;
pub fn mq_close(mqd: ::mqd_t) -> ::c_int;
diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs
index ef92bd5cd4..e69035e197 100644
--- a/src/unix/bsd/mod.rs
+++ b/src/unix/bsd/mod.rs
@@ -508,7 +508,6 @@ extern {
pub fn getpwent() -> *mut passwd;
pub fn setpwent();
pub fn endpwent();
- pub fn setgrent();
pub fn endgrent();
pub fn getgrent() -> *mut ::group;
@@ -524,14 +523,20 @@ extern {
#[cfg_attr(target_os = "macos", link_name = "glob$INODE64")]
#[cfg_attr(target_os = "netbsd", link_name = "__glob30")]
- #[cfg_attr(target_os = "freebsd", link_name = "glob@FBSD_1.0")]
+ #[cfg_attr(
+ all(target_os = "freebsd", not(freebsd12)),
+ link_name = "glob@FBSD_1.0"
+ )]
pub fn glob(pattern: *const ::c_char,
flags: ::c_int,
errfunc: ::Option<extern fn(epath: *const ::c_char,
errno: ::c_int) -> ::c_int>,
pglob: *mut ::glob_t) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__globfree30")]
- #[cfg_attr(target_os = "freebsd", link_name = "globfree@FBSD_1.0")]
+ #[cfg_attr(
+ all(target_os = "freebsd", not(freebsd12)),
+ link_name = "globfree@FBSD_1.0"
+ )]
pub fn globfree(pglob: *mut ::glob_t);
pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs
index 6e8383061c..751e0beefd 100644
--- a/src/unix/bsd/netbsdlike/mod.rs
+++ b/src/unix/bsd/netbsdlike/mod.rs
@@ -597,6 +597,7 @@ pub const TIMER_ABSTIME: ::c_int = 1;
#[link(name = "util")]
extern {
+ pub fn setgrent();
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
pub fn sem_init(sem: *mut sem_t,
pshared: ::c_int,