Commit Graph

2509 Commits

Author SHA1 Message Date
bors[bot]
fc3a77b7fc
Merge #1665
1665: Add ENOTRECOVERABLE and EOWNERDEAD error codes on DragonFly r=asomers a=rtzoeller



Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-02-22 01:05:18 +00:00
Ryan Zoeller
1a51fbe157 Add ENOTRECOVERABLE and EOWNERDEAD error codes on DragonFly 2022-02-21 17:45:29 -06:00
bors[bot]
b0a39cb112
Merge #1553
1553: Implement Extend and From/IntoIterator for SigSet r=rtzoeller a=magicant



Co-authored-by: WATANABE Yuki <magicant@wonderwand.net>
2022-02-21 04:28:41 +00:00
WATANABE Yuki
2196824f1e Implement Extend and From/IntoIterator for SigSet 2022-02-20 13:17:09 +09:00
bors[bot]
3ea9b7b673
Merge #1655
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-14 05:06:45 +00:00
Alex Saveau
bb54af538d
30X performance improvement in with_nix_path by not initializing memory
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-02-13 13:32:52 -08:00
bors[bot]
b38a88a306
Merge #1662
1662: Enable uconxtext module for s390x r=asomers a=rtzoeller

Added to libc by 38569c719b

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-02-13 15:51:37 +00:00
Ryan Zoeller
263e8709fa Enable uconxtext module for s390x
Added to libc by 38569c719b
2022-02-13 09:32:56 -06:00
bors[bot]
432fb90615
Merge #1557
1557: expose process_vm_readv, process_vm_writev for android r=rtzoeller a=rupansh

see https://github.com/rust-lang/libc/pull/1878

Co-authored-by: rupansh-arch <rupanshsekar@hotmail.com>
2022-02-07 18:07:44 +00:00
rupansh-arch
abd76aa759 enable process_vm_readv, process_vm_writev for android
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-07 22:39:18 +05:30
bors[bot]
0244b83ea2
Merge #1563
1563: Impl `AsRawFd` for `OwningIter` r=rtzoeller a=deantvv

For issue #1558

Co-authored-by: Dean Li <deantvv@gmail.com>
2022-02-07 14:04:53 +00:00
Dean Li
08e40c0fee
update changelog 2022-02-07 21:39:29 +08:00
Dean Li
378530d615
Impl AsRawFd for OwningIter
For issue #1558
2022-02-07 21:39:29 +08:00
bors[bot]
16ceae331c
Merge #1658
1658: use version of libc published on crates r=rtzoeller a=pacak

https://github.com/rust-lang/libc/pull/2543 was merged and is available
starting from 0.2.114.

Using published version of libc makes it easier to use git version of nix

Co-authored-by: Michael Baikov <manpacket@gmail.com>
2022-02-07 03:15:57 +00:00
Michael Baikov
6e09f6c6e5 use version of libc published on crates
https://github.com/rust-lang/libc/pull/2543 was merged and is available
starting from 0.2.114.

Using published version of libc makes it easier to use git version of nix
2022-02-07 08:29:11 +08:00
bors[bot]
7bec9f70de
Merge #1652
1652: Add support for aarch64-apple-darwin r=asomers a=rtzoeller

Supersedes #1396, resolves #1646.

Also replace 'OSX' language with 'macOS', to match Rust's language.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-02-06 23:47:12 +00:00
bors[bot]
2038ce6b99
Merge #1653
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-06 23:31:42 +00:00
bors[bot]
0bd56d96e3
Merge #1654
1654: Add accept4 on DragonFly, Emscripten, Fuchsia, Illumos, and NetBSD. r=rtzoeller a=rtzoeller

Expand accept4 support to more platforms.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-02-06 17:10:45 +00:00
Ryan Zoeller
9269056e8e Add accept4 on supported platforms 2022-02-04 19:46:25 -06:00
Ryan Zoeller
7baf6d12c8 Document timerfd.rs 2022-02-02 17:53:52 -06:00
Ryan Zoeller
d3ff2666d6 Document reboot.rs 2022-02-02 17:53:52 -06:00
Ryan Zoeller
7c9a7af4fc Document personality.rs 2022-02-02 17:53:52 -06:00
Ryan Zoeller
e6f01f20e1 Document mman.rs
No documentation provided for MADV_CAN_REUSE, as Darwin doesn't actually
document its functionality.
2022-02-02 17:53:47 -06:00
Ryan Zoeller
7d0344141c Document inotify.rs 2022-01-31 21:32:28 -06:00
Ryan Zoeller
b637f12bf9 Add support for aarch64-apple-darwin
Replace 'OSX' language with 'macOS', to match Rust's language.
2022-01-29 23:39:21 -06:00
bors[bot]
2143ffe90d
Merge #1651
1651: Fix typo in pread docs r=rtzoeller a=rtzoeller

Fixes #1648.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-30 05:23:38 +00:00
Ryan Zoeller
3b00f37bfb Fix typo in pread docs 2022-01-29 22:50:29 -06:00
bors[bot]
5cd01a1fd7
Merge #1603
1603: uclibc support r=rtzoeller a=skrap

uclibc is a libc alternative (peer to glibc and musl) which is used in low-resource embedded linux applications.

It's supported in rust as the `target_env` of several tier 3 targets, but `nix` currently doesn't build.  This patch provides a few customizations to get uclibc building.

To test:
* Get nightly rust
* Follow directions for getting a cross toolchain and env setup here: https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/armv7-unknown-linux-uclibceabihf.md

Thanks for your consideration!



Co-authored-by: Jonah Petri <jonah@petri.us>
2022-01-25 03:37:44 +00:00
Jonah Petri
6c4b9133f1 uclibc support 2022-01-24 10:06:35 -05:00
bors[bot]
ae2b7b3552
Merge #1642
1642: InetAddr::from_std should set sin_len/sin6_len on the BSDs r=asomers a=rtzoeller

Resolves #1246.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-23 21:56:25 +00:00
bors[bot]
4c3001b0b2
Merge #1644
1644: Make memoffset dependency optional r=asomers a=rtzoeller

Only the socket feature depends on memoffset. Allow clients to skip pulling memoffset in as a dependency if they don't need it.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-23 21:42:01 +00:00
Ryan Zoeller
50d22ce0e5 Make memoffset dependency optional
Only the socket feature depends on memoffset. Allow clients to skip
pulling memoffset in as a dependency if they don't need it.
2022-01-23 14:52:02 -06:00
Ryan Zoeller
ad7e3c719c InetAddr::from_std should set sin_len/sin6_len on the BSDs 2022-01-23 13:26:32 -06:00
bors[bot]
8ee93662e7
Merge #1640
1640: Add fspacectl on FreeBSD r=rtzoeller a=asomers



Co-authored-by: Alan Somers <asomers@gmail.com>
2022-01-23 16:36:20 +00:00
Alan Somers
e2ce5efece Disable the fspacectl tests
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-23 08:37:56 -07:00
Alan Somers
5419c79601 Add fspacectl on FreeBSD 2022-01-23 07:41:08 -07:00
bors[bot]
0c02ee2630
Merge #1639
1639: Fix Clippy warnings on FreeBSD with the latest nightly r=rtzoeller a=asomers

* Better type safety for mqueue
* Suppress clippy::not_unsafe_ptr_arg_deref warnings in ptrace on BSD

Co-authored-by: Alan Somers <asomers@gmail.com>
2022-01-23 01:57:04 +00:00
Alan Somers
91049bc03b Suppress clippy::not_unsafe_ptr_arg_deref warnings in ptrace on BSD
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-22 14:48:48 -07:00
Alan Somers
475da53d56 Better type safety for mqueue
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-22 14:48:48 -07:00
bors[bot]
c84316b7fc
Merge #1636
1636: Add MAP_FIXED_NOREPLACE on Linux r=rtzoeller a=rtzoeller

Resolves #1393.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-19 13:55:51 +00:00
bors[bot]
c3731f1e7c
Merge #1634
1634: Define UMOUNT_NOFOLLOW, FUSE_SUPER_MAGIC r=rtzoeller a=rtzoeller

Resolves #1631 and resolves  #1633.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-18 23:13:55 +00:00
Ryan Zoeller
65039212d1 Define UMOUNT_NOFOLLOW, FUSE_SUPER_MAGIC on Linux
Requested-by: jiangliu
2022-01-18 16:52:23 -06:00
Ryan Zoeller
5f0072130e Add MAP_FIXED_NOREPLACE on Linux 2022-01-18 16:48:12 -06:00
bors[bot]
18d1f62b15
Merge #1635
1635: Remove EventFlag::EV_SYSFLAG r=rtzoeller a=rtzoeller

It is not stable across OpenBSD versions and is reserved by the system on FreeBSD and NetBSD.

This should fix the nix build for OpenBSD, which is failing due to https://github.com/rust-lang/libc/pull/2596. Bump the libc dependency to uptake that change.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-18 22:26:20 +00:00
Ryan Zoeller
84e3c56bcc Remove EventFlag::EV_SYSFLAG
It is not stable across OpenBSD versions and is reserved by the system
on FreeBSD and NetBSD.
2022-01-16 10:17:05 -06:00
bors[bot]
916bbfac03
Merge #1610
1610: Re-enable deprecation warnings on DragonFly r=asomers a=rtzoeller

Reverts 0df82ded47 and ac159d9c4e.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-13 04:44:46 +00:00
Ryan Zoeller
3674d58b6f Re-enable deprecation warnings on DragonFly
Use latest nightly compiler.
2022-01-12 22:03:55 -06:00
bors[bot]
f8e27505f5
Merge #1630
1630: Change port used by test_txtime to avoid conflict r=asomers a=rtzoeller

The socket tests request specific ports, and `test_timestamping` and `test_txtime` are currently conflicting in the port they request.

This leads to the second of the tests failing with `EADDRINUSE` when run locally.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-11 05:15:35 +00:00
bors[bot]
b641788f8f
Merge #1628
1628: Add getresuid/gid and setresuid/gid on BSDs r=asomers a=rtzoeller



Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-11 05:00:16 +00:00
Ryan Zoeller
ebd4acebc0 Change port used by test_txtime to avoid conflict 2022-01-10 21:57:55 -06:00