summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2022-03-13Merge #1671bors[bot]
1671: docs: fix link in doc for cmsg_space in sys/socket r=rtzoeller a=liubin Link to cmsg_space macro for recvmmsg and recvmsg should be the doc's root of crate as macro is an exported macro. Signed-off-by: bin liu <liubin0329@gmail.com> Co-authored-by: bin liu <liubin0329@gmail.com>
2022-03-09wait: implement waitid()Matthias Schiffer
waitid() has a number of additional features that waitpid() is missing: - WNOWAIT is only accepted for waitid() on Linux (and possibly other platforms) - Support for waiting on PID file descriptors on Linux For now support is added for all platforms with waitid() that have proper siginfo_t support in libc. NetBSD support is currently a work in progress [1]. Tests for the signal/exit code are currently skipped on MIPS platforms due to bugs in qemu-user's translation of siginfo_t (fixed in [2] and [3]; the second fix is not in a released qemu version yet). [1] https://github.com/rust-lang/libc/pull/2476 [2] https://lists.nongnu.org/archive/html/qemu-devel/2021-01/msg04810.html [3] https://lists.nongnu.org/archive/html/qemu-devel/2021-10/msg05433.html
2022-03-09docs: fix link in doc for cmsg_space in sys/socketbin liu
Link to cmsg_space macro for recvmmsg and recvmsg should be the doc's root of crate as macro is an exported macro. Signed-off-by: bin liu <liubin0329@gmail.com>
2022-03-08Merge #1670bors[bot]
1670: Add `MsgFlag::MSG_NOSIGNAL` r=rtzoeller a=i509VCB (I guess I will see if I did the cfg block correctly) Co-authored-by: i509VCB <git@i509.me>
2022-03-06Add MsgFlag::MSG_NOSIGNALi509VCB
2022-03-05linux.rs: Define consts for rv32 architectureKhem Raj
Upstream-Status: Pending Signed-off-by: Khem Raj <raj.khem@gmail.com>
2022-03-05Fix complation on riscv32Khem Raj
Signed-off-by: Khem Raj <raj.khem@gmail.com>
2022-02-27Remove `PATH_MAX` restriction from `with_nix_path`Alex Saveau
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-02-27Define _POSIX_VDISABLE on Android to fix doc testRyan Zoeller
2022-02-22also implement Read and Write for &PtyMasterJesse Luehrs
2022-02-21Add ENOTRECOVERABLE and EOWNERDEAD error codes on DragonFlyRyan Zoeller
2022-02-20Implement Extend and From/IntoIterator for SigSetWATANABE Yuki
2022-02-14Merge #1655bors[bot]
1655: 30x performance improvement in `with_nix_path` r=rtzoeller a=SUPERCILEX I've been digging into CPU instructions counts and found that `nix` accounted for an eye-watering 85% of my program's instruction counts (yes, I do a lot of I/O, I know). The fix is simple: don't initialize the stack memory since we're just going to overwrite it anyway. > Note: I also ran rustfmt in a separate commit, not sure if that's ok. ### Before ``` 650,398,225 (85.05%) 5,451,056 (17.31%) 627,714,969 (97.28%) 60 ( 0.54%) 22 ( 0.07%) 3,997 (20.98%) 10 ( 0.18%) 0 752 ( 5.98%) 627,716,244 (97.30%) 267,333 (34.62%) 914,814 (35.11%) 105 ( 0.73%) => /home/asaveau/Desktop/nix/src/lib.rs:<[u8] as nix::NixPath>::with_nix_path (152,469x) ``` ``` 1,677,159 ( 0.22%) 0 762,345 ( 0.12%) 14 ( 0.13%) 0 0 2 ( 0.04%) . . . . . . fn with_nix_path<T, F>(&self, f: F) -> Result<T> 2,287,035 ( 0.30%) 304,938 ( 0.97%) 152,469 ( 0.02%) 5 ( 0.04%) 0 0 0 0 0 304,938 ( 0.05%) . . . => ???:__rust_probestack (152,469x) . . . . . . . . . . . . . where . . . . . . . . . . . . . F: FnOnce(&CStr) -> T, . . . . . . . . . . . . . { 457,407 ( 0.06%) 152,469 ( 0.48%) 152,469 ( 0.02%) 0 0 93 ( 0.49%) 0 0 16 ( 0.13%) 0 0 152,469 ( 5.85%) 97 ( 0.67%) let mut buf = [0u8; PATH_MAX as usize]; 627,104,997 (82.00%) 304,938 ( 0.97%) 624,513,024 (96.78%) 1 ( 0.01%) 0 3,814 (20.02%) 1 ( 0.02%) 0 720 ( 5.72%) 625,122,900 (96.90%) 152,495 (19.75%) . . => ./string/../sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S:__memset_avx2_unaligned_erms (152,469x) . . . . . . . . . . . . . 304,938 ( 0.04%) 0 0 0 0 0 0 0 0 152,469 ( 0.02%) 2 ( 0.00%) . . if self.len() >= PATH_MAX as usize { . . . . . . . . . . . . . return Err(Errno::ENAMETOOLONG); . . . . . . . . . . . . . } . . . . . . . . . . . . . 1,067,283 ( 0.14%) 152,469 ( 0.48%) 152,469 ( 0.02%) 1 ( 0.01%) 4 ( 0.01%) 0 1 ( 0.02%) 0 0 0 0 152,469 ( 5.85%) 1 ( 0.01%) buf[..self.len()].copy_from_slice(self); 3,202,541 ( 0.42%) 914,814 ( 2.91%) 609,876 ( 0.09%) 1 ( 0.01%) 2 ( 0.01%) 0 0 0 0 458,005 ( 0.07%) 114,562 (14.84%) 152,469 ( 5.85%) . => /rustc/21b4a9cfdcbb1e76f4b36b5c3cfd64d627285093/library/core/src/slice/mod.rs:core::slice::<impl [T]>::copy_from_slice (152,469x) 762,345 ( 0.10%) 304,938 ( 0.97%) 152,469 ( 0.02%) 0 6 ( 0.02%) 0 0 0 0 152,469 ( 0.02%) 6 ( 0.00%) 152,469 ( 5.85%) 1 ( 0.01%) match CStr::from_bytes_with_nul(&buf[..=self.len()]) { 8,350,190 ( 1.09%) 1,181,828 ( 3.75%) 1,067,283 ( 0.17%) 19 ( 0.17%) 2 ( 0.01%) 87 ( 0.46%) 3 ( 0.05%) 0 16 ( 0.13%) 1,220,525 ( 0.19%) 167 ( 0.02%) 152,469 ( 5.85%) 5 ( 0.03%) => /rustc/21b4a9cfdcbb1e76f4b36b5c3cfd64d627285093//library/std/src/ffi/c_str.rs:std::ffi::c_str::CStr::from_bytes_with_nul (152,469x) 609,876 ( 0.08%) 609,876 ( 1.94%) 0 0 1 ( 0.00%) . . . . . . . . Ok(s) => Ok(f(s)), . . . . . . . . . . . . . Err(_) => Err(Errno::EINVAL), . . . . . . . . . . . . . } 914,814 ( 0.12%) 762,345 ( 2.42%) . . . . . . . . . . . } . . . . . . . . . . . . . } ``` ### After ``` 21,462,416 (15.81%) 4,688,455 (15.27%) 2,896,847 (14.17%) 74 ( 0.64%) 11 ( 0.04%) 249 ( 1.58%) 8 ( 0.15%) 0 48 ( 0.38%) 2,593,200 (12.98%) 1,128 ( 0.22%) 762,305 (31.08%) 158 ( 1.32%) => /home/asaveau/Desktop/nix/src/lib.rs:<[u8] as nix::NixPath>::with_nix_path (152,461x) ``` ``` 1,067,227 ( 0.79%) 0 609,844 ( 2.98%) 1 ( 0.01%) 0 0 1 ( 0.02%) . . . . . . fn with_nix_path<T, F>(&self, f: F) -> Result<T> 2,286,915 ( 1.68%) 304,922 ( 0.99%) 152,461 ( 0.75%) 19 ( 0.16%) 0 0 0 0 0 304,922 ( 1.53%) . . . => ???:__rust_probestack (152,461x) . . . . . . . . . . . . . where . . . . . . . . . . . . . F: FnOnce(&CStr) -> T, . . . . . . . . . . . . . { 304,922 ( 0.22%) 0 0 0 0 0 0 0 0 152,461 ( 0.76%) 6 ( 0.00%) . . if self.len() >= PATH_MAX as usize { . . . . . . . . . . . . . return Err(Errno::ENAMETOOLONG); . . . . . . . . . . . . . } . . . . . . . . . . . . . . . . . . . . . . . . . . let mut buf = MaybeUninit::<[u8; PATH_MAX as usize]>::uninit(); . . . . . . . . . . . . . let buf_ptr = buf.as_mut_ptr() as *mut u8; . . . . . . . . . . . . . . . . . . . . . . . . . . unsafe { . . . . . . . . . . . . . ptr::copy_nonoverlapping(self.as_ptr(), buf_ptr, self.len()); . . . . . . . . . . . . . buf_ptr.add(self.len()).write(0); . . . . . . . . . . . . . } . . . . . . . . . . . . . 1,067,227 ( 0.79%) 304,922 ( 0.99%) 152,461 ( 0.75%) 1 ( 0.01%) 3 ( 0.01%) 0 1 ( 0.02%) 0 0 304,922 ( 1.53%) 4 ( 0.00%) 152,461 ( 6.22%) 1 ( 0.01%) match CStr::from_bytes_with_nul(unsafe { slice::from_raw_parts(buf_ptr, self.len() + 1) }) { 8,349,726 ( 6.15%) 1,181,764 ( 3.85%) 1,067,227 ( 5.22%) 18 ( 0.15%) 1 ( 0.00%) 83 ( 0.53%) 2 ( 0.04%) 0 16 ( 0.13%) 1,220,453 ( 6.11%) 158 ( 0.03%) 152,461 ( 6.22%) 4 ( 0.03%) => /rustc/21b4a9cfdcbb1e76f4b36b5c3cfd64d627285093//library/std/src/ffi/c_str.rs:std::ffi::c_str::CStr::from_bytes_with_nul (152,461x) 609,844 ( 0.45%) 609,844 ( 1.99%) . . . . . . . . . . . Ok(s) => Ok(f(s)), . . . . . . . . . . . . . Err(_) => Err(Errno::EINVAL), . . . . . . . . . . . . . } 762,305 ( 0.56%) 609,844 ( 1.99%) 0 1 ( 0.01%) 0 0 1 ( 0.02%) . . . . . . } . . . . . . . . . . . . . } ``` Co-authored-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-02-1330X performance improvement in with_nix_path by not initializing memoryAlex Saveau
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-02-13Enable uconxtext module for s390xRyan Zoeller
Added to libc by https://github.com/rust-lang/libc/commit/38569c719befeb5b5051caeb6b0ff628ccd0ff90
2022-02-07enable process_vm_readv, process_vm_writev for androidrupansh-arch
CHANGELOG: add process_vm_* entry process_vm_*: fix documentation for android expose process_vm_readv, process_vm_writev for android Signed-off-by: rupansh-arch <rupanshsekar@hotmail.com>
2022-02-07Impl `AsRawFd` for `OwningIter`Dean Li
For issue #1558
2022-02-06Merge #1653bors[bot]
1653: Document inotify, mman, personality, reboot, timerfd r=asomers a=rtzoeller Document the `inotify`, `mman`, `personality`, `reboot`, and `timerfd` modules. Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-02-04Add accept4 on supported platformsRyan Zoeller
2022-02-02Document timerfd.rsRyan Zoeller
2022-02-02Document reboot.rsRyan Zoeller
2022-02-02Document personality.rsRyan Zoeller
2022-02-02Document mman.rsRyan Zoeller
No documentation provided for MADV_CAN_REUSE, as Darwin doesn't actually document its functionality.
2022-01-31Document inotify.rsRyan Zoeller
2022-01-29Fix typo in pread docsRyan Zoeller
2022-01-24uclibc supportJonah Petri
2022-01-23InetAddr::from_std should set sin_len/sin6_len on the BSDsRyan Zoeller
2022-01-23Disable the fspacectl testsAlan Somers
They fail to link prior to FreeBSD 14.0, which we don't use in CI. So mark them as no_run. The only alternative I see would be to add a build script.
2022-01-23Add fspacectl on FreeBSDAlan Somers
2022-01-22Suppress clippy::not_unsafe_ptr_arg_deref warnings in ptrace on BSDAlan Somers
Technically these functions don't violate Rust's safety rules, because libc::ptrace doesn't dereference those pointer args. Instead, it passes them directly to the kernel.
2022-01-22Better type safety for mqueueAlan Somers
On some platforms, mqd_t is a pointer. That means code like the below can trigger a segfault. Fix it by defining a Newtype around mqd_t that prevents use-after-free and dangling pointer scenarios. ```rust fn invalid_mqd_t() { let mqd: libc::mqd_t = std::ptr::null_mut(); mq_close(mqd).unwrap(); } ``` Also, get test coverage for mqueue in CI on FreeBSD.
2022-01-19Merge #1636bors[bot]
1636: Add MAP_FIXED_NOREPLACE on Linux r=rtzoeller a=rtzoeller Resolves #1393. Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-18Define UMOUNT_NOFOLLOW, FUSE_SUPER_MAGIC on LinuxRyan Zoeller
Requested-by: jiangliu
2022-01-18Add MAP_FIXED_NOREPLACE on LinuxRyan Zoeller
2022-01-16Remove EventFlag::EV_SYSFLAGRyan Zoeller
It is not stable across OpenBSD versions and is reserved by the system on FreeBSD and NetBSD.
2022-01-10Add getresuid/gid and setresuid/gid on BSDsRyan Zoeller
2022-01-03Add sendfile(2) for DragonFlyRyan Zoeller
2022-01-02Correct MAP_FIXED documentation for NetBSDRyan Zoeller
The previous documentation described the default behavior, rather than the behavior when the flag was set. Also fix a test which is failing due to passing this flag erroneously.
2021-12-31Merge #1622 #1623bors[bot]
1622: Introduce `timer_*` support r=asomers a=blt This commit adds support for the signal timer mechanism in POSIX, the mirror to timerfd on Linux. I wasn't _quite_ sure of how to fit into the project organization but hopefully this patch isn't too far off. Resolves #1424 Signed-off-by: Brian L. Troutwine <brian@troutwine.us> 1623: Remove cc dependency on DragonFly r=asomers a=rtzoeller f5ee22db489f78b9c003ef60b7ad1b837503bc4a removed the need for this dependency. Co-authored-by: Brian L. Troutwine <brian@troutwine.us> Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2021-12-31Merge #1618bors[bot]
1618: Refactor UnixAddr r=asomers a=asomers * Within UnixAddr, replace the path_len variable (length of the sun_path field) with sun_len (length of the whole structure). This is more similar to how other sockaddr types work, and it's the same way that the BSDs use the sun_len field. Also, don't require that sun_path be nul-terminated. The OS doesn't require it. * On BSD-derived operating systems, struct sockaddr has a sa_len field that holds the length of the structure. UnixAddr's path_len field is redundant. Remove path_len on BSD-derived OSes, retaining it only for Illumos and Linux-based OSes. Co-authored-by: Alan Somers <asomers@gmail.com>
2021-12-30Introduce timer_* supportBrian L. Troutwine
This commit adds support for the signal timer mechanism in POSIX, the mirror to timerfd on Linux. Resolves #1424 Signed-off-by: Brian L. Troutwine <brian@troutwine.us>
2021-12-30Optimize UnixAddr for the BSDsAlan Somers
On BSD-derived operating systems, struct sockaddr has a sa_len field that holds the length of the structure. UnixAddr's path_len field is redundant. Remove path_len on BSD-derived OSes, retaining it only for Illumos and Linux-based OSes. Also, ensure that two UnixAddrs compare equal if they differ only by the presence of a trailing NUL. On Linux, syscalls like getsockname add a trailing NUL to the sockaddr they return, even if no NUL was present on the sockaddr originally passed to the kernel via a syscall like bind, and even though the docs explicitly say that any NUL passed to bind is not considered to be part of the address. Work around this bug by stripping it in UnixAddrKind::get(), so that at least two UnixAddrs will compare identical even if they differ in the presence of a trailing NUL.
2021-12-29Add support for the SO_TXTIME sockopt and SCM_TXTIME control messageAlessandro Ghedini
2021-12-28Merge #1619bors[bot]
1619: Added getters for the MqAttr struct r=rtzoeller a=fpagliughi With the existing code, if you call `mq_getattr()`, there does not appear to be a way to get any of the attributes from the returned `MqAttr` struct, other than the flags. This adds getter functions to retrieve the size parameters of the queue, and the current number of messages in the queue. Co-authored-by: fpagliughi <fpagliughi@mindspring.com>
2021-12-27Added getters for the MqAttr structfpagliughi
2021-12-27Merge #1596 #1621bors[bot]
1596: Add NetBSD configuration for supported process resources r=asomers a=schctl In addition to existing resources, NetBSD supports `RLIMIT_MEMLOCK`, `RLIMIT_NPROC` and `RLIMIT_RSS`. https://man.netbsd.org/setrlimit.2 `RLIMIT_AS` is also supported, but it looks like it was added [after version 5.0](https://mail-index.netbsd.org/tech-kern/2009/03/28/msg004702.html), so I'm not sure if that should be enabled. 1621: Add posix_fallocate on DragonFly r=asomers a=rtzoeller Enable the existing `posix_fallocate()` tests as they are passing locally. Co-authored-by: Sachin Cherian <sachinctl@protonmail.com> Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2021-12-27Add posix_fallocate on DragonFlyRyan Zoeller
2021-12-26Fix typosRyan Zoeller
2021-12-24Merge #1547bors[bot]
1547: feat: Add glibc::SOF_TIMESTAMPING_* support r=asomers a=pacak Support for kernel and hardware receive timestamps Co-authored-by: Michael Baikov <manpacket@gmail.com>
2021-12-24Add NetBSD configuration for supported process resourcesSachin Cherian