1 // APIs that were changed after FreeBSD 11 2 3 // The type of `nlink_t` changed from `u16` to `u64` in FreeBSD 12: 4 pub type nlink_t = u16; 5 // Type of `dev_t` changed from `u32` to `u64` in FreeBSD 12: 6 pub type dev_t = u32; 7 // Type of `ino_t` changed from `unsigned int` to `unsigned long` in FreeBSD 12: 8 pub type ino_t = u32; 9 10 s! { 11 pub struct kevent { 12 pub ident: ::uintptr_t, 13 pub filter: ::c_short, 14 pub flags: ::c_ushort, 15 pub fflags: ::c_uint, 16 pub data: ::intptr_t, 17 pub udata: *mut ::c_void, 18 } 19 20 pub struct shmid_ds { 21 pub shm_perm: ::ipc_perm, 22 pub shm_segsz: ::size_t, 23 pub shm_lpid: ::pid_t, 24 pub shm_cpid: ::pid_t, 25 // Type of shm_nattc changed from `int` to `shmatt_t` (aka `unsigned 26 // int`) in FreeBSD 12: 27 pub shm_nattch: ::c_int, 28 pub shm_atime: ::time_t, 29 pub shm_dtime: ::time_t, 30 pub shm_ctime: ::time_t, 31 } 32 } 33 34 s_no_extra_traits! { 35 pub struct dirent { 36 pub d_fileno: ::ino_t, 37 pub d_reclen: u16, 38 pub d_type: u8, 39 // Type of `d_namlen` changed from `char` to `u16` in FreeBSD 12: 40 pub d_namlen: u8, 41 pub d_name: [::c_char; 256], 42 } 43 44 pub struct statfs { 45 pub f_version: u32, 46 pub f_type: u32, 47 pub f_flags: u64, 48 pub f_bsize: u64, 49 pub f_iosize: u64, 50 pub f_blocks: u64, 51 pub f_bfree: u64, 52 pub f_bavail: i64, 53 pub f_files: u64, 54 pub f_ffree: i64, 55 pub f_syncwrites: u64, 56 pub f_asyncwrites: u64, 57 pub f_syncreads: u64, 58 pub f_asyncreads: u64, 59 f_spare: [u64; 10], 60 pub f_namemax: u32, 61 pub f_owner: ::uid_t, 62 pub f_fsid: ::fsid_t, 63 f_charspare: [::c_char; 80], 64 pub f_fstypename: [::c_char; 16], 65 // Array length changed from 88 to 1024 in FreeBSD 12: 66 pub f_mntfromname: [::c_char; 88], 67 // Array length changed from 88 to 1024 in FreeBSD 12: 68 pub f_mntonname: [::c_char; 88], 69 } 70 } 71 72 cfg_if! { 73 if #[cfg(feature = "extra_traits")] { 74 impl PartialEq for statfs { 75 fn eq(&self, other: &statfs) -> bool { 76 self.f_version == other.f_version 77 && self.f_type == other.f_type 78 && self.f_flags == other.f_flags 79 && self.f_bsize == other.f_bsize 80 && self.f_iosize == other.f_iosize 81 && self.f_blocks == other.f_blocks 82 && self.f_bfree == other.f_bfree 83 && self.f_bavail == other.f_bavail 84 && self.f_files == other.f_files 85 && self.f_ffree == other.f_ffree 86 && self.f_syncwrites == other.f_syncwrites 87 && self.f_asyncwrites == other.f_asyncwrites 88 && self.f_syncreads == other.f_syncreads 89 && self.f_asyncreads == other.f_asyncreads 90 && self.f_namemax == other.f_namemax 91 && self.f_owner == other.f_owner 92 && self.f_fsid == other.f_fsid 93 && self.f_fstypename == other.f_fstypename 94 && self 95 .f_mntfromname 96 .iter() 97 .zip(other.f_mntfromname.iter()) 98 .all(|(a,b)| a == b) 99 && self 100 .f_mntonname 101 .iter() 102 .zip(other.f_mntonname.iter()) 103 .all(|(a,b)| a == b) 104 } 105 } 106 impl Eq for statfs {} 107 impl ::fmt::Debug for statfs { 108 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { 109 f.debug_struct("statfs") 110 .field("f_bsize", &self.f_bsize) 111 .field("f_iosize", &self.f_iosize) 112 .field("f_blocks", &self.f_blocks) 113 .field("f_bfree", &self.f_bfree) 114 .field("f_bavail", &self.f_bavail) 115 .field("f_files", &self.f_files) 116 .field("f_ffree", &self.f_ffree) 117 .field("f_syncwrites", &self.f_syncwrites) 118 .field("f_asyncwrites", &self.f_asyncwrites) 119 .field("f_syncreads", &self.f_syncreads) 120 .field("f_asyncreads", &self.f_asyncreads) 121 .field("f_namemax", &self.f_namemax) 122 .field("f_owner", &self.f_owner) 123 .field("f_fsid", &self.f_fsid) 124 .field("f_fstypename", &self.f_fstypename) 125 .field("f_mntfromname", &&self.f_mntfromname[..]) 126 .field("f_mntonname", &&self.f_mntonname[..]) 127 .finish() 128 } 129 } 130 impl ::hash::Hash for statfs { 131 fn hash<H: ::hash::Hasher>(&self, state: &mut H) { 132 self.f_version.hash(state); 133 self.f_type.hash(state); 134 self.f_flags.hash(state); 135 self.f_bsize.hash(state); 136 self.f_iosize.hash(state); 137 self.f_blocks.hash(state); 138 self.f_bfree.hash(state); 139 self.f_bavail.hash(state); 140 self.f_files.hash(state); 141 self.f_ffree.hash(state); 142 self.f_syncwrites.hash(state); 143 self.f_asyncwrites.hash(state); 144 self.f_syncreads.hash(state); 145 self.f_asyncreads.hash(state); 146 self.f_namemax.hash(state); 147 self.f_owner.hash(state); 148 self.f_fsid.hash(state); 149 self.f_fstypename.hash(state); 150 self.f_mntfromname.hash(state); 151 self.f_mntonname.hash(state); 152 } 153 } 154 155 impl PartialEq for dirent { 156 fn eq(&self, other: &dirent) -> bool { 157 self.d_fileno == other.d_fileno 158 && self.d_reclen == other.d_reclen 159 && self.d_type == other.d_type 160 && self.d_namlen == other.d_namlen 161 && self 162 .d_name[..self.d_namlen as _] 163 .iter() 164 .zip(other.d_name.iter()) 165 .all(|(a,b)| a == b) 166 } 167 } 168 impl Eq for dirent {} 169 impl ::fmt::Debug for dirent { 170 fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { 171 f.debug_struct("dirent") 172 .field("d_fileno", &self.d_fileno) 173 .field("d_reclen", &self.d_reclen) 174 .field("d_type", &self.d_type) 175 .field("d_namlen", &self.d_namlen) 176 .field("d_name", &&self.d_name[..self.d_namlen as _]) 177 .finish() 178 } 179 } 180 impl ::hash::Hash for dirent { 181 fn hash<H: ::hash::Hasher>(&self, state: &mut H) { 182 self.d_fileno.hash(state); 183 self.d_reclen.hash(state); 184 self.d_type.hash(state); 185 self.d_namlen.hash(state); 186 self.d_name[..self.d_namlen as _].hash(state); 187 } 188 } 189 } 190 } 191 192 pub const ELAST: ::c_int = 96; 193 pub const RAND_MAX: ::c_int = 0x7fff_fffd; 194 195 extern "C" { 196 // Return type ::c_int was removed in FreeBSD 12 setgrent() -> ::c_int197 pub fn setgrent() -> ::c_int; 198 199 // Type of `addr` argument changed from `const void*` to `void*` 200 // in FreeBSD 12 mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int201 pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; 202 203 // Return type ::c_int was removed in FreeBSD 12 freelocale(loc: ::locale_t) -> ::c_int204 pub fn freelocale(loc: ::locale_t) -> ::c_int; 205 206 // Return type ::c_int changed to ::ssize_t in FreeBSD 12: msgrcv( msqid: ::c_int, msgp: *mut ::c_void, msgsz: ::size_t, msgtyp: ::c_long, msgflg: ::c_int, ) -> ::c_int207 pub fn msgrcv( 208 msqid: ::c_int, 209 msgp: *mut ::c_void, 210 msgsz: ::size_t, 211 msgtyp: ::c_long, 212 msgflg: ::c_int, 213 ) -> ::c_int; 214 fdatasync(fd: ::c_int) -> ::c_int215 pub fn fdatasync(fd: ::c_int) -> ::c_int; 216 } 217 218 cfg_if! { 219 if #[cfg(any(target_arch = "x86_64", 220 target_arch = "aarch64"))] { 221 mod b64; 222 pub use self::b64::*; 223 } 224 } 225