summaryrefslogtreecommitdiff
path: root/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs
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/freebsdlike/freebsd/freebsd11/mod.rs
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/freebsdlike/freebsd/freebsd11/mod.rs')
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs214
1 files changed, 214 insertions, 0 deletions
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::*;
+ }
+}