diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4014d75b07805..81fde8d6eafc2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -261,6 +261,7 @@ jobs: matrix: include: - target: x86_64-pc-solaris + - target: x86_64-unknown-netbsd timeout-minutes: 25 steps: - uses: actions/checkout@v5 @@ -281,6 +282,37 @@ jobs: export PATH=$HOME/.rust_solaris/bin:$PATH ./ci/run.sh ${{ matrix.target }} + - name: Test on NetBSD + uses: vmactions/netbsd-vm@v1 + if: contains(matrix.target, 'netbsd') + with: + release: "10.1" + usesh: true + mem: 4096 + copyback: false + prepare: | + set -x + /usr/sbin/pkg_add curl + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \ + --profile minimal --default-toolchain nightly -y + run: | + set -x + . "$HOME/.cargo/env" + which rustc + rustc -Vv + ./ci/run.sh ${{ matrix.target }} + + docs: + name: Ensure docs build + runs-on: ubuntu-24.04 + timeout-minutes: 10 + steps: + - uses: actions/checkout@master + - name: Install Rust + run: rustup update nightly --no-self-update && rustup default nightly + - uses: Swatinem/rust-cache@v2 + - run: cargo doc --workspace --no-deps + # One job that "summarizes" the success state of this pipeline. This can then be added to branch # protection, rather than having to add each job separately. success: @@ -292,8 +324,9 @@ jobs: - test_tier2 - test_tier2_vm - verify_build + - docs - clippy - # GitHub branch protection is exceedingly silly and treats "jobs skipped because a dependency + # Github branch protection is exceedingly silly and treats "jobs skipped because a dependency # failed" as success. So we have to do some contortions to ensure the job fails if any of its # dependencies fails. if: always() # make sure this is never "skipped" diff --git a/ci/create-artifacts.py b/ci/create-artifacts.py index 2854daa563154..bd5656fd040b2 100755 --- a/ci/create-artifacts.py +++ b/ci/create-artifacts.py @@ -30,7 +30,11 @@ def main(): archive_name = f"archive-{now}" archive_path = f"{archive_name}.tar.gz" - sp.run(["tar", "czvf", archive_path, "-C", build_dir, "-T-"], input=file_list) + sp.run( + ["tar", "czvf", archive_path, "-C", build_dir, "-T-"], + input=file_list, + check=True, + ) # If we are in GHA, set these env vars for future use gh_env = os.getenv("GITHUB_ENV") @@ -42,6 +46,7 @@ def main(): if __name__ == "__main__": + print("Starting script...") # For debugging CI failures # FIXME(ci): remove after the bump to windoes-2025 GHA images # Python <= 3.9 does not support the very helpful `root_dir` argument, # and that is the version used by the Windows GHA images. Rather than @@ -55,10 +60,12 @@ def main(): sys.exit(1) # Find the next 3.1x Python version - dirs = sorted(list(Path(r"C:\hostedtoolcache\windows\Python").iterdir())) + dirs = sorted(Path(r"C:\hostedtoolcache\windows\Python").iterdir()) usepy = next(x for x in dirs if r"\3.1" in str(x)) py = usepy.joinpath(r"x64\python.exe") print(f"relaunching with {py}") os.execvp(py, [__file__] + sys.argv) main() +else: + print("not invoked as main, exiting") # For debugging CI failures diff --git a/libc-test/build.rs b/libc-test/build.rs index c31fa7e3fb5df..5725a9c8607ff 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1254,6 +1254,12 @@ fn test_netbsd(target: &str) { assert!(target.contains("netbsd")); let mut cfg = ctest_cfg(); + // Assume netbsd10 but check for netbsd9 for test config. + let netbsd9 = match try_command_output("uname", &["-sr"]) { + Some(s) if s.starts_with("NetBSD 9.") => true, + _ => false, + }; + cfg.flag("-Wno-deprecated-declarations"); cfg.define("_NETBSD_SOURCE", Some("1")); @@ -1280,10 +1286,12 @@ fn test_netbsd(target: &str) { "ctype.h", "dirent.h", "dlfcn.h", + "execinfo.h", "glob.h", "grp.h", "ifaddrs.h", "langinfo.h", + "lwp.h", "net/bpf.h", "net/if.h", "net/if_arp.h", @@ -1302,12 +1310,14 @@ fn test_netbsd(target: &str) { "sched.h", "semaphore.h", "signal.h", + "spawn.h", "string.h", "sys/endian.h", "sys/exec_elf.h", "sys/xattr.h", "sys/extattr.h", "sys/file.h", + (!netbsd9, "sys/futex.h"), "sys/ioctl.h", "sys/ioctl_compat.h", "sys/ipc.h", @@ -1315,12 +1325,15 @@ fn test_netbsd(target: &str) { "sys/mman.h", "sys/mount.h", "sys/ptrace.h", + (!netbsd9, "sys/random.h"), "sys/resource.h", + "sys/sched.h", "sys/shm.h", "sys/socket.h", "sys/statvfs.h", "sys/sysctl.h", "sys/time.h", + (!netbsd9, "sys/timerfd.h"), "sys/times.h", "sys/timex.h", "sys/ucontext.h", @@ -1343,6 +1356,8 @@ fn test_netbsd(target: &str) { "sys/reboot.h", "sys/shm.h", "iconv.h", + "utmp.h", + "utmpx.h", ); cfg.rename_type(move |ty| { @@ -1375,10 +1390,14 @@ fn test_netbsd(target: &str) { } }); + cfg.alias_is_c_enum(|ty| ty == "fae_action"); + cfg.skip_alias(move |ty| { match ty.ident() { // FIXME(netbsd): sighandler_t is crazy across platforms "sighandler_t" => true, + // Incomplete type in C + "cpuset_t" => true, _ => false, } }); @@ -1390,6 +1409,14 @@ fn test_netbsd(target: &str) { // These are tested as part of the linux_fcntl tests since there are // header conflicts when including them with all the other structs. "termios2" => true, + // Anon struct + "__exit_status" => true, + // FIXME(netbsd): Should be importable but aren't for some reason. + "Aux32Info" | "Aux64Info" => true, + // deprecated, obsolete upstream + "ptrace_lwpinfo" => true, + // ABI change in NetBSD10, with symbol versioning. + "statvfs" if !netbsd9 => true, _ => false, } }); @@ -1409,12 +1436,19 @@ fn test_netbsd(target: &str) { "SIG_DFL" | "SIG_ERR" | "SIG_IGN" => true, // sighandler_t weirdness "SIGUNUSED" => true, // removed in glibc 2.26 + // deprecated, obsolete upstream + "PT_LWPINFO" | "PL_EVENT_NONE" | "PL_EVENT_SIGNAL" | "PL_EVENT_SUSPENDED" => true, + // weird signed extension or something like that? "MS_NOUSER" => true, "MS_RMT_MASK" => true, // updated in glibc 2.22 and musl 1.1.13 "BOTHER" => true, "GRND_RANDOM" | "GRND_INSECURE" | "GRND_NONBLOCK" => true, // netbsd 10 minimum + // Due to the NetBSD `__BIT` macro this turns out to be an `unsigned long`, but + // the futex syscall takes `int` ops. + "FUTEX_CMD_MASK" => true, + _ => false, } }); @@ -1422,15 +1456,20 @@ fn test_netbsd(target: &str) { cfg.skip_fn(move |func| { #[expect(clippy::wildcard_in_or_patterns)] match func.ident() { - // FIXME(netbsd): netbsd 10 minimum // FIXME(netbsd): https://github.com/rust-lang/libc/issues/1272 "execv" | "execve" | "execvp" => true, - "getentropy" | "getrandom" => true, + // FIXME(netbsd): Look into setting `_POSIX_C_SOURCE` to enable this + "qsort_r" => true, - "getrlimit" | "getrlimit64" | // non-int in 1st arg - "setrlimit" | "setrlimit64" | // non-int in 1st arg - "prlimit" | "prlimit64" | // non-int in 2nd arg + _ => false, + } + }); + cfg.skip_fn_ptrcheck(move |func| { + match func { + // New symbol version present in NetBSD10, but we keep the old versions for NetBSD9 + // compatibility. + "getmntinfo" | "statvfs" | "fstatvfs" | "getvfsstat" | "sigaction" => true, _ => false, } }); @@ -1453,10 +1492,65 @@ fn test_netbsd(target: &str) { ("Elf64_Phdr", "p_type") => true, // pthread_spin_t is a volatile uchar ("pthread_spinlock_t", "pts_spin") => true, + + // `tcp_snd_wscale` and `tcp_rcv_wscale` are bitfields + ("tcp_info", "tcp_snd_wscale") => true, + ("tcp_info", "tcp_rcv_wscale") => true, + + // Anonymous unions + ("ifconf", "ifc_ifcu") => true, + ("ifreq", "ifr_ifru") => true, + ("utmpx", "ut_exit") => true, + ("posix_spawn_file_actions_entry_t", "fae_data") => true, + _ => false, } }); + // Unless otherwise noted, everything in this block was an addition in NetBS 10. + if netbsd9 { + cfg.skip_const(move |constant| match constant.ident() { + "EOWNERDEAD" + | "ENOTRECOVERABLE" + | "F_GETPATH" + | "MNT_NFS4ACLS" + | "MNT_POSIX1EACLS" + | "MNT_ACLS" + | "EVFILT_USER" + | "EVFILT_EMPTY" + | "REG_ILLSEQ" + | "PT_SET_SIGPASS" + | "PT_GET_SIGPASS" + | "EXTATTR_NAMESPACE_EMPTY" => true, + x if x.starts_with("FUTEX") => true, + x if x.starts_with("NOTE_") => true, + x if x.starts_with("PT_LWP") => true, + x if x.starts_with("TFD_") => true, + "ELAST" => true, // not version-stable + _ => false, + }); + + cfg.skip_struct(move |struct_| match struct_.ident() { + "sockaddr_dl" => true, // Last field increased size in 10 + x if x.starts_with("ptrace_lwp") => true, + // These were packed before NetBSD 10 + "arphdr" | "in_addr" | "ip_mreq" | "sockaddr_in" => true, + _ => false, + }); + + cfg.skip_fn(move |func| match func.ident() { + "reallocarray" | "getentropy" | "ppoll" | "getrandom" => true, + x if x.starts_with("timerfd_") => true, + _ => false, + }); + + cfg.skip_struct_field(|struct_, field| match (struct_.ident(), field.ident()) { + ("statvfs", "f_mntfromlabel") => true, // added field + ("kevent", "udata") => true, // changed type (ABI-compatible) + _ => false, + }); + } + ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } @@ -2286,7 +2380,21 @@ fn test_freebsd(target: &str) { assert!(target.contains("freebsd")); let mut cfg = ctest_cfg(); - let freebsd_ver = which_freebsd(); + let freebsd_ver = if let Ok(version) = env::var("RUST_LIBC_UNSTABLE_FREEBSD_VERSION") { + let vers = version.parse().unwrap(); + println!("cargo:warning=setting FreeBSD version to {vers}"); + Some(vers) + } else { + match &try_command_output("freebsd-version", &[]) { + Some(s) if s.starts_with("10") => Some(10), + Some(s) if s.starts_with("11") => Some(11), + Some(s) if s.starts_with("12") => Some(12), + Some(s) if s.starts_with("13") => Some(13), + Some(s) if s.starts_with("14") => Some(14), + Some(s) if s.starts_with("15") => Some(15), + Some(_) | None => None, + } + }; match freebsd_ver { Some(12) => cfg.cfg("freebsd12", None), @@ -4905,34 +5013,6 @@ fn test_linux_like_apis(target: &str) { } } -fn which_freebsd() -> Option { - if let Ok(version) = env::var("RUST_LIBC_UNSTABLE_FREEBSD_VERSION") { - let vers = version.parse().unwrap(); - println!("cargo:warning=setting FreeBSD version to {vers}"); - return Some(vers); - } - - let output = std::process::Command::new("freebsd-version") - .output() - .ok()?; - - if !output.status.success() { - return None; - } - - let stdout = String::from_utf8(output.stdout).ok()?; - - match &stdout { - s if s.starts_with("10") => Some(10), - s if s.starts_with("11") => Some(11), - s if s.starts_with("12") => Some(12), - s if s.starts_with("13") => Some(13), - s if s.starts_with("14") => Some(14), - s if s.starts_with("15") => Some(15), - _ => None, - } -} - fn test_haiku(target: &str) { assert!(target.contains("haiku")); @@ -5573,3 +5653,17 @@ fn test_aix(target: &str) { ctest::generate_test(&mut cfg, "../src/lib.rs", "ctest_output.rs").unwrap(); } + +/// Attempt to execute a command and collect its output, If the command fails for whatever +/// reason, return `None`. +fn try_command_output(cmd: &str, args: &[&str]) -> Option { + let output = std::process::Command::new(cmd).args(args).output().ok()?; + + if !output.status.success() { + return None; + } + + let res = String::from_utf8(output.stdout) + .unwrap_or_else(|e| panic!("command {cmd} returned non-UTF-8 output: {e}")); + Some(res) +} diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index bcd25eca15b93..982f610a4f3aa 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -93,7 +93,6 @@ AT_SUN_IFLUSH AT_SUN_LDELF AT_SUN_LDNAME AT_SUN_LDSHDR -AT_SUN_LPGSIZE AT_SUN_PLATFORM AT_SYMLINK_FOLLOW AT_SYMLINK_NOFOLLOW @@ -104,23 +103,6 @@ B460800 B7200 B76800 B921600 -BIOCFLUSH -BIOCGBLEN -BIOCGDLT -BIOCGETIF -BIOCGHDRCMPLT -BIOCGRSIG -BIOCGSEESENT -BIOCGSTATS -BIOCIMMEDIATE -BIOCPROMISC -BIOCSBLEN -BIOCSDLT -BIOCSETIF -BIOCSHDRCMPLT -BIOCSRSIG -BIOCSSEESENT -BIOCVERSION BOOT_TIME BUFSIZ BUS_ADRALN @@ -180,7 +162,6 @@ CTL_HW CTL_IPPROTO_IPSEC CTL_KERN CTL_MACHDEP -CTL_MAXID CTL_MAXNAME CTL_MMAP CTL_NET @@ -417,7 +398,6 @@ IFF_LINK2 IFF_LOOPBACK IFF_MULTICAST IFF_NOARP -IFF_NOTRAILERS IFF_OACTIVE IFF_POINTOPOINT IFF_PROMISC @@ -534,7 +514,6 @@ KERN_LOGSIGEXIT KERN_LWP KERN_MAPPED_FILES KERN_MAXFILES -KERN_MAXID KERN_MAXPARTITIONS KERN_MAXPHYS KERN_MAXPROC @@ -728,13 +707,11 @@ NANOSECOND NET_RT_DUMP NET_RT_FLAGS NET_RT_IFLIST -NET_RT_MAXID NET_RT_OIFLIST NET_RT_OOIFLIST NET_RT_OOOIFLIST NEW_TIME NI_DGRAM -NI_MAXHOST NI_MAXSERV NI_NAMEREQD NI_NOFQDN @@ -845,7 +822,6 @@ POSIX_SPAWN_RETURNERROR POSIX_SPAWN_SETPGROUP POSIX_SPAWN_SETSCHEDPARAM POSIX_SPAWN_SETSCHEDULER -POSIX_SPAWN_SETSIGDEP POSIX_SPAWN_SETSIGMASK PROT_MPROTECT PTHREAD_CREATE_DETACHED @@ -908,7 +884,6 @@ REG_ECOLLATE REG_ECTYPE REG_EESCAPE REG_EMPTY -REG_ENOSYS REG_EPAREN REG_ERANGE REG_ESPACE @@ -997,7 +972,6 @@ SIGINFO SIGIO SIGNATURE SIGSTKSZ -SIOCGIFADDR SOCKCREDSIZE SOCK_CLOEXEC SOCK_CONN_DGRAM @@ -1342,7 +1316,6 @@ futimes getbootfile getbyteorder getdiskrawname -getdistcookedname getdomainname getdtablesize getentropy @@ -1422,7 +1395,6 @@ lcong48 lgetxattr lio_listio listxattr -llistxaatr localeconv_l lockf login @@ -1651,11 +1623,10 @@ updwtmpx useconds_t utimensat utmp +utmpname utmpx utmpxname -utpname utrace uucred -vm_size_t wait4 waitid diff --git a/src/macros.rs b/src/macros.rs index eec90c7e44cc1..c6001e7bc37c9 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -87,6 +87,7 @@ macro_rules! prelude { pub(crate) use core::prelude::v1::derive; #[allow(unused_imports)] pub(crate) use core::{ + cfg, fmt, hash, iter, diff --git a/src/new/mod.rs b/src/new/mod.rs index 1846ada479fba..38a0759afb65d 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -182,6 +182,17 @@ cfg_if! { pub use net::route::*; } else if #[cfg(target_vendor = "apple")] { pub use signal::*; + } else if #[cfg(target_os = "netbsd")] { + pub use net::if_::*; + pub use sys::ipc::*; + pub use sys::statvfs::*; + pub use sys::time::*; + pub use sys::timex::*; + pub use sys::types::*; + pub use utmp_::*; + pub use utmpx_::*; + } else if #[cfg(target_os = "openbsd")] { + pub use sys::ipc::*; } } diff --git a/src/new/netbsd/mod.rs b/src/new/netbsd/mod.rs index b43e7aeb088d2..5db71760c4de9 100644 --- a/src/new/netbsd/mod.rs +++ b/src/new/netbsd/mod.rs @@ -1,5 +1,14 @@ //! NetBSD libc. //! +//! * Headers: +//! * Sys headers: //! * Manual pages: +pub(crate) mod net { + pub(crate) mod if_; +} + +pub(crate) mod sys; pub(crate) mod unistd; +pub(crate) mod utmp_; +pub(crate) mod utmpx_; diff --git a/src/new/netbsd/net/if_.rs b/src/new/netbsd/net/if_.rs new file mode 100644 index 0000000000000..7cceadfc2b3d6 --- /dev/null +++ b/src/new/netbsd/net/if_.rs @@ -0,0 +1,96 @@ +//! Header: `net/if.h` +//! +//! + +use crate::prelude::*; +use crate::IFNAMSIZ; + +s! { + pub struct if_data { + pub ifi_type: c_uchar, + pub ifi_addrlen: c_uchar, + pub ifi_hdrlen: c_uchar, + pub ifi_link_state: c_int, + pub ifi_mtu: u64, + pub ifi_metric: u64, + pub ifi_baudrate: u64, + pub ifi_ipackets: u64, + pub ifi_ierrors: u64, + pub ifi_opackets: u64, + pub ifi_oerrors: u64, + pub ifi_collisions: u64, + pub ifi_ibytes: u64, + pub ifi_obytes: u64, + pub ifi_imcasts: u64, + pub ifi_omcasts: u64, + pub ifi_iqdrops: u64, + pub ifi_noproto: u64, + pub ifi_lastchange: crate::timespec, + } +} + +pub const IFF_UP: c_int = 0x0001; // interface is up +pub const IFF_BROADCAST: c_int = 0x0002; // broadcast address valid +pub const IFF_DEBUG: c_int = 0x0004; // turn on debugging +pub const IFF_LOOPBACK: c_int = 0x0008; // is a loopback net +pub const IFF_POINTOPOINT: c_int = 0x0010; // interface is point-to-point link +pub const IFF_RUNNING: c_int = 0x0040; // resources allocated +pub const IFF_NOARP: c_int = 0x0080; // no address resolution protocol +pub const IFF_PROMISC: c_int = 0x0100; // receive all packets +pub const IFF_ALLMULTI: c_int = 0x0200; // receive all multicast packets +pub const IFF_OACTIVE: c_int = 0x0400; // transmission in progress +pub const IFF_SIMPLEX: c_int = 0x0800; // can't hear own transmissions +pub const IFF_LINK0: c_int = 0x1000; // per link layer defined bit +pub const IFF_LINK1: c_int = 0x2000; // per link layer defined bit +pub const IFF_LINK2: c_int = 0x4000; // per link layer defined bit +pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast + +s! { + pub struct if_msghdr { + pub ifm_msglen: c_ushort, + pub ifm_version: c_uchar, + pub ifm_type: c_uchar, + pub ifm_addrs: c_int, + pub ifm_flags: c_int, + pub ifm_index: c_ushort, + pub ifm_data: if_data, + } +} + +s_no_extra_traits! { + pub struct ifreq { + pub ifr_name: [c_char; IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru, + } + + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: crate::sockaddr, + pub ifru_dstaddr: crate::sockaddr, + pub ifru_broadaddr: crate::sockaddr, + pub space: crate::sockaddr_storage, + pub ifru_flags: c_short, + pub ifru_addrflags: c_int, + pub ifru_metrics: c_int, + pub ifru_mtu: c_int, + pub ifru_dlt: c_int, + pub ifru_value: c_uint, + pub ifru_data: *mut c_void, + // buf and buflen are deprecated but they contribute to union size + ifru_b: __c_anonymous_ifr_ifru_ifru_b, + } + + struct __c_anonymous_ifr_ifru_ifru_b { + b_buflen: u32, + b_buf: *mut c_void, + } + + pub struct ifconf { + pub ifc_len: c_int, + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + } + + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: *mut c_void, + pub ifcu_req: *mut ifreq, + } +} diff --git a/src/new/netbsd/sys/ipc.rs b/src/new/netbsd/sys/ipc.rs new file mode 100644 index 0000000000000..49a1c84d74296 --- /dev/null +++ b/src/new/netbsd/sys/ipc.rs @@ -0,0 +1,17 @@ +//! Header: `sys/ipc.h` +//! +//! + +use crate::prelude::*; + +s! { + pub struct ipc_perm { + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub _seq: c_ushort, + pub _key: crate::key_t, + } +} diff --git a/src/new/netbsd/sys/mod.rs b/src/new/netbsd/sys/mod.rs new file mode 100644 index 0000000000000..185c1f1c2cba1 --- /dev/null +++ b/src/new/netbsd/sys/mod.rs @@ -0,0 +1,9 @@ +//! Directory: `sys/` +//! +//! https://github.com/NetBSD/src/tree/trunk/sys/sys + +pub(crate) mod ipc; +pub(crate) mod statvfs; +pub(crate) mod time; +pub(crate) mod timex; +pub(crate) mod types; diff --git a/src/new/netbsd/sys/statvfs.rs b/src/new/netbsd/sys/statvfs.rs new file mode 100644 index 0000000000000..eee3766300ce6 --- /dev/null +++ b/src/new/netbsd/sys/statvfs.rs @@ -0,0 +1,47 @@ +//! Header: `sys/statvfs.h` +//! +//! + +use crate::prelude::*; + +const _VFS_NAMELEN: usize = 32; +const _VFS_MNAMELEN: usize = 1024; + +s! { + pub struct statvfs { + pub f_flag: c_ulong, + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_iosize: c_ulong, + + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_bresvd: crate::fsblkcnt_t, + + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fresvd: crate::fsfilcnt_t, + + pub f_syncreads: u64, + pub f_syncwrites: u64, + + pub f_asyncreads: u64, + pub f_asyncwrites: u64, + + pub f_fsidx: crate::fsid_t, + pub f_fsid: c_ulong, + pub f_namemax: c_ulong, + pub f_owner: crate::uid_t, + + // This type is updated in a future version + f_spare: [u32; 4], + + pub f_fstypename: [c_char; _VFS_NAMELEN], + pub f_mntonname: [c_char; _VFS_MNAMELEN], + pub f_mntfromname: [c_char; _VFS_MNAMELEN], + // Added in NetBSD10 + // pub f_mntfromlabel: [c_char; _VFS_MNAMELEN], + } +} diff --git a/src/new/netbsd/sys/time.rs b/src/new/netbsd/sys/time.rs new file mode 100644 index 0000000000000..5f2d39d347e69 --- /dev/null +++ b/src/new/netbsd/sys/time.rs @@ -0,0 +1,13 @@ +//! Header: `sys/time.h` +//! +//! + +s! { + pub struct itimerspec { + pub it_interval: crate::timespec, + pub it_value: crate::timespec, + } +} + +pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 0x20000000; +pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 0x40000000; diff --git a/src/new/netbsd/sys/timex.rs b/src/new/netbsd/sys/timex.rs new file mode 100644 index 0000000000000..82844bf0e732d --- /dev/null +++ b/src/new/netbsd/sys/timex.rs @@ -0,0 +1,95 @@ +//! Header: `sys/timex.h` +//! +//! + +use crate::prelude::*; + +pub const MAXPHASE: c_long = 500000000; +pub const MAXFREQ: c_long = 500000; +pub const MINSEC: c_int = 256; +pub const MAXSEC: c_int = 2048; +pub const NANOSECOND: c_long = 1000000000; +pub const SCALE_PPM: c_int = 65; +pub const MAXTC: c_int = 10; + +pub const MOD_OFFSET: c_uint = 0x0001; +pub const MOD_FREQUENCY: c_uint = 0x0002; +pub const MOD_MAXERROR: c_uint = 0x0004; +pub const MOD_ESTERROR: c_uint = 0x0008; +pub const MOD_STATUS: c_uint = 0x0010; +pub const MOD_TIMECONST: c_uint = 0x0020; +pub const MOD_PPSMAX: c_uint = 0x0040; +pub const MOD_TAI: c_uint = 0x0080; +pub const MOD_MICRO: c_uint = 0x1000; +pub const MOD_NANO: c_uint = 0x2000; +pub const MOD_CLKB: c_uint = 0x4000; +pub const MOD_CLKA: c_uint = 0x8000; + +pub const STA_PLL: c_int = 0x0001; +pub const STA_PPSFREQ: c_int = 0x0002; +pub const STA_PPSTIME: c_int = 0x0004; +pub const STA_FLL: c_int = 0x0008; +pub const STA_INS: c_int = 0x0010; +pub const STA_DEL: c_int = 0x0020; +pub const STA_UNSYNC: c_int = 0x0040; +pub const STA_FREQHOLD: c_int = 0x0080; +pub const STA_PPSSIGNAL: c_int = 0x0100; +pub const STA_PPSJITTER: c_int = 0x0200; +pub const STA_PPSWANDER: c_int = 0x0400; +pub const STA_PPSERROR: c_int = 0x0800; +pub const STA_CLOCKERR: c_int = 0x1000; +pub const STA_NANO: c_int = 0x2000; +pub const STA_MODE: c_int = 0x4000; +pub const STA_CLK: c_int = 0x8000; + +pub const STA_RONLY: c_int = STA_PPSSIGNAL + | STA_PPSJITTER + | STA_PPSWANDER + | STA_PPSERROR + | STA_CLOCKERR + | STA_NANO + | STA_MODE + | STA_CLK; + +pub const TIME_OK: c_int = 0; +pub const TIME_INS: c_int = 1; +pub const TIME_DEL: c_int = 2; +pub const TIME_OOP: c_int = 3; +pub const TIME_WAIT: c_int = 4; +pub const TIME_ERROR: c_int = 5; + +s! { + pub struct ntptimeval { + pub time: crate::timespec, + pub maxerror: c_long, + pub esterror: c_long, + pub tai: c_long, + pub time_state: c_int, + } + + pub struct timex { + pub modes: c_uint, + pub offset: c_long, + pub freq: c_long, + pub maxerror: c_long, + pub esterror: c_long, + pub status: c_int, + pub constant: c_long, + pub precision: c_long, + pub tolerance: c_long, + pub ppsfreq: c_long, + pub jitter: c_long, + pub shift: c_int, + pub stabil: c_long, + pub jitcnt: c_long, + pub calcnt: c_long, + pub errcnt: c_long, + pub stbcnt: c_long, + } +} + +extern "C" { + #[link_name = "__ntp_gettime50"] + pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int; + pub fn ntp_adjtime(buf: *mut timex) -> c_int; +} diff --git a/src/new/netbsd/sys/types.rs b/src/new/netbsd/sys/types.rs new file mode 100644 index 0000000000000..8dfc049426170 --- /dev/null +++ b/src/new/netbsd/sys/types.rs @@ -0,0 +1,16 @@ +//! Header: `sys/types.h` +//! +//! + +use crate::prelude::*; + +pub type dev_t = u64; + +pub type lwpid_t = i32; + +pub type mqd_t = c_int; +pub type cpuid_t = c_ulong; + +pub type clock_t = c_uint; +pub type timer_t = c_int; +pub type suseconds_t = c_int; diff --git a/src/new/netbsd/utmp_.rs b/src/new/netbsd/utmp_.rs new file mode 100644 index 0000000000000..2047449053ce8 --- /dev/null +++ b/src/new/netbsd/utmp_.rs @@ -0,0 +1,33 @@ +//! Header: `utmp.h` +//! +//! + +use crate::prelude::*; + +pub const UT_NAMESIZE: usize = 8; +pub const UT_LINESIZE: usize = 8; +pub const UT_HOSTSIZE: usize = 16; + +s! { + pub struct lastlog { + pub ll_time: crate::time_t, + pub ll_line: [c_char; UT_LINESIZE], + pub ll_host: [c_char; UT_HOSTSIZE], + } + + pub struct utmp { + pub ut_line: [c_char; UT_LINESIZE], + pub ut_name: [c_char; UT_NAMESIZE], + pub ut_host: [c_char; UT_HOSTSIZE], + pub ut_time: crate::time_t, + } +} + +#[link(name = "util")] +extern "C" { + pub fn utmpname(file: *const c_char) -> c_int; + pub fn setutent(); + #[link_name = "__getutent50"] + pub fn getutent() -> *mut utmp; + pub fn endutent(); +} diff --git a/src/new/netbsd/utmpx_.rs b/src/new/netbsd/utmpx_.rs new file mode 100644 index 0000000000000..813c8fb69712e --- /dev/null +++ b/src/new/netbsd/utmpx_.rs @@ -0,0 +1,92 @@ +//! Header: `utmpx.h` +//! +//! + +use crate::prelude::*; + +// pub const _PATH_UTMPX: &[c_char; 14] = b"/var/run/utmpx"; +// pub const _PATH_WTMPX: &[c_char; 14] = b"/var/log/wtmpx"; +// pub const _PATH_LASTLOGX: &[c_char; 17] = b"/var/log/lastlogx"; +// pub const _PATH_UTMP_UPDATE: &[c_char; 24] = b"/usr/libexec/utmp_update"; + +pub const _UTX_USERSIZE: usize = 32; +pub const _UTX_LINESIZE: usize = 32; +pub const _UTX_IDSIZE: usize = 4; +pub const _UTX_HOSTSIZE: usize = 256; + +pub const EMPTY: u16 = 0; +pub const RUN_LVL: u16 = 1; +pub const BOOT_TIME: u16 = 2; +pub const OLD_TIME: u16 = 3; +pub const NEW_TIME: u16 = 4; +pub const INIT_PROCESS: u16 = 5; +pub const LOGIN_PROCESS: u16 = 6; +pub const USER_PROCESS: u16 = 7; +pub const DEAD_PROCESS: u16 = 8; +pub const ACCOUNTING: u16 = 9; +pub const SIGNATURE: u16 = 10; +pub const DOWN_TIME: u16 = 11; + +// Expression based on the comment in NetBSD source. +pub const _UTX_PADSIZE: usize = if cfg!(target_pointer_width = "64") { + 36 +} else { + 40 +}; + +s! { + pub struct utmpx { + pub ut_name: [c_char; _UTX_USERSIZE], + pub ut_id: [c_char; _UTX_IDSIZE], + pub ut_line: [c_char; _UTX_LINESIZE], + pub ut_host: [c_char; _UTX_HOSTSIZE], + pub ut_session: u16, + pub ut_type: u16, + pub ut_pid: crate::pid_t, + pub ut_exit: __exit_status, // FIXME(netbsd): when anonymous struct are supported + pub ut_ss: crate::sockaddr_storage, + pub ut_tv: crate::timeval, + ut_pad: [u8; _UTX_PADSIZE], + } + + pub struct __exit_status { + pub e_termination: u16, + pub e_exit: u16, + } + + pub struct lastlogx { + pub ll_tv: crate::timeval, + pub ll_line: [c_char; _UTX_LINESIZE], + pub ll_host: [c_char; _UTX_HOSTSIZE], + pub ll_ss: crate::sockaddr_storage, + } +} + +#[link(name = "util")] +extern "C" { + pub fn setutxent(); + pub fn endutxent(); + + #[link_name = "__getutxent50"] + pub fn getutxent() -> *mut utmpx; + #[link_name = "__getutxid50"] + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + #[link_name = "__getutxline50"] + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + #[link_name = "__pututxline50"] + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + + #[link_name = "__updwtmpx50"] + pub fn updwtmpx(file: *const c_char, ut: *const utmpx) -> c_int; + #[link_name = "__getlastlogx50"] + pub fn getlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) + -> *mut lastlogx; + + #[link_name = "__updlastlogx50"] + pub fn updlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) -> c_int; + #[link_name = "__getutmp50"] + pub fn getutmp(ux: *const utmpx, u: *mut crate::utmp); + #[link_name = "__getutmpx50"] + pub fn getutmpx(u: *const crate::utmp, ux: *mut utmpx); + pub fn utmpxname(file: *const c_char) -> c_int; +} diff --git a/src/new/newlib/unistd.rs b/src/new/newlib/unistd.rs index 8d55ee5823315..6b240be9b7698 100644 --- a/src/new/newlib/unistd.rs +++ b/src/new/newlib/unistd.rs @@ -5,3 +5,155 @@ pub use crate::new::common::posix::unistd::{ STDIN_FILENO, STDOUT_FILENO, }; +use crate::prelude::*; + +pub const _SC_ARG_MAX: c_int = 0; +pub const _SC_CHILD_MAX: c_int = 1; +pub const _SC_CLK_TCK: c_int = 2; +pub const _SC_NGROUPS_MAX: c_int = 3; +pub const _SC_OPEN_MAX: c_int = 4; +pub const _SC_JOB_CONTROL: c_int = 5; +pub const _SC_SAVED_IDS: c_int = 6; +pub const _SC_VERSION: c_int = 7; +pub const _SC_PAGESIZE: c_int = 8; +pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; +pub const _SC_NPROCESSORS_CONF: c_int = 9; +pub const _SC_NPROCESSORS_ONLN: c_int = 10; +pub const _SC_PHYS_PAGES: c_int = 11; +pub const _SC_AVPHYS_PAGES: c_int = 12; +pub const _SC_MQ_OPEN_MAX: c_int = 13; +pub const _SC_MQ_PRIO_MAX: c_int = 14; +pub const _SC_RTSIG_MAX: c_int = 15; +pub const _SC_SEM_NSEMS_MAX: c_int = 16; +pub const _SC_SEM_VALUE_MAX: c_int = 17; +pub const _SC_SIGQUEUE_MAX: c_int = 18; +pub const _SC_TIMER_MAX: c_int = 19; +pub const _SC_TZNAME_MAX: c_int = 20; +pub const _SC_ASYNCHRONOUS_IO: c_int = 21; +pub const _SC_FSYNC: c_int = 22; +pub const _SC_MAPPED_FILES: c_int = 23; +pub const _SC_MEMLOCK: c_int = 24; +pub const _SC_MEMLOCK_RANGE: c_int = 25; +pub const _SC_MEMORY_PROTECTION: c_int = 26; +pub const _SC_MESSAGE_PASSING: c_int = 27; +pub const _SC_PRIORITIZED_IO: c_int = 28; +pub const _SC_REALTIME_SIGNALS: c_int = 29; +pub const _SC_SEMAPHORES: c_int = 30; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 31; +pub const _SC_SYNCHRONIZED_IO: c_int = 32; +pub const _SC_TIMERS: c_int = 33; +pub const _SC_AIO_LISTIO_MAX: c_int = 34; +pub const _SC_AIO_MAX: c_int = 35; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 36; +pub const _SC_DELAYTIMER_MAX: c_int = 37; +pub const _SC_THREAD_KEYS_MAX: c_int = 38; +pub const _SC_THREAD_STACK_MIN: c_int = 39; +pub const _SC_THREAD_THREADS_MAX: c_int = 40; +pub const _SC_TTY_NAME_MAX: c_int = 41; +pub const _SC_THREADS: c_int = 42; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 43; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 44; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 45; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 46; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 47; +pub const _SC_THREAD_PRIO_CEILING: c_int = _SC_THREAD_PRIO_PROTECT; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 48; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 49; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 50; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 51; +pub const _SC_LOGIN_NAME_MAX: c_int = 52; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 53; +pub const _SC_ADVISORY_INFO: c_int = 54; +pub const _SC_ATEXIT_MAX: c_int = 55; +pub const _SC_BARRIERS: c_int = 56; +pub const _SC_BC_BASE_MAX: c_int = 57; +pub const _SC_BC_DIM_MAX: c_int = 58; +pub const _SC_BC_SCALE_MAX: c_int = 59; +pub const _SC_BC_STRING_MAX: c_int = 60; +pub const _SC_CLOCK_SELECTION: c_int = 61; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 62; +pub const _SC_CPUTIME: c_int = 63; +pub const _SC_EXPR_NEST_MAX: c_int = 64; +pub const _SC_HOST_NAME_MAX: c_int = 65; +pub const _SC_IOV_MAX: c_int = 66; +pub const _SC_IPV6: c_int = 67; +pub const _SC_LINE_MAX: c_int = 68; +pub const _SC_MONOTONIC_CLOCK: c_int = 69; +pub const _SC_RAW_SOCKETS: c_int = 70; +pub const _SC_READER_WRITER_LOCKS: c_int = 71; +pub const _SC_REGEXP: c_int = 72; +pub const _SC_RE_DUP_MAX: c_int = 73; +pub const _SC_SHELL: c_int = 74; +pub const _SC_SPAWN: c_int = 75; +pub const _SC_SPIN_LOCKS: c_int = 76; +pub const _SC_SPORADIC_SERVER: c_int = 77; +pub const _SC_SS_REPL_MAX: c_int = 78; +pub const _SC_SYMLOOP_MAX: c_int = 79; +pub const _SC_THREAD_CPUTIME: c_int = 80; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 81; +pub const _SC_TIMEOUTS: c_int = 82; +pub const _SC_TRACE: c_int = 83; +pub const _SC_TRACE_EVENT_FILTER: c_int = 84; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 85; +pub const _SC_TRACE_INHERIT: c_int = 86; +pub const _SC_TRACE_LOG: c_int = 87; +pub const _SC_TRACE_NAME_MAX: c_int = 88; +pub const _SC_TRACE_SYS_MAX: c_int = 89; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 90; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 91; +pub const _SC_V7_ILP32_OFF32: c_int = 92; +pub const _SC_V6_ILP32_OFF32: c_int = _SC_V7_ILP32_OFF32; +pub const _SC_XBS5_ILP32_OFF32: c_int = _SC_V7_ILP32_OFF32; +pub const _SC_V7_ILP32_OFFBIG: c_int = 93; +pub const _SC_V6_ILP32_OFFBIG: c_int = _SC_V7_ILP32_OFFBIG; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = _SC_V7_ILP32_OFFBIG; +pub const _SC_V7_LP64_OFF64: c_int = 94; +pub const _SC_V6_LP64_OFF64: c_int = _SC_V7_LP64_OFF64; +pub const _SC_XBS5_LP64_OFF64: c_int = _SC_V7_LP64_OFF64; +pub const _SC_V7_LPBIG_OFFBIG: c_int = 95; +pub const _SC_V6_LPBIG_OFFBIG: c_int = _SC_V7_LPBIG_OFFBIG; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = _SC_V7_LPBIG_OFFBIG; +pub const _SC_XOPEN_CRYPT: c_int = 96; +pub const _SC_XOPEN_ENH_I18N: c_int = 97; +pub const _SC_XOPEN_LEGACY: c_int = 98; +pub const _SC_XOPEN_REALTIME: c_int = 99; +pub const _SC_STREAM_MAX: c_int = 100; +pub const _SC_PRIORITY_SCHEDULING: c_int = 101; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 102; +pub const _SC_XOPEN_SHM: c_int = 103; +pub const _SC_XOPEN_STREAMS: c_int = 104; +pub const _SC_XOPEN_UNIX: c_int = 105; +pub const _SC_XOPEN_VERSION: c_int = 106; +pub const _SC_2_CHAR_TERM: c_int = 107; +pub const _SC_2_C_BIND: c_int = 108; +pub const _SC_2_C_DEV: c_int = 109; +pub const _SC_2_FORT_DEV: c_int = 110; +pub const _SC_2_FORT_RUN: c_int = 111; +pub const _SC_2_LOCALEDEF: c_int = 112; +pub const _SC_2_PBS: c_int = 113; +pub const _SC_2_PBS_ACCOUNTING: c_int = 114; +pub const _SC_2_PBS_CHECKPOINT: c_int = 115; +pub const _SC_2_PBS_LOCATE: c_int = 116; +pub const _SC_2_PBS_MESSAGE: c_int = 117; +pub const _SC_2_PBS_TRACK: c_int = 118; +pub const _SC_2_SW_DEV: c_int = 119; +pub const _SC_2_UPE: c_int = 120; +pub const _SC_2_VERSION: c_int = 121; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 122; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 123; +pub const _SC_XOPEN_UUCP: c_int = 124; +pub const _SC_LEVEL1_ICACHE_SIZE: c_int = 125; +pub const _SC_LEVEL1_ICACHE_ASSOC: c_int = 126; +pub const _SC_LEVEL1_ICACHE_LINESIZE: c_int = 127; +pub const _SC_LEVEL1_DCACHE_SIZE: c_int = 128; +pub const _SC_LEVEL1_DCACHE_ASSOC: c_int = 129; +pub const _SC_LEVEL1_DCACHE_LINESIZE: c_int = 130; +pub const _SC_LEVEL2_CACHE_SIZE: c_int = 131; +pub const _SC_LEVEL2_CACHE_ASSOC: c_int = 132; +pub const _SC_LEVEL2_CACHE_LINESIZE: c_int = 133; +pub const _SC_LEVEL3_CACHE_SIZE: c_int = 134; +pub const _SC_LEVEL3_CACHE_ASSOC: c_int = 135; +pub const _SC_LEVEL3_CACHE_LINESIZE: c_int = 136; +pub const _SC_LEVEL4_CACHE_SIZE: c_int = 137; +pub const _SC_LEVEL4_CACHE_ASSOC: c_int = 138; +pub const _SC_LEVEL4_CACHE_LINESIZE: c_int = 139; diff --git a/src/new/openbsd/mod.rs b/src/new/openbsd/mod.rs index d5debb80f3928..25fa784b2b004 100644 --- a/src/new/openbsd/mod.rs +++ b/src/new/openbsd/mod.rs @@ -3,4 +3,5 @@ //! * Headers: //! * Manual pages: +pub(crate) mod sys; pub(crate) mod unistd; diff --git a/src/new/openbsd/sys/ipc.rs b/src/new/openbsd/sys/ipc.rs new file mode 100644 index 0000000000000..59774405bcdd0 --- /dev/null +++ b/src/new/openbsd/sys/ipc.rs @@ -0,0 +1,17 @@ +//! Header: `sys/ipc.h` +//! +//! + +use crate::prelude::*; + +s! { + pub struct ipc_perm { + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub mode: crate::mode_t, + pub seq: c_ushort, + pub key: crate::key_t, + } +} diff --git a/src/new/openbsd/sys/mod.rs b/src/new/openbsd/sys/mod.rs new file mode 100644 index 0000000000000..7ba77c537356e --- /dev/null +++ b/src/new/openbsd/sys/mod.rs @@ -0,0 +1,5 @@ +//! Directory: `sys/` +//! +//! https://github.com/openbsd/src/tree/trunk/sys/sys + +pub(crate) mod ipc; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs index dca7d6ee79988..8a8f6b4f10126 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs @@ -1,37 +1,29 @@ use crate::off_t; use crate::prelude::*; -#[repr(C)] -#[derive(Debug)] -#[cfg_attr(feature = "extra_traits", derive(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 +s! { + 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], } } diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs index 1f31aac0e3d3d..9e80a792a8c7b 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs @@ -1,36 +1,28 @@ use crate::off_t; use crate::prelude::*; -#[repr(C)] -#[derive(Debug)] -#[cfg_attr(feature = "extra_traits", derive(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 +s! { + 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, } } diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 2916d821a4d6a..8ab3632968c95 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -398,19 +398,24 @@ pub const POLLWRNORM: c_short = 0x004; pub const POLLRDBAND: c_short = 0x080; pub const POLLWRBAND: c_short = 0x100; -pub const BIOCGBLEN: c_ulong = 0x40044266; -pub const BIOCSBLEN: c_ulong = 0xc0044266; -pub const BIOCFLUSH: c_uint = 0x20004268; -pub const BIOCPROMISC: c_uint = 0x20004269; -pub const BIOCGDLT: c_ulong = 0x4004426a; -pub const BIOCGETIF: c_ulong = 0x4020426b; -pub const BIOCSETIF: c_ulong = 0x8020426c; -pub const BIOCGSTATS: c_ulong = 0x4008426f; -pub const BIOCIMMEDIATE: c_ulong = 0x80044270; -pub const BIOCVERSION: c_ulong = 0x40044271; -pub const BIOCGHDRCMPLT: c_ulong = 0x40044274; -pub const BIOCSHDRCMPLT: c_ulong = 0x80044275; -pub const SIOCGIFADDR: c_ulong = 0xc0206921; +cfg_if! { + // Not yet implemented on NetBSD + if #[cfg(not(any(target_os = "netbsd")))] { + pub const BIOCGBLEN: c_ulong = 0x40044266; + pub const BIOCSBLEN: c_ulong = 0xc0044266; + pub const BIOCFLUSH: c_uint = 0x20004268; + pub const BIOCPROMISC: c_uint = 0x20004269; + pub const BIOCGDLT: c_ulong = 0x4004426a; + pub const BIOCGETIF: c_ulong = 0x4020426b; + pub const BIOCSETIF: c_ulong = 0x8020426c; + pub const BIOCGSTATS: c_ulong = 0x4008426f; + pub const BIOCIMMEDIATE: c_ulong = 0x80044270; + pub const BIOCVERSION: c_ulong = 0x40044271; + pub const BIOCGHDRCMPLT: c_ulong = 0x40044274; + pub const BIOCSHDRCMPLT: c_ulong = 0x80044275; + pub const SIOCGIFADDR: c_ulong = 0xc0206921; + } +} pub const REG_BASIC: c_int = 0o0000; pub const REG_EXTENDED: c_int = 0o0001; @@ -725,6 +730,7 @@ extern "C" { )] #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigsuspend14")] pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int; pub fn sem_close(sem: *mut sem_t) -> c_int; pub fn getdtablesize() -> c_int; @@ -799,6 +805,7 @@ extern "C" { all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)), link_name = "wait4@FBSD_1.0" )] + #[cfg_attr(target_os = "netbsd", link_name = "__wait450")] pub fn wait4( pid: crate::pid_t, status: *mut c_int, @@ -809,11 +816,13 @@ extern "C" { all(target_os = "macos", target_arch = "x86"), link_name = "getitimer$UNIX2003" )] + #[cfg_attr(target_os = "netbsd", link_name = "__getitimer50")] pub fn getitimer(which: c_int, curr_value: *mut crate::itimerval) -> c_int; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "setitimer$UNIX2003" )] + #[cfg_attr(target_os = "netbsd", link_name = "__setitimer50")] pub fn setitimer( which: c_int, new_value: *const crate::itimerval, @@ -874,6 +883,7 @@ extern "C" { locale: crate::locale_t, ) -> size_t; + #[cfg_attr(target_os = "netbsd", link_name = "__devname50")] pub fn devname(dev: crate::dev_t, mode_t: crate::mode_t) -> *mut c_char; pub fn issetugid() -> c_int; diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index dc5e4528cf299..e1edcf9ffdc07 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -61,22 +61,6 @@ s! { pub l_whence: c_short, } - pub struct ipc_perm { - pub cuid: crate::uid_t, - pub cgid: crate::gid_t, - pub uid: crate::uid_t, - pub gid: crate::gid_t, - pub mode: mode_t, - #[cfg(target_os = "openbsd")] - pub seq: c_ushort, - #[cfg(target_os = "netbsd")] - pub _seq: c_ushort, - #[cfg(target_os = "openbsd")] - pub key: crate::key_t, - #[cfg(target_os = "netbsd")] - pub _key: crate::key_t, - } - pub struct ptrace_io_desc { pub piod_op: c_int, pub piod_offs: *mut c_void, @@ -720,7 +704,8 @@ extern "C" { pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: crate::dev_t) + -> c_int; pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; @@ -764,6 +749,7 @@ extern "C" { pub fn shmget(key: crate::key_t, size: size_t, shmflg: c_int) -> c_int; pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void; pub fn shmdt(shmaddr: *const c_void) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__shmctl50")] pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int; // DIFF(main): changed to `*const *mut` in e77f551de9 diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 2a360ca28af73..56563ddc386e4 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1,25 +1,19 @@ use crate::prelude::*; use crate::{ cmsghdr, + cpuid_t, + lwpid_t, off_t, }; -pub type clock_t = c_uint; -pub type suseconds_t = c_int; -pub type dev_t = u64; pub type blksize_t = i32; pub type fsblkcnt_t = u64; pub type fsfilcnt_t = u64; pub type idtype_t = c_int; -pub type mqd_t = c_int; type __pthread_spin_t = __cpu_simple_lock_nv_t; -pub type vm_size_t = crate::uintptr_t; // FIXME(deprecated): deprecated since long time -pub type lwpid_t = c_uint; pub type shmatt_t = c_uint; -pub type cpuid_t = c_ulong; pub type cpuset_t = _cpuset; pub type pthread_spin_t = c_uchar; -pub type timer_t = c_int; // elf.h @@ -50,6 +44,10 @@ e! { } } +extern_ty! { + pub enum _cpuset {} +} + cfg_if! { if #[cfg(target_pointer_width = "64")] { type Elf_Addr = Elf64_Addr; @@ -169,11 +167,6 @@ s! { pub mq_curmsgs: c_long, } - pub struct itimerspec { - pub it_interval: crate::timespec, - pub it_value: crate::timespec, - } - pub struct sigset_t { __bits: [u32; 4], } @@ -301,8 +294,7 @@ s! { pub flags: u32, pub fflags: u32, pub data: i64, - // FIXME(netbsd): NetBSD 10.0 will finally have same layout as other BSD - pub udata: intptr_t, + pub udata: *mut c_void, } pub struct dqblk { @@ -350,38 +342,6 @@ s! { pub int_n_sign_posn: c_char, } - pub struct if_data { - pub ifi_type: c_uchar, - pub ifi_addrlen: c_uchar, - pub ifi_hdrlen: c_uchar, - pub ifi_link_state: c_int, - pub ifi_mtu: u64, - pub ifi_metric: u64, - pub ifi_baudrate: u64, - pub ifi_ipackets: u64, - pub ifi_ierrors: u64, - pub ifi_opackets: u64, - pub ifi_oerrors: u64, - pub ifi_collisions: u64, - pub ifi_ibytes: u64, - pub ifi_obytes: u64, - pub ifi_imcasts: u64, - pub ifi_omcasts: u64, - pub ifi_iqdrops: u64, - pub ifi_noproto: u64, - pub ifi_lastchange: crate::timespec, - } - - pub struct if_msghdr { - pub ifm_msglen: c_ushort, - pub ifm_version: c_uchar, - pub ifm_type: c_uchar, - pub ifm_addrs: c_int, - pub ifm_flags: c_int, - pub ifm_index: c_ushort, - pub ifm_data: if_data, - } - pub struct sockcred { pub sc_pid: crate::pid_t, pub sc_uid: crate::uid_t, @@ -396,7 +356,7 @@ s! { pub cr_unused: c_ushort, pub cr_uid: crate::uid_t, pub cr_gid: crate::gid_t, - pub cr_ngroups: c_int, + pub cr_ngroups: c_short, pub cr_groups: [crate::gid_t; NGROUPS_MAX as usize], } @@ -414,12 +374,7 @@ s! { pub sdl_nlen: u8, pub sdl_alen: u8, pub sdl_slen: u8, - pub sdl_data: [c_char; 12], - } - - pub struct __exit_status { - pub e_termination: u16, - pub e_exit: u16, + pub sdl_data: [c_char; 24], } pub struct shmid_ds { @@ -434,47 +389,6 @@ s! { _shm_internal: *mut c_void, } - pub struct utmp { - pub ut_line: [c_char; UT_LINESIZE], - pub ut_name: [c_char; UT_NAMESIZE], - pub ut_host: [c_char; UT_HOSTSIZE], - pub ut_time: crate::time_t, - } - - pub struct lastlog { - pub ll_line: [c_char; UT_LINESIZE], - pub ll_host: [c_char; UT_HOSTSIZE], - pub ll_time: crate::time_t, - } - - pub struct timex { - pub modes: c_uint, - pub offset: c_long, - pub freq: c_long, - pub maxerror: c_long, - pub esterror: c_long, - pub status: c_int, - pub constant: c_long, - pub precision: c_long, - pub tolerance: c_long, - pub ppsfreq: c_long, - pub jitter: c_long, - pub shift: c_int, - pub stabil: c_long, - pub jitcnt: c_long, - pub calcnt: c_long, - pub errcnt: c_long, - pub stbcnt: c_long, - } - - pub struct ntptimeval { - pub time: crate::timespec, - pub maxerror: c_long, - pub esterror: c_long, - pub tai: c_long, - pub time_state: c_int, - } - // elf.h pub struct Elf32_Phdr { @@ -522,10 +436,6 @@ s! { pub dlpi_tls_data: *mut c_void, } - pub struct _cpuset { - bits: [u32; 0], - } - pub struct accept_filter_arg { pub af_name: [c_char; 16], af_arg: [c_char; 256 - 16], @@ -713,6 +623,7 @@ s! { pub fae: *mut posix_spawn_file_actions_entry_t, } + #[deprecated(since = "0.2.178", note = "obsolete upstream")] pub struct ptrace_lwpinfo { pub pl_lwpid: lwpid_t, pub pl_event: c_int, @@ -742,15 +653,6 @@ s! { pub descr_str: [c_char; 1], } - pub struct ifreq { - pub _priv: [[c_char; 6]; 24], - } - - pub struct ifconf { - pub ifc_len: c_int, - pub ifc_ifcu: __c_anonymous_ifc_ifcu, - } - pub struct tcp_info { pub tcpi_state: u8, pub __tcpi_ca_state: u8, @@ -794,27 +696,6 @@ s! { pub __tcpi_pad: [u32; 26], } - pub struct utmpx { - pub ut_name: [c_char; _UTX_USERSIZE], - pub ut_id: [c_char; _UTX_IDSIZE], - pub ut_line: [c_char; _UTX_LINESIZE], - pub ut_host: [c_char; _UTX_HOSTSIZE], - pub ut_session: u16, - pub ut_type: u16, - pub ut_pid: crate::pid_t, - pub ut_exit: __exit_status, // FIXME(netbsd): when anonymous struct are supported - pub ut_ss: sockaddr_storage, - pub ut_tv: crate::timeval, - pub ut_pad: [u8; _UTX_PADSIZE], - } - - pub struct lastlogx { - pub ll_tv: crate::timeval, - pub ll_line: [c_char; _UTX_LINESIZE], - pub ll_host: [c_char; _UTX_HOSTSIZE], - pub ll_ss: sockaddr_storage, - } - pub struct in_pktinfo { pub ipi_addr: crate::in_addr, pub ipi_ifindex: c_uint, @@ -853,40 +734,6 @@ s! { pub d_name: [c_char; 512], } - pub struct statvfs { - pub f_flag: c_ulong, - pub f_bsize: c_ulong, - pub f_frsize: c_ulong, - pub f_iosize: c_ulong, - - pub f_blocks: crate::fsblkcnt_t, - pub f_bfree: crate::fsblkcnt_t, - pub f_bavail: crate::fsblkcnt_t, - pub f_bresvd: crate::fsblkcnt_t, - - pub f_files: crate::fsfilcnt_t, - pub f_ffree: crate::fsfilcnt_t, - pub f_favail: crate::fsfilcnt_t, - pub f_fresvd: crate::fsfilcnt_t, - - pub f_syncreads: u64, - pub f_syncwrites: u64, - - pub f_asyncreads: u64, - pub f_asyncwrites: u64, - - pub f_fsidx: crate::fsid_t, - pub f_fsid: c_ulong, - pub f_namemax: c_ulong, - pub f_owner: crate::uid_t, - - pub f_spare: [u32; 4], - - pub f_fstypename: [c_char; 32], - pub f_mntonname: [c_char; 1024], - pub f_mntfromname: [c_char; 1024], - } - pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: crate::sa_family_t, @@ -909,11 +756,6 @@ s_no_extra_traits! { pub open: __c_anonymous_posix_spawn_fae_open, pub dup2: __c_anonymous_posix_spawn_fae_dup2, } - - pub union __c_anonymous_ifc_ifcu { - pub ifcu_buf: *mut c_void, - pub ifcu_req: *mut ifreq, - } } cfg_if! { @@ -932,21 +774,6 @@ cfg_if! { } } } - - impl Eq for __c_anonymous_ifc_ifcu {} - impl PartialEq for __c_anonymous_ifc_ifcu { - fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool { - unsafe { self.ifcu_buf == other.ifcu_buf || self.ifcu_req == other.ifcu_req } - } - } - impl hash::Hash for __c_anonymous_ifc_ifcu { - fn hash(&self, state: &mut H) { - unsafe { - self.ifcu_buf.hash(state); - self.ifcu_req.hash(state); - } - } - } } } @@ -977,7 +804,6 @@ pub const AT_RGID: c_int = 2003; pub const AT_SUN_LDELF: c_int = 2004; pub const AT_SUN_LDSHDR: c_int = 2005; pub const AT_SUN_LDNAME: c_int = 2006; -pub const AT_SUN_LDPGSIZE: c_int = 2007; pub const AT_SUN_PLATFORM: c_int = 2008; pub const AT_SUN_HWCAP: c_int = 2009; pub const AT_SUN_IFLUSH: c_int = 2010; @@ -1113,22 +939,6 @@ pub const LOCAL_PEEREID: c_int = 0x0003; // get peer identification pub const LOCAL_CREDS: c_int = 0x0004; // pass credentials to receiver // https://github.com/NetBSD/src/blob/trunk/sys/net/if.h#L373 -pub const IFF_UP: c_int = 0x0001; // interface is up -pub const IFF_BROADCAST: c_int = 0x0002; // broadcast address valid -pub const IFF_DEBUG: c_int = 0x0004; // turn on debugging -pub const IFF_LOOPBACK: c_int = 0x0008; // is a loopback net -pub const IFF_POINTOPOINT: c_int = 0x0010; // interface is point-to-point link -pub const IFF_NOTRAILERS: c_int = 0x0020; // avoid use of trailers -pub const IFF_RUNNING: c_int = 0x0040; // resources allocated -pub const IFF_NOARP: c_int = 0x0080; // no address resolution protocol -pub const IFF_PROMISC: c_int = 0x0100; // receive all packets -pub const IFF_ALLMULTI: c_int = 0x0200; // receive all multicast packets -pub const IFF_OACTIVE: c_int = 0x0400; // transmission in progress -pub const IFF_SIMPLEX: c_int = 0x0800; // can't hear own transmissions -pub const IFF_LINK0: c_int = 0x1000; // per link layer defined bit -pub const IFF_LINK1: c_int = 0x2000; // per link layer defined bit -pub const IFF_LINK2: c_int = 0x4000; // per link layer defined bit -pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast // sys/netinet/in.h // Protocols (RFC 1700) @@ -1220,7 +1030,6 @@ pub const NET_RT_OOOIFLIST: c_int = 3; pub const NET_RT_OOIFLIST: c_int = 4; pub const NET_RT_OIFLIST: c_int = 5; pub const NET_RT_IFLIST: c_int = 6; -pub const NET_RT_MAXID: c_int = 7; pub const PF_OROUTE: c_int = AF_OROUTE; pub const PF_ARP: c_int = AF_ARP; @@ -1407,12 +1216,6 @@ pub const FD_SETSIZE: usize = 0x100; pub const ST_NOSUID: c_ulong = 8; -pub const BIOCGRSIG: c_ulong = 0x40044272; -pub const BIOCSRSIG: c_ulong = 0x80044273; -pub const BIOCSDLT: c_ulong = 0x80044278; -pub const BIOCGSEESENT: c_ulong = 0x40044276; -pub const BIOCSSEESENT: c_ulong = 0x80044277; - // pub const MNT_UNION: c_int = 0x00000020; pub const MNT_NOCOREDUMP: c_int = 0x00008000; @@ -1456,65 +1259,16 @@ pub const fn _IOC(inout: c_ulong, group: c_ulong, num: c_ulong, len: c_ulong) -> | (num) } -// -pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 2; -pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 4; pub const NTP_API: c_int = 4; -pub const MAXPHASE: c_long = 500000000; -pub const MAXFREQ: c_long = 500000; -pub const MINSEC: c_int = 256; -pub const MAXSEC: c_int = 2048; -pub const NANOSECOND: c_long = 1000000000; -pub const SCALE_PPM: c_int = 65; -pub const MAXTC: c_int = 10; -pub const MOD_OFFSET: c_uint = 0x0001; -pub const MOD_FREQUENCY: c_uint = 0x0002; -pub const MOD_MAXERROR: c_uint = 0x0004; -pub const MOD_ESTERROR: c_uint = 0x0008; -pub const MOD_STATUS: c_uint = 0x0010; -pub const MOD_TIMECONST: c_uint = 0x0020; -pub const MOD_PPSMAX: c_uint = 0x0040; -pub const MOD_TAI: c_uint = 0x0080; -pub const MOD_MICRO: c_uint = 0x1000; -pub const MOD_NANO: c_uint = 0x2000; -pub const MOD_CLKB: c_uint = 0x4000; -pub const MOD_CLKA: c_uint = 0x8000; -pub const STA_PLL: c_int = 0x0001; -pub const STA_PPSFREQ: c_int = 0x0002; -pub const STA_PPSTIME: c_int = 0x0004; -pub const STA_FLL: c_int = 0x0008; -pub const STA_INS: c_int = 0x0010; -pub const STA_DEL: c_int = 0x0020; -pub const STA_UNSYNC: c_int = 0x0040; -pub const STA_FREQHOLD: c_int = 0x0080; -pub const STA_PPSSIGNAL: c_int = 0x0100; -pub const STA_PPSJITTER: c_int = 0x0200; -pub const STA_PPSWANDER: c_int = 0x0400; -pub const STA_PPSERROR: c_int = 0x0800; -pub const STA_CLOCKERR: c_int = 0x1000; -pub const STA_NANO: c_int = 0x2000; -pub const STA_MODE: c_int = 0x4000; -pub const STA_CLK: c_int = 0x8000; -pub const STA_RONLY: c_int = STA_PPSSIGNAL - | STA_PPSJITTER - | STA_PPSWANDER - | STA_PPSERROR - | STA_CLOCKERR - | STA_NANO - | STA_MODE - | STA_CLK; -pub const TIME_OK: c_int = 0; -pub const TIME_INS: c_int = 1; -pub const TIME_DEL: c_int = 2; -pub const TIME_OOP: c_int = 3; -pub const TIME_WAIT: c_int = 4; -pub const TIME_ERROR: c_int = 5; pub const LITTLE_ENDIAN: c_int = 1234; pub const BIG_ENDIAN: c_int = 4321; +#[deprecated(since = "0.2.178", note = "obsolete upstream")] pub const PL_EVENT_NONE: c_int = 0; +#[deprecated(since = "0.2.178", note = "obsolete upstream")] pub const PL_EVENT_SIGNAL: c_int = 1; +#[deprecated(since = "0.2.178", note = "obsolete upstream")] pub const PL_EVENT_SUSPENDED: c_int = 2; cfg_if! { @@ -1702,7 +1456,6 @@ pub const CTL_PROC: c_int = 10; pub const CTL_VENDOR: c_int = 11; pub const CTL_EMUL: c_int = 12; pub const CTL_SECURITY: c_int = 13; -pub const CTL_MAXID: c_int = 14; pub const KERN_OSTYPE: c_int = 1; pub const KERN_OSRELEASE: c_int = 2; pub const KERN_OSREV: c_int = 3; @@ -1787,7 +1540,6 @@ pub const KERN_ARND: c_int = 81; pub const KERN_SYSVIPC: c_int = 82; pub const KERN_BOOTTIME: c_int = 83; pub const KERN_EVCNT: c_int = 84; -pub const KERN_MAXID: c_int = 85; pub const KERN_PROC_ALL: c_int = 0; pub const KERN_PROC_PID: c_int = 1; pub const KERN_PROC_PGRP: c_int = 2; @@ -1855,31 +1607,6 @@ pub const ONLRET: crate::tcflag_t = 0x40; pub const CDTRCTS: crate::tcflag_t = 0x00020000; pub const CHWFLOW: crate::tcflag_t = crate::MDMBUF | crate::CRTSCTS | crate::CDTRCTS; -// pub const _PATH_UTMPX: &[c_char; 14] = b"/var/run/utmpx"; -// pub const _PATH_WTMPX: &[c_char; 14] = b"/var/log/wtmpx"; -// pub const _PATH_LASTLOGX: &[c_char; 17] = b"/var/log/lastlogx"; -// pub const _PATH_UTMP_UPDATE: &[c_char; 24] = b"/usr/libexec/utmp_update"; -pub const UT_NAMESIZE: usize = 8; -pub const UT_LINESIZE: usize = 8; -pub const UT_HOSTSIZE: usize = 16; -pub const _UTX_USERSIZE: usize = 32; -pub const _UTX_LINESIZE: usize = 32; -pub const _UTX_PADSIZE: usize = 40; -pub const _UTX_IDSIZE: usize = 4; -pub const _UTX_HOSTSIZE: usize = 256; -pub const EMPTY: u16 = 0; -pub const RUN_LVL: u16 = 1; -pub const BOOT_TIME: u16 = 2; -pub const OLD_TIME: u16 = 3; -pub const NEW_TIME: u16 = 4; -pub const INIT_PROCESS: u16 = 5; -pub const LOGIN_PROCESS: u16 = 6; -pub const USER_PROCESS: u16 = 7; -pub const DEAD_PROCESS: u16 = 8; -pub const ACCOUNTING: u16 = 9; -pub const SIGNATURE: u16 = 10; -pub const DOWN_TIME: u16 = 11; - pub const SOCK_CLOEXEC: c_int = 0x10000000; pub const SOCK_NONBLOCK: c_int = 0x20000000; @@ -1894,9 +1621,10 @@ pub const FIBMAP: c_ulong = 0xc008667a; pub const SIGSTKSZ: size_t = 40960; -pub const REG_ENOSYS: c_int = 17; +pub const REG_ILLSEQ: c_int = 17; pub const PT_DUMPCORE: c_int = 12; +#[deprecated(note = "obsolete operation")] pub const PT_LWPINFO: c_int = 13; pub const PT_SYSCALL: c_int = 14; pub const PT_SYSCALLEMU: c_int = 15; @@ -1906,7 +1634,7 @@ pub const PT_GET_PROCESS_STATE: c_int = 18; pub const PT_SET_SIGINFO: c_int = 19; pub const PT_GET_SIGINFO: c_int = 20; pub const PT_RESUME: c_int = 21; -pub const PT_SUSPEND: c_int = 23; +pub const PT_SUSPEND: c_int = 22; pub const PT_STOP: c_int = 23; pub const PT_LWPSTATUS: c_int = 24; pub const PT_LWPNEXT: c_int = 25; @@ -2112,8 +1840,6 @@ safe_f! { } extern "C" { - pub fn ntp_adjtime(buf: *mut timex) -> c_int; - pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int; pub fn clock_nanosleep( clk_id: crate::clockid_t, flags: c_int, @@ -2398,7 +2124,9 @@ extern "C" { ) -> c_int; pub fn timer_delete(timerid: crate::timer_t) -> c_int; pub fn timer_getoverrun(timerid: crate::timer_t) -> c_int; + #[link_name = "__timer_gettime50"] pub fn timer_gettime(timerid: crate::timer_t, curr_value: *mut crate::itimerspec) -> c_int; + #[link_name = "__timer_settime50"] pub fn timer_settime( timerid: crate::timer_t, flags: c_int, @@ -2424,6 +2152,7 @@ extern "C" { flags: c_int, ) -> *mut c_void; + #[link_name = "__sched_rr_get_interval50"] pub fn sched_rr_get_interval(pid: crate::pid_t, t: *mut crate::timespec) -> c_int; pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int; pub fn sched_getparam(pid: crate::pid_t, param: *mut crate::sched_param) -> c_int; @@ -2466,18 +2195,17 @@ extern "C" { ntargets: size_t, hint: *const c_void, ) -> c_int; - #[link_name = "__getmntinfo13"] pub fn getmntinfo(mntbufp: *mut *mut crate::statvfs, flags: c_int) -> c_int; - pub fn getvfsstat(buf: *mut statvfs, bufsize: size_t, flags: c_int) -> c_int; + pub fn getvfsstat(buf: *mut crate::statvfs, bufsize: size_t, flags: c_int) -> c_int; // Added in `NetBSD` 10.0 pub fn timerfd_create(clockid: crate::clockid_t, flags: c_int) -> c_int; - pub fn timerfd_gettime(fd: c_int, curr_value: *mut itimerspec) -> c_int; + pub fn timerfd_gettime(fd: c_int, curr_value: *mut crate::itimerspec) -> c_int; pub fn timerfd_settime( fd: c_int, flags: c_int, - new_value: *const itimerspec, - old_value: *mut itimerspec, + new_value: *const crate::itimerspec, + old_value: *mut crate::itimerspec, ) -> c_int; pub fn qsort_r( @@ -2513,7 +2241,7 @@ extern "C" { #[link(name = "util")] extern "C" { - #[cfg_attr(target_os = "netbsd", link_name = "__getpwent_r50")] + #[link_name = "__getpwent_r50"] pub fn getpwent_r( pwd: *mut crate::passwd, buf: *mut c_char, @@ -2527,26 +2255,6 @@ extern "C" { result: *mut *mut crate::group, ) -> c_int; - pub fn updwtmpx(file: *const c_char, ut: *const utmpx) -> c_int; - pub fn getlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) - -> *mut lastlogx; - pub fn updlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) -> c_int; - pub fn utmpxname(file: *const c_char) -> c_int; - pub fn getutxent() -> *mut utmpx; - pub fn getutxid(ut: *const utmpx) -> *mut utmpx; - pub fn getutxline(ut: *const utmpx) -> *mut utmpx; - pub fn pututxline(ut: *const utmpx) -> *mut utmpx; - pub fn setutxent(); - pub fn endutxent(); - - pub fn getutmp(ux: *const utmpx, u: *mut utmp); - pub fn getutmpx(u: *const utmp, ux: *mut utmpx); - - pub fn utpname(file: *const c_char) -> c_int; - pub fn setutent(); - pub fn endutent(); - pub fn getutent() -> *mut utmp; - pub fn efopen(p: *const c_char, m: *const c_char) -> crate::FILE; pub fn emalloc(n: size_t) -> *mut c_void; pub fn ecalloc(n: size_t, c: size_t) -> *mut c_void; @@ -2608,9 +2316,9 @@ extern "C" { precision: size_t, ) -> *mut c_char; #[link_name = "__login50"] - pub fn login(ut: *const utmp); + pub fn login(ut: *const crate::utmp); #[link_name = "__loginx50"] - pub fn loginx(ut: *const utmpx); + pub fn loginx(ut: *const crate::utmpx); pub fn logout(line: *const c_char); pub fn logoutx(line: *const c_char, status: c_int, tpe: c_int); pub fn logwtmp(line: *const c_char, name: *const c_char, host: *const c_char); diff --git a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs index 47240cb2818c0..8cacb7250eddc 100644 --- a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs @@ -1,16 +1,15 @@ -use PT_FIRSTMACH; - use crate::prelude::*; +use crate::PT_FIRSTMACH; pub type __greg_t = u64; pub type __cpu_simple_lock_nv_t = c_int; pub type __gregset = [__greg_t; _NGREG]; -pub type __fregset = [__freg; _NFREG]; +pub type __fregset = [__fpreg; _NFREG]; s! { pub struct mcontext_t { pub __gregs: __gregset, - pub __fregs: __fpregset, + pub __fregs: __fregset, __spare: [crate::__greg_t; 7], } } @@ -22,6 +21,22 @@ s_no_extra_traits! { } } +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __fpreg { + fn eq(&self, other: &Self) -> bool { + unsafe { self.u_u64 == other.u_u64 } + } + } + impl Eq for __fpreg {} + impl hash::Hash for __fpreg { + fn hash(&self, state: &mut H) { + unsafe { self.u_u64.hash(state) }; + } + } + } +} + pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const PT_GETREGS: c_int = PT_FIRSTMACH + 0; diff --git a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs index 77daa4b1e9eb2..801b326b70fa5 100644 --- a/src/unix/bsd/netbsdlike/netbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/x86_64.rs @@ -4,11 +4,14 @@ use crate::PT_FIRSTMACH; pub type c___greg_t = u64; pub type __cpu_simple_lock_nv_t = c_uchar; +// FIXME(alignment): Type is `__aligned(8)` +type __fpregset_t = [c_char; 512]; + s! { pub struct mcontext_t { pub __gregs: [c___greg_t; 26], pub _mc_tlsbase: c___greg_t, - pub __fpregs: [[c_char; 32]; 16], + pub __fpregs: __fpregset_t, } pub struct ucontext_t { diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index e942bedfbdb19..8e50af515364f 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -630,6 +630,29 @@ s_no_extra_traits! { pub ifc_len: c_int, /* Size of buffer. */ pub ifc_ifcu: __c_anonymous_ifc_ifcu, } + + // Internal, for casts to access union fields + struct sifields_sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: c_long, + si_stime: c_long, + } + + // Internal, for casts to access union fields + union sifields { + _align_pointer: *mut c_void, + sigchld: sifields_sigchld, + } + + // Internal, for casts to access union fields. Note that some variants + // of sifields start with a pointer, which makes the alignment of + // sifields vary on 32-bit and 64-bit architectures. + struct siginfo_f { + _siginfo_base: [c_int; 3], + sifields: sifields, + } } cfg_if! { @@ -3860,38 +3883,6 @@ impl siginfo_t { } } -// Internal, for casts to access union fields -#[repr(C)] -struct sifields_sigchld { - si_pid: crate::pid_t, - si_uid: crate::uid_t, - si_status: c_int, - si_utime: c_long, - si_stime: c_long, -} -impl Copy for sifields_sigchld {} -impl Clone for sifields_sigchld { - fn clone(&self) -> sifields_sigchld { - *self - } -} - -// Internal, for casts to access union fields -#[repr(C)] -union sifields { - _align_pointer: *mut c_void, - sigchld: sifields_sigchld, -} - -// Internal, for casts to access union fields. Note that some variants -// of sifields start with a pointer, which makes the alignment of -// sifields vary on 32-bit and 64-bit architectures. -#[repr(C)] -struct siginfo_f { - _siginfo_base: [c_int; 3], - sifields: sifields, -} - impl siginfo_t { unsafe fn sifields(&self) -> &sifields { &(*(self as *const siginfo_t as *const siginfo_f)).sifields diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 3aae0164cab08..61ccee3e75234 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -422,36 +422,29 @@ impl siginfo_t { } } -// Internal, for casts to access union fields -#[repr(C)] -struct sifields_sigchld { - si_pid: crate::pid_t, - si_uid: crate::uid_t, - si_status: c_int, - si_utime: c_long, - si_stime: c_long, -} -impl Copy for sifields_sigchld {} -impl Clone for sifields_sigchld { - fn clone(&self) -> sifields_sigchld { - *self +s_no_extra_traits! { + // Internal, for casts to access union fields + struct sifields_sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: c_long, + si_stime: c_long, } -} -// Internal, for casts to access union fields -#[repr(C)] -union sifields { - _align_pointer: *mut c_void, - sigchld: sifields_sigchld, -} + // Internal, for casts to access union fields + union sifields { + _align_pointer: *mut c_void, + sigchld: sifields_sigchld, + } -// Internal, for casts to access union fields. Note that some variants -// of sifields start with a pointer, which makes the alignment of -// sifields vary on 32-bit and 64-bit architectures. -#[repr(C)] -struct siginfo_f { - _siginfo_base: [c_int; 3], - sifields: sifields, + // Internal, for casts to access union fields. Note that some variants + // of sifields start with a pointer, which makes the alignment of + // sifields vary on 32-bit and 64-bit architectures. + struct siginfo_f { + _siginfo_base: [c_int; 3], + sifields: sifields, + } } impl siginfo_t { diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 793af6eb5be3e..c835ddbde2992 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -63,36 +63,29 @@ impl siginfo_t { } } -// Internal, for casts to access union fields -#[repr(C)] -struct sifields_sigchld { - si_pid: crate::pid_t, - si_uid: crate::uid_t, - si_status: c_int, - si_utime: c_long, - si_stime: c_long, -} -impl Copy for sifields_sigchld {} -impl Clone for sifields_sigchld { - fn clone(&self) -> sifields_sigchld { - *self +s_no_extra_traits! { + // Internal, for casts to access union fields + struct sifields_sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: c_long, + si_stime: c_long, } -} -// Internal, for casts to access union fields -#[repr(C)] -union sifields { - _align_pointer: *mut c_void, - sigchld: sifields_sigchld, -} + // Internal, for casts to access union fields + union sifields { + _align_pointer: *mut c_void, + sigchld: sifields_sigchld, + } -// Internal, for casts to access union fields. Note that some variants -// of sifields start with a pointer, which makes the alignment of -// sifields vary on 32-bit and 64-bit architectures. -#[repr(C)] -struct siginfo_f { - _siginfo_base: [c_int; 3], - sifields: sifields, + // Internal, for casts to access union fields. Note that some variants + // of sifields start with a pointer, which makes the alignment of + // sifields vary on 32-bit and 64-bit architectures. + struct siginfo_f { + _siginfo_base: [c_int; 3], + sifields: sifields, + } } impl siginfo_t { diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 4fef82ed8e167..69f1b006e1c01 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -181,36 +181,29 @@ impl siginfo_t { } } -// Internal, for casts to access union fields -#[repr(C)] -struct sifields_sigchld { - si_pid: crate::pid_t, - si_uid: crate::uid_t, - si_status: c_int, - si_utime: c_long, - si_stime: c_long, -} -impl Copy for sifields_sigchld {} -impl Clone for sifields_sigchld { - fn clone(&self) -> sifields_sigchld { - *self +s_no_extra_traits! { + // Internal, for casts to access union fields + struct sifields_sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: c_long, + si_stime: c_long, } -} -// Internal, for casts to access union fields -#[repr(C)] -union sifields { - _align_pointer: *mut c_void, - sigchld: sifields_sigchld, -} + // Internal, for casts to access union fields + union sifields { + _align_pointer: *mut c_void, + sigchld: sifields_sigchld, + } -// Internal, for casts to access union fields. Note that some variants -// of sifields start with a pointer, which makes the alignment of -// sifields vary on 32-bit and 64-bit architectures. -#[repr(C)] -struct siginfo_f { - _siginfo_base: [c_int; 3], - sifields: sifields, + // Internal, for casts to access union fields. Note that some variants + // of sifields start with a pointer, which makes the alignment of + // sifields vary on 32-bit and 64-bit architectures. + struct siginfo_f { + _siginfo_base: [c_int; 3], + sifields: sifields, + } } impl siginfo_t { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 0de47f4e92b8e..677788e9fc9ad 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -60,7 +60,7 @@ s! { pub struct timeval { pub tv_sec: time_t, #[cfg(not(gnu_time_bits64))] - pub tv_usec: suseconds_t, + pub tv_usec: crate::suseconds_t, // For 64 bit time on 32 bit linux glibc, suseconds_t is still // a 32 bit type. Use __suseconds64_t instead #[cfg(gnu_time_bits64)] @@ -351,7 +351,11 @@ cfg_if! { pub const FNM_NOMATCH: c_int = 1; cfg_if! { - if #[cfg(any(target_os = "illumos", target_os = "solaris",))] { + if #[cfg(any( + target_os = "illumos", + target_os = "solaris", + target_os = "netbsd" + ))] { pub const FNM_CASEFOLD: c_int = 1 << 3; } else if #[cfg(not(target_os = "aix"))] { pub const FNM_CASEFOLD: c_int = 1 << 4; @@ -365,6 +369,7 @@ cfg_if! { target_os = "android", target_os = "openbsd", target_os = "cygwin", + target_os = "netbsd", ))] { pub const FNM_PATHNAME: c_int = 1 << 1; } else { @@ -378,6 +383,7 @@ cfg_if! { target_os = "freebsd", target_os = "android", target_os = "openbsd", + target_os = "netbsd", ))] { pub const FNM_NOESCAPE: c_int = 1 << 0; } else if #[cfg(target_os = "nto")] { @@ -1537,9 +1543,9 @@ extern "C" { pub fn sem_trywait(sem: *mut sem_t) -> c_int; pub fn sem_post(sem: *mut sem_t) -> c_int; #[cfg_attr(gnu_file_offset_bits64, link_name = "statvfs64")] - pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> c_int; + pub fn statvfs(path: *const c_char, buf: *mut crate::statvfs) -> c_int; #[cfg_attr(gnu_file_offset_bits64, link_name = "fstatvfs64")] - pub fn fstatvfs(fd: c_int, buf: *mut statvfs) -> c_int; + pub fn fstatvfs(fd: c_int, buf: *mut crate::statvfs) -> c_int; #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")] pub fn sigemptyset(set: *mut sigset_t) -> c_int; @@ -1640,6 +1646,7 @@ cfg_if! { target_os = "aix", )))] { extern "C" { + #[cfg_attr(target_os = "netbsd", link_name = "__adjtime50")] #[cfg_attr(gnu_time_bits64, link_name = "__adjtime64")] pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> c_int; } diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 4f8fd105d57a5..1e5fc221296c1 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -668,71 +668,38 @@ cfg_if! { } } -#[repr(C)] -struct siginfo_fault { - addr: *mut c_void, - trapno: c_int, - pc: *mut crate::caddr_t, -} -impl Copy for siginfo_fault {} -impl Clone for siginfo_fault { - fn clone(&self) -> Self { - *self +s_no_extra_traits! { + struct siginfo_fault { + addr: *mut c_void, + trapno: c_int, + pc: *mut crate::caddr_t, } -} -#[repr(C)] -struct siginfo_cldval { - utime: crate::clock_t, - status: c_int, - stime: crate::clock_t, -} -impl Copy for siginfo_cldval {} -impl Clone for siginfo_cldval { - fn clone(&self) -> Self { - *self + struct siginfo_cldval { + utime: crate::clock_t, + status: c_int, + stime: crate::clock_t, } -} -#[repr(C)] -struct siginfo_killval { - uid: crate::uid_t, - value: crate::sigval, - // Pad out to match the SIGCLD value size - _pad: *mut c_void, -} -impl Copy for siginfo_killval {} -impl Clone for siginfo_killval { - fn clone(&self) -> Self { - *self + struct siginfo_killval { + uid: crate::uid_t, + value: crate::sigval, + // Pad out to match the SIGCLD value size + _pad: *mut c_void, } -} -#[repr(C)] -struct siginfo_sigcld { - pid: crate::pid_t, - val: siginfo_cldval, - ctid: crate::ctid_t, - zoneid: crate::zoneid_t, -} -impl Copy for siginfo_sigcld {} -impl Clone for siginfo_sigcld { - fn clone(&self) -> Self { - *self + struct siginfo_sigcld { + pid: crate::pid_t, + val: siginfo_cldval, + ctid: crate::ctid_t, + zoneid: crate::zoneid_t, } -} -#[repr(C)] -struct siginfo_kill { - pid: crate::pid_t, - val: siginfo_killval, - ctid: crate::ctid_t, - zoneid: crate::zoneid_t, -} -impl Copy for siginfo_kill {} -impl Clone for siginfo_kill { - fn clone(&self) -> Self { - *self + struct siginfo_kill { + pid: crate::pid_t, + val: siginfo_killval, + ctid: crate::ctid_t, + zoneid: crate::zoneid_t, } }