From 2da0438979fb51945c5e40d6217f403d34f4295f Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 5 Mar 2023 10:20:49 +0000 Subject: [PATCH] removing freebsd 11 EOL proposal. --- build.rs | 6 +- .../bsd/freebsdlike/freebsd/freebsd11/b32.rs | 36 -- .../bsd/freebsdlike/freebsd/freebsd11/b64.rs | 35 -- .../bsd/freebsdlike/freebsd/freebsd11/mod.rs | 437 ------------------ .../bsd/freebsdlike/freebsd/freebsd12/mod.rs | 170 +------ .../bsd/freebsdlike/freebsd/freebsd13/mod.rs | 167 +------ .../bsd/freebsdlike/freebsd/freebsd14/mod.rs | 167 +------ .../bsd/freebsdlike/freebsd/freebsd15/mod.rs | 167 +------ src/unix/bsd/freebsdlike/freebsd/mod.rs | 223 ++++++--- .../bsd/freebsdlike/freebsd/x86_64/mod.rs | 4 + src/unix/bsd/freebsdlike/mod.rs | 16 - src/unix/bsd/mod.rs | 20 - src/unix/mod.rs | 28 -- 13 files changed, 188 insertions(+), 1288 deletions(-) delete mode 100644 src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs delete mode 100644 src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs delete mode 100644 src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs diff --git a/build.rs b/build.rs index 2476820caffe4..cac7233d3e89e 100644 --- a/build.rs +++ b/build.rs @@ -7,8 +7,6 @@ use std::{env, str}; const ALLOWED_CFGS: &[&str] = &[ "emscripten_old_stat_abi", "espidf_time32", - "freebsd10", - "freebsd11", "freebsd12", "freebsd13", "freebsd14", @@ -73,9 +71,7 @@ fn main() { }; match which_freebsd { - x if x < 10 => panic!("FreeBSD older than 10 is not supported"), - 10 => set_cfg("freebsd10"), - 11 => set_cfg("freebsd11"), + x if x < 12 => panic!("FreeBSD older than 12 is not supported"), 12 => set_cfg("freebsd12"), 13 => set_cfg("freebsd13"), 14 => set_cfg("freebsd14"), diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs deleted file mode 100644 index 4b96972433ec9..0000000000000 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs +++ /dev/null @@ -1,36 +0,0 @@ -use crate::off_t; -use crate::prelude::*; - -#[repr(C)] -#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] -pub struct stat { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - pub st_size: off_t, - pub st_blocks: crate::blkcnt_t, - pub st_blksize: crate::blksize_t, - pub st_flags: crate::fflags_t, - pub st_gen: u32, - pub st_lspare: i32, - pub st_birthtime: crate::time_t, - pub st_birthtime_nsec: c_long, - __unused: [u8; 8], -} - -impl Copy for crate::stat {} -impl Clone for crate::stat { - fn clone(&self) -> crate::stat { - *self - } -} diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs deleted file mode 100644 index c492ceb47aa41..0000000000000 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs +++ /dev/null @@ -1,35 +0,0 @@ -use crate::off_t; -use crate::prelude::*; - -#[repr(C)] -#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] -pub struct stat { - pub st_dev: crate::dev_t, - pub st_ino: crate::ino_t, - pub st_mode: crate::mode_t, - pub st_nlink: crate::nlink_t, - pub st_uid: crate::uid_t, - pub st_gid: crate::gid_t, - pub st_rdev: crate::dev_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - pub st_size: off_t, - pub st_blocks: crate::blkcnt_t, - pub st_blksize: crate::blksize_t, - pub st_flags: crate::fflags_t, - pub st_gen: u32, - pub st_lspare: i32, - pub st_birthtime: crate::time_t, - pub st_birthtime_nsec: c_long, -} - -impl Copy for crate::stat {} -impl Clone for crate::stat { - fn clone(&self) -> crate::stat { - *self - } -} diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs deleted file mode 100644 index f886c17db2b91..0000000000000 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ /dev/null @@ -1,437 +0,0 @@ -use crate::prelude::*; - -// APIs that were changed after FreeBSD 11 - -// The type of `nlink_t` changed from `u16` to `u64` in FreeBSD 12: -pub type nlink_t = u16; -// Type of `dev_t` changed from `u32` to `u64` in FreeBSD 12: -pub type dev_t = u32; -// Type of `ino_t` changed from `__uint32_t` to `__uint64_t` in FreeBSD 12: -pub type ino_t = u32; - -s! { - pub struct kevent { - pub ident: crate::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: crate::ipc_perm, - pub shm_segsz: size_t, - pub shm_lpid: crate::pid_t, - pub shm_cpid: crate::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: crate::time_t, - pub shm_dtime: crate::time_t, - pub shm_ctime: crate::time_t, - } - - pub struct kinfo_proc { - /// Size of this structure. - pub ki_structsize: c_int, - /// Reserved: layout identifier. - pub ki_layout: c_int, - /// Address of command arguments. - pub ki_args: *mut crate::pargs, - // This is normally "struct proc". - /// Address of proc. - pub ki_paddr: *mut c_void, - // This is normally "struct user". - /// Kernel virtual address of u-area. - pub ki_addr: *mut c_void, - // This is normally "struct vnode". - /// Pointer to trace file. - pub ki_tracep: *mut c_void, - // This is normally "struct vnode". - /// Pointer to executable file. - pub ki_textvp: *mut c_void, - /// Pointer to open file info. - pub ki_fd: *mut crate::filedesc, - // This is normally "struct vmspace". - /// Pointer to kernel vmspace struct. - pub ki_vmspace: *mut c_void, - /// Sleep address. - pub ki_wchan: *mut c_void, - /// Process identifier. - pub ki_pid: crate::pid_t, - /// Parent process ID. - pub ki_ppid: crate::pid_t, - /// Process group ID. - pub ki_pgid: crate::pid_t, - /// tty process group ID. - pub ki_tpgid: crate::pid_t, - /// Process session ID. - pub ki_sid: crate::pid_t, - /// Terminal session ID. - pub ki_tsid: crate::pid_t, - /// Job control counter. - pub ki_jobc: c_short, - /// Unused (just here for alignment). - pub ki_spare_short1: c_short, - /// Controlling tty dev. - pub ki_tdev: crate::dev_t, - /// Signals arrived but not delivered. - pub ki_siglist: crate::sigset_t, - /// Current signal mask. - pub ki_sigmask: crate::sigset_t, - /// Signals being ignored. - pub ki_sigignore: crate::sigset_t, - /// Signals being caught by user. - pub ki_sigcatch: crate::sigset_t, - /// Effective user ID. - pub ki_uid: crate::uid_t, - /// Real user ID. - pub ki_ruid: crate::uid_t, - /// Saved effective user ID. - pub ki_svuid: crate::uid_t, - /// Real group ID. - pub ki_rgid: crate::gid_t, - /// Saved effective group ID. - pub ki_svgid: crate::gid_t, - /// Number of groups. - pub ki_ngroups: c_short, - /// Unused (just here for alignment). - pub ki_spare_short2: c_short, - /// Groups. - pub ki_groups: [crate::gid_t; crate::KI_NGROUPS], - /// Virtual size. - pub ki_size: crate::vm_size_t, - /// Current resident set size in pages. - pub ki_rssize: crate::segsz_t, - /// Resident set size before last swap. - pub ki_swrss: crate::segsz_t, - /// Text size (pages) XXX. - pub ki_tsize: crate::segsz_t, - /// Data size (pages) XXX. - pub ki_dsize: crate::segsz_t, - /// Stack size (pages). - pub ki_ssize: crate::segsz_t, - /// Exit status for wait & stop signal. - pub ki_xstat: crate::u_short, - /// Accounting flags. - pub ki_acflag: crate::u_short, - /// %cpu for process during `ki_swtime`. - pub ki_pctcpu: crate::fixpt_t, - /// Time averaged value of `ki_cpticks`. - pub ki_estcpu: crate::u_int, - /// Time since last blocked. - pub ki_slptime: crate::u_int, - /// Time swapped in or out. - pub ki_swtime: crate::u_int, - /// Number of copy-on-write faults. - pub ki_cow: crate::u_int, - /// Real time in microsec. - pub ki_runtime: u64, - /// Starting time. - pub ki_start: crate::timeval, - /// Time used by process children. - pub ki_childtime: crate::timeval, - /// P_* flags. - pub ki_flag: c_long, - /// KI_* flags (below). - pub ki_kiflag: c_long, - /// Kernel trace points. - pub ki_traceflag: c_int, - /// S* process status. - pub ki_stat: c_char, - /// Process "nice" value. - pub ki_nice: i8, // signed char - /// Process lock (prevent swap) count. - pub ki_lock: c_char, - /// Run queue index. - pub ki_rqindex: c_char, - /// Which cpu we are on. - pub ki_oncpu_old: c_uchar, - /// Last cpu we were on. - pub ki_lastcpu_old: c_uchar, - /// Thread name. - pub ki_tdname: [c_char; crate::TDNAMLEN + 1], - /// Wchan message. - pub ki_wmesg: [c_char; crate::WMESGLEN + 1], - /// Setlogin name. - pub ki_login: [c_char; crate::LOGNAMELEN + 1], - /// Lock name. - pub ki_lockname: [c_char; crate::LOCKNAMELEN + 1], - /// Command name. - pub ki_comm: [c_char; crate::COMMLEN + 1], - /// Emulation name. - pub ki_emul: [c_char; crate::KI_EMULNAMELEN + 1], - /// Login class. - pub ki_loginclass: [c_char; crate::LOGINCLASSLEN + 1], - /// More thread name. - pub ki_moretdname: [c_char; crate::MAXCOMLEN - crate::TDNAMLEN + 1], - /// Spare string space. - pub ki_sparestrings: [c_char; 46], - /// Spare room for growth. - pub ki_spareints: [c_int; crate::KI_NSPARE_INT], - /// Which cpu we are on. - pub ki_oncpu: c_int, - /// Last cpu we were on. - pub ki_lastcpu: c_int, - /// PID of tracing process. - pub ki_tracer: c_int, - /// P2_* flags. - pub ki_flag2: c_int, - /// Default FIB number. - pub ki_fibnum: c_int, - /// Credential flags. - pub ki_cr_flags: crate::u_int, - /// Process jail ID. - pub ki_jid: c_int, - /// Number of threads in total. - pub ki_numthreads: c_int, - /// Thread ID. - pub ki_tid: crate::lwpid_t, - /// Process priority. - pub ki_pri: crate::priority, - /// Process rusage statistics. - pub ki_rusage: crate::rusage, - /// rusage of children processes. - pub ki_rusage_ch: crate::rusage, - // This is normally "struct pcb". - /// Kernel virtual addr of pcb. - pub ki_pcb: *mut c_void, - /// Kernel virtual addr of stack. - pub ki_kstack: *mut c_void, - /// User convenience pointer. - pub ki_udata: *mut c_void, - // This is normally "struct thread". - pub ki_tdaddr: *mut c_void, - pub ki_spareptrs: [*mut c_void; crate::KI_NSPARE_PTR], - pub ki_sparelongs: [c_long; crate::KI_NSPARE_LONG], - /// PS_* flags. - pub ki_sflag: c_long, - /// kthread flag. - pub ki_tdflags: c_long, - } -} - -s_no_extra_traits! { - pub struct dirent { - pub d_fileno: crate::ino_t, - pub d_reclen: u16, - pub d_type: u8, - // Type of `d_namlen` changed from `char` to `u16` in FreeBSD 12: - pub d_namlen: u8, - pub d_name: [c_char; 256], - } - - pub struct statfs { - pub f_version: u32, - pub f_type: u32, - pub f_flags: u64, - pub f_bsize: u64, - pub f_iosize: u64, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: i64, - pub f_files: u64, - pub f_ffree: i64, - pub f_syncwrites: u64, - pub f_asyncwrites: u64, - pub f_syncreads: u64, - pub f_asyncreads: u64, - f_spare: [u64; 10], - pub f_namemax: u32, - pub f_owner: crate::uid_t, - pub f_fsid: crate::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], - } - - pub struct vnstat { - pub vn_fileid: u64, - pub vn_size: u64, - pub vn_mntdir: *mut c_char, - pub vn_dev: u32, - pub vn_fsid: u32, - pub vn_type: c_int, - pub vn_mode: u16, - pub vn_devname: [c_char; crate::SPECNAMELEN as usize + 1], - } -} - -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 hash::Hash for statfs { - fn hash(&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 hash::Hash for dirent { - fn hash(&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); - } - } - - impl PartialEq for vnstat { - fn eq(&self, other: &vnstat) -> bool { - let self_vn_devname: &[c_char] = &self.vn_devname; - let other_vn_devname: &[c_char] = &other.vn_devname; - - self.vn_fileid == other.vn_fileid - && self.vn_size == other.vn_size - && self.vn_mntdir == other.vn_mntdir - && self.vn_dev == other.vn_dev - && self.vn_fsid == other.vn_fsid - && self.vn_type == other.vn_type - && self.vn_mode == other.vn_mode - && self_vn_devname == other_vn_devname - } - } - impl Eq for vnstat {} - impl hash::Hash for vnstat { - fn hash(&self, state: &mut H) { - let self_vn_devname: &[c_char] = &self.vn_devname; - - self.vn_fileid.hash(state); - self.vn_size.hash(state); - self.vn_mntdir.hash(state); - self.vn_dev.hash(state); - self.vn_fsid.hash(state); - self.vn_type.hash(state); - self.vn_mode.hash(state); - self_vn_devname.hash(state); - } - } - } -} - -pub const ELAST: c_int = 96; -pub const RAND_MAX: c_int = 0x7fff_fffd; -pub const KI_NSPARE_PTR: usize = 6; -pub const MINCORE_SUPER: c_int = 0x20; -/// max length of devicename -pub const SPECNAMELEN: c_int = 63; - -safe_f! { - pub {const} fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { - let major = major as crate::dev_t; - let minor = minor as crate::dev_t; - (major << 8) | minor - } - - pub {const} fn major(dev: crate::dev_t) -> c_int { - ((dev >> 8) & 0xff) as c_int - } - - pub {const} fn minor(dev: crate::dev_t) -> c_int { - (dev & 0xffff00ff) as c_int - } -} - -extern "C" { - // 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: crate::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; - - // Type of `path` argument changed from `const void*` to `void*` - // in FreeBSD 12 - pub fn dirname(path: *const c_char) -> *mut c_char; - pub fn basename(path: *const c_char) -> *mut c_char; -} - -cfg_if! { - if #[cfg(target_pointer_width = "64")] { - mod b64; - pub use self::b64::*; - } else { - mod b32; - pub use self::b32::*; - } -} diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index 256e96295f705..d39ff96dbad8d 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -3,33 +3,7 @@ use crate::prelude::*; // APIs in FreeBSD 12 that have changed since 11. -pub type nlink_t = u64; -pub type dev_t = u64; -pub type ino_t = u64; -pub type shmatt_t = c_uint; - s! { - pub struct shmid_ds { - pub shm_perm: crate::ipc_perm, - pub shm_segsz: size_t, - pub shm_lpid: crate::pid_t, - pub shm_cpid: crate::pid_t, - pub shm_nattch: crate::shmatt_t, - pub shm_atime: crate::time_t, - pub shm_dtime: crate::time_t, - pub shm_ctime: crate::time_t, - } - - pub struct kevent { - pub ident: crate::uintptr_t, - pub filter: c_short, - pub flags: c_ushort, - pub fflags: c_uint, - pub data: i64, - pub udata: *mut c_void, - pub ext: [u64; 4], - } - pub struct kvm_page { pub version: c_uint, pub paddr: c_ulong, @@ -257,42 +231,6 @@ s! { } s_no_extra_traits! { - pub struct dirent { - pub d_fileno: crate::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: u32, - pub f_type: u32, - pub f_flags: u64, - pub f_bsize: u64, - pub f_iosize: u64, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: i64, - pub f_files: u64, - pub f_ffree: i64, - pub f_syncwrites: u64, - pub f_asyncwrites: u64, - pub f_syncreads: u64, - pub f_asyncreads: u64, - f_spare: [u64; 10], - pub f_namemax: u32, - pub f_owner: crate::uid_t, - pub f_fsid: crate::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], - } - pub struct vnstat { pub vn_fileid: u64, pub vn_size: u64, @@ -307,90 +245,6 @@ s_no_extra_traits! { 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 hash::Hash for statfs { - fn hash(&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 hash::Hash for dirent { - fn hash(&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); - } - } - impl PartialEq for vnstat { fn eq(&self, other: &vnstat) -> bool { let self_vn_devname: &[c_char] = &self.vn_devname; @@ -438,10 +292,10 @@ safe_f! { let major = major as crate::dev_t; let minor = minor as crate::dev_t; let mut dev = 0; - dev |= ((major & 0xffffff00) as dev_t) << 32; - dev |= ((major & 0x000000ff) as dev_t) << 8; - dev |= ((minor & 0x0000ff00) as dev_t) << 24; - dev |= ((minor & 0xffff00ff) as dev_t) << 0; + dev |= ((major & 0xffffff00) as crate::dev_t) << 32; + dev |= ((major & 0x000000ff) as crate::dev_t) << 8; + dev |= ((minor & 0x0000ff00) as crate::dev_t) << 24; + dev |= ((minor & 0xffff00ff) as crate::dev_t) << 0; dev } @@ -454,22 +308,6 @@ safe_f! { } } -extern "C" { - pub fn setgrent(); - pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; - pub fn freelocale(loc: crate::locale_t); - pub fn msgrcv( - msqid: c_int, - msgp: *mut c_void, - msgsz: size_t, - msgtyp: c_long, - msgflg: c_int, - ) -> ssize_t; - - pub fn dirname(path: *mut c_char) -> *mut c_char; - pub fn basename(path: *mut c_char) -> *mut c_char; -} - cfg_if! { if #[cfg(target_arch = "x86_64")] { mod x86_64; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index d9eb98ab4e3f6..7538b36b55851 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -3,36 +3,11 @@ use crate::prelude::*; // APIs in FreeBSD 13 that have changed since 11. -pub type nlink_t = u64; -pub type dev_t = u64; -pub type ino_t = u64; -pub type shmatt_t = c_uint; pub type kpaddr_t = u64; pub type kssize_t = i64; pub type domainset_t = __c_anonymous_domainset; s! { - pub struct shmid_ds { - pub shm_perm: crate::ipc_perm, - pub shm_segsz: size_t, - pub shm_lpid: crate::pid_t, - pub shm_cpid: crate::pid_t, - pub shm_nattch: crate::shmatt_t, - pub shm_atime: crate::time_t, - pub shm_dtime: crate::time_t, - pub shm_ctime: crate::time_t, - } - - pub struct kevent { - pub ident: crate::uintptr_t, - pub filter: c_short, - pub flags: c_ushort, - pub fflags: c_uint, - pub data: i64, - pub udata: *mut c_void, - pub ext: [u64; 4], - } - pub struct kvm_page { pub kp_version: crate::u_int, pub kp_paddr: crate::kpaddr_t, @@ -270,42 +245,6 @@ s! { } s_no_extra_traits! { - pub struct dirent { - pub d_fileno: crate::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: u32, - pub f_type: u32, - pub f_flags: u64, - pub f_bsize: u64, - pub f_iosize: u64, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: i64, - pub f_files: u64, - pub f_ffree: i64, - pub f_syncwrites: u64, - pub f_asyncwrites: u64, - pub f_syncreads: u64, - pub f_asyncreads: u64, - f_spare: [u64; 10], - pub f_namemax: u32, - pub f_owner: crate::uid_t, - pub f_fsid: crate::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], - } - pub struct vnstat { pub vn_fileid: u64, pub vn_size: u64, @@ -320,90 +259,6 @@ s_no_extra_traits! { 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 hash::Hash for statfs { - fn hash(&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 hash::Hash for dirent { - fn hash(&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); - } - } - impl PartialEq for vnstat { fn eq(&self, other: &vnstat) -> bool { let self_vn_devname: &[c_char] = &self.vn_devname; @@ -460,10 +315,10 @@ safe_f! { let major = major as crate::dev_t; let minor = minor as crate::dev_t; let mut dev = 0; - dev |= ((major & 0xffffff00) as dev_t) << 32; - dev |= ((major & 0x000000ff) as dev_t) << 8; - dev |= ((minor & 0x0000ff00) as dev_t) << 24; - dev |= ((minor & 0xffff00ff) as dev_t) << 0; + dev |= ((major & 0xffffff00) as crate::dev_t) << 32; + dev |= ((major & 0x000000ff) as crate::dev_t) << 8; + dev |= ((minor & 0x0000ff00) as crate::dev_t) << 24; + dev |= ((minor & 0xffff00ff) as crate::dev_t) << 0; dev } @@ -477,17 +332,6 @@ safe_f! { } extern "C" { - pub fn setgrent(); - pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; - pub fn freelocale(loc: crate::locale_t); - pub fn msgrcv( - msqid: c_int, - msgp: *mut c_void, - msgsz: size_t, - msgtyp: c_long, - msgflg: c_int, - ) -> ssize_t; - pub fn cpuset_getdomain( level: crate::cpulevel_t, which: crate::cpuwhich_t, @@ -504,9 +348,6 @@ extern "C" { mask: *const crate::domainset_t, policy: c_int, ) -> c_int; - - pub fn dirname(path: *mut c_char) -> *mut c_char; - pub fn basename(path: *mut c_char) -> *mut c_char; } #[link(name = "kvm")] diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index b2fe6fe99b687..df62878455675 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -3,36 +3,11 @@ use crate::prelude::*; // APIs in FreeBSD 14 that have changed since 11. -pub type nlink_t = u64; -pub type dev_t = u64; -pub type ino_t = u64; -pub type shmatt_t = c_uint; pub type kpaddr_t = u64; pub type kssize_t = i64; pub type domainset_t = __c_anonymous_domainset; s! { - pub struct shmid_ds { - pub shm_perm: crate::ipc_perm, - pub shm_segsz: size_t, - pub shm_lpid: crate::pid_t, - pub shm_cpid: crate::pid_t, - pub shm_nattch: crate::shmatt_t, - pub shm_atime: crate::time_t, - pub shm_dtime: crate::time_t, - pub shm_ctime: crate::time_t, - } - - pub struct kevent { - pub ident: crate::uintptr_t, - pub filter: c_short, - pub flags: c_ushort, - pub fflags: c_uint, - pub data: i64, - pub udata: *mut c_void, - pub ext: [u64; 4], - } - pub struct kvm_page { pub kp_version: crate::u_int, pub kp_paddr: crate::kpaddr_t, @@ -270,42 +245,6 @@ s! { } s_no_extra_traits! { - pub struct dirent { - pub d_fileno: crate::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: u32, - pub f_type: u32, - pub f_flags: u64, - pub f_bsize: u64, - pub f_iosize: u64, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: i64, - pub f_files: u64, - pub f_ffree: i64, - pub f_syncwrites: u64, - pub f_asyncwrites: u64, - pub f_syncreads: u64, - pub f_asyncreads: u64, - f_spare: [u64; 10], - pub f_namemax: u32, - pub f_owner: crate::uid_t, - pub f_fsid: crate::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], - } - pub struct vnstat { pub vn_fileid: u64, pub vn_size: u64, @@ -320,90 +259,6 @@ s_no_extra_traits! { 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 hash::Hash for statfs { - fn hash(&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 hash::Hash for dirent { - fn hash(&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); - } - } - impl PartialEq for vnstat { fn eq(&self, other: &vnstat) -> bool { let self_vn_devname: &[c_char] = &self.vn_devname; @@ -460,10 +315,10 @@ safe_f! { let major = major as crate::dev_t; let minor = minor as crate::dev_t; let mut dev = 0; - dev |= ((major & 0xffffff00) as dev_t) << 32; - dev |= ((major & 0x000000ff) as dev_t) << 8; - dev |= ((minor & 0x0000ff00) as dev_t) << 24; - dev |= ((minor & 0xffff00ff) as dev_t) << 0; + dev |= ((major & 0xffffff00) as crate::dev_t) << 32; + dev |= ((major & 0x000000ff) as crate::dev_t) << 8; + dev |= ((minor & 0x0000ff00) as crate::dev_t) << 24; + dev |= ((minor & 0xffff00ff) as crate::dev_t) << 0; dev } @@ -477,17 +332,6 @@ safe_f! { } extern "C" { - pub fn setgrent(); - pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; - pub fn freelocale(loc: crate::locale_t); - pub fn msgrcv( - msqid: c_int, - msgp: *mut c_void, - msgsz: size_t, - msgtyp: c_long, - msgflg: c_int, - ) -> ssize_t; - pub fn cpuset_getdomain( level: crate::cpulevel_t, which: crate::cpuwhich_t, @@ -504,9 +348,6 @@ extern "C" { mask: *const crate::domainset_t, policy: c_int, ) -> c_int; - - pub fn dirname(path: *mut c_char) -> *mut c_char; - pub fn basename(path: *mut c_char) -> *mut c_char; } #[link(name = "kvm")] diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index 6b9eb1271184f..4975c1362c5c2 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -3,36 +3,11 @@ use crate::prelude::*; // APIs in FreeBSD 15 that have changed since 11. -pub type nlink_t = u64; -pub type dev_t = u64; -pub type ino_t = u64; -pub type shmatt_t = c_uint; pub type kpaddr_t = u64; pub type kssize_t = i64; pub type domainset_t = __c_anonymous_domainset; s! { - pub struct shmid_ds { - pub shm_perm: crate::ipc_perm, - pub shm_segsz: size_t, - pub shm_lpid: crate::pid_t, - pub shm_cpid: crate::pid_t, - pub shm_nattch: crate::shmatt_t, - pub shm_atime: crate::time_t, - pub shm_dtime: crate::time_t, - pub shm_ctime: crate::time_t, - } - - pub struct kevent { - pub ident: crate::uintptr_t, - pub filter: c_short, - pub flags: c_ushort, - pub fflags: c_uint, - pub data: i64, - pub udata: *mut c_void, - pub ext: [u64; 4], - } - pub struct kvm_page { pub kp_version: crate::u_int, pub kp_paddr: crate::kpaddr_t, @@ -271,42 +246,6 @@ s! { } s_no_extra_traits! { - pub struct dirent { - pub d_fileno: crate::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: u32, - pub f_type: u32, - pub f_flags: u64, - pub f_bsize: u64, - pub f_iosize: u64, - pub f_blocks: u64, - pub f_bfree: u64, - pub f_bavail: i64, - pub f_files: u64, - pub f_ffree: i64, - pub f_syncwrites: u64, - pub f_asyncwrites: u64, - pub f_syncreads: u64, - pub f_asyncreads: u64, - f_spare: [u64; 10], - pub f_namemax: u32, - pub f_owner: crate::uid_t, - pub f_fsid: crate::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], - } - pub struct vnstat { pub vn_fileid: u64, pub vn_size: u64, @@ -321,90 +260,6 @@ s_no_extra_traits! { 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 hash::Hash for statfs { - fn hash(&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 hash::Hash for dirent { - fn hash(&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); - } - } - impl PartialEq for vnstat { fn eq(&self, other: &vnstat) -> bool { let self_vn_devname: &[c_char] = &self.vn_devname; @@ -461,10 +316,10 @@ safe_f! { let major = major as crate::dev_t; let minor = minor as crate::dev_t; let mut dev = 0; - dev |= ((major & 0xffffff00) as dev_t) << 32; - dev |= ((major & 0x000000ff) as dev_t) << 8; - dev |= ((minor & 0x0000ff00) as dev_t) << 24; - dev |= ((minor & 0xffff00ff) as dev_t) << 0; + dev |= ((major & 0xffffff00) as crate::dev_t) << 32; + dev |= ((major & 0x000000ff) as crate::dev_t) << 8; + dev |= ((minor & 0x0000ff00) as crate::dev_t) << 24; + dev |= ((minor & 0xffff00ff) as crate::dev_t) << 0; dev } @@ -478,17 +333,6 @@ safe_f! { } extern "C" { - pub fn setgrent(); - pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; - pub fn freelocale(loc: crate::locale_t); - pub fn msgrcv( - msqid: c_int, - msgp: *mut c_void, - msgsz: size_t, - msgtyp: c_long, - msgflg: c_int, - ) -> ssize_t; - pub fn cpuset_getdomain( level: crate::cpulevel_t, which: crate::cpuwhich_t, @@ -505,9 +349,6 @@ extern "C" { mask: *const crate::domainset_t, policy: c_int, ) -> c_int; - - pub fn dirname(path: *mut c_char) -> *mut c_char; - pub fn basename(path: *mut c_char) -> *mut c_char; } #[link(name = "kvm")] diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 4d9d0a1ff4945..fbb6e9e020894 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -53,6 +53,11 @@ pub type sctp_assoc_t = u32; pub type eventfd_t = u64; +pub type nlink_t = u64; +pub type dev_t = u64; +pub type ino_t = c_ulong; +pub type shmatt_t = c_uint; + c_enum! { #[repr(u32)] pub enum devstat_support_flags { @@ -388,10 +393,7 @@ s! { pub kve_end: u64, pub kve_offset: u64, pub kve_vn_fileid: u64, - #[cfg(not(freebsd11))] pub kve_vn_fsid_freebsd11: u32, - #[cfg(freebsd11)] - pub kve_vn_fsid: u32, pub kve_flags: c_int, pub kve_resident: c_int, pub kve_private_resident: c_int, @@ -400,20 +402,12 @@ s! { pub kve_shadow_count: c_int, pub kve_vn_type: c_int, pub kve_vn_size: u64, - #[cfg(not(freebsd11))] pub kve_vn_rdev_freebsd11: u32, - #[cfg(freebsd11)] - pub kve_vn_rdev: u32, pub kve_vn_mode: u16, pub kve_status: u16, - #[cfg(not(freebsd11))] pub kve_vn_fsid: u64, - #[cfg(not(freebsd11))] pub kve_vn_rdev: u64, - #[cfg(not(freebsd11))] _kve_is_spare: [c_int; 8], - #[cfg(freebsd11)] - _kve_is_spare: [c_int; 12], pub kve_path: [c_char; crate::PATH_MAX as usize], } @@ -1352,6 +1346,27 @@ s! { pub sp_max: off_t, pub sp_idle: crate::timeval, } + + pub struct kevent { + pub ident: crate::uintptr_t, + pub filter: c_short, + pub flags: c_ushort, + pub fflags: c_uint, + pub data: i64, + pub udata: *mut c_void, + pub ext: [u64; 4], + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_lpid: crate::pid_t, + pub shm_cpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + } } s_no_extra_traits! { @@ -1737,6 +1752,42 @@ s_no_extra_traits! { pub rcv: crate::xktls_session_onedir, pub snd: crate::xktls_session_onedir, } + + pub struct dirent { + pub d_fileno: crate::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: u32, + pub f_type: u32, + pub f_flags: u64, + pub f_bsize: u64, + pub f_iosize: u64, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: i64, + pub f_files: u64, + pub f_ffree: i64, + pub f_syncwrites: u64, + pub f_asyncwrites: u64, + pub f_syncreads: u64, + pub f_asyncreads: u64, + f_spare: [u64; 10], + pub f_namemax: u32, + pub f_owner: crate::uid_t, + pub f_fsid: crate::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! { @@ -2330,6 +2381,90 @@ cfg_if! { self.kf_path.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_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 hash::Hash for statfs { + fn hash(&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 hash::Hash for dirent { + fn hash(&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); + } + } } } @@ -3776,13 +3911,7 @@ pub const COMMLEN: usize = 19; pub const KI_EMULNAMELEN: usize = 16; /// number of groups in ki_groups pub const KI_NGROUPS: usize = 16; -cfg_if! { - if #[cfg(freebsd11)] { - pub const KI_NSPARE_INT: usize = 4; - } else { - pub const KI_NSPARE_INT: usize = 2; - } -} +pub const KI_NSPARE_INT: usize = 2; pub const KI_NSPARE_LONG: usize = 12; /// Flags for the process credential. pub const KI_CRF_CAPABILITY_MODE: usize = 0x00000001; @@ -3956,14 +4085,7 @@ pub const NZERO: c_int = 0; // Resource utilization information. pub const RUSAGE_THREAD: c_int = 1; - -cfg_if! { - if #[cfg(any(freebsd11, target_pointer_width = "32"))] { - pub const ARG_MAX: c_int = 256 * 1024; - } else { - pub const ARG_MAX: c_int = 2 * 256 * 1024; - } -} +pub const ARG_MAX: c_int = 2 * 256 * 1024; pub const CHILD_MAX: c_int = 40; /// max command name remembered pub const MAXCOMLEN: usize = 19; @@ -4128,6 +4250,7 @@ pub const P_CONTROLT: c_int = 0x00000002; pub const P_KPROC: c_int = 0x00000004; #[deprecated(since = "1.0", note = "Replaced in FreeBSD 15 by P_IDLEPROC")] pub const P_UNUSED3: c_int = 0x00000008; +#[cfg(freebsd15)] pub const P_IDLEPROC: c_int = 0x00000008; pub const P_PPWAIT: c_int = 0x00000010; pub const P_PROFIL: c_int = 0x00000020; @@ -4255,16 +4378,8 @@ pub const PS_FST_FFLAG_HASLOCK: c_int = 0x4000; pub const MAXFIDSZ: c_int = 16; /// Length of type name including null. pub const MFSNAMELEN: c_int = 16; -cfg_if! { - if #[cfg(any(freebsd10, freebsd11))] { - /// Size of on/from name bufs. - pub const MNAMELEN: c_int = 88; - } else { - /// Size of on/from name bufs. - pub const MNAMELEN: c_int = 1024; - } -} - +/// Size of on/from name bufs. +pub const MNAMELEN: c_int = 1024; /// Using journaled soft updates. pub const MNT_SUJ: u64 = 0x100000000; /// Mounted by automountd(8). @@ -4788,18 +4903,11 @@ safe_f! { } } -cfg_if! { - if #[cfg(not(any(freebsd10, freebsd11)))] { - extern "C" { - pub fn fhlink(fhp: *mut fhandle_t, to: *const c_char) -> c_int; - pub fn fhlinkat(fhp: *mut fhandle_t, tofd: c_int, to: *const c_char) -> c_int; - pub fn fhreadlink(fhp: *mut fhandle_t, buf: *mut c_char, bufsize: size_t) -> c_int; - pub fn getfhat(fd: c_int, path: *mut c_char, fhp: *mut fhandle, flag: c_int) -> c_int; - } - } -} - extern "C" { + pub fn fhlink(fhp: *mut fhandle_t, to: *const c_char) -> c_int; + pub fn fhlinkat(fhp: *mut fhandle_t, tofd: c_int, to: *const c_char) -> c_int; + pub fn fhreadlink(fhp: *mut fhandle_t, buf: *mut c_char, bufsize: size_t) -> c_int; + pub fn getfhat(fd: c_int, path: *mut c_char, fhp: *mut fhandle, flag: c_int) -> c_int; #[cfg_attr(doc, doc(alias = "__errno_location"))] #[cfg_attr(doc, doc(alias = "errno"))] pub fn __error() -> *mut c_int; @@ -5007,9 +5115,7 @@ extern "C" { pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> c_int; pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> c_int; - #[cfg_attr(all(target_os = "freebsd", freebsd11), link_name = "statfs@FBSD_1.0")] pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; - #[cfg_attr(all(target_os = "freebsd", freebsd11), link_name = "fstatfs@FBSD_1.0")] 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; @@ -5041,10 +5147,6 @@ extern "C" { pub fn getfh(path: *const c_char, fhp: *mut fhandle_t) -> c_int; pub fn lgetfh(path: *const c_char, fhp: *mut fhandle_t) -> c_int; pub fn getfsstat(buf: *mut crate::statfs, bufsize: c_long, mode: c_int) -> c_int; - #[cfg_attr( - all(target_os = "freebsd", freebsd11), - link_name = "getmntinfo@FBSD_1.0" - )] pub fn getmntinfo(mntbufp: *mut *mut crate::statfs, mode: c_int) -> c_int; pub fn mount( type_: *const c_char, @@ -5252,6 +5354,18 @@ extern "C" { idx1: c_ulong, idx2: c_ulong, ) -> c_int; + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn setgrent(); + pub fn freelocale(loc: crate::locale_t); + pub fn msgrcv( + msqid: c_int, + msgp: *mut c_void, + msgsz: size_t, + msgtyp: c_long, + msgflg: c_int, + ) -> ssize_t; + pub fn dirname(path: *mut c_char) -> *mut c_char; + pub fn basename(path: *mut c_char) -> *mut c_char; } #[link(name = "memstat")] @@ -5505,9 +5619,6 @@ cfg_if! { } else if #[cfg(freebsd12)] { mod freebsd12; pub use self::freebsd12::*; - } else if #[cfg(any(freebsd10, freebsd11))] { - mod freebsd11; - pub use self::freebsd11::*; } else { // Unknown freebsd version } diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index fa85f11ce2812..66c2c6770f056 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -136,8 +136,12 @@ s_no_extra_traits! { pub mc_gsbase: register_t, pub mc_xfpustate: register_t, pub mc_xfpustate_len: register_t, + #[cfg(freebsd15)] pub mc_tlsbase: register_t, + #[cfg(freebsd15)] pub mc_spare: [c_long; 3], + #[cfg(not(freebsd15))] + pub mc_spare: [c_long; 4], } } diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 8ef551d52ecbb..46e5e03f22ddf 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1572,26 +1572,10 @@ extern "C" { pub fn getutxid(ut: *const utmpx) -> *mut utmpx; pub fn getutxline(ut: *const utmpx) -> *mut utmpx; pub fn initgroups(name: *const c_char, basegid: crate::gid_t) -> c_int; - #[cfg_attr( - all(target_os = "freebsd", any(freebsd11, freebsd10)), - link_name = "kevent@FBSD_1.0" - )] - pub fn kevent( - kq: c_int, - changelist: *const crate::kevent, - nchanges: c_int, - eventlist: *mut crate::kevent, - nevents: c_int, - timeout: *const crate::timespec, - ) -> c_int; pub fn lchflags(path: *const c_char, flags: c_ulong) -> c_int; pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; - #[cfg_attr( - all(target_os = "freebsd", any(freebsd11, freebsd10)), - 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 malloc_usable_size(ptr: *const c_void) -> size_t; pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) -> c_int; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 63897640635c1..417c41ffc4b41 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -644,15 +644,7 @@ extern "C" { pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; pub fn abs(i: c_int) -> c_int; pub fn labs(i: c_long) -> c_long; - #[cfg_attr( - all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)), - link_name = "rand@FBSD_1.0" - )] pub fn rand() -> c_int; - #[cfg_attr( - all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)), - link_name = "srand@FBSD_1.0" - )] pub fn srand(seed: c_uint); pub fn getifaddrs(ifap: *mut *mut crate::ifaddrs) -> c_int; @@ -682,10 +674,6 @@ extern "C" { link_name = "glob$INODE64" )] #[cfg_attr(target_os = "netbsd", link_name = "__glob30")] - #[cfg_attr( - all(target_os = "freebsd", any(freebsd11, freebsd10)), - link_name = "glob@FBSD_1.0" - )] pub fn glob( pattern: *const c_char, flags: c_int, @@ -693,10 +681,6 @@ extern "C" { pglob: *mut crate::glob_t, ) -> c_int; #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")] - #[cfg_attr( - all(target_os = "freebsd", any(freebsd11, freebsd10)), - link_name = "globfree@FBSD_1.0" - )] pub fn globfree(pglob: *mut crate::glob_t); pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; @@ -864,10 +848,6 @@ extern "C" { all(target_os = "macos", target_arch = "x86"), link_name = "wait4$UNIX2003" )] - #[cfg_attr( - all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)), - link_name = "wait4@FBSD_1.0" - )] pub fn wait4( pid: crate::pid_t, status: *mut c_int, diff --git a/src/unix/mod.rs b/src/unix/mod.rs index c9a8964eb1099..dcb52aa187f66 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -867,10 +867,6 @@ extern "C" { link_name = "fstat$INODE64" )] #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")] - #[cfg_attr( - all(target_os = "freebsd", any(freebsd11, freebsd10)), - link_name = "fstat@FBSD_1.0" - )] #[cfg_attr(gnu_time_bits64, link_name = "__fstat64_time64")] #[cfg_attr( all(not(gnu_time_bits64), gnu_file_offset_bits64), @@ -885,10 +881,6 @@ extern "C" { link_name = "stat$INODE64" )] #[cfg_attr(target_os = "netbsd", link_name = "__stat50")] - #[cfg_attr( - all(target_os = "freebsd", any(freebsd11, freebsd10)), - link_name = "stat@FBSD_1.0" - )] #[cfg_attr(gnu_time_bits64, link_name = "__stat64_time64")] #[cfg_attr( all(not(gnu_time_bits64), gnu_file_offset_bits64), @@ -943,10 +935,6 @@ extern "C" { link_name = "readdir$INODE64" )] #[cfg_attr(target_os = "netbsd", link_name = "__readdir30")] - #[cfg_attr( - all(target_os = "freebsd", any(freebsd11, freebsd10)), - link_name = "readdir@FBSD_1.0" - )] #[cfg_attr(gnu_file_offset_bits64, link_name = "readdir64")] pub fn readdir(dirp: *mut crate::DIR) -> *mut crate::dirent; #[cfg_attr( @@ -977,10 +965,6 @@ extern "C" { all(target_os = "macos", not(target_arch = "aarch64")), link_name = "fstatat$INODE64" )] - #[cfg_attr( - all(target_os = "freebsd", any(freebsd11, freebsd10)), - link_name = "fstatat@FBSD_1.1" - )] #[cfg_attr(gnu_time_bits64, link_name = "__fstatat64_time64")] #[cfg_attr( all(not(gnu_time_bits64), gnu_file_offset_bits64), @@ -1176,10 +1160,6 @@ extern "C" { link_name = "lstat$INODE64" )] #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")] - #[cfg_attr( - all(target_os = "freebsd", any(freebsd11, freebsd10)), - link_name = "lstat@FBSD_1.0" - )] #[cfg_attr(gnu_time_bits64, link_name = "__lstat64_time64")] #[cfg_attr( all(not(gnu_time_bits64), gnu_file_offset_bits64), @@ -1456,10 +1436,6 @@ extern "C" { pub fn timegm(tm: *mut crate::tm) -> time_t; #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")] - #[cfg_attr( - all(target_os = "freebsd", any(freebsd11, freebsd10)), - link_name = "mknod@FBSD_1.0" - )] pub fn mknod(pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int; pub fn gethostname(name: *mut c_char, len: size_t) -> c_int; pub fn endservent(); @@ -1722,10 +1698,6 @@ cfg_if! { link_name = "readdir_r$INODE64" )] #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")] - #[cfg_attr( - all(target_os = "freebsd", any(freebsd11, freebsd10)), - link_name = "readdir_r@FBSD_1.0" - )] #[allow(non_autolinks)] // FIXME(docs): `<>` breaks line length limit. /// The 64-bit libc on Solaris and illumos only has readdir_r. If a /// 32-bit Solaris or illumos target is ever created, it should use