about summary refs log tree commit diff
path: root/library/std/src/sys/unix
AgeCommit message (Collapse)AuthorLines
2020-10-16Take sys/vxworks/stack_overflow from sys/unix instead.Mara Bos-1/+1
2020-10-14Remove lifetime from StaticMutex and assume 'static.Mara Bos-1/+1
StaticMutex is only ever used with as a static (as the name already suggests). So it doesn't have to be generic over a lifetime, but can simply assume 'static. This 'static lifetime guarantees the object is never moved, so this is no longer a manually checked requirement for unsafe calls to lock().
2020-10-13Use fdatasync for File::sync_data on more OSesThomas de Zeeuw-2/+16
Add support for the following OSes: * Android * FreeBSD: https://www.freebsd.org/cgi/man.cgi?query=fdatasync&sektion=2 * OpenBSD: https://man.openbsd.org/OpenBSD-5.8/fsync.2 * NetBSD: https://man.netbsd.org/fdatasync.2 * illumos: https://illumos.org/man/3c/fdatasync
2020-10-11Fix unresolved imports for `recv_vectored_with_ancillary_from`, ↵LinkTed-0/+1
`send_vectored_with_ancillary_to` and `SocketAncillary`
2020-10-11Auto merge of #77727 - thomcc:mach-info-order, r=Amanieubors-23/+33
Avoid SeqCst or static mut in mach_timebase_info and QueryPerformanceFrequency caches This patch went through a couple iterations but the end result is replacing a pattern where an `AtomicUsize` (updated with many SeqCst ops) guards a `static mut` with a single `AtomicU64` that is known to use 0 as a value indicating that it is not initialized. The code in both places exists to cache values used in the conversion of Instants to Durations on macOS, iOS, and Windows. I have no numbers to prove that this improves performance (It seems a little futile to benchmark something like this), but it's much simpler, safer, and in practice we'd expect it to be faster everywhere where Relaxed operations on AtomicU64 are cheaper than SeqCst operations on AtomicUsize, which is a lot of places. Anyway, it also removes a bunch of unsafe code and greatly simplifies the logic, so IMO that alone would be worth it unless it was a regression. If you want to take a look at the assembly output though, see https://godbolt.org/z/rbr6vn for x86_64, https://godbolt.org/z/cqcbqv for aarch64 (Note that this just the output of the mac side, but i'd expect the windows part to be the same and don't feel like doing another godbolt for it). There are several versions of this function in the godbolt: - `info_new`: version in the current patch - `info_less_new`: version in initial PR - `info_original`: version currently in the tree - `info_orig_but_better_orderings`: a version that just tries to change the original code's orderings from SeqCst to the (probably) minimal orderings required for soundness/correctness. The biggest concern I have here is if we can use AtomicU64, or if there are targets that dont have it that this code supports. AFAICT: no. (If that changes in the future, it's easy enough to do something different for them) r? `@Amanieu` because he caught a couple issues last time I tried to do a patch reducing orderings 😅 --- <details> <summary>I rewrote this whole message so the original is inside here</summary> I happened to notice the code we use for caching the result of mach_timebase_info uses SeqCst exclusively. However, thinking a little more, it's actually pretty easy to avoid the static mut by packing the timebase info into an AtomicU64. This entirely avoids needing to do the compare_exchange. The AtomicU64 can be read/written using Relaxed ops, which on current macos/ios platforms (x86_64/aarch64) have no overhead compared to direct loads/stores. This simplifies the code and makes it a lot safer too. I have no numbers to prove that this improves performance (It seems a little futile to benchmark something like this), although it should do that on both targets it applies to. That said, it also removes a bunch of unsafe code and simplifies the logic (arguably at least — there are only two states now, initialized or not), so I think it's a net win even without concrete numbers. If you want to take a look at the assembly output though, see below. It has the new version, the original, and a version of the original with lower Orderings (which is still worse than the version in this PR) - godbolt.org/z/obfqf9 x86_64-apple-darwin - godbolt.org/z/Wz5cWc aarch64-unknown-linux-gnu (godbolt can't do aarch64-apple-ios but that doesn't matter here) A different (and more efficient) option than this would be to just use the AtomicU64 and use the knowledge that after initialization the denominator should be nonzero... That felt like it's relying on too many things I'm not confident in, so I didn't want to do that. </details>
2020-10-10Fix unresolved link to `SocketAncillary`LinkTed-0/+2
2020-10-10Fix `libc` is ambiguous for WindowsLinkTed-9/+6
2020-10-10Fix import errors for `#[cfg(doc)]` targetLinkTed-2/+4
2020-10-10Add fake definitions for WindowsLinkTed-0/+10
2020-10-10Fix imports for MacOsLinkTed-8/+4
2020-10-10Change imports for `cfg(doc)`LinkTed-30/+29
2020-10-10Remove `passcred` for `emscripten`LinkTed-6/+6
2020-10-10Remove unnecessary trailing semicolonLinkTed-1/+1
2020-10-10Fix type mismatching for different OSes.LinkTed-41/+105
2020-10-10Remove `SocketCred` for `emscripten`LinkTed-13/+9
2020-10-10Fix unused import for `IoSliceMut` for macosLinkTed-0/+9
2020-10-10Fix `SO_PASSCRED` for macosLinkTed-0/+2
2020-10-10Fix `MSG_CMSG_CLOEXEC` for macosLinkTed-0/+18
2020-10-10Add conditional compilation for importLinkTed-0/+1
2020-10-10Fix cfg condition for testLinkTed-1/+1
2020-10-10Remove `target_os`, which does not have `SO_PASSCRED` constant in `libc`LinkTed-56/+5
2020-10-10Remove `target_os`, which does not have `cmsghdr` struct in `libc`LinkTed-12/+0
2020-10-10Remove `target_os`, which does not have `MSG_CMSG_CLOEXEC` constant in `libc`LinkTed-54/+31
2020-10-10Add the code of the tracking issueLinkTed-36/+36
2020-10-10Replace `assert` with `unreachable`LinkTed-3/+3
2020-10-10Cast boolean into int directly in function set_passcredLinkTed-2/+1
2020-10-10Remove unsupported target_os for SocketCredLinkTed-125/+7
2020-10-10Change standard types to libc typesLinkTed-6/+8
2020-10-10Change name of struct to SocketCredLinkTed-9/+9
2020-10-10Change API to unsafe and add doc commentsLinkTed-3/+20
2020-10-10Add `set_passcred` and `passcred` methods to `UnixStream` and `UnixDatagram`LinkTed-11/+131
2020-10-10Rename `test.rs` to `tests.rs`LinkTed-625/+19
2020-10-10Add doc commentsLinkTed-1/+21
2020-10-10Add doc(cfg(...))LinkTed-0/+24
2020-10-10Reduce impl trait by using macro in `raw_fd.rs`LinkTed-61/+34
2020-10-10Move conditional compilation to the upper module and sort the target OS list ↵LinkTed-189/+199
alphabetically
2020-10-10Remove unnecessary pathLinkTed-1/+1
2020-10-10Use `fill` instead of `memset`LinkTed-9/+16
2020-10-10Remove inner function in `bind`, `connect` and `send_to`LinkTed-49/+33
2020-10-10Remove lifetime annotation in `messages` functionLinkTed-1/+1
2020-10-10Remove `Clone` trait bound in `add_to_ancillary_data`LinkTed-1/+1
2020-10-10Add integer overflow checkLinkTed-1/+9
2020-10-10Replace `TryFrom` of `AncillaryData` with a private method.LinkTed-23/+18
2020-10-10Using `read_unaligned` instead of `memcpy`.LinkTed-8/+6
2020-10-10Move `add_to_ancillary_data` and `AncillaryDataIter` to ancillary.rsLinkTed-87/+86
2020-10-10Add UCred structLinkTed-9/+53
2020-10-10Add AncillaryErrorLinkTed-29/+44
2020-10-10Split net.rs into multiple filesLinkTed-2635/+3297
2020-10-10unix: Extend UnixStream and UnixDatagram to send and receive file descriptorsLinkTed-0/+1111
Add the functions `recv_vectored_fds` and `send_vectored_fds` to send and receive file descriptors, by using `recvmsg` and `sendmsg` system call.
2020-10-10Auto merge of #77717 - tmiasko:posix-spawn-error-check, r=cuviperbors-18/+24
Fix error checking in posix_spawn implementation of Command * Check for errors returned from posix_spawn*_init functions * Check for non-zero return value from posix_spawn functions